Skip to content

Commit d3f23ce

Browse files
authored
Added missing 'version' field to ScheduledEvent from CloudWatch (aws#447)
* Adding version field to avoid UnrecognizedPropertyException upon invocation of lambdas
1 parent 90155b3 commit d3f23ce

File tree

1 file changed

+44
-12
lines changed
  • aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events

1 file changed

+44
-12
lines changed

aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ScheduledEvent.java

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class ScheduledEvent implements Serializable, Cloneable {
2626

2727
private static final long serialVersionUID = -5810383198587331146L;
2828

29+
private String version;
30+
2931
private String account;
3032

3133
private String region;
@@ -47,6 +49,29 @@ public class ScheduledEvent implements Serializable, Cloneable {
4749
*/
4850
public ScheduledEvent() {}
4951

52+
/**
53+
* @return the version number
54+
*/
55+
public String getVersion() {
56+
return version;
57+
}
58+
59+
/**
60+
* @param version the version number
61+
*/
62+
public void setVersion(String version) {
63+
this.version = version;
64+
}
65+
66+
/**
67+
* @param version version number
68+
* @return ScheduledEvent
69+
*/
70+
public ScheduledEvent withVersion(String version) {
71+
setVersion(version);
72+
return this;
73+
}
74+
5075
/**
5176
* @return the account id
5277
*/
@@ -69,7 +94,7 @@ public ScheduledEvent withAccount(String account) {
6994
setAccount(account);
7095
return this;
7196
}
72-
97+
7398
/**
7499
* @return the aws region
75100
*/
@@ -92,7 +117,7 @@ public ScheduledEvent withRegion(String region) {
92117
setRegion(region);
93118
return this;
94119
}
95-
120+
96121
/**
97122
* @return The details of the events (usually left blank)
98123
*/
@@ -115,7 +140,7 @@ public ScheduledEvent withDetail(Map<String, Object> detail) {
115140
setDetail(detail);
116141
return this;
117142
}
118-
143+
119144
/**
120145
* @return The details type - see cloud watch events for more info
121146
*/
@@ -138,19 +163,19 @@ public ScheduledEvent withDetailType(String detailType) {
138163
setDetailType(detailType);
139164
return this;
140165
}
141-
166+
142167
/**
143-
* @return the soruce of the event
168+
* @return the source of the event
144169
*/
145170
public String getSource() {
146171
return source;
147172
}
148173

149174
/**
150-
* @param soruce the soruce of the event
175+
* @param source the source of the event
151176
*/
152-
public void setSource(String soruce) {
153-
this.source = soruce;
177+
public void setSource(String source) {
178+
this.source = source;
154179
}
155180

156181
/**
@@ -161,7 +186,7 @@ public ScheduledEvent withSource(String source) {
161186
setSource(source);
162187
return this;
163188
}
164-
189+
165190
/**
166191
* @return the timestamp for when the event is scheduled
167192
*/
@@ -184,7 +209,7 @@ public ScheduledEvent withTime(DateTime time) {
184209
setTime(time);
185210
return this;
186211
}
187-
212+
188213
/**
189214
* @return the id of the event
190215
*/
@@ -207,7 +232,7 @@ public ScheduledEvent withId(String id) {
207232
setId(id);
208233
return this;
209234
}
210-
235+
211236
/**
212237
* @return the resources used by event
213238
*/
@@ -242,6 +267,8 @@ public ScheduledEvent withResources(List<String> resources) {
242267
public String toString() {
243268
StringBuilder sb = new StringBuilder();
244269
sb.append("{");
270+
if (getVersion() != null)
271+
sb.append("version: ").append(getVersion()).append(",");
245272
if (getAccount() != null)
246273
sb.append("account: ").append(getAccount()).append(",");
247274
if (getRegion() != null)
@@ -272,6 +299,10 @@ public boolean equals(Object obj) {
272299
if (obj instanceof ScheduledEvent == false)
273300
return false;
274301
ScheduledEvent other = (ScheduledEvent) obj;
302+
if (other.getVersion() == null ^ this.getVersion() == null)
303+
return false;
304+
if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false)
305+
return false;
275306
if (other.getAccount() == null ^ this.getAccount() == null)
276307
return false;
277308
if (other.getAccount() != null && other.getAccount().equals(this.getAccount()) == false)
@@ -312,6 +343,7 @@ public int hashCode() {
312343
final int prime = 31;
313344
int hashCode = 1;
314345

346+
hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode());
315347
hashCode = prime * hashCode + ((getAccount() == null) ? 0 : getAccount().hashCode());
316348
hashCode = prime * hashCode + ((getRegion() == null) ? 0 : getRegion().hashCode());
317349
hashCode = prime * hashCode + ((getDetail() == null) ? 0 : getDetail().hashCode());
@@ -331,5 +363,5 @@ public ScheduledEvent clone() {
331363
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e);
332364
}
333365
}
334-
366+
335367
}

0 commit comments

Comments
 (0)