Skip to content

Commit 7b61bd0

Browse files
authored
S3 Event Notifications parsers (#4994)
* s3-event-notifications new module * fix pom.xml * Equals, hashcode, tostring. More tests. Remove Entity suffix. * handle null fields * Checkstyle * changelog * new module checklist * readme, extra fields, cleanup * remove duplicate dependency * update pom version * update pom version, for real this time * fix pom * cleanup * documentation * PR comments - refactor expectStringOrNull - Added GlacierEventData documentation - removed some explicit version in pom * update pom, again * PR comment: - make S3EventNotificationRecord SdkTestInternalApi only and use getters instead * Suppress non-final fields in EqualsVerifier test. * update pom to 2.25.7-SNAPSHOT * make S3EventNotificationRecord test constructor package-protected * maven version
1 parent 895e0fd commit 7b61bd0

File tree

34 files changed

+3070
-3
lines changed

34 files changed

+3070
-3
lines changed

.brazil.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"protocol-core": { "packageName": "AwsJavaSdk-Core-ProtocolCore" },
2828
"regions": { "packageName": "AwsJavaSdk-Core-Regions" },
2929
"s3-transfer-manager": { "packageName": "AwsJavaSdk-S3-TransferManager" },
30+
"s3-event-notifications": { "packageName": "AwsJavaSdk-S3-EventNotifications" },
3031
"sdk-core": { "packageName": "AwsJavaSdk-Core" },
3132
"url-connection-client": { "packageName": "AwsJavaSdk-HttpClient-UrlConnectionClient" },
3233
"utils": { "packageName": "AwsJavaSdk-Core-Utils" },
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "feature",
3+
"category": "AWS SDK for Java v2",
4+
"contributor": "",
5+
"description": "Add the model for S3 Event Notifications and json parsers for them"
6+
}

aws-sdk-java/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,11 @@ Amazon AutoScaling, etc).</description>
743743
<artifactId>s3-transfer-manager</artifactId>
744744
<version>${awsjavasdk.version}</version>
745745
</dependency>
746+
<dependency>
747+
<groupId>software.amazon.awssdk</groupId>
748+
<artifactId>s3-event-notifications</artifactId>
749+
<version>${awsjavasdk.version}</version>
750+
</dependency>
746751
<dependency>
747752
<groupId>software.amazon.awssdk</groupId>
748753
<artifactId>sagemaker</artifactId>

bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@
202202
<artifactId>s3-transfer-manager</artifactId>
203203
<version>${awsjavasdk.version}</version>
204204
</dependency>
205+
<dependency>
206+
<groupId>software.amazon.awssdk</groupId>
207+
<artifactId>s3-event-notifications</artifactId>
208+
<version>${awsjavasdk.version}</version>
209+
</dependency>
205210
<dependency>
206211
<groupId>software.amazon.awssdk</groupId>
207212
<artifactId>aws-crt-client</artifactId>

core/json-utils/src/main/java/software/amazon/awssdk/protocols/jsoncore/JsonWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public JsonWriter writeEndArray() {
7070
}
7171

7272
public JsonWriter writeNull() {
73-
return unsafeWrite(generator::writeEndArray);
73+
return unsafeWrite(generator::writeNull);
7474
}
7575

