Skip to content

Commit

Permalink
S3 Event Notifications parsers (#4994)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
L-Applin authored Mar 15, 2024
1 parent 895e0fd commit 7b61bd0
Show file tree
Hide file tree
Showing 34 changed files with 3,070 additions and 3 deletions.
1 change: 1 addition & 0 deletions .brazil.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"protocol-core": { "packageName": "AwsJavaSdk-Core-ProtocolCore" },
"regions": { "packageName": "AwsJavaSdk-Core-Regions" },
"s3-transfer-manager": { "packageName": "AwsJavaSdk-S3-TransferManager" },
"s3-event-notifications": { "packageName": "AwsJavaSdk-S3-EventNotifications" },
"sdk-core": { "packageName": "AwsJavaSdk-Core" },
"url-connection-client": { "packageName": "AwsJavaSdk-HttpClient-UrlConnectionClient" },
"utils": { "packageName": "AwsJavaSdk-Core-Utils" },
Expand Down
6 changes: 6 additions & 0 deletions .changes/next-release/feature-AWSSDKforJavav2-10ff57d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "AWS SDK for Java v2",
"contributor": "",
"description": "Add the model for S3 Event Notifications and json parsers for them"
}
5 changes: 5 additions & 0 deletions aws-sdk-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,11 @@ Amazon AutoScaling, etc).</description>
<artifactId>s3-transfer-manager</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3-event-notifications</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sagemaker</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@
<artifactId>s3-transfer-manager</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3-event-notifications</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-crt-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public JsonWriter writeEndArray() {
}

public JsonWriter writeNull() {
return unsafeWrite(generator::writeEndArray);
return unsafeWrite(generator::writeNull);
}

public JsonWriter writeStartObject() {
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@
<includeModule>dynamodb-enhanced</includeModule>
<includeModule>s3-transfer-manager</includeModule>
<includeModule>iam-policy-builder</includeModule>
<includeModule>s3-event-notifications</includeModule>

<!-- Service modules that are heavily customized should be included -->
<includeModule>s3</includeModule>
Expand Down
1 change: 1 addition & 0 deletions services-custom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<module>dynamodb-enhanced</module>
<module>s3-transfer-manager</module>
<module>iam-policy-builder</module>
<module>s3-event-notifications</module>
</modules>

<dependencyManagement>
Expand Down
36 changes: 36 additions & 0 deletions services-custom/s3-event-notifications/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# S3 Event Notifications

## Overview

This module contains the classes used to represent Amazon S3 Event Notifications.


## Deserialization

To convert a json notification to java classes, use the static methods
available on `S3EventNotification`:

```java
String json = "..."; // the notification as json
S3EventNotification event = S3EventNotification.fromJson(json);
event.getRecords().forEach(rec -> println(rec.toString()));
```

Any missing fields of the json will be null in the resulting object.
Any extra fields will be ignored.


## Serialization

To convert an instance of `S3EventNotification` to json, use the `.toJson()`
or `toJsonPretty()` method:

```java
S3EventNotification event = new S3EventNotification(...);
String json = event.toJson();
String jsonPretty = event.toJsonPretty();
```

`GlacierEventData`, `ReplicationEventData`, `IntelligentTieringEventData` and `LifecycleEventData`
will be excluded from the json if null. Any other null fields of the object will be
serialized in the json as `null`.
111 changes: 111 additions & 0 deletions services-custom/s3-event-notifications/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License").
~ You may not use this file except in compliance with the License.
~ A copy of the License is located at
~
~ http://aws.amazon.com/apache2.0
~
~ or in the "license" file accompanying this file. This file is distributed
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
~ express or implied. See the License for the specific language governing
~ permissions and limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java-pom</artifactId>
<version>2.25.11-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>s3-event-notifications</artifactId>
<name>AWS Java SDK :: S3 :: Event Notification</name>
<description>
The AWS SDK for Java - S3 Even Notification contains POJO classes and utils method to help serialize and
deserialize Amazon S3 Event Notifications.
</description>

<properties>
<jre.version>1.8</jre.version>
<awsjavasdk.version>${project.parent.version}</awsjavasdk.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom-internal</artifactId>
<version>${awsjavasdk.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>third-party-jackson-core</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>json-utils</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>annotations</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>utils</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>software.amazon.awssdk.eventnotifications.s3</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 7b61bd0

Please sign in to comment.