Skip to content

Commit f6caaa2

Browse files
committed
Adding missing s3 event notification fields
Signed-off-by: Divyansh Bokadia <dbokadia@amazon.com>
1 parent 6e74852 commit f6caaa2

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

data-prepper-plugins/s3-source/src/main/java/org/opensearch/dataprepper/plugins/source/s3/S3EventBridgeNotification.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ public static class Detail {
9797
private final String sourceIpAddress;
9898
private final String reason;
9999
private final String eventVersion;
100+
private final String deletionType;
101+
private final DateTime restoreExpiryTime;
102+
private final String sourceStorageClass;
103+
private final String destinationStorageClass;
104+
private final String destinationAccessTier;
105+
private final String objectAnnotation;
106+
private final boolean hasObjectAnnotation;
100107

101108
@JsonCreator
102109
public Detail(@JsonProperty(value = "version") final String version,
@@ -106,7 +113,14 @@ public Detail(@JsonProperty(value = "version") final String version,
106113
@JsonProperty("requester") final String requester,
107114
@JsonProperty("source-ip-address") final String sourceIpAddress,
108115
@JsonProperty("reason") final String reason,
109-
@JsonProperty("event-version") final String eventVersion) {
116+
@JsonProperty("event-version") final String eventVersion,
117+
@JsonProperty("deletion-type") final String deletionType,
118+
@JsonProperty("restore-expiry-time") final String restoreExpiryTime,
119+
@JsonProperty("source-storage-class") final String sourceStorageClass,
120+
@JsonProperty("destination-storage-class") final String destinationStorageClass,
121+
@JsonProperty("destination-access-tier") final String destinationAccessTier,
122+
@JsonProperty("object-annotation") final String objectAnnotation,
123+
@JsonProperty("has-object-annotation") final boolean hasObjectAnnotation) {
110124
this.version = version;
111125
this.bucket = bucket;
112126
this.object = object;
@@ -115,6 +129,13 @@ public Detail(@JsonProperty(value = "version") final String version,
115129
this.sourceIpAddress = sourceIpAddress;
116130
this.reason = reason;
117131
this.eventVersion = eventVersion;
132+
this.deletionType = deletionType;
133+
this.restoreExpiryTime = restoreExpiryTime != null ? DateTime.parse(restoreExpiryTime) : null;
134+
this.sourceStorageClass = sourceStorageClass;
135+
this.destinationStorageClass = destinationStorageClass;
136+
this.destinationAccessTier = destinationAccessTier;
137+
this.objectAnnotation = objectAnnotation;
138+
this.hasObjectAnnotation = hasObjectAnnotation;
118139
}
119140

120141
public String getVersion() {

data-prepper-plugins/s3-source/src/main/java/org/opensearch/dataprepper/plugins/source/s3/S3EventNotification.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.fasterxml.jackson.annotation.JsonCreator;
99
import com.fasterxml.jackson.annotation.JsonIgnore;
10+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1011
import com.fasterxml.jackson.annotation.JsonProperty;
1112
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
1213
import org.joda.time.DateTime;
@@ -84,13 +85,15 @@ public String getArn() {
8485
}
8586
}
8687

88+
@JsonIgnoreProperties(ignoreUnknown = true)
8789
public static class S3ObjectEntity {
8890

8991
private final String key;
9092
private final Long size;
9193
private final String eTag;
9294
private final String versionId;
9395
private final String sequencer;
96+
private final boolean hasObjectAnnotation;
9497

9598
@Deprecated
9699
public S3ObjectEntity(
@@ -104,6 +107,7 @@ public S3ObjectEntity(
104107
this.eTag = eTag;
105108
this.versionId = versionId;
106109
this.sequencer = null;
110+
this.hasObjectAnnotation = false;
107111
}
108112

109113
@Deprecated
@@ -113,7 +117,7 @@ public S3ObjectEntity(
113117
String eTag,
114118
String versionId)
115119
{
116-
this(key, size, eTag, versionId, null);
120+
this(key, size, eTag, versionId, null, false);
117121
}
118122

119123
@JsonCreator
@@ -122,13 +126,15 @@ public S3ObjectEntity(
122126
@JsonProperty(value = "size") Long size,
123127
@JsonProperty(value = "eTag") String eTag,
124128
@JsonProperty(value = "versionId") String versionId,
125-
@JsonProperty(value = "sequencer") String sequencer)
129+
@JsonProperty(value = "sequencer") String sequencer,
130+
@JsonProperty(value = "hasObjectAnnotation") boolean hasObjectAnnotation)
126131
{
127132
this.key = key;
128133
this.size = size;
129134
this.eTag = eTag;
130135
this.versionId = versionId;
131136
this.sequencer = sequencer;
137+
this.hasObjectAnnotation = hasObjectAnnotation;
132138
}
133139

134140
public String getKey() {

data-prepper-plugins/s3-source/src/test/java/org/opensearch/dataprepper/plugins/source/s3/parser/S3EventNotificationParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class S3EventNotificationParserTest {
2323
"\"responseElements\":{\"x-amz-request-id\":\"xyz\",\"x-amz-id-2\":\"xyz\"},\"s3\":{\"s3SchemaVersion\":\"1.0\"," +
2424
"\"configurationId\":\"xyz\",\"bucket\":{\"name\":\"my-bucket\",\"ownerIdentity\":{\"principalId\":\"ABC\"}," +
2525
"\"arn\":\"arn:aws:s3:::my-bucket\"},\"object\":{\"key\":\"path/to/myfile.log.gz\",\"size\":3159112,\"eTag\":\"abcd123\"," +
26-
"\"sequencer\":\"000\"}}}]}";
26+
"\"sequencer\":\"000\", \"hasObjectAnnotation\":true}}}]}";
2727

2828
public static final String SNS_BASED_MESSAGE = "{\n" +
2929
" \"Type\" : \"Notification\",\n" +

0 commit comments

Comments
 (0)