7676
public JsonWriter writeStartObject() {

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@
657657
<includeModule>dynamodb-enhanced</includeModule>
658658
<includeModule>s3-transfer-manager</includeModule>
659659
<includeModule>iam-policy-builder</includeModule>
660+
<includeModule>s3-event-notifications</includeModule>
660661

661662
<!-- Service modules that are heavily customized should be included -->
662663
<includeModule>s3</includeModule>

services-custom/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<module>dynamodb-enhanced</module>
3232
<module>s3-transfer-manager</module>
3333
<module>iam-policy-builder</module>
34+
<module>s3-event-notifications</module>
3435
</modules>
3536

3637
<dependencyManagement>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# S3 Event Notifications
2+
3+
## Overview
4+
5+
This module contains the classes used to represent Amazon S3 Event Notifications.
6+
7+
8+
## Deserialization
9+
10+
To convert a json notification to java classes, use the static methods
11+
available on `S3EventNotification`:
12+
13+
```java
14+
String json = "..."; // the notification as json
15+
S3EventNotification event = S3EventNotification.fromJson(json);
16+
event.getRecords().forEach(rec -> println(rec.toString()));
17+
```
18+
19+
Any missing fields of the json will be null in the resulting object.
20+
Any extra fields will be ignored.
21+
22+
23+
## Serialization
24+
25+
To convert an instance of `S3EventNotification` to json, use the `.toJson()`
26+
or `toJsonPretty()` method:
27+
28+
```java
29+
S3EventNotification event = new S3EventNotification(...);
30+
String json = event.toJson();
31+
String jsonPretty = event.toJsonPretty();
32+
```
33+
34+
`GlacierEventData`, `ReplicationEventData`, `IntelligentTieringEventData` and `LifecycleEventData`
35+
will be excluded from the json if null. Any other null fields of the object will be
36+
serialized in the json as `null`.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License").
6+
~ You may not use this file except in compliance with the License.
7+
~ A copy of the License is located at
8+
~
9+
~ http://aws.amazon.com/apache2.0
10+
~
11+
~ or in the "license" file accompanying this file. This file is distributed
12+
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
~ express or implied. See the License for the specific language governing
14+
~ permissions and limitations under the License.
15+
-->
16+
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<groupId>software.amazon.awssdk</groupId>
23+
<artifactId>aws-sdk-java-pom</artifactId>
24+
<version>2.25.11-SNAPSHOT</version>
25+
<relativePath>../../pom.xml</relativePath>
26+
</parent>
27+
<artifactId>s3-event-notifications</artifactId>
28+
<name>AWS Java SDK :: S3 :: Event Notification</name>
29+
<description>
30+
The AWS SDK for Java - S3 Even Notification contains POJO classes and utils method to help serialize and
31+
deserialize Amazon S3 Event Notifications.
32+
</description>
33+
34+
<properties>
35+
<jre.version>1.8</jre.version>
36+
<awsjavasdk.version>${project.parent.version}</awsjavasdk.version>
37+
</properties>
38+
39+
<dependencyManagement>
40+
<dependencies>
41+
<dependency>
42+
<groupId>software.amazon.awssdk</groupId>
43+
<artifactId>bom-internal</artifactId>
44+
<version>${awsjavasdk.version}</version>
45+
<type>pom</type>
46+
<scope>import</scope>
47+
</dependency>
48+
</dependencies>
49+
</dependencyManagement>
50+
51+
<dependencies>
52+
<dependency>
53+
<groupId>software.amazon.awssdk</groupId>
54+
<artifactId>third-party-jackson-core</artifactId>
55+
<version>${awsjavasdk.version}</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>software.amazon.awssdk</groupId>
59+
<artifactId>json-utils</artifactId>
60+
<version>${awsjavasdk.version}</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>software.amazon.awssdk</groupId>
64+
<artifactId>annotations</artifactId>
65+
<version>${awsjavasdk.version}</version>
66+
</dependency>
67+
<dependency>
68+
<groupId>software.amazon.awssdk</groupId>
69+
<artifactId>utils</artifactId>
70+
<version>${awsjavasdk.version}</version>
71+
</dependency>
72+
73+
<dependency>
74+
<groupId>org.junit.jupiter</groupId>
75+
<artifactId>junit-jupiter</artifactId>
76+
<scope>test</scope>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.junit.jupiter</groupId>
80+
<artifactId>junit-jupiter-engine</artifactId>
81+
<scope>test</scope>
82+
</dependency>
83+
<dependency>
84+
<groupId>org.assertj</groupId>
85+
<artifactId>assertj-core</artifactId>
86+
<scope>test</scope>
87+
</dependency>
88+
<dependency>
89+
<groupId>nl.jqno.equalsverifier</groupId>
90+
<artifactId>equalsverifier</artifactId>
91+
<scope>test</scope>
92+
</dependency>
93+
</dependencies>
94+
95+
<build>
96+
<plugins>
97+
<plugin>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-jar-plugin</artifactId>
100+
<configuration>
101+
<archive>
102+
<manifestEntries>
103+
<Automatic-Module-Name>software.amazon.awssdk.eventnotifications.s3</Automatic-Module-Name>
104+
</manifestEntries>
105+
</archive>
106+
</configuration>
107+
</plugin>
108+
</plugins>
109+
</build>
110+
111+
</project>

0 commit comments

Comments
 (0)