From a4edc2210df93c9551cf8aefaee247f352efb2b1 Mon Sep 17 00:00:00 2001 From: Mark Sailes Date: Fri, 15 May 2020 11:06:09 +0100 Subject: [PATCH 1/8] Added support for secret manager rotation event. --- .../events/SecretsManagerRotationEvent.java | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java new file mode 100644 index 00000000..e9ef7b96 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java @@ -0,0 +1,128 @@ +/* + * Copyright 2020 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. + */ + +package com.amazonaws.services.lambda.runtime.events; + +/** + * Class to represent the events which are sent during a Secrets Manager rotation process. + * + * @see Rotating secrets lambda function overview + * + * @author msailes + */ +public class SecretsManagerRotationEvent { + + private String step; + private String secretId; + private String clientRequestToken; + + /** + * Default constructor + */ + public SecretsManagerRotationEvent() { + } + + /** + * The current step in the rotation process. + * + * @return step + */ + public String getStep() { + return step; + } + + /** + * Sets the current step in the rotation process. + * + * @param step + */ + public void setStep(String step) { + this.step = step; + } + + /** + * The ID or Amazon Resource Name (ARN) for the secret to rotate. + * + * @return secretId + */ + public String getSecretId() { + return secretId; + } + + /** + * Sets the ID or ARN for the secret to rotate. + * + * @param secretId + */ + public void setSecretId(String secretId) { + this.secretId = secretId; + } + + /** + * The request token Secrets Manager uses this token to ensure the idempotency of requests during any required + * retries caused by failures of individual calls. + * + * @return clientRequestToken + */ + public String getClientRequestToken() { + return clientRequestToken; + } + + /** + * Sets the request token. + * + * @param clientRequestToken + */ + public void setClientRequestToken(String clientRequestToken) { + this.clientRequestToken = clientRequestToken; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SecretsManagerRotationEvent that = (SecretsManagerRotationEvent) o; + + if (step != null ? !step.equals(that.step) : that.step != null) return false; + if (secretId != null ? !secretId.equals(that.secretId) : that.secretId != null) return false; + return clientRequestToken != null ? clientRequestToken.equals(that.clientRequestToken) : that.clientRequestToken == null; + } + + @Override + public int hashCode() { + int result = step != null ? step.hashCode() : 0; + result = 31 * result + (secretId != null ? secretId.hashCode() : 0); + result = 31 * result + (clientRequestToken != null ? clientRequestToken.hashCode() : 0); + return result; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("SecretsManagerRotationEvent{"); + sb.append("step='").append(step).append('\''); + sb.append(", secretId='").append(secretId).append('\''); + sb.append(", clientRequestToken='").append(clientRequestToken).append('\''); + sb.append('}'); + return sb.toString(); + } + + @Override + public SecretsManagerRotationEvent clone() { + try { + return (SecretsManagerRotationEvent) super.clone(); + } catch (CloneNotSupportedException e) { + throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); + } + } +} From 5f7a0b61af88c52fb57a3690092a5f18d87deacc Mon Sep 17 00:00:00 2001 From: Mark Sailes Date: Mon, 18 May 2020 10:08:39 +0100 Subject: [PATCH 2/8] Migrating to use Lombok. --- aws-lambda-java-events/pom.xml | 6 + .../events/SecretsManagerRotationEvent.java | 105 +----------------- 2 files changed, 12 insertions(+), 99 deletions(-) diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index 5f9e15eb..899fe4b2 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -67,6 +67,12 @@ 1.11.163 provided + + org.projectlombok + lombok + 1.18.12 + provided + diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java index e9ef7b96..a820b496 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java @@ -13,6 +13,9 @@ package com.amazonaws.services.lambda.runtime.events; +import lombok.Data; +import lombok.NoArgsConstructor; + /** * Class to represent the events which are sent during a Secrets Manager rotation process. * @@ -20,109 +23,13 @@ * * @author msailes */ + +@NoArgsConstructor +@Data public class SecretsManagerRotationEvent { private String step; private String secretId; private String clientRequestToken; - /** - * Default constructor - */ - public SecretsManagerRotationEvent() { - } - - /** - * The current step in the rotation process. - * - * @return step - */ - public String getStep() { - return step; - } - - /** - * Sets the current step in the rotation process. - * - * @param step - */ - public void setStep(String step) { - this.step = step; - } - - /** - * The ID or Amazon Resource Name (ARN) for the secret to rotate. - * - * @return secretId - */ - public String getSecretId() { - return secretId; - } - - /** - * Sets the ID or ARN for the secret to rotate. - * - * @param secretId - */ - public void setSecretId(String secretId) { - this.secretId = secretId; - } - - /** - * The request token Secrets Manager uses this token to ensure the idempotency of requests during any required - * retries caused by failures of individual calls. - * - * @return clientRequestToken - */ - public String getClientRequestToken() { - return clientRequestToken; - } - - /** - * Sets the request token. - * - * @param clientRequestToken - */ - public void setClientRequestToken(String clientRequestToken) { - this.clientRequestToken = clientRequestToken; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SecretsManagerRotationEvent that = (SecretsManagerRotationEvent) o; - - if (step != null ? !step.equals(that.step) : that.step != null) return false; - if (secretId != null ? !secretId.equals(that.secretId) : that.secretId != null) return false; - return clientRequestToken != null ? clientRequestToken.equals(that.clientRequestToken) : that.clientRequestToken == null; - } - - @Override - public int hashCode() { - int result = step != null ? step.hashCode() : 0; - result = 31 * result + (secretId != null ? secretId.hashCode() : 0); - result = 31 * result + (clientRequestToken != null ? clientRequestToken.hashCode() : 0); - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("SecretsManagerRotationEvent{"); - sb.append("step='").append(step).append('\''); - sb.append(", secretId='").append(secretId).append('\''); - sb.append(", clientRequestToken='").append(clientRequestToken).append('\''); - sb.append('}'); - return sb.toString(); - } - - @Override - public SecretsManagerRotationEvent clone() { - try { - return (SecretsManagerRotationEvent) super.clone(); - } catch (CloneNotSupportedException e) { - throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); - } - } } From fdad30774b162ed2b2e6fe57c0468cf3f0cadc60 Mon Sep 17 00:00:00 2001 From: Mark Sailes Date: Mon, 18 May 2020 10:51:32 +0100 Subject: [PATCH 3/8] Updated README.md --- aws-lambda-java-events/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index f7c7db8b..5f986f33 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -22,6 +22,7 @@ * `LexEvent` * `S3Event` * `ScheduledEvent` +* `SecretsManagerRotationEvent` * `SNSEvent` * `SQSEvent` From 24ebaf694b2b84c12423a906a4d7b898901e2fa4 Mon Sep 17 00:00:00 2001 From: Mark Sailes Date: Fri, 15 May 2020 11:06:09 +0100 Subject: [PATCH 4/8] Added support for secret manager rotation event. --- README.md | 8 +- aws-lambda-java-events/README.md | 149 +-- aws-lambda-java-events/RELEASE.CHANGELOG.md | 17 + aws-lambda-java-events/pom.xml | 23 +- .../lambda/runtime/events/DynamodbEvent.java | 20 +- .../lambda/runtime/events/KinesisEvent.java | 25 +- .../lambda/runtime/events/S3Event.java | 18 +- .../events/SecretsManagerRotationEvent.java | 35 + .../models/dynamodb/AttributeValue.java | 1111 +++++++++++++++++ .../events/models/dynamodb/Identity.java | 182 +++ .../events/models/dynamodb/OperationType.java | 54 + .../events/models/dynamodb/Record.java | 801 ++++++++++++ .../events/models/dynamodb/StreamRecord.java | 645 ++++++++++ .../models/dynamodb/StreamViewType.java | 59 + .../events/models/kinesis/EncryptionType.java | 54 + .../runtime/events/models/kinesis/Record.java | 494 ++++++++ .../events/models/s3/S3EventNotification.java | 310 +++++ .../lambda/runtime/events/HttpUtils.java | 87 ++ .../models/s3/S3EventNotificationTest.java | 35 + 19 files changed, 3987 insertions(+), 140 deletions(-) create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/AttributeValue.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/Identity.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/OperationType.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/Record.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/StreamRecord.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/StreamViewType.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/kinesis/EncryptionType.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/kinesis/Record.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/s3/S3EventNotification.java create mode 100644 aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/HttpUtils.java create mode 100644 aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/models/s3/S3EventNotificationTest.java diff --git a/README.md b/README.md index df86bfff..ca2460db 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ ___ com.amazonaws aws-lambda-java-events - 2.2.8 + 3.0.0 com.amazonaws @@ -58,7 +58,7 @@ ___ ```groovy 'com.amazonaws:aws-lambda-java-core:1.2.1' -'com.amazonaws:aws-lambda-java-events:2.2.8' +'com.amazonaws:aws-lambda-java-events:3.0.0' 'com.amazonaws:aws-lambda-java-events-sdk-transformer:1.0.0' 'com.amazonaws:aws-lambda-java-log4j:1.0.1' 'com.amazonaws:aws-lambda-java-log4j2:1.2.0' @@ -68,7 +68,7 @@ ___ ```clojure [com.amazonaws/aws-lambda-java-core "1.2.1"] -[com.amazonaws/aws-lambda-java-events "2.2.8"] +[com.amazonaws/aws-lambda-java-events "3.0.0"] [com.amazonaws/aws-lambda-java-events-sdk-transformer "1.0.0"] [com.amazonaws/aws-lambda-java-log4j "1.0.1"] [com.amazonaws/aws-lambda-java-log4j2 "1.2.0"] @@ -78,7 +78,7 @@ ___ ```scala "com.amazonaws" % "aws-lambda-java-core" % "1.2.1" -"com.amazonaws" % "aws-lambda-java-events" % "2.2.8" +"com.amazonaws" % "aws-lambda-java-events" % "3.0.0" "com.amazonaws" % "aws-lambda-java-events-sdk-transformer" % "1.0.0" "com.amazonaws" % "aws-lambda-java-log4j" % "1.0.1" "com.amazonaws" % "aws-lambda-java-log4j2" % "1.2.0" diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index acf53c02..5f986f33 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -1,41 +1,37 @@ -# AWS Lambda Java Events v2.0 +# AWS Lambda Java Events v3.0 -### New Event Models Supported -* APIGatewayProxyRequestEvent -* APIGatewayProxyResponseEvent -* APIGatewayV2ProxyRequestEvent -* APIGatewayV2ProxyResponseEvent -* CloudFrontEvent -* CloudWatchLogsEvent -* CodeCommitEvent -* IoTButtonEvent -* KinesisFirehoseEvent -* LexEvent -* ScheduledEvent +### Event Models Supported +* `APIGatewayProxyRequestEvent` +* `APIGatewayProxyResponseEvent` +* `APIGatewayV2ProxyRequestEvent` +* `APIGatewayV2ProxyResponseEvent` +* `CloudFrontEvent` +* `CloudWatchLogsEvent` +* `CodeCommitEvent` +* `CognitoEvent` +* `ConfigEvent` +* `DynamodbEvent` +* `IoTButtonEvent` +* `KinesisAnalyticsFirehoseInputPreprocessingEvent` +* `KinesisAnalyticsInputPreprocessingResponse` +* `KinesisAnalyticsOutputDeliveryEvent` +* `KinesisAnalyticsOutputDeliveryResponse` +* `KinesisAnalyticsStreamsInputPreprocessingEvent` +* `KinesisEvent` +* `KinesisFirehoseEvent` +* `LexEvent` +* `S3Event` +* `ScheduledEvent` +* `SecretsManagerRotationEvent` +* `SNSEvent` +* `SQSEvent` -### New package inclusion model -The old package inclusion model required users to pull unused dependencies into -their package. We have removed this inclusion so that users' jars will be -smaller, which will results in reduced latency times. Customers using older -versions do not need to make any changes to their existing code. +*As of version `3.0.0`, users are no longer required to pull in SDK dependencies in order to use this library.* -The following event models do not require any SDK dependencies -* APIGatewayProxyRequestEvent -* APIGatewayProxyResponseEvent -* APIGatewayV2ProxyRequestEvent -* APIGatewayV2ProxyResponseEvent -* CloudFrontEvent -* CloudWatchLogsEvent -* CodeCommitEvent -* CognitoEvent -* ConfigEvent -* IoTButtonEvent -* KinesisFirehoseEvent -* LexEvent -* ScheduledEvent -* SNSEvent -so the dependencies section in the pom.xml file would like this +### Getting Started + +[Maven](https://maven.apache.org) ```xml @@ -48,86 +44,29 @@ so the dependencies section in the pom.xml file would like this com.amazonaws aws-lambda-java-events - 2.2.9 + 3.0.0 ... ``` -#### S3 Event - -For the S3 event the pom would look like this: +[Gradle](https://gradle.org) -```xml - - ... - - com.amazonaws - aws-lambda-java-core - 1.2.1 - - - com.amazonaws - aws-lambda-java-events - 2.2.9 - - - com.amazonaws - aws-java-sdk-s3 - 1.11.163 - - ... - +```groovy +'com.amazonaws:aws-lambda-java-core:1.2.1' +'com.amazonaws:aws-lambda-java-events:3.0.0' ``` -#### Kinesis Event - -For the Kinesis event +[Leiningen](http://leiningen.org) and [Boot](http://boot-clj.com) -```xml - - .... - - com.amazonaws - aws-lambda-java-core - 1.2.1 - - - com.amazonaws - aws-lambda-java-events - 2.2.9 - - - com.amazonaws - aws-java-sdk-kinesis - 1.11.163 - - ... - +```clojure +[com.amazonaws/aws-lambda-java-core "1.2.1"] +[com.amazonaws/aws-lambda-java-events "3.0.0"] ``` -#### Dynamodb Event - -For the Dynamodb event +[sbt](http://www.scala-sbt.org) -```xml - - ... - - com.amazonaws - aws-lambda-java-core - 1.2.1 - - - com.amazonaws - aws-lambda-java-events - 2.2.9 - - - com.amazonaws - aws-java-sdk-dynamodb - 1.11.163 - - ... - -``` +```scala +"com.amazonaws" % "aws-lambda-java-core" % "1.2.1" +"com.amazonaws" % "aws-lambda-java-events" % "3.0.0" +``` \ No newline at end of file diff --git a/aws-lambda-java-events/RELEASE.CHANGELOG.md b/aws-lambda-java-events/RELEASE.CHANGELOG.md index d332599a..8573a030 100644 --- a/aws-lambda-java-events/RELEASE.CHANGELOG.md +++ b/aws-lambda-java-events/RELEASE.CHANGELOG.md @@ -1,3 +1,20 @@ +### May 18, 2020 +`3.0.0`: +- Removed AWS SDK v1 dependencies ([#74](https://github.com/aws/aws-lambda-java-libs/issues/74)) + - Copied relevant S3, Kinesis and DynamoDB model classes under namespace `com.amazonaws.services.lambda.runtime.events.models` + - S3: + - `S3EventNotification` + - Kinesis: + - `EncryptionType` + - `Record` + - DynamoDB: + - `AttributeValue` + - `Identity` + - `OperationType` + - `Record` + - `StreamRecord` + - `StreamViewType` + ### May 13, 2020 `2.2.9`: - Added field `operationName` to `APIGatewayProxyRequestEvent` ([#126](https://github.com/aws/aws-lambda-java-libs/pull/126)) diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index 5f9e15eb..98d03e32 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -5,7 +5,7 @@ com.amazonaws aws-lambda-java-events - 2.2.9 + 3.0.0 jar AWS Lambda Java Events Library @@ -49,22 +49,17 @@ joda-time 2.6 + - com.amazonaws - aws-java-sdk-s3 - 1.11.163 - provided - - - com.amazonaws - aws-java-sdk-kinesis - 1.11.163 - provided + org.junit.jupiter + junit-jupiter-engine + 5.5.2 + test - com.amazonaws - aws-java-sdk-dynamodb - 1.11.163 + org.projectlombok + lombok + 1.18.12 provided diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbEvent.java index 6853e381..353f587f 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbEvent.java @@ -1,9 +1,17 @@ -/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ - +/* + * Copyright 2015-2020 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. + */ package com.amazonaws.services.lambda.runtime.events; -import com.amazonaws.services.dynamodbv2.model.Record; - import java.io.Serializable; import java.util.List; @@ -19,7 +27,7 @@ public class DynamodbEvent implements Serializable, Cloneable { /** * The unit of data of an Amazon DynamoDB event */ - public static class DynamodbStreamRecord extends Record { + public static class DynamodbStreamRecord extends com.amazonaws.services.lambda.runtime.events.models.dynamodb.Record { private static final long serialVersionUID = 3638381544604354963L; @@ -52,7 +60,7 @@ public void setEventSourceARN(String eventSourceARN) { * * @return A string representation of this object. * - * @see java.lang.Object#toString() + * @see Object#toString() */ @Override public String toString() { diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisEvent.java index 6d1e5300..d3c44e5b 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisEvent.java @@ -1,6 +1,17 @@ -/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ - +/* + * Copyright 2015-2020 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. + */ package com.amazonaws.services.lambda.runtime.events; + import java.io.Serializable; import java.util.List; @@ -16,7 +27,7 @@ public class KinesisEvent implements Serializable, Cloneable { /** * The unit of data of an Amazon Kinesis stream */ - public static class Record extends com.amazonaws.services.kinesis.model.Record { + public static class Record extends com.amazonaws.services.lambda.runtime.events.models.kinesis.Record { private static final long serialVersionUID = 7856672931457425976L; @@ -49,7 +60,7 @@ public void setKinesisSchemaVersion(String kinesisSchemaVersion) { * * @return A string representation of this object. * - * @see java.lang.Object#toString() + * @see Object#toString() */ @Override public String toString() { @@ -109,7 +120,7 @@ public boolean equals(Object obj) { } /* (non-Javadoc) - * @see com.amazonaws.services.kinesis.model.Record#hashCode() + * @see com.amazonaws.services.lambda.runtime.events.models.kinesis.Record#hashCode() */ @Override public int hashCode() { @@ -288,7 +299,7 @@ public void setAwsRegion(String awsRegion) { * * @return A string representation of this object. * - * @see java.lang.Object#toString() + * @see Object#toString() */ @Override public String toString() { @@ -413,7 +424,7 @@ public void setRecords(List records) { * * @return A string representation of this object. * - * @see java.lang.Object#toString() + * @see Object#toString() */ @Override public String toString() { diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3Event.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3Event.java index c1a83ee0..a51acf7c 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3Event.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3Event.java @@ -1,8 +1,18 @@ -/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ - +/* + * Copyright 2015-2020 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. + */ package com.amazonaws.services.lambda.runtime.events; -import com.amazonaws.services.s3.event.S3EventNotification; +import com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification; import java.io.Serializable; import java.util.ArrayList; @@ -28,7 +38,7 @@ public S3Event() { * Create a new instance of S3Event * @param records A list of S3 event notification records */ - public S3Event(List records) { + public S3Event(List records) { super(records); } diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java new file mode 100644 index 00000000..a820b496 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright 2020 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. + */ + +package com.amazonaws.services.lambda.runtime.events; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Class to represent the events which are sent during a Secrets Manager rotation process. + * + * @see Rotating secrets lambda function overview + * + * @author msailes + */ + +@NoArgsConstructor +@Data +public class SecretsManagerRotationEvent { + + private String step; + private String secretId; + private String clientRequestToken; + +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/AttributeValue.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/AttributeValue.java new file mode 100644 index 00000000..555b42f8 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/AttributeValue.java @@ -0,0 +1,1111 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.dynamodb; + +import java.io.Serializable; + +/** + *

+ * Represents the data for an attribute. + *

+ *

+ * Each attribute value is described as a name-value pair. The name is the data type, and the value is the data itself. + *

+ *

+ * For more information, see Data Types in the Amazon DynamoDB Developer Guide. + *

+ * + * @see AWS API + * Documentation + */ +public class AttributeValue implements Serializable, Cloneable { + + /** + *

+ * An attribute of type String. For example: + *

+ *

+ * "S": "Hello" + *

+ */ + private String s; + /** + *

+ * An attribute of type Number. For example: + *

+ *

+ * "N": "123.45" + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + *

+ */ + private String n; + /** + *

+ * An attribute of type Binary. For example: + *

+ *

+ * "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" + *

+ */ + private java.nio.ByteBuffer b; + /** + *

+ * An attribute of type String Set. For example: + *

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + *

+ */ + private java.util.List sS; + /** + *

+ * An attribute of type Number Set. For example: + *

+ *

+ * "NS": ["42.2", "-19", "7.5", "3.14"] + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + *

+ */ + private java.util.List nS; + /** + *

+ * An attribute of type Binary Set. For example: + *

+ *

+ * "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] + *

+ */ + private java.util.List bS; + /** + *

+ * An attribute of type Map. For example: + *

+ *

+ * "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} + *

+ */ + private java.util.Map m; + /** + *

+ * An attribute of type List. For example: + *

+ *

+ * "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}] + *

+ */ + private java.util.List l; + /** + *

+ * An attribute of type Null. For example: + *

+ *

+ * "NULL": true + *

+ */ + private Boolean nULLValue; + /** + *

+ * An attribute of type Boolean. For example: + *

+ *

+ * "BOOL": true + *

+ */ + private Boolean bOOL; + + /** + * Default constructor for DynamodbAttributeValue object. Callers should use the setter or fluent setter (with...) methods + * to initialize the object after creating it. + */ + public AttributeValue() { + } + + /** + * Constructs a new DynamodbAttributeValue object. Callers should use the setter or fluent setter (with...) methods to + * initialize any additional object members. + * + * @param s + * An attribute of type String. For example:

+ *

+ * "S": "Hello" + */ + public AttributeValue(String s) { + setS(s); + } + + /** + * Constructs a new DynamodbAttributeValue object. Callers should use the setter or fluent setter (with...) methods to + * initialize any additional object members. + * + * @param sS + * An attribute of type String Set. For example:

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + */ + public AttributeValue(java.util.List sS) { + setSS(sS); + } + + /** + *

+ * An attribute of type String. For example: + *

+ *

+ * "S": "Hello" + *

+ * + * @param s + * An attribute of type String. For example:

+ *

+ * "S": "Hello" + */ + + public void setS(String s) { + this.s = s; + } + + /** + *

+ * An attribute of type String. For example: + *

+ *

+ * "S": "Hello" + *

+ * + * @return An attribute of type String. For example:

+ *

+ * "S": "Hello" + */ + + public String getS() { + return this.s; + } + + /** + *

+ * An attribute of type String. For example: + *

+ *

+ * "S": "Hello" + *

+ * + * @param s + * An attribute of type String. For example:

+ *

+ * "S": "Hello" + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withS(String s) { + setS(s); + return this; + } + + /** + *

+ * An attribute of type Number. For example: + *

+ *

+ * "N": "123.45" + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + *

+ * + * @param n + * An attribute of type Number. For example:

+ *

+ * "N": "123.45" + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + */ + + public void setN(String n) { + this.n = n; + } + + /** + *

+ * An attribute of type Number. For example: + *

+ *

+ * "N": "123.45" + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + *

+ * + * @return An attribute of type Number. For example:

+ *

+ * "N": "123.45" + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages + * and libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + */ + + public String getN() { + return this.n; + } + + /** + *

+ * An attribute of type Number. For example: + *

+ *

+ * "N": "123.45" + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + *

+ * + * @param n + * An attribute of type Number. For example:

+ *

+ * "N": "123.45" + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withN(String n) { + setN(n); + return this; + } + + /** + *

+ * An attribute of type Binary. For example: + *

+ *

+ * "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" + *

+ *

+ * The AWS SDK for Java performs a Base64 encoding on this field before sending this request to the AWS service. + * Users of the SDK should not perform Base64 encoding on this field. + *

+ *

+ * Warning: ByteBuffers returned by the SDK are mutable. Changes to the content or position of the byte buffer will + * be seen by all objects that have a reference to this object. It is recommended to call ByteBuffer.duplicate() or + * ByteBuffer.asReadOnlyBuffer() before using or reading from the buffer. This behavior will be changed in a future + * major version of the SDK. + *

+ * + * @param b + * An attribute of type Binary. For example:

+ *

+ * "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" + */ + + public void setB(java.nio.ByteBuffer b) { + this.b = b; + } + + /** + *

+ * An attribute of type Binary. For example: + *

+ *

+ * "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" + *

+ *

+ * {@code ByteBuffer}s are stateful. Calling their {@code get} methods changes their {@code position}. We recommend + * using {@link java.nio.ByteBuffer#asReadOnlyBuffer()} to create a read-only view of the buffer with an independent + * {@code position}, and calling {@code get} methods on this rather than directly on the returned {@code ByteBuffer}. + * Doing so will ensure that anyone else using the {@code ByteBuffer} will not be affected by changes to the + * {@code position}. + *

+ * + * @return An attribute of type Binary. For example:

+ *

+ * "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" + */ + + public java.nio.ByteBuffer getB() { + return this.b; + } + + /** + *

+ * An attribute of type Binary. For example: + *

+ *

+ * "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" + *

+ *

+ * The AWS SDK for Java performs a Base64 encoding on this field before sending this request to the AWS service. + * Users of the SDK should not perform Base64 encoding on this field. + *

+ *

+ * Warning: ByteBuffers returned by the SDK are mutable. Changes to the content or position of the byte buffer will + * be seen by all objects that have a reference to this object. It is recommended to call ByteBuffer.duplicate() or + * ByteBuffer.asReadOnlyBuffer() before using or reading from the buffer. This behavior will be changed in a future + * major version of the SDK. + *

+ * + * @param b + * An attribute of type Binary. For example:

+ *

+ * "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk" + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withB(java.nio.ByteBuffer b) { + setB(b); + return this; + } + + /** + *

+ * An attribute of type String Set. For example: + *

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + *

+ * + * @return An attribute of type String Set. For example:

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + */ + + public java.util.List getSS() { + return sS; + } + + /** + *

+ * An attribute of type String Set. For example: + *

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + *

+ * + * @param sS + * An attribute of type String Set. For example:

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + */ + + public void setSS(java.util.Collection sS) { + if (sS == null) { + this.sS = null; + return; + } + + this.sS = new java.util.ArrayList(sS); + } + + /** + *

+ * An attribute of type String Set. For example: + *

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + *

+ *

+ * NOTE: This method appends the values to the existing list (if any). Use + * {@link #setSS(java.util.Collection)} or {@link #withSS(java.util.Collection)} if you want to override the + * existing values. + *

+ * + * @param sS + * An attribute of type String Set. For example:

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withSS(String... sS) { + if (this.sS == null) { + setSS(new java.util.ArrayList(sS.length)); + } + for (String ele : sS) { + this.sS.add(ele); + } + return this; + } + + /** + *

+ * An attribute of type String Set. For example: + *

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + *

+ * + * @param sS + * An attribute of type String Set. For example:

+ *

+ * "SS": ["Giraffe", "Hippo" ,"Zebra"] + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withSS(java.util.Collection sS) { + setSS(sS); + return this; + } + + /** + *

+ * An attribute of type Number Set. For example: + *

+ *

+ * "NS": ["42.2", "-19", "7.5", "3.14"] + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + *

+ * + * @return An attribute of type Number Set. For example:

+ *

+ * "NS": ["42.2", "-19", "7.5", "3.14"] + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages + * and libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + */ + + public java.util.List getNS() { + return nS; + } + + /** + *

+ * An attribute of type Number Set. For example: + *

+ *

+ * "NS": ["42.2", "-19", "7.5", "3.14"] + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + *

+ * + * @param nS + * An attribute of type Number Set. For example:

+ *

+ * "NS": ["42.2", "-19", "7.5", "3.14"] + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + */ + + public void setNS(java.util.Collection nS) { + if (nS == null) { + this.nS = null; + return; + } + + this.nS = new java.util.ArrayList(nS); + } + + /** + *

+ * An attribute of type Number Set. For example: + *

+ *

+ * "NS": ["42.2", "-19", "7.5", "3.14"] + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + *

+ *

+ * NOTE: This method appends the values to the existing list (if any). Use + * {@link #setNS(java.util.Collection)} or {@link #withNS(java.util.Collection)} if you want to override the + * existing values. + *

+ * + * @param nS + * An attribute of type Number Set. For example:

+ *

+ * "NS": ["42.2", "-19", "7.5", "3.14"] + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withNS(String... nS) { + if (this.nS == null) { + setNS(new java.util.ArrayList(nS.length)); + } + for (String ele : nS) { + this.nS.add(ele); + } + return this; + } + + /** + *

+ * An attribute of type Number Set. For example: + *

+ *

+ * "NS": ["42.2", "-19", "7.5", "3.14"] + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + *

+ * + * @param nS + * An attribute of type Number Set. For example:

+ *

+ * "NS": ["42.2", "-19", "7.5", "3.14"] + *

+ *

+ * Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and + * libraries. However, DynamoDB treats them as number type attributes for mathematical operations. + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withNS(java.util.Collection nS) { + setNS(nS); + return this; + } + + /** + *

+ * An attribute of type Binary Set. For example: + *

+ *

+ * "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] + *

+ * + * @return An attribute of type Binary Set. For example:

+ *

+ * "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] + */ + + public java.util.List getBS() { + return bS; + } + + /** + *

+ * An attribute of type Binary Set. For example: + *

+ *

+ * "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] + *

+ * + * @param bS + * An attribute of type Binary Set. For example:

+ *

+ * "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] + */ + + public void setBS(java.util.Collection bS) { + if (bS == null) { + this.bS = null; + return; + } + + this.bS = new java.util.ArrayList(bS); + } + + /** + *

+ * An attribute of type Binary Set. For example: + *

+ *

+ * "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] + *

+ *

+ * NOTE: This method appends the values to the existing list (if any). Use + * {@link #setBS(java.util.Collection)} or {@link #withBS(java.util.Collection)} if you want to override the + * existing values. + *

+ * + * @param bS + * An attribute of type Binary Set. For example:

+ *

+ * "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withBS(java.nio.ByteBuffer... bS) { + if (this.bS == null) { + setBS(new java.util.ArrayList(bS.length)); + } + for (java.nio.ByteBuffer ele : bS) { + this.bS.add(ele); + } + return this; + } + + /** + *

+ * An attribute of type Binary Set. For example: + *

+ *

+ * "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] + *

+ * + * @param bS + * An attribute of type Binary Set. For example:

+ *

+ * "BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="] + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withBS(java.util.Collection bS) { + setBS(bS); + return this; + } + + /** + *

+ * An attribute of type Map. For example: + *

+ *

+ * "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} + *

+ * + * @return An attribute of type Map. For example:

+ *

+ * "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} + */ + + public java.util.Map getM() { + return m; + } + + /** + *

+ * An attribute of type Map. For example: + *

+ *

+ * "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} + *

+ * + * @param m + * An attribute of type Map. For example:

+ *

+ * "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} + */ + + public void setM(java.util.Map m) { + this.m = m; + } + + /** + *

+ * An attribute of type Map. For example: + *

+ *

+ * "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} + *

+ * + * @param m + * An attribute of type Map. For example:

+ *

+ * "M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}} + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withM(java.util.Map m) { + setM(m); + return this; + } + + public AttributeValue addMEntry(String key, AttributeValue value) { + if (null == this.m) { + this.m = new java.util.HashMap(); + } + if (this.m.containsKey(key)) + throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided."); + this.m.put(key, value); + return this; + } + + /** + * Removes all the entries added into M. + * + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue clearMEntries() { + this.m = null; + return this; + } + + /** + *

+ * An attribute of type List. For example: + *

+ *

+ * "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}] + *

+ * + * @return An attribute of type List. For example:

+ *

+ * "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}] + */ + + public java.util.List getL() { + return l; + } + + /** + *

+ * An attribute of type List. For example: + *

+ *

+ * "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}] + *

+ * + * @param l + * An attribute of type List. For example:

+ *

+ * "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}] + */ + + public void setL(java.util.Collection l) { + if (l == null) { + this.l = null; + return; + } + + this.l = new java.util.ArrayList(l); + } + + /** + *

+ * An attribute of type List. For example: + *

+ *

+ * "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}] + *

+ *

+ * NOTE: This method appends the values to the existing list (if any). Use + * {@link #setL(java.util.Collection)} or {@link #withL(java.util.Collection)} if you want to override the existing + * values. + *

+ * + * @param l + * An attribute of type List. For example:

+ *

+ * "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}] + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withL(AttributeValue... l) { + if (this.l == null) { + setL(new java.util.ArrayList(l.length)); + } + for (AttributeValue ele : l) { + this.l.add(ele); + } + return this; + } + + /** + *

+ * An attribute of type List. For example: + *

+ *

+ * "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}] + *

+ * + * @param l + * An attribute of type List. For example:

+ *

+ * "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N", "3.14159"}] + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withL(java.util.Collection l) { + setL(l); + return this; + } + + /** + *

+ * An attribute of type Null. For example: + *

+ *

+ * "NULL": true + *

+ * + * @param nULLValue + * An attribute of type Null. For example:

+ *

+ * "NULL": true + */ + + public void setNULL(Boolean nULLValue) { + this.nULLValue = nULLValue; + } + + /** + *

+ * An attribute of type Null. For example: + *

+ *

+ * "NULL": true + *

+ * + * @return An attribute of type Null. For example:

+ *

+ * "NULL": true + */ + + public Boolean getNULL() { + return this.nULLValue; + } + + /** + *

+ * An attribute of type Null. For example: + *

+ *

+ * "NULL": true + *

+ * + * @param nULLValue + * An attribute of type Null. For example:

+ *

+ * "NULL": true + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withNULL(Boolean nULLValue) { + setNULL(nULLValue); + return this; + } + + /** + *

+ * An attribute of type Null. For example: + *

+ *

+ * "NULL": true + *

+ * + * @return An attribute of type Null. For example:

+ *

+ * "NULL": true + */ + + public Boolean isNULL() { + return this.nULLValue; + } + + /** + *

+ * An attribute of type Boolean. For example: + *

+ *

+ * "BOOL": true + *

+ * + * @param bOOL + * An attribute of type Boolean. For example:

+ *

+ * "BOOL": true + */ + + public void setBOOL(Boolean bOOL) { + this.bOOL = bOOL; + } + + /** + *

+ * An attribute of type Boolean. For example: + *

+ *

+ * "BOOL": true + *

+ * + * @return An attribute of type Boolean. For example:

+ *

+ * "BOOL": true + */ + + public Boolean getBOOL() { + return this.bOOL; + } + + /** + *

+ * An attribute of type Boolean. For example: + *

+ *

+ * "BOOL": true + *

+ * + * @param bOOL + * An attribute of type Boolean. For example:

+ *

+ * "BOOL": true + * @return Returns a reference to this object so that method calls can be chained together. + */ + + public AttributeValue withBOOL(Boolean bOOL) { + setBOOL(bOOL); + return this; + } + + /** + *

+ * An attribute of type Boolean. For example: + *

+ *

+ * "BOOL": true + *

+ * + * @return An attribute of type Boolean. For example:

+ *

+ * "BOOL": true + */ + + public Boolean isBOOL() { + return this.bOOL; + } + + /** + * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be + * redacted from this string using a placeholder value. + * + * @return A string representation of this object. + * + * @see Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (getS() != null) + sb.append("S: ").append(getS()).append(","); + if (getN() != null) + sb.append("N: ").append(getN()).append(","); + if (getB() != null) + sb.append("B: ").append(getB()).append(","); + if (getSS() != null) + sb.append("SS: ").append(getSS()).append(","); + if (getNS() != null) + sb.append("NS: ").append(getNS()).append(","); + if (getBS() != null) + sb.append("BS: ").append(getBS()).append(","); + if (getM() != null) + sb.append("M: ").append(getM()).append(","); + if (getL() != null) + sb.append("L: ").append(getL()).append(","); + if (getNULL() != null) + sb.append("NULL: ").append(getNULL()).append(","); + if (getBOOL() != null) + sb.append("BOOL: ").append(getBOOL()); + sb.append("}"); + return sb.toString(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + + if (obj instanceof AttributeValue == false) + return false; + AttributeValue other = (AttributeValue) obj; + if (other.getS() == null ^ this.getS() == null) + return false; + if (other.getS() != null && other.getS().equals(this.getS()) == false) + return false; + if (other.getN() == null ^ this.getN() == null) + return false; + if (other.getN() != null && other.getN().equals(this.getN()) == false) + return false; + if (other.getB() == null ^ this.getB() == null) + return false; + if (other.getB() != null && other.getB().equals(this.getB()) == false) + return false; + if (other.getSS() == null ^ this.getSS() == null) + return false; + if (other.getSS() != null && other.getSS().equals(this.getSS()) == false) + return false; + if (other.getNS() == null ^ this.getNS() == null) + return false; + if (other.getNS() != null && other.getNS().equals(this.getNS()) == false) + return false; + if (other.getBS() == null ^ this.getBS() == null) + return false; + if (other.getBS() != null && other.getBS().equals(this.getBS()) == false) + return false; + if (other.getM() == null ^ this.getM() == null) + return false; + if (other.getM() != null && other.getM().equals(this.getM()) == false) + return false; + if (other.getL() == null ^ this.getL() == null) + return false; + if (other.getL() != null && other.getL().equals(this.getL()) == false) + return false; + if (other.getNULL() == null ^ this.getNULL() == null) + return false; + if (other.getNULL() != null && other.getNULL().equals(this.getNULL()) == false) + return false; + if (other.getBOOL() == null ^ this.getBOOL() == null) + return false; + if (other.getBOOL() != null && other.getBOOL().equals(this.getBOOL()) == false) + return false; + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getS() == null) ? 0 : getS().hashCode()); + hashCode = prime * hashCode + ((getN() == null) ? 0 : getN().hashCode()); + hashCode = prime * hashCode + ((getB() == null) ? 0 : getB().hashCode()); + hashCode = prime * hashCode + ((getSS() == null) ? 0 : getSS().hashCode()); + hashCode = prime * hashCode + ((getNS() == null) ? 0 : getNS().hashCode()); + hashCode = prime * hashCode + ((getBS() == null) ? 0 : getBS().hashCode()); + hashCode = prime * hashCode + ((getM() == null) ? 0 : getM().hashCode()); + hashCode = prime * hashCode + ((getL() == null) ? 0 : getL().hashCode()); + hashCode = prime * hashCode + ((getNULL() == null) ? 0 : getNULL().hashCode()); + hashCode = prime * hashCode + ((getBOOL() == null) ? 0 : getBOOL().hashCode()); + return hashCode; + } + + @Override + public AttributeValue clone() { + try { + return (AttributeValue) super.clone(); + } catch (CloneNotSupportedException e) { + throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() even though we're Cloneable!", e); + } + } + +} \ No newline at end of file diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/Identity.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/Identity.java new file mode 100644 index 00000000..12b2fbba --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/Identity.java @@ -0,0 +1,182 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.dynamodb; + +import java.io.Serializable; + +/** + *

+ * Contains details about the type of identity that made the request. + *

+ * + * @see AWS API + * Documentation + */ +public class Identity implements Serializable, Cloneable { + + /** + *

+ * A unique identifier for the entity that made the call. For Time To Live, the principalId is + * "dynamodb.amazonaws.com". + *

+ */ + private String principalId; + + /** + *

+ * The type of the identity. For Time To Live, the type is "Service". + *

+ */ + private String type; + + /** + *

+ * A unique identifier for the entity that made the call. For Time To Live, the principalId is + * "dynamodb.amazonaws.com". + *

+ * + * @param principalId + * A unique identifier for the entity that made the call. For Time To Live, the principalId is + * "dynamodb.amazonaws.com". + */ + public void setPrincipalId(String principalId) { + this.principalId = principalId; + } + + /** + *

+ * A unique identifier for the entity that made the call. For Time To Live, the principalId is + * "dynamodb.amazonaws.com". + *

+ * + * @return A unique identifier for the entity that made the call. For Time To Live, the principalId is + * "dynamodb.amazonaws.com". + */ + public String getPrincipalId() { + return this.principalId; + } + + /** + *

+ * A unique identifier for the entity that made the call. For Time To Live, the principalId is + * "dynamodb.amazonaws.com". + *

+ * + * @param principalId + * A unique identifier for the entity that made the call. For Time To Live, the principalId is + * "dynamodb.amazonaws.com". + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Identity withPrincipalId(String principalId) { + setPrincipalId(principalId); + return this; + } + + /** + *

+ * The type of the identity. For Time To Live, the type is "Service". + *

+ * + * @param type + * The type of the identity. For Time To Live, the type is "Service". + */ + public void setType(String type) { + this.type = type; + } + + /** + *

+ * The type of the identity. For Time To Live, the type is "Service". + *

+ * + * @return The type of the identity. For Time To Live, the type is "Service". + */ + public String getType() { + return this.type; + } + + /** + *

+ * The type of the identity. For Time To Live, the type is "Service". + *

+ * + * @param type + * The type of the identity. For Time To Live, the type is "Service". + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Identity withType(String type) { + setType(type); + return this; + } + + /** + * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be + * redacted from this string using a placeholder value. + * + * @return A string representation of this object. + * + * @see Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (getPrincipalId() != null) + sb.append("PrincipalId: ").append(getPrincipalId()).append(","); + if (getType() != null) + sb.append("Type: ").append(getType()); + sb.append("}"); + return sb.toString(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + + if (obj instanceof Identity == false) + return false; + Identity other = (Identity) obj; + if (other.getPrincipalId() == null ^ this.getPrincipalId() == null) + return false; + if (other.getPrincipalId() != null && other.getPrincipalId().equals(this.getPrincipalId()) == false) + return false; + if (other.getType() == null ^ this.getType() == null) + return false; + if (other.getType() != null && other.getType().equals(this.getType()) == false) + return false; + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getPrincipalId() == null) ? 0 : getPrincipalId().hashCode()); + hashCode = prime * hashCode + ((getType() == null) ? 0 : getType().hashCode()); + return hashCode; + } + + @Override + public Identity clone() { + try { + return (Identity) super.clone(); + } catch (CloneNotSupportedException e) { + throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); + } + } + +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/OperationType.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/OperationType.java new file mode 100644 index 00000000..8d5574ee --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/OperationType.java @@ -0,0 +1,54 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.dynamodb; + +public enum OperationType { + + INSERT("INSERT"), + MODIFY("MODIFY"), + REMOVE("REMOVE"); + + private String value; + + private OperationType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return OperationType corresponding to the value + * + * @throws IllegalArgumentException + * If the specified value does not map to one of the known values in this enum. + */ + public static OperationType fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + } + + for (OperationType enumEntry : OperationType.values()) { + if (enumEntry.toString().equals(value)) { + return enumEntry; + } + } + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } +} \ No newline at end of file diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/Record.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/Record.java new file mode 100644 index 00000000..81065811 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/Record.java @@ -0,0 +1,801 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.dynamodb; + +import java.io.Serializable; + +/** + *

+ * A description of a unique event within a stream. + *

+ * + * @see AWS API + * Documentation + */ +public class Record implements Serializable, Cloneable { + + /** + *

+ * A globally unique identifier for the event that was recorded in this stream record. + *

+ */ + private String eventID; + /** + *

+ * The type of data modification that was performed on the DynamoDB table: + *

+ *
    + *
  • + *

    + * INSERT - a new item was added to the table. + *

    + *
  • + *
  • + *

    + * MODIFY - one or more of an existing item's attributes were modified. + *

    + *
  • + *
  • + *

    + * REMOVE - the item was deleted from the table + *

    + *
  • + *
+ */ + private String eventName; + /** + *

+ * The version number of the stream record format. This number is updated whenever the structure of + * Record is modified. + *

+ *

+ * Client applications must not assume that eventVersion will remain at a particular value, as this + * number is subject to change at any time. In general, eventVersion will only increase as the + * low-level DynamoDB Streams API evolves. + *

+ */ + private String eventVersion; + /** + *

+ * The AWS service from which the stream record originated. For DynamoDB Streams, this is aws:dynamodb. + *

+ */ + private String eventSource; + /** + *

+ * The region in which the GetRecords request was received. + *

+ */ + private String awsRegion; + /** + *

+ * The main body of the stream record, containing all of the DynamoDB-specific fields. + *

+ */ + private StreamRecord dynamodb; + /** + *

+ * Items that are deleted by the Time to Live process after expiration have the following fields: + *

+ *
    + *
  • + *

    + * Records[].userIdentity.type + *

    + *

    + * "Service" + *

    + *
  • + *
  • + *

    + * Records[].userIdentity.principalId + *

    + *

    + * "dynamodb.amazonaws.com" + *

    + *
  • + *
+ */ + private Identity userIdentity; + + /** + *

+ * A globally unique identifier for the event that was recorded in this stream record. + *

+ * + * @param eventID + * A globally unique identifier for the event that was recorded in this stream record. + */ + public void setEventID(String eventID) { + this.eventID = eventID; + } + + /** + *

+ * A globally unique identifier for the event that was recorded in this stream record. + *

+ * + * @return A globally unique identifier for the event that was recorded in this stream record. + */ + public String getEventID() { + return this.eventID; + } + + /** + *

+ * A globally unique identifier for the event that was recorded in this stream record. + *

+ * + * @param eventID + * A globally unique identifier for the event that was recorded in this stream record. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withEventID(String eventID) { + setEventID(eventID); + return this; + } + + /** + *

+ * The type of data modification that was performed on the DynamoDB table: + *

+ *
    + *
  • + *

    + * INSERT - a new item was added to the table. + *

    + *
  • + *
  • + *

    + * MODIFY - one or more of an existing item's attributes were modified. + *

    + *
  • + *
  • + *

    + * REMOVE - the item was deleted from the table + *

    + *
  • + *
+ * + * @param eventName + * The type of data modification that was performed on the DynamoDB table:

+ *
    + *
  • + *

    + * INSERT - a new item was added to the table. + *

    + *
  • + *
  • + *

    + * MODIFY - one or more of an existing item's attributes were modified. + *

    + *
  • + *
  • + *

    + * REMOVE - the item was deleted from the table + *

    + *
  • + * @see OperationType + */ + public void setEventName(String eventName) { + this.eventName = eventName; + } + + /** + *

    + * The type of data modification that was performed on the DynamoDB table: + *

    + *
      + *
    • + *

      + * INSERT - a new item was added to the table. + *

      + *
    • + *
    • + *

      + * MODIFY - one or more of an existing item's attributes were modified. + *

      + *
    • + *
    • + *

      + * REMOVE - the item was deleted from the table + *

      + *
    • + *
    + * + * @return The type of data modification that was performed on the DynamoDB table:

    + *
      + *
    • + *

      + * INSERT - a new item was added to the table. + *

      + *
    • + *
    • + *

      + * MODIFY - one or more of an existing item's attributes were modified. + *

      + *
    • + *
    • + *

      + * REMOVE - the item was deleted from the table + *

      + *
    • + * @see OperationType + */ + public String getEventName() { + return this.eventName; + } + + /** + *

      + * The type of data modification that was performed on the DynamoDB table: + *

      + *
        + *
      • + *

        + * INSERT - a new item was added to the table. + *

        + *
      • + *
      • + *

        + * MODIFY - one or more of an existing item's attributes were modified. + *

        + *
      • + *
      • + *

        + * REMOVE - the item was deleted from the table + *

        + *
      • + *
      + * + * @param eventName + * The type of data modification that was performed on the DynamoDB table:

      + *
        + *
      • + *

        + * INSERT - a new item was added to the table. + *

        + *
      • + *
      • + *

        + * MODIFY - one or more of an existing item's attributes were modified. + *

        + *
      • + *
      • + *

        + * REMOVE - the item was deleted from the table + *

        + *
      • + * @return Returns a reference to this object so that method calls can be chained together. + * @see OperationType + */ + public Record withEventName(String eventName) { + setEventName(eventName); + return this; + } + + /** + *

        + * The type of data modification that was performed on the DynamoDB table: + *

        + *
          + *
        • + *

          + * INSERT - a new item was added to the table. + *

          + *
        • + *
        • + *

          + * MODIFY - one or more of an existing item's attributes were modified. + *

          + *
        • + *
        • + *

          + * REMOVE - the item was deleted from the table + *

          + *
        • + *
        + * + * @param eventName + * The type of data modification that was performed on the DynamoDB table:

        + *
          + *
        • + *

          + * INSERT - a new item was added to the table. + *

          + *
        • + *
        • + *

          + * MODIFY - one or more of an existing item's attributes were modified. + *

          + *
        • + *
        • + *

          + * REMOVE - the item was deleted from the table + *

          + *
        • + * @see OperationType + */ + public void setEventName(OperationType eventName) { + this.eventName = eventName.toString(); + } + + /** + *

          + * The type of data modification that was performed on the DynamoDB table: + *

          + *
            + *
          • + *

            + * INSERT - a new item was added to the table. + *

            + *
          • + *
          • + *

            + * MODIFY - one or more of an existing item's attributes were modified. + *

            + *
          • + *
          • + *

            + * REMOVE - the item was deleted from the table + *

            + *
          • + *
          + * + * @param eventName + * The type of data modification that was performed on the DynamoDB table:

          + *
            + *
          • + *

            + * INSERT - a new item was added to the table. + *

            + *
          • + *
          • + *

            + * MODIFY - one or more of an existing item's attributes were modified. + *

            + *
          • + *
          • + *

            + * REMOVE - the item was deleted from the table + *

            + *
          • + * @return Returns a reference to this object so that method calls can be chained together. + * @see OperationType + */ + public Record withEventName(OperationType eventName) { + setEventName(eventName); + return this; + } + + /** + *

            + * The version number of the stream record format. This number is updated whenever the structure of + * Record is modified. + *

            + *

            + * Client applications must not assume that eventVersion will remain at a particular value, as this + * number is subject to change at any time. In general, eventVersion will only increase as the + * low-level DynamoDB Streams API evolves. + *

            + * + * @param eventVersion + * The version number of the stream record format. This number is updated whenever the structure of + * Record is modified.

            + *

            + * Client applications must not assume that eventVersion will remain at a particular value, as + * this number is subject to change at any time. In general, eventVersion will only increase as + * the low-level DynamoDB Streams API evolves. + */ + public void setEventVersion(String eventVersion) { + this.eventVersion = eventVersion; + } + + /** + *

            + * The version number of the stream record format. This number is updated whenever the structure of + * Record is modified. + *

            + *

            + * Client applications must not assume that eventVersion will remain at a particular value, as this + * number is subject to change at any time. In general, eventVersion will only increase as the + * low-level DynamoDB Streams API evolves. + *

            + * + * @return The version number of the stream record format. This number is updated whenever the structure of + * Record is modified.

            + *

            + * Client applications must not assume that eventVersion will remain at a particular value, as + * this number is subject to change at any time. In general, eventVersion will only increase as + * the low-level DynamoDB Streams API evolves. + */ + public String getEventVersion() { + return this.eventVersion; + } + + /** + *

            + * The version number of the stream record format. This number is updated whenever the structure of + * Record is modified. + *

            + *

            + * Client applications must not assume that eventVersion will remain at a particular value, as this + * number is subject to change at any time. In general, eventVersion will only increase as the + * low-level DynamoDB Streams API evolves. + *

            + * + * @param eventVersion + * The version number of the stream record format. This number is updated whenever the structure of + * Record is modified.

            + *

            + * Client applications must not assume that eventVersion will remain at a particular value, as + * this number is subject to change at any time. In general, eventVersion will only increase as + * the low-level DynamoDB Streams API evolves. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withEventVersion(String eventVersion) { + setEventVersion(eventVersion); + return this; + } + + /** + *

            + * The AWS service from which the stream record originated. For DynamoDB Streams, this is aws:dynamodb. + *

            + * + * @param eventSource + * The AWS service from which the stream record originated. For DynamoDB Streams, this is + * aws:dynamodb. + */ + public void setEventSource(String eventSource) { + this.eventSource = eventSource; + } + + /** + *

            + * The AWS service from which the stream record originated. For DynamoDB Streams, this is aws:dynamodb. + *

            + * + * @return The AWS service from which the stream record originated. For DynamoDB Streams, this is + * aws:dynamodb. + */ + public String getEventSource() { + return this.eventSource; + } + + /** + *

            + * The AWS service from which the stream record originated. For DynamoDB Streams, this is aws:dynamodb. + *

            + * + * @param eventSource + * The AWS service from which the stream record originated. For DynamoDB Streams, this is + * aws:dynamodb. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withEventSource(String eventSource) { + setEventSource(eventSource); + return this; + } + + /** + *

            + * The region in which the GetRecords request was received. + *

            + * + * @param awsRegion + * The region in which the GetRecords request was received. + */ + public void setAwsRegion(String awsRegion) { + this.awsRegion = awsRegion; + } + + /** + *

            + * The region in which the GetRecords request was received. + *

            + * + * @return The region in which the GetRecords request was received. + */ + public String getAwsRegion() { + return this.awsRegion; + } + + /** + *

            + * The region in which the GetRecords request was received. + *

            + * + * @param awsRegion + * The region in which the GetRecords request was received. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withAwsRegion(String awsRegion) { + setAwsRegion(awsRegion); + return this; + } + + /** + *

            + * The main body of the stream record, containing all of the DynamoDB-specific fields. + *

            + * + * @param dynamodb + * The main body of the stream record, containing all of the DynamoDB-specific fields. + */ + public void setDynamodb(StreamRecord dynamodb) { + this.dynamodb = dynamodb; + } + + /** + *

            + * The main body of the stream record, containing all of the DynamoDB-specific fields. + *

            + * + * @return The main body of the stream record, containing all of the DynamoDB-specific fields. + */ + public StreamRecord getDynamodb() { + return this.dynamodb; + } + + /** + *

            + * The main body of the stream record, containing all of the DynamoDB-specific fields. + *

            + * + * @param dynamodb + * The main body of the stream record, containing all of the DynamoDB-specific fields. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withDynamodb(StreamRecord dynamodb) { + setDynamodb(dynamodb); + return this; + } + + /** + *

            + * Items that are deleted by the Time to Live process after expiration have the following fields: + *

            + *
              + *
            • + *

              + * Records[].userIdentity.type + *

              + *

              + * "Service" + *

              + *
            • + *
            • + *

              + * Records[].userIdentity.principalId + *

              + *

              + * "dynamodb.amazonaws.com" + *

              + *
            • + *
            + * + * @param userIdentity + * Items that are deleted by the Time to Live process after expiration have the following fields:

            + *
              + *
            • + *

              + * Records[].userIdentity.type + *

              + *

              + * "Service" + *

              + *
            • + *
            • + *

              + * Records[].userIdentity.principalId + *

              + *

              + * "dynamodb.amazonaws.com" + *

              + *
            • + */ + public void setUserIdentity(Identity userIdentity) { + this.userIdentity = userIdentity; + } + + /** + *

              + * Items that are deleted by the Time to Live process after expiration have the following fields: + *

              + *
                + *
              • + *

                + * Records[].userIdentity.type + *

                + *

                + * "Service" + *

                + *
              • + *
              • + *

                + * Records[].userIdentity.principalId + *

                + *

                + * "dynamodb.amazonaws.com" + *

                + *
              • + *
              + * + * @return Items that are deleted by the Time to Live process after expiration have the following fields:

              + *
                + *
              • + *

                + * Records[].userIdentity.type + *

                + *

                + * "Service" + *

                + *
              • + *
              • + *

                + * Records[].userIdentity.principalId + *

                + *

                + * "dynamodb.amazonaws.com" + *

                + *
              • + */ + public Identity getUserIdentity() { + return this.userIdentity; + } + + /** + *

                + * Items that are deleted by the Time to Live process after expiration have the following fields: + *

                + *
                  + *
                • + *

                  + * Records[].userIdentity.type + *

                  + *

                  + * "Service" + *

                  + *
                • + *
                • + *

                  + * Records[].userIdentity.principalId + *

                  + *

                  + * "dynamodb.amazonaws.com" + *

                  + *
                • + *
                + * + * @param userIdentity + * Items that are deleted by the Time to Live process after expiration have the following fields:

                + *
                  + *
                • + *

                  + * Records[].userIdentity.type + *

                  + *

                  + * "Service" + *

                  + *
                • + *
                • + *

                  + * Records[].userIdentity.principalId + *

                  + *

                  + * "dynamodb.amazonaws.com" + *

                  + *
                • + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withUserIdentity(Identity userIdentity) { + setUserIdentity(userIdentity); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and debugging. + * + * @return A string representation of this object. + * + * @see Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (getEventID() != null) + sb.append("EventID: ").append(getEventID()).append(","); + if (getEventName() != null) + sb.append("EventName: ").append(getEventName()).append(","); + if (getEventVersion() != null) + sb.append("EventVersion: ").append(getEventVersion()).append(","); + if (getEventSource() != null) + sb.append("EventSource: ").append(getEventSource()).append(","); + if (getAwsRegion() != null) + sb.append("AwsRegion: ").append(getAwsRegion()).append(","); + if (getDynamodb() != null) + sb.append("Dynamodb: ").append(getDynamodb()).append(","); + if (getUserIdentity() != null) + sb.append("UserIdentity: ").append(getUserIdentity()); + sb.append("}"); + return sb.toString(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + + if (obj instanceof Record == false) + return false; + Record other = (Record) obj; + if (other.getEventID() == null ^ this.getEventID() == null) + return false; + if (other.getEventID() != null && other.getEventID().equals(this.getEventID()) == false) + return false; + if (other.getEventName() == null ^ this.getEventName() == null) + return false; + if (other.getEventName() != null && other.getEventName().equals(this.getEventName()) == false) + return false; + if (other.getEventVersion() == null ^ this.getEventVersion() == null) + return false; + if (other.getEventVersion() != null && other.getEventVersion().equals(this.getEventVersion()) == false) + return false; + if (other.getEventSource() == null ^ this.getEventSource() == null) + return false; + if (other.getEventSource() != null && other.getEventSource().equals(this.getEventSource()) == false) + return false; + if (other.getAwsRegion() == null ^ this.getAwsRegion() == null) + return false; + if (other.getAwsRegion() != null && other.getAwsRegion().equals(this.getAwsRegion()) == false) + return false; + if (other.getDynamodb() == null ^ this.getDynamodb() == null) + return false; + if (other.getDynamodb() != null && other.getDynamodb().equals(this.getDynamodb()) == false) + return false; + if (other.getUserIdentity() == null ^ this.getUserIdentity() == null) + return false; + if (other.getUserIdentity() != null && other.getUserIdentity().equals(this.getUserIdentity()) == false) + return false; + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getEventID() == null) ? 0 : getEventID().hashCode()); + hashCode = prime * hashCode + ((getEventName() == null) ? 0 : getEventName().hashCode()); + hashCode = prime * hashCode + ((getEventVersion() == null) ? 0 : getEventVersion().hashCode()); + hashCode = prime * hashCode + ((getEventSource() == null) ? 0 : getEventSource().hashCode()); + hashCode = prime * hashCode + ((getAwsRegion() == null) ? 0 : getAwsRegion().hashCode()); + hashCode = prime * hashCode + ((getDynamodb() == null) ? 0 : getDynamodb().hashCode()); + hashCode = prime * hashCode + ((getUserIdentity() == null) ? 0 : getUserIdentity().hashCode()); + return hashCode; + } + + @Override + public Record clone() { + try { + return (Record) super.clone(); + } catch (CloneNotSupportedException e) { + throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); + } + } + +} \ No newline at end of file diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/StreamRecord.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/StreamRecord.java new file mode 100644 index 00000000..0e41c0de --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/StreamRecord.java @@ -0,0 +1,645 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.dynamodb; + +import java.io.Serializable; + +/** + *

                  + * A description of a single data modification that was performed on an item in a DynamoDB table. + *

                  + * + * @see AWS API + * Documentation + */ +public class StreamRecord implements Serializable, Cloneable { + + /** + *

                  + * The approximate date and time when the stream record was created, in UNIX epoch time format. + *

                  + */ + private java.util.Date approximateCreationDateTime; + /** + *

                  + * The primary key attribute(s) for the DynamoDB item that was modified. + *

                  + */ + private java.util.Map keys; + /** + *

                  + * The item in the DynamoDB table as it appeared after it was modified. + *

                  + */ + private java.util.Map newImage; + /** + *

                  + * The item in the DynamoDB table as it appeared before it was modified. + *

                  + */ + private java.util.Map oldImage; + /** + *

                  + * The sequence number of the stream record. + *

                  + */ + private String sequenceNumber; + /** + *

                  + * The size of the stream record, in bytes. + *

                  + */ + private Long sizeBytes; + /** + *

                  + * The type of data from the modified DynamoDB item that was captured in this stream record: + *

                  + *
                    + *
                  • + *

                    + * KEYS_ONLY - only the key attributes of the modified item. + *

                    + *
                  • + *
                  • + *

                    + * NEW_IMAGE - the entire item, as it appeared after it was modified. + *

                    + *
                  • + *
                  • + *

                    + * OLD_IMAGE - the entire item, as it appeared before it was modified. + *

                    + *
                  • + *
                  • + *

                    + * NEW_AND_OLD_IMAGES - both the new and the old item images of the item. + *

                    + *
                  • + *
                  + */ + private String streamViewType; + + /** + *

                  + * The approximate date and time when the stream record was created, in UNIX epoch time format. + *

                  + * + * @param approximateCreationDateTime + * The approximate date and time when the stream record was created, in UNIX epoch time format. + */ + public void setApproximateCreationDateTime(java.util.Date approximateCreationDateTime) { + this.approximateCreationDateTime = approximateCreationDateTime; + } + + /** + *

                  + * The approximate date and time when the stream record was created, in UNIX epoch time format. + *

                  + * + * @return The approximate date and time when the stream record was created, in UNIX epoch time format. + */ + public java.util.Date getApproximateCreationDateTime() { + return this.approximateCreationDateTime; + } + + /** + *

                  + * The approximate date and time when the stream record was created, in UNIX epoch time format. + *

                  + * + * @param approximateCreationDateTime + * The approximate date and time when the stream record was created, in UNIX epoch time format. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public StreamRecord withApproximateCreationDateTime(java.util.Date approximateCreationDateTime) { + setApproximateCreationDateTime(approximateCreationDateTime); + return this; + } + + /** + *

                  + * The primary key attribute(s) for the DynamoDB item that was modified. + *

                  + * + * @return The primary key attribute(s) for the DynamoDB item that was modified. + */ + public java.util.Map getKeys() { + return keys; + } + + /** + *

                  + * The primary key attribute(s) for the DynamoDB item that was modified. + *

                  + * + * @param keys + * The primary key attribute(s) for the DynamoDB item that was modified. + */ + public void setKeys(java.util.Map keys) { + this.keys = keys; + } + + /** + *

                  + * The primary key attribute(s) for the DynamoDB item that was modified. + *

                  + * + * @param keys + * The primary key attribute(s) for the DynamoDB item that was modified. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public StreamRecord withKeys(java.util.Map keys) { + setKeys(keys); + return this; + } + + public StreamRecord addKeysEntry(String key, AttributeValue value) { + if (null == this.keys) { + this.keys = new java.util.HashMap(); + } + if (this.keys.containsKey(key)) + throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided."); + this.keys.put(key, value); + return this; + } + + /** + * Removes all the entries added into Keys. + * + * @return Returns a reference to this object so that method calls can be chained together. + */ + public StreamRecord clearKeysEntries() { + this.keys = null; + return this; + } + + /** + *

                  + * The item in the DynamoDB table as it appeared after it was modified. + *

                  + * + * @return The item in the DynamoDB table as it appeared after it was modified. + */ + public java.util.Map getNewImage() { + return newImage; + } + + /** + *

                  + * The item in the DynamoDB table as it appeared after it was modified. + *

                  + * + * @param newImage + * The item in the DynamoDB table as it appeared after it was modified. + */ + public void setNewImage(java.util.Map newImage) { + this.newImage = newImage; + } + + /** + *

                  + * The item in the DynamoDB table as it appeared after it was modified. + *

                  + * + * @param newImage + * The item in the DynamoDB table as it appeared after it was modified. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public StreamRecord withNewImage(java.util.Map newImage) { + setNewImage(newImage); + return this; + } + + public StreamRecord addNewImageEntry(String key, AttributeValue value) { + if (null == this.newImage) { + this.newImage = new java.util.HashMap(); + } + if (this.newImage.containsKey(key)) + throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided."); + this.newImage.put(key, value); + return this; + } + + /** + * Removes all the entries added into NewImage. + * + * @return Returns a reference to this object so that method calls can be chained together. + */ + public StreamRecord clearNewImageEntries() { + this.newImage = null; + return this; + } + + /** + *

                  + * The item in the DynamoDB table as it appeared before it was modified. + *

                  + * + * @return The item in the DynamoDB table as it appeared before it was modified. + */ + public java.util.Map getOldImage() { + return oldImage; + } + + /** + *

                  + * The item in the DynamoDB table as it appeared before it was modified. + *

                  + * + * @param oldImage + * The item in the DynamoDB table as it appeared before it was modified. + */ + public void setOldImage(java.util.Map oldImage) { + this.oldImage = oldImage; + } + + /** + *

                  + * The item in the DynamoDB table as it appeared before it was modified. + *

                  + * + * @param oldImage + * The item in the DynamoDB table as it appeared before it was modified. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public StreamRecord withOldImage(java.util.Map oldImage) { + setOldImage(oldImage); + return this; + } + + public StreamRecord addOldImageEntry(String key, AttributeValue value) { + if (null == this.oldImage) { + this.oldImage = new java.util.HashMap(); + } + if (this.oldImage.containsKey(key)) + throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided."); + this.oldImage.put(key, value); + return this; + } + + /** + * Removes all the entries added into OldImage. + * + * @return Returns a reference to this object so that method calls can be chained together. + */ + public StreamRecord clearOldImageEntries() { + this.oldImage = null; + return this; + } + + /** + *

                  + * The sequence number of the stream record. + *

                  + * + * @param sequenceNumber + * The sequence number of the stream record. + */ + public void setSequenceNumber(String sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } + + /** + *

                  + * The sequence number of the stream record. + *

                  + * + * @return The sequence number of the stream record. + */ + public String getSequenceNumber() { + return this.sequenceNumber; + } + + /** + *

                  + * The sequence number of the stream record. + *

                  + * + * @param sequenceNumber + * The sequence number of the stream record. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public StreamRecord withSequenceNumber(String sequenceNumber) { + setSequenceNumber(sequenceNumber); + return this; + } + + /** + *

                  + * The size of the stream record, in bytes. + *

                  + * + * @param sizeBytes + * The size of the stream record, in bytes. + */ + public void setSizeBytes(Long sizeBytes) { + this.sizeBytes = sizeBytes; + } + + /** + *

                  + * The size of the stream record, in bytes. + *

                  + * + * @return The size of the stream record, in bytes. + */ + public Long getSizeBytes() { + return this.sizeBytes; + } + + /** + *

                  + * The size of the stream record, in bytes. + *

                  + * + * @param sizeBytes + * The size of the stream record, in bytes. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public StreamRecord withSizeBytes(Long sizeBytes) { + setSizeBytes(sizeBytes); + return this; + } + + /** + *

                  + * The type of data from the modified DynamoDB item that was captured in this stream record: + *

                  + *
                    + *
                  • + *

                    + * KEYS_ONLY - only the key attributes of the modified item. + *

                    + *
                  • + *
                  • + *

                    + * NEW_IMAGE - the entire item, as it appeared after it was modified. + *

                    + *
                  • + *
                  • + *

                    + * OLD_IMAGE - the entire item, as it appeared before it was modified. + *

                    + *
                  • + *
                  • + *

                    + * NEW_AND_OLD_IMAGES - both the new and the old item images of the item. + *

                    + *
                  • + *
                  + * + * @return The type of data from the modified DynamoDB item that was captured in this stream record:

                  + *
                    + *
                  • + *

                    + * KEYS_ONLY - only the key attributes of the modified item. + *

                    + *
                  • + *
                  • + *

                    + * NEW_IMAGE - the entire item, as it appeared after it was modified. + *

                    + *
                  • + *
                  • + *

                    + * OLD_IMAGE - the entire item, as it appeared before it was modified. + *

                    + *
                  • + *
                  • + *

                    + * NEW_AND_OLD_IMAGES - both the new and the old item images of the item. + *

                    + *
                  • + * @see StreamViewType + */ + public String getStreamViewType() { + return this.streamViewType; + } + + /** + *

                    + * The type of data from the modified DynamoDB item that was captured in this stream record: + *

                    + *
                      + *
                    • + *

                      + * KEYS_ONLY - only the key attributes of the modified item. + *

                      + *
                    • + *
                    • + *

                      + * NEW_IMAGE - the entire item, as it appeared after it was modified. + *

                      + *
                    • + *
                    • + *

                      + * OLD_IMAGE - the entire item, as it appeared before it was modified. + *

                      + *
                    • + *
                    • + *

                      + * NEW_AND_OLD_IMAGES - both the new and the old item images of the item. + *

                      + *
                    • + *
                    + * + * @param streamViewType + * The type of data from the modified DynamoDB item that was captured in this stream record:

                    + *
                      + *
                    • + *

                      + * KEYS_ONLY - only the key attributes of the modified item. + *

                      + *
                    • + *
                    • + *

                      + * NEW_IMAGE - the entire item, as it appeared after it was modified. + *

                      + *
                    • + *
                    • + *

                      + * OLD_IMAGE - the entire item, as it appeared before it was modified. + *

                      + *
                    • + *
                    • + *

                      + * NEW_AND_OLD_IMAGES - both the new and the old item images of the item. + *

                      + *
                    • + * @see StreamViewType + */ + public void setStreamViewType(StreamViewType streamViewType) { + withStreamViewType(streamViewType); + } + + /** + *

                      + * The type of data from the modified DynamoDB item that was captured in this stream record: + *

                      + *
                        + *
                      • + *

                        + * KEYS_ONLY - only the key attributes of the modified item. + *

                        + *
                      • + *
                      • + *

                        + * NEW_IMAGE - the entire item, as it appeared after it was modified. + *

                        + *
                      • + *
                      • + *

                        + * OLD_IMAGE - the entire item, as it appeared before it was modified. + *

                        + *
                      • + *
                      • + *

                        + * NEW_AND_OLD_IMAGES - both the new and the old item images of the item. + *

                        + *
                      • + *
                      + * + * @param streamViewType + * The type of data from the modified DynamoDB item that was captured in this stream record:

                      + *
                        + *
                      • + *

                        + * KEYS_ONLY - only the key attributes of the modified item. + *

                        + *
                      • + *
                      • + *

                        + * NEW_IMAGE - the entire item, as it appeared after it was modified. + *

                        + *
                      • + *
                      • + *

                        + * OLD_IMAGE - the entire item, as it appeared before it was modified. + *

                        + *
                      • + *
                      • + *

                        + * NEW_AND_OLD_IMAGES - both the new and the old item images of the item. + *

                        + *
                      • + * @return Returns a reference to this object so that method calls can be chained together. + * @see StreamViewType + */ + public StreamRecord withStreamViewType(StreamViewType streamViewType) { + this.streamViewType = streamViewType.toString(); + return this; + } + + /** + * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be + * redacted from this string using a placeholder value. + * + * @return A string representation of this object. + * + * @see Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (getApproximateCreationDateTime() != null) + sb.append("ApproximateCreationDateTime: ").append(getApproximateCreationDateTime()).append(","); + if (getKeys() != null) + sb.append("Keys: ").append(getKeys()).append(","); + if (getNewImage() != null) + sb.append("NewImage: ").append(getNewImage()).append(","); + if (getOldImage() != null) + sb.append("OldImage: ").append(getOldImage()).append(","); + if (getSequenceNumber() != null) + sb.append("SequenceNumber: ").append(getSequenceNumber()).append(","); + if (getSizeBytes() != null) + sb.append("SizeBytes: ").append(getSizeBytes()).append(","); + if (getStreamViewType() != null) + sb.append("StreamViewType: ").append(getStreamViewType()); + sb.append("}"); + return sb.toString(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + + if (obj instanceof StreamRecord == false) + return false; + StreamRecord other = (StreamRecord) obj; + if (other.getApproximateCreationDateTime() == null ^ this.getApproximateCreationDateTime() == null) + return false; + if (other.getApproximateCreationDateTime() != null && other.getApproximateCreationDateTime().equals(this.getApproximateCreationDateTime()) == false) + return false; + if (other.getKeys() == null ^ this.getKeys() == null) + return false; + if (other.getKeys() != null && other.getKeys().equals(this.getKeys()) == false) + return false; + if (other.getNewImage() == null ^ this.getNewImage() == null) + return false; + if (other.getNewImage() != null && other.getNewImage().equals(this.getNewImage()) == false) + return false; + if (other.getOldImage() == null ^ this.getOldImage() == null) + return false; + if (other.getOldImage() != null && other.getOldImage().equals(this.getOldImage()) == false) + return false; + if (other.getSequenceNumber() == null ^ this.getSequenceNumber() == null) + return false; + if (other.getSequenceNumber() != null && other.getSequenceNumber().equals(this.getSequenceNumber()) == false) + return false; + if (other.getSizeBytes() == null ^ this.getSizeBytes() == null) + return false; + if (other.getSizeBytes() != null && other.getSizeBytes().equals(this.getSizeBytes()) == false) + return false; + if (other.getStreamViewType() == null ^ this.getStreamViewType() == null) + return false; + if (other.getStreamViewType() != null && other.getStreamViewType().equals(this.getStreamViewType()) == false) + return false; + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getApproximateCreationDateTime() == null) ? 0 : getApproximateCreationDateTime().hashCode()); + hashCode = prime * hashCode + ((getKeys() == null) ? 0 : getKeys().hashCode()); + hashCode = prime * hashCode + ((getNewImage() == null) ? 0 : getNewImage().hashCode()); + hashCode = prime * hashCode + ((getOldImage() == null) ? 0 : getOldImage().hashCode()); + hashCode = prime * hashCode + ((getSequenceNumber() == null) ? 0 : getSequenceNumber().hashCode()); + hashCode = prime * hashCode + ((getSizeBytes() == null) ? 0 : getSizeBytes().hashCode()); + hashCode = prime * hashCode + ((getStreamViewType() == null) ? 0 : getStreamViewType().hashCode()); + return hashCode; + } + + @Override + public StreamRecord clone() { + try { + return (StreamRecord) super.clone(); + } catch (CloneNotSupportedException e) { + throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); + } + } + +} \ No newline at end of file diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/StreamViewType.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/StreamViewType.java new file mode 100644 index 00000000..93cdbc8f --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/dynamodb/StreamViewType.java @@ -0,0 +1,59 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.dynamodb; + +public enum StreamViewType { + + NEW_IMAGE("NEW_IMAGE"), + OLD_IMAGE("OLD_IMAGE"), + NEW_AND_OLD_IMAGES("NEW_AND_OLD_IMAGES"), + KEYS_ONLY("KEYS_ONLY"); + + private String value; + + StreamViewType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value real value + * @return StreamViewType corresponding to the value + * + * @throws IllegalArgumentException + * If the specified value does not map to one of the known values in this enum. + */ + public static StreamViewType fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + } + + for (StreamViewType enumEntry : StreamViewType.values()) { + if (enumEntry.toString().equals(value)) { + return enumEntry; + } + } + + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } +} \ No newline at end of file diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/kinesis/EncryptionType.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/kinesis/EncryptionType.java new file mode 100644 index 00000000..8ffb3e14 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/kinesis/EncryptionType.java @@ -0,0 +1,54 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.kinesis; + +public enum EncryptionType { + + NONE("NONE"), + KMS("KMS"); + + private String value; + + private EncryptionType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return EncryptionType corresponding to the value + * + * @throws IllegalArgumentException + * If the specified value does not map to one of the known values in this enum. + */ + public static EncryptionType fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + } + + for (EncryptionType enumEntry : EncryptionType.values()) { + if (enumEntry.toString().equals(value)) { + return enumEntry; + } + } + + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } +} \ No newline at end of file diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/kinesis/Record.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/kinesis/Record.java new file mode 100644 index 00000000..085fe8e5 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/kinesis/Record.java @@ -0,0 +1,494 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.kinesis; + +import java.io.Serializable; + +/** + *

                        + * The unit of data of the Kinesis data stream, which is composed of a sequence number, a partition key, and a data + * blob. + *

                        + * + * @see AWS API + * Documentation + */ +public class Record implements Serializable, Cloneable { + + /** + *

                        + * The unique identifier of the record within its shard. + *

                        + */ + private String sequenceNumber; + /** + *

                        + * The approximate time that the record was inserted into the stream. + *

                        + */ + private java.util.Date approximateArrivalTimestamp; + /** + *

                        + * The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not inspect, + * interpret, or change the data in the blob in any way. When the data blob (the payload before base64-encoding) is + * added to the partition key size, the total size must not exceed the maximum record size (1 MB). + *

                        + */ + private java.nio.ByteBuffer data; + /** + *

                        + * Identifies which shard in the stream the data record is assigned to. + *

                        + */ + private String partitionKey; + /** + *

                        + * The encryption type used on the record. This parameter can be one of the following values: + *

                        + *
                          + *
                        • + *

                          + * NONE: Do not encrypt the records in the stream. + *

                          + *
                        • + *
                        • + *

                          + * KMS: Use server-side encryption on the records in the stream using a customer-managed AWS KMS key. + *

                          + *
                        • + *
                        + */ + private String encryptionType; + + /** + *

                        + * The unique identifier of the record within its shard. + *

                        + * + * @param sequenceNumber + * The unique identifier of the record within its shard. + */ + public void setSequenceNumber(String sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } + + /** + *

                        + * The unique identifier of the record within its shard. + *

                        + * + * @return The unique identifier of the record within its shard. + */ + public String getSequenceNumber() { + return this.sequenceNumber; + } + + /** + *

                        + * The unique identifier of the record within its shard. + *

                        + * + * @param sequenceNumber + * The unique identifier of the record within its shard. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withSequenceNumber(String sequenceNumber) { + setSequenceNumber(sequenceNumber); + return this; + } + + /** + *

                        + * The approximate time that the record was inserted into the stream. + *

                        + * + * @param approximateArrivalTimestamp + * The approximate time that the record was inserted into the stream. + */ + public void setApproximateArrivalTimestamp(java.util.Date approximateArrivalTimestamp) { + this.approximateArrivalTimestamp = approximateArrivalTimestamp; + } + + /** + *

                        + * The approximate time that the record was inserted into the stream. + *

                        + * + * @return The approximate time that the record was inserted into the stream. + */ + public java.util.Date getApproximateArrivalTimestamp() { + return this.approximateArrivalTimestamp; + } + + /** + *

                        + * The approximate time that the record was inserted into the stream. + *

                        + * + * @param approximateArrivalTimestamp + * The approximate time that the record was inserted into the stream. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withApproximateArrivalTimestamp(java.util.Date approximateArrivalTimestamp) { + setApproximateArrivalTimestamp(approximateArrivalTimestamp); + return this; + } + + /** + *

                        + * The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not inspect, + * interpret, or change the data in the blob in any way. When the data blob (the payload before base64-encoding) is + * added to the partition key size, the total size must not exceed the maximum record size (1 MB). + *

                        + *

                        + * The AWS SDK for Java performs a Base64 encoding on this field before sending this request to the AWS service. + * Users of the SDK should not perform Base64 encoding on this field. + *

                        + *

                        + * Warning: ByteBuffers returned by the SDK are mutable. Changes to the content or position of the byte buffer will + * be seen by all objects that have a reference to this object. It is recommended to call ByteBuffer.duplicate() or + * ByteBuffer.asReadOnlyBuffer() before using or reading from the buffer. This behavior will be changed in a future + * major version of the SDK. + *

                        + * + * @param data + * The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not + * inspect, interpret, or change the data in the blob in any way. When the data blob (the payload before + * base64-encoding) is added to the partition key size, the total size must not exceed the maximum record + * size (1 MB). + */ + public void setData(java.nio.ByteBuffer data) { + this.data = data; + } + + /** + *

                        + * The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not inspect, + * interpret, or change the data in the blob in any way. When the data blob (the payload before base64-encoding) is + * added to the partition key size, the total size must not exceed the maximum record size (1 MB). + *

                        + *

                        + * {@code ByteBuffer}s are stateful. Calling their {@code get} methods changes their {@code position}. We recommend + * using {@link java.nio.ByteBuffer#asReadOnlyBuffer()} to create a read-only view of the buffer with an independent + * {@code position}, and calling {@code get} methods on this rather than directly on the returned {@code ByteBuffer}. + * Doing so will ensure that anyone else using the {@code ByteBuffer} will not be affected by changes to the + * {@code position}. + *

                        + * + * @return The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not + * inspect, interpret, or change the data in the blob in any way. When the data blob (the payload before + * base64-encoding) is added to the partition key size, the total size must not exceed the maximum record + * size (1 MB). + */ + public java.nio.ByteBuffer getData() { + return this.data; + } + + /** + *

                        + * The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not inspect, + * interpret, or change the data in the blob in any way. When the data blob (the payload before base64-encoding) is + * added to the partition key size, the total size must not exceed the maximum record size (1 MB). + *

                        + *

                        + * The AWS SDK for Java performs a Base64 encoding on this field before sending this request to the AWS service. + * Users of the SDK should not perform Base64 encoding on this field. + *

                        + *

                        + * Warning: ByteBuffers returned by the SDK are mutable. Changes to the content or position of the byte buffer will + * be seen by all objects that have a reference to this object. It is recommended to call ByteBuffer.duplicate() or + * ByteBuffer.asReadOnlyBuffer() before using or reading from the buffer. This behavior will be changed in a future + * major version of the SDK. + *

                        + * + * @param data + * The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not + * inspect, interpret, or change the data in the blob in any way. When the data blob (the payload before + * base64-encoding) is added to the partition key size, the total size must not exceed the maximum record + * size (1 MB). + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withData(java.nio.ByteBuffer data) { + setData(data); + return this; + } + + /** + *

                        + * Identifies which shard in the stream the data record is assigned to. + *

                        + * + * @param partitionKey + * Identifies which shard in the stream the data record is assigned to. + */ + public void setPartitionKey(String partitionKey) { + this.partitionKey = partitionKey; + } + + /** + *

                        + * Identifies which shard in the stream the data record is assigned to. + *

                        + * + * @return Identifies which shard in the stream the data record is assigned to. + */ + public String getPartitionKey() { + return this.partitionKey; + } + + /** + *

                        + * Identifies which shard in the stream the data record is assigned to. + *

                        + * + * @param partitionKey + * Identifies which shard in the stream the data record is assigned to. + * @return Returns a reference to this object so that method calls can be chained together. + */ + public Record withPartitionKey(String partitionKey) { + setPartitionKey(partitionKey); + return this; + } + + /** + *

                        + * The encryption type used on the record. This parameter can be one of the following values: + *

                        + *
                          + *
                        • + *

                          + * NONE: Do not encrypt the records in the stream. + *

                          + *
                        • + *
                        • + *

                          + * KMS: Use server-side encryption on the records in the stream using a customer-managed AWS KMS key. + *

                          + *
                        • + *
                        + * + * @param encryptionType + * The encryption type used on the record. This parameter can be one of the following values:

                        + *
                          + *
                        • + *

                          + * NONE: Do not encrypt the records in the stream. + *

                          + *
                        • + *
                        • + *

                          + * KMS: Use server-side encryption on the records in the stream using a customer-managed AWS KMS + * key. + *

                          + *
                        • + * @see EncryptionType + */ + public void setEncryptionType(String encryptionType) { + this.encryptionType = encryptionType; + } + + /** + *

                          + * The encryption type used on the record. This parameter can be one of the following values: + *

                          + *
                            + *
                          • + *

                            + * NONE: Do not encrypt the records in the stream. + *

                            + *
                          • + *
                          • + *

                            + * KMS: Use server-side encryption on the records in the stream using a customer-managed AWS KMS key. + *

                            + *
                          • + *
                          + * + * @return The encryption type used on the record. This parameter can be one of the following values:

                          + *
                            + *
                          • + *

                            + * NONE: Do not encrypt the records in the stream. + *

                            + *
                          • + *
                          • + *

                            + * KMS: Use server-side encryption on the records in the stream using a customer-managed AWS + * KMS key. + *

                            + *
                          • + * @see EncryptionType + */ + public String getEncryptionType() { + return this.encryptionType; + } + + /** + *

                            + * The encryption type used on the record. This parameter can be one of the following values: + *

                            + *
                              + *
                            • + *

                              + * NONE: Do not encrypt the records in the stream. + *

                              + *
                            • + *
                            • + *

                              + * KMS: Use server-side encryption on the records in the stream using a customer-managed AWS KMS key. + *

                              + *
                            • + *
                            + * + * @param encryptionType + * The encryption type used on the record. This parameter can be one of the following values:

                            + *
                              + *
                            • + *

                              + * NONE: Do not encrypt the records in the stream. + *

                              + *
                            • + *
                            • + *

                              + * KMS: Use server-side encryption on the records in the stream using a customer-managed AWS KMS + * key. + *

                              + *
                            • + * @return Returns a reference to this object so that method calls can be chained together. + * @see EncryptionType + */ + public Record withEncryptionType(String encryptionType) { + setEncryptionType(encryptionType); + return this; + } + + /** + *

                              + * The encryption type used on the record. This parameter can be one of the following values: + *

                              + *
                                + *
                              • + *

                                + * NONE: Do not encrypt the records in the stream. + *

                                + *
                              • + *
                              • + *

                                + * KMS: Use server-side encryption on the records in the stream using a customer-managed AWS KMS key. + *

                                + *
                              • + *
                              + * + * @param encryptionType + * The encryption type used on the record. This parameter can be one of the following values:

                              + *
                                + *
                              • + *

                                + * NONE: Do not encrypt the records in the stream. + *

                                + *
                              • + *
                              • + *

                                + * KMS: Use server-side encryption on the records in the stream using a customer-managed AWS KMS + * key. + *

                                + *
                              • + * @return Returns a reference to this object so that method calls can be chained together. + * @see EncryptionType + */ + public Record withEncryptionType(EncryptionType encryptionType) { + this.encryptionType = encryptionType.toString(); + return this; + } + + /** + * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be + * redacted from this string using a placeholder value. + * + * @return A string representation of this object. + * + * @see Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (getSequenceNumber() != null) + sb.append("SequenceNumber: ").append(getSequenceNumber()).append(","); + if (getApproximateArrivalTimestamp() != null) + sb.append("ApproximateArrivalTimestamp: ").append(getApproximateArrivalTimestamp()).append(","); + if (getData() != null) + sb.append("Data: ").append(getData()).append(","); + if (getPartitionKey() != null) + sb.append("PartitionKey: ").append(getPartitionKey()).append(","); + if (getEncryptionType() != null) + sb.append("EncryptionType: ").append(getEncryptionType()); + sb.append("}"); + return sb.toString(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + + if (obj instanceof Record == false) + return false; + Record other = (Record) obj; + if (other.getSequenceNumber() == null ^ this.getSequenceNumber() == null) + return false; + if (other.getSequenceNumber() != null && other.getSequenceNumber().equals(this.getSequenceNumber()) == false) + return false; + if (other.getApproximateArrivalTimestamp() == null ^ this.getApproximateArrivalTimestamp() == null) + return false; + if (other.getApproximateArrivalTimestamp() != null && other.getApproximateArrivalTimestamp().equals(this.getApproximateArrivalTimestamp()) == false) + return false; + if (other.getData() == null ^ this.getData() == null) + return false; + if (other.getData() != null && other.getData().equals(this.getData()) == false) + return false; + if (other.getPartitionKey() == null ^ this.getPartitionKey() == null) + return false; + if (other.getPartitionKey() != null && other.getPartitionKey().equals(this.getPartitionKey()) == false) + return false; + if (other.getEncryptionType() == null ^ this.getEncryptionType() == null) + return false; + if (other.getEncryptionType() != null && other.getEncryptionType().equals(this.getEncryptionType()) == false) + return false; + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getSequenceNumber() == null) ? 0 : getSequenceNumber().hashCode()); + hashCode = prime * hashCode + ((getApproximateArrivalTimestamp() == null) ? 0 : getApproximateArrivalTimestamp().hashCode()); + hashCode = prime * hashCode + ((getData() == null) ? 0 : getData().hashCode()); + hashCode = prime * hashCode + ((getPartitionKey() == null) ? 0 : getPartitionKey().hashCode()); + hashCode = prime * hashCode + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode()); + return hashCode; + } + + @Override + public Record clone() { + try { + return (Record) super.clone(); + } catch (CloneNotSupportedException e) { + throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); + } + } +} \ No newline at end of file diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/s3/S3EventNotification.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/s3/S3EventNotification.java new file mode 100644 index 00000000..5df14ea2 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/s3/S3EventNotification.java @@ -0,0 +1,310 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.s3; + +import org.joda.time.DateTime; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.List; + +/** +* A helper class that represents a strongly typed S3 EventNotification item sent +* to SQS, SNS, or Lambda. +*/ +public class S3EventNotification { + + private final List records; + + public S3EventNotification(List records) { + this.records = records; + } + + /** + * @return the records in this notification + */ + public List getRecords() { + return records; + } + + + public static class UserIdentityEntity { + + private final String principalId; + + public UserIdentityEntity(String principalId) { + this.principalId = principalId; + } + + public String getPrincipalId() { + return principalId; + } + } + + public static class S3BucketEntity { + + private final String name; + private final UserIdentityEntity ownerIdentity; + private final String arn; + + public S3BucketEntity(String name, UserIdentityEntity ownerIdentity, String arn) { + this.name = name; + this.ownerIdentity = ownerIdentity; + this.arn = arn; + } + + public String getName() { + return name; + } + + public UserIdentityEntity getOwnerIdentity() { + return ownerIdentity; + } + + public String getArn() { + return arn; + } + } + + public static class S3ObjectEntity { + + private final String key; + private final Long size; + private final String eTag; + private final String versionId; + private final String sequencer; + + @Deprecated + public S3ObjectEntity( + String key, + Integer size, + String eTag, + String versionId) + { + this.key = key; + this.size = size == null ? null : size.longValue(); + this.eTag = eTag; + this.versionId = versionId; + this.sequencer = null; + } + + @Deprecated + public S3ObjectEntity( + String key, + Long size, + String eTag, + String versionId) + { + this(key, size, eTag, versionId, null); + } + + public S3ObjectEntity(String key, Long size, String eTag, String versionId, String sequencer) { + this.key = key; + this.size = size; + this.eTag = eTag; + this.versionId = versionId; + this.sequencer = sequencer; + } + + public String getKey() { + return key; + } + + /** + * S3 URL encodes the key of the object involved in the event. This is + * a convenience method to automatically URL decode the key. + * @return The URL decoded object key. + */ + public String getUrlDecodedKey() { + return urlDecode(getKey()); + } + + private static final String DEFAULT_ENCODING = "UTF-8"; + + /** + * Decode a string for use in the path of a URL; uses URLDecoder.decode, + * which decodes a string for use in the query portion of a URL. + * + * @param value The value to decode + * @return The decoded value if parameter is not null, otherwise, null is returned. + */ + private static String urlDecode(final String value) { + if (value == null) { + return null; + } + + try { + return URLDecoder.decode(value, DEFAULT_ENCODING); + } catch (UnsupportedEncodingException ex) { + throw new RuntimeException(ex); + } + } + + /** + * @deprecated use {@link #getSizeAsLong()} instead. + */ + @Deprecated + public Integer getSize() { + return size == null ? null : size.intValue(); + } + + public Long getSizeAsLong() { + return size; + } + + public String geteTag() { + return eTag; + } + + public String getVersionId() { + return versionId; + } + + public String getSequencer() { + return sequencer; + } + } + + public static class S3Entity { + + private final String configurationId; + private final S3BucketEntity bucket; + private final S3ObjectEntity object; + private final String s3SchemaVersion; + + public S3Entity(String configurationId, S3BucketEntity bucket, S3ObjectEntity object, String s3SchemaVersion) { + this.configurationId = configurationId; + this.bucket = bucket; + this.object = object; + this.s3SchemaVersion = s3SchemaVersion; + } + + public String getConfigurationId() { + return configurationId; + } + + public S3BucketEntity getBucket() { + return bucket; + } + + public S3ObjectEntity getObject() { + return object; + } + + public String getS3SchemaVersion() { + return s3SchemaVersion; + } + } + + public static class RequestParametersEntity { + + private final String sourceIPAddress; + + public RequestParametersEntity(String sourceIPAddress) { + this.sourceIPAddress = sourceIPAddress; + } + + public String getSourceIPAddress() { + return sourceIPAddress; + } + } + + public static class ResponseElementsEntity { + + private final String xAmzId2; + private final String xAmzRequestId; + + public ResponseElementsEntity(String xAmzId2, String xAmzRequestId) + { + this.xAmzId2 = xAmzId2; + this.xAmzRequestId = xAmzRequestId; + } + + public String getxAmzId2() { + return xAmzId2; + } + + public String getxAmzRequestId() { + return xAmzRequestId; + } + } + + public static class S3EventNotificationRecord { + + private final String awsRegion; + private final String eventName; + private final String eventSource; + private DateTime eventTime; + private final String eventVersion; + private final RequestParametersEntity requestParameters; + private final ResponseElementsEntity responseElements; + private final S3Entity s3; + private final UserIdentityEntity userIdentity; + + public S3EventNotificationRecord(String awsRegion, String eventName, String eventSource, String eventTime, + String eventVersion, RequestParametersEntity requestParameters, + ResponseElementsEntity responseElements, S3Entity s3, + UserIdentityEntity userIdentity) { + this.awsRegion = awsRegion; + this.eventName = eventName; + this.eventSource = eventSource; + + if (eventTime != null) + { + this.eventTime = DateTime.parse(eventTime); + } + + this.eventVersion = eventVersion; + this.requestParameters = requestParameters; + this.responseElements = responseElements; + this.s3 = s3; + this.userIdentity = userIdentity; + } + + public String getAwsRegion() { + return awsRegion; + } + + public String getEventName() { + return eventName; + } + + public String getEventSource() { + return eventSource; + } + + public DateTime getEventTime() { + return eventTime; + } + + public String getEventVersion() { + return eventVersion; + } + + public RequestParametersEntity getRequestParameters() { + return requestParameters; + } + + public ResponseElementsEntity getResponseElements() { + return responseElements; + } + + public S3Entity getS3() { + return s3; + } + + public UserIdentityEntity getUserIdentity() { + return userIdentity; + } + } +} diff --git a/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/HttpUtils.java b/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/HttpUtils.java new file mode 100644 index 00000000..d6ff1aa4 --- /dev/null +++ b/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/HttpUtils.java @@ -0,0 +1,87 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class HttpUtils { + + private static final String DEFAULT_ENCODING = "UTF-8"; + + /** + * Regex which matches any of the sequences that we need to fix up after + * URLEncoder.encode(). + */ + private static final Pattern ENCODED_CHARACTERS_PATTERN; + static { + StringBuilder pattern = new StringBuilder() + .append(Pattern.quote("+")) + .append("|") + .append(Pattern.quote("*")) + .append("|") + .append(Pattern.quote("%7E")) + .append("|") + .append(Pattern.quote("%2F")); + + ENCODED_CHARACTERS_PATTERN = Pattern.compile(pattern.toString()); + } + + /** + * Encode a string for use in the path of a URL; uses URLEncoder.encode, + * (which encodes a string for use in the query portion of a URL), then + * applies some postfilters to fix things up per the RFC. Can optionally + * handle strings which are meant to encode a path (ie include '/'es + * which should NOT be escaped). + * + * @param value the value to encode + * @param path true if the value is intended to represent a path + * @return the encoded value + */ + public static String urlEncode(final String value, final boolean path) { + if (value == null) { + return ""; + } + + try { + String encoded = URLEncoder.encode(value, DEFAULT_ENCODING); + + Matcher matcher = ENCODED_CHARACTERS_PATTERN.matcher(encoded); + StringBuffer buffer = new StringBuffer(encoded.length()); + + while (matcher.find()) { + String replacement = matcher.group(0); + + if ("+".equals(replacement)) { + replacement = "%20"; + } else if ("*".equals(replacement)) { + replacement = "%2A"; + } else if ("%7E".equals(replacement)) { + replacement = "~"; + } else if (path && "%2F".equals(replacement)) { + replacement = "/"; + } + + matcher.appendReplacement(buffer, replacement); + } + + matcher.appendTail(buffer); + return buffer.toString(); + + } catch (UnsupportedEncodingException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/models/s3/S3EventNotificationTest.java b/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/models/s3/S3EventNotificationTest.java new file mode 100644 index 00000000..8a3cb072 --- /dev/null +++ b/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/models/s3/S3EventNotificationTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2020 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. + */ +package com.amazonaws.services.lambda.runtime.events.models.s3; + +import com.amazonaws.services.lambda.runtime.events.HttpUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; + +public class S3EventNotificationTest { + + private List KEYS_REQUIRING_URL_ENCODE = Arrays.asList("foo bar.jpg", "foo/bar.csv", "foo<>bar"); + + @Test + public void testGetUrlDecodedKey() { + for (String testKey : KEYS_REQUIRING_URL_ENCODE) { + String urlEncoded = HttpUtils.urlEncode(testKey, false); + S3EventNotification.S3ObjectEntity entity = new S3EventNotification.S3ObjectEntity( + urlEncoded, 1L, "E-Tag", "versionId"); + Assertions.assertEquals(testKey, entity.getUrlDecodedKey()); + } + } +} From 8057a554133220f10584123ce1a902c6571fe62d Mon Sep 17 00:00:00 2001 From: Mark Sailes Date: Wed, 10 Jun 2020 16:44:21 +0100 Subject: [PATCH 5/8] Removed the NoArgsConstructor as it is superfluous. --- .../lambda/runtime/events/SecretsManagerRotationEvent.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java index a820b496..4ce9fb8d 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java @@ -14,7 +14,6 @@ package com.amazonaws.services.lambda.runtime.events; import lombok.Data; -import lombok.NoArgsConstructor; /** * Class to represent the events which are sent during a Secrets Manager rotation process. @@ -24,7 +23,6 @@ * @author msailes */ -@NoArgsConstructor @Data public class SecretsManagerRotationEvent { From 0be87c9bde377c2a0bc2c76e2ba08172a09e2177 Mon Sep 17 00:00:00 2001 From: Mark Sailes Date: Wed, 10 Jun 2020 16:45:32 +0100 Subject: [PATCH 6/8] Removed the NoArgsConstructor as it is superfluous. --- .../lambda/runtime/events/SecretsManagerRotationEvent.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java index a820b496..4ce9fb8d 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java @@ -14,7 +14,6 @@ package com.amazonaws.services.lambda.runtime.events; import lombok.Data; -import lombok.NoArgsConstructor; /** * Class to represent the events which are sent during a Secrets Manager rotation process. @@ -24,7 +23,6 @@ * @author msailes */ -@NoArgsConstructor @Data public class SecretsManagerRotationEvent { From fc68194ecb5aa5d125c28182b9ee234efd9af74f Mon Sep 17 00:00:00 2001 From: Mark Sailes Date: Mon, 6 Jul 2020 09:54:12 +0100 Subject: [PATCH 7/8] Added the builder annotation. --- .../lambda/runtime/events/SecretsManagerRotationEvent.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java index 4ce9fb8d..952d9521 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java @@ -13,7 +13,10 @@ package com.amazonaws.services.lambda.runtime.events; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; /** * Class to represent the events which are sent during a Secrets Manager rotation process. @@ -24,6 +27,9 @@ */ @Data +@Builder +@NoArgsConstructor +@AllArgsConstructor public class SecretsManagerRotationEvent { private String step; From 1578528646eb6f3f55015b47ddc209d63ac04241 Mon Sep 17 00:00:00 2001 From: msailes Date: Tue, 11 Aug 2020 20:33:04 +0100 Subject: [PATCH 8/8] Changing lombok annotations for consistency. --- .../lambda/runtime/events/SecretsManagerRotationEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java index 952d9521..4634c515 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java @@ -27,7 +27,7 @@ */ @Data -@Builder +@Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class SecretsManagerRotationEvent {