From a15116b53db989e0375dc07f78a5c402a072fbe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Raupach?= Date: Thu, 20 Sep 2018 16:25:40 +0200 Subject: [PATCH 01/65] Added annotations for documentation --- .../services/lambda/runtime/Endpoint.java | 17 +++++++++++++++++ .../services/lambda/runtime/FunctionName.java | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Endpoint.java create mode 100644 aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/FunctionName.java diff --git a/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Endpoint.java b/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Endpoint.java new file mode 100644 index 00000000..d2c74c54 --- /dev/null +++ b/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Endpoint.java @@ -0,0 +1,17 @@ +package com.amazonaws.services.lambda.runtime; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Indicates this the API Gateway endpoint for this Lambda Function. + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.SOURCE) +public @interface Endpoint { + + String value(); + +} diff --git a/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/FunctionName.java b/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/FunctionName.java new file mode 100644 index 00000000..e5174607 --- /dev/null +++ b/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/FunctionName.java @@ -0,0 +1,17 @@ +package com.amazonaws.services.lambda.runtime; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Indicates that the name of this Lambda Function in the AWS Console. + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.SOURCE) +public @interface FunctionName { + + String value(); + +} From a565b6d045082f96d4ac82fe908cb973f9499d65 Mon Sep 17 00:00:00 2001 From: Luis Alberto Medina Bravo Date: Mon, 29 Oct 2018 11:54:55 -0400 Subject: [PATCH 02/65] Support for Multi-Value Headers and Query String Parameters --- .../events/APIGatewayProxyRequestEvent.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java index b827eb47..8e790ec3 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java @@ -1,6 +1,7 @@ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; +import java.util.List; import java.util.Map; /** @@ -18,8 +19,12 @@ public class APIGatewayProxyRequestEvent implements Serializable, Cloneable { private Map headers; + private Map> multiValueHeaders; + private Map queryStringParameters; + private Map> multiValueQueryStringParameters; + private Map pathParameters; private Map stageVariables; @@ -914,6 +919,29 @@ public APIGatewayProxyRequestEvent withHeaders(Map headers) { return this; } + /** + * @return The multi value headers sent with the request + */ + public Map> getMultiValueHeaders() { + return multiValueHeaders; + } + + /** + * @param multiValueHeaders The multi value headers sent with the request + */ + public void setMultiValueHeaders(Map> multiValueHeaders) { + this.multiValueHeaders = multiValueHeaders; + } + + /** + * @param multiValueHeaders The multi value headers sent with the request + * @return APIGatewayProxyRequestEvent object + */ + public APIGatewayProxyRequestEvent withMultiValueHeaders(Map> multiValueHeaders) { + this.setMultiValueHeaders(multiValueHeaders); + return this; + } + /** * @return The query string parameters that were part of the request */ @@ -937,6 +965,29 @@ public APIGatewayProxyRequestEvent withQueryStringParamters(Map return this; } + /** + * @return The multi value query string parameters that were part of the request + */ + public Map> getMultiValueQueryStringParameters() { + return multiValueQueryStringParameters; + } + + /** + * @param multiValueQueryStringParameters The multi value query string parameters that were part of the request + */ + public void setMultiValueQueryStringParameters(Map> multiValueQueryStringParameters) { + this.multiValueQueryStringParameters = multiValueQueryStringParameters; + } + + /** + * @param multiValueQueryStringParameters The multi value query string parameters that were part of the request + * @return APIGatewayProxyRequestEvent + */ + public APIGatewayProxyRequestEvent withMultiValueQueryStringParameters(Map> multiValueQueryStringParameters) { + this.setMultiValueQueryStringParameters(multiValueQueryStringParameters); + return this; + } + /** * @return The path parameters that were part of the request */ @@ -1071,8 +1122,12 @@ public String toString() { sb.append("httpMethod: ").append(getHttpMethod()).append(","); if (getHeaders() != null) sb.append("headers: ").append(getHeaders().toString()).append(","); + if (getMultiValueHeaders() != null) + sb.append("multiValueHeaders: ").append(getMultiValueHeaders().toString()).append(","); if (getQueryStringParameters() != null) sb.append("queryStringParameters: ").append(getQueryStringParameters().toString()).append(","); + if (getMultiValueQueryStringParameters() != null) + sb.append("multiValueQueryStringParameters: ").append(getMultiValueQueryStringParameters().toString()).append(","); if (getPathParameters() != null) sb.append("pathParameters: ").append(getPathParameters().toString()).append(","); if (getStageVariables() != null) @@ -1113,10 +1168,18 @@ public boolean equals(Object obj) { return false; if (other.getHeaders() != null && other.getHeaders().equals(this.getHeaders()) == false) return false; + if (other.getMultiValueHeaders() == null ^ this.getMultiValueHeaders() == null) + return false; + if (other.getMultiValueHeaders() != null && other.getMultiValueHeaders().equals(this.getMultiValueHeaders()) == false) + return false; if (other.getQueryStringParameters() == null ^ this.getQueryStringParameters() == null) return false; if (other.getQueryStringParameters() != null && other.getQueryStringParameters().equals(this.getQueryStringParameters()) == false) return false; + if (other.getMultiValueQueryStringParameters() == null ^ this.getMultiValueQueryStringParameters() == null) + return false; + if (other.getMultiValueQueryStringParameters() != null && other.getMultiValueQueryStringParameters().equals(this.getMultiValueQueryStringParameters()) == false) + return false; if (other.getPathParameters() == null ^ this.getPathParameters() == null) return false; if (other.getPathParameters() != null && other.getPathParameters().equals(this.getPathParameters()) == false) @@ -1149,7 +1212,9 @@ public int hashCode() { hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); hashCode = prime * hashCode + ((getHttpMethod() == null) ? 0 : getHttpMethod().hashCode()); hashCode = prime * hashCode + ((getHeaders() == null) ? 0 : getHeaders().hashCode()); + hashCode = prime * hashCode + ((getMultiValueHeaders() == null) ? 0 : getMultiValueHeaders().hashCode()); hashCode = prime * hashCode + ((getQueryStringParameters() == null) ? 0 : getQueryStringParameters().hashCode()); + hashCode = prime * hashCode + ((getMultiValueQueryStringParameters() == null) ? 0 : getMultiValueQueryStringParameters().hashCode()); hashCode = prime * hashCode + ((getPathParameters() == null) ? 0 : getPathParameters().hashCode()); hashCode = prime * hashCode + ((getStageVariables() == null) ? 0 : getStageVariables().hashCode()); hashCode = prime * hashCode + ((getRequestContext() == null) ? 0 : getRequestContext().hashCode()); From 6ab192cebf5af7da89ad82dd6278e1169017a44c Mon Sep 17 00:00:00 2001 From: Moffatt Date: Mon, 5 Nov 2018 13:50:53 +0000 Subject: [PATCH 03/65] Version bump events library to 2.2.3 --- README.md | 8 ++++---- aws-lambda-java-events/README.md | 8 ++++---- aws-lambda-java-events/pom.xml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f1813df2..1f02b258 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ ___ com.amazonaws aws-lambda-java-events - 2.2.2 + 2.2.3 com.amazonaws @@ -50,7 +50,7 @@ ___ ```groovy 'com.amazonaws:aws-lambda-java-core:1.1.0' -'com.amazonaws:aws-lambda-java-events:2.2.2' +'com.amazonaws:aws-lambda-java-events:2.2.3' 'com.amazonaws:aws-lambda-java-log4j:1.0.0' 'com.amazonaws:aws-lambda-java-log4j2:1.0.0' ``` @@ -59,7 +59,7 @@ ___ ```clojure [com.amazonaws/aws-lambda-java-core "1.1.0"] -[com.amazonaws/aws-lambda-java-events "2.2.2"] +[com.amazonaws/aws-lambda-java-events "2.2.3"] [com.amazonaws/aws-lambda-java-log4j "1.0.0"] [com.amazonaws/aws-lambda-java-log4j2 "1.0.0"] ``` @@ -68,7 +68,7 @@ ___ ```scala "com.amazonaws" % "aws-lambda-java-core" % "1.1.0" -"com.amazonaws" % "aws-lambda-java-events" % "2.2.2" +"com.amazonaws" % "aws-lambda-java-events" % "2.2.3" "com.amazonaws" % "aws-lambda-java-log4j" % "1.0.0" "com.amazonaws" % "aws-lambda-java-log4j2" % "1.0.0" ``` diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index dfdf4354..83965d6e 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -44,7 +44,7 @@ so the dependencies section in the pom.xml file would like this com.amazonaws aws-lambda-java-events - 2.2.2 + 2.2.3 ... @@ -65,7 +65,7 @@ For the S3 event the pom would look like this: com.amazonaws aws-lambda-java-events - 2.2.2 + 2.2.3 com.amazonaws @@ -91,7 +91,7 @@ For the Kinesis event com.amazonaws aws-lambda-java-events - 2.2.2 + 2.2.3 com.amazonaws @@ -117,7 +117,7 @@ For the Dynamodb event com.amazonaws aws-lambda-java-events - 2.2.2 + 2.2.3 com.amazonaws diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index e9d915e4..af1ce2a9 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -3,7 +3,7 @@ com.amazonaws aws-lambda-java-events - 2.2.2 + 2.2.3 jar AWS Lambda Java Events Library From 2009fbdb468d23407cf52259e3990f78d2c92c82 Mon Sep 17 00:00:00 2001 From: gal bashan Date: Thu, 8 Nov 2018 17:26:38 +0200 Subject: [PATCH 04/65] [s3-event-default-constructor] Adding default constructor for S3Event for easier deserialization --- .../services/lambda/runtime/events/S3Event.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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 4ceeb5dd..c1a83ee0 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 @@ -5,6 +5,7 @@ import com.amazonaws.services.s3.event.S3EventNotification; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; /** @@ -15,6 +16,14 @@ public class S3Event extends S3EventNotification implements Serializable, Clonea private static final long serialVersionUID = -8094860465750962044L; + /** + * default constructor + * (Not available in v1) + */ + public S3Event() { + super(new ArrayList()); + } + /** * Create a new instance of S3Event * @param records A list of S3 event notification records From 55809cc01ecbe2695b7584cddb9bf8b0287bdc73 Mon Sep 17 00:00:00 2001 From: Igor Stepanov Date: Wed, 2 Jan 2019 19:07:19 +0200 Subject: [PATCH 05/65] GH-65 Fix "Paramters" typo - keep the old methods for backward compatibility (marked as @Deprecated) - ignore folder with maven build results and IDEA-specific metadata --- .gitignore | 7 ++++++ .../events/APIGatewayProxyRequestEvent.java | 22 ++++++++++++++++--- .../lambda/runtime/events/ConfigEvent.java | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 32858aad..e7133935 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,10 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# Maven build +target/ + +# IDEA internal +*.iml +.idea diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java index 8e790ec3..71ea238d 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java @@ -960,11 +960,19 @@ public void setQueryStringParameters(Map queryStringParameters) * @param queryStringParameters The query string parameters that were part of the request * @return APIGatewayProxyRequestEvent */ - public APIGatewayProxyRequestEvent withQueryStringParamters(Map queryStringParameters) { + public APIGatewayProxyRequestEvent withQueryStringParameters(Map queryStringParameters) { this.setQueryStringParameters(queryStringParameters); return this; } + /** + * @deprecated Because of typo in method's name, use {@link #withQueryStringParameters} instead. + */ + @Deprecated + public APIGatewayProxyRequestEvent withQueryStringParamters(Map queryStringParameters) { + return withQueryStringParameters(queryStringParameters); + } + /** * @return The multi value query string parameters that were part of the request */ @@ -1003,14 +1011,22 @@ public void setPathParameters(Map pathParameters) { } /** - * @param pathParameters The path paramters that were part of the request + * @param pathParameters The path parameters that were part of the request * @return APIGatewayProxyRequestEvent object */ - public APIGatewayProxyRequestEvent withPathParamters(Map pathParameters) { + public APIGatewayProxyRequestEvent withPathParameters(Map pathParameters) { this.setPathParameters(pathParameters); return this; } + /** + * @deprecated Because of typo in method's name, use {@link #withPathParameters} instead. + */ + @Deprecated + public APIGatewayProxyRequestEvent withPathParamters(Map pathParameters) { + return withPathParameters(pathParameters); + } + /** * @return The stage variables defined for the stage in API Gateway */ diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ConfigEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ConfigEvent.java index 303f94fe..b2bb9b00 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ConfigEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ConfigEvent.java @@ -114,7 +114,7 @@ public void setRuleParameters(String ruleParameters) { } /** - * @param ruleParameters String with rule paramters + * @param ruleParameters String with rule parameters * @return ConfigEvent */ public ConfigEvent withRuleParameters(String ruleParameters) { From ca6e4aa789df3aed83fff6cf0266e1e109377d0e Mon Sep 17 00:00:00 2001 From: theo Date: Wed, 2 Jan 2019 18:28:45 +0000 Subject: [PATCH 06/65] Version bump events library to 2.2.4 --- README.md | 8 ++++---- aws-lambda-java-events/README.md | 8 ++++---- aws-lambda-java-events/pom.xml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1f02b258..97afec9c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ ___ com.amazonaws aws-lambda-java-events - 2.2.3 + 2.2.4 com.amazonaws @@ -50,7 +50,7 @@ ___ ```groovy 'com.amazonaws:aws-lambda-java-core:1.1.0' -'com.amazonaws:aws-lambda-java-events:2.2.3' +'com.amazonaws:aws-lambda-java-events:2.2.4' 'com.amazonaws:aws-lambda-java-log4j:1.0.0' 'com.amazonaws:aws-lambda-java-log4j2:1.0.0' ``` @@ -59,7 +59,7 @@ ___ ```clojure [com.amazonaws/aws-lambda-java-core "1.1.0"] -[com.amazonaws/aws-lambda-java-events "2.2.3"] +[com.amazonaws/aws-lambda-java-events "2.2.4"] [com.amazonaws/aws-lambda-java-log4j "1.0.0"] [com.amazonaws/aws-lambda-java-log4j2 "1.0.0"] ``` @@ -68,7 +68,7 @@ ___ ```scala "com.amazonaws" % "aws-lambda-java-core" % "1.1.0" -"com.amazonaws" % "aws-lambda-java-events" % "2.2.3" +"com.amazonaws" % "aws-lambda-java-events" % "2.2.4" "com.amazonaws" % "aws-lambda-java-log4j" % "1.0.0" "com.amazonaws" % "aws-lambda-java-log4j2" % "1.0.0" ``` diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index 83965d6e..3be2c2e8 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -44,7 +44,7 @@ so the dependencies section in the pom.xml file would like this com.amazonaws aws-lambda-java-events - 2.2.3 + 2.2.4 ... @@ -65,7 +65,7 @@ For the S3 event the pom would look like this: com.amazonaws aws-lambda-java-events - 2.2.3 + 2.2.4 com.amazonaws @@ -91,7 +91,7 @@ For the Kinesis event com.amazonaws aws-lambda-java-events - 2.2.3 + 2.2.4 com.amazonaws @@ -117,7 +117,7 @@ For the Dynamodb event com.amazonaws aws-lambda-java-events - 2.2.3 + 2.2.4 com.amazonaws diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index af1ce2a9..32dd2ea9 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -3,7 +3,7 @@ com.amazonaws aws-lambda-java-events - 2.2.3 + 2.2.4 jar AWS Lambda Java Events Library From 5c3879ca8f00b8f91e20fc013d5d5b03f891cf4c Mon Sep 17 00:00:00 2001 From: theo Date: Thu, 3 Jan 2019 15:52:36 +0000 Subject: [PATCH 07/65] Version bump events library to 2.2.5 --- README.md | 8 ++++---- aws-lambda-java-events/README.md | 8 ++++---- aws-lambda-java-events/pom.xml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 97afec9c..ff221366 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ ___ com.amazonaws aws-lambda-java-events - 2.2.4 + 2.2.5 com.amazonaws @@ -50,7 +50,7 @@ ___ ```groovy 'com.amazonaws:aws-lambda-java-core:1.1.0' -'com.amazonaws:aws-lambda-java-events:2.2.4' +'com.amazonaws:aws-lambda-java-events:2.2.5' 'com.amazonaws:aws-lambda-java-log4j:1.0.0' 'com.amazonaws:aws-lambda-java-log4j2:1.0.0' ``` @@ -59,7 +59,7 @@ ___ ```clojure [com.amazonaws/aws-lambda-java-core "1.1.0"] -[com.amazonaws/aws-lambda-java-events "2.2.4"] +[com.amazonaws/aws-lambda-java-events "2.2.5"] [com.amazonaws/aws-lambda-java-log4j "1.0.0"] [com.amazonaws/aws-lambda-java-log4j2 "1.0.0"] ``` @@ -68,7 +68,7 @@ ___ ```scala "com.amazonaws" % "aws-lambda-java-core" % "1.1.0" -"com.amazonaws" % "aws-lambda-java-events" % "2.2.4" +"com.amazonaws" % "aws-lambda-java-events" % "2.2.5" "com.amazonaws" % "aws-lambda-java-log4j" % "1.0.0" "com.amazonaws" % "aws-lambda-java-log4j2" % "1.0.0" ``` diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index 3be2c2e8..e44c2724 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -44,7 +44,7 @@ so the dependencies section in the pom.xml file would like this com.amazonaws aws-lambda-java-events - 2.2.4 + 2.2.5 ... @@ -65,7 +65,7 @@ For the S3 event the pom would look like this: com.amazonaws aws-lambda-java-events - 2.2.4 + 2.2.5 com.amazonaws @@ -91,7 +91,7 @@ For the Kinesis event com.amazonaws aws-lambda-java-events - 2.2.4 + 2.2.5 com.amazonaws @@ -117,7 +117,7 @@ For the Dynamodb event com.amazonaws aws-lambda-java-events - 2.2.4 + 2.2.5 com.amazonaws diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index 32dd2ea9..f66124c2 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -3,7 +3,7 @@ com.amazonaws aws-lambda-java-events - 2.2.4 + 2.2.5 jar AWS Lambda Java Events Library From ee1da8840602bbd8660e31843aeebf058c92251a Mon Sep 17 00:00:00 2001 From: Theo Hultberg Date: Tue, 30 Oct 2018 18:13:33 +0100 Subject: [PATCH 08/65] Fix the packages directive in the example config When using the config in the readme you get these errors: ``` Error processing element Lambda ([Appenders: null]): CLASS_NOT_FOUND Unable to locate appender "lambda" for logger config "root" ``` The Lambda documentation site (https://docs.aws.amazon.com/lambda/latest/dg/java-logging.html) does not have the class name in the attribute, and removing the class name makes the errors above go away. --- aws-lambda-java-log4j2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws-lambda-java-log4j2/README.md b/aws-lambda-java-log4j2/README.md index ae32f60a..f5449d8c 100644 --- a/aws-lambda-java-log4j2/README.md +++ b/aws-lambda-java-log4j2/README.md @@ -68,7 +68,7 @@ Add the following file `/src/main/resources/log4j2.xml` ```xml - + From c53467321efab57439344a8addc12acc166360e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Raupach?= Date: Thu, 24 Jan 2019 19:26:25 +0100 Subject: [PATCH 09/65] Changed version of aws-lambda-java-core to 1.2.0 (#73) * Changed version of aws-lambda-java-core to 1.2.0 * Updated all mentions of 1.1.0 to 1.2.0 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ff221366..d2b58e60 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ___ com.amazonaws aws-lambda-java-core - 1.1.0 + 1.2.0 com.amazonaws @@ -49,7 +49,7 @@ ___ [Gradle](https://gradle.org) ```groovy -'com.amazonaws:aws-lambda-java-core:1.1.0' +'com.amazonaws:aws-lambda-java-core:1.2.0' 'com.amazonaws:aws-lambda-java-events:2.2.5' 'com.amazonaws:aws-lambda-java-log4j:1.0.0' 'com.amazonaws:aws-lambda-java-log4j2:1.0.0' @@ -58,7 +58,7 @@ ___ [Leiningen](http://leiningen.org) and [Boot](http://boot-clj.com) ```clojure -[com.amazonaws/aws-lambda-java-core "1.1.0"] +[com.amazonaws/aws-lambda-java-core "1.2.0"] [com.amazonaws/aws-lambda-java-events "2.2.5"] [com.amazonaws/aws-lambda-java-log4j "1.0.0"] [com.amazonaws/aws-lambda-java-log4j2 "1.0.0"] @@ -67,7 +67,7 @@ ___ [sbt](http://www.scala-sbt.org) ```scala -"com.amazonaws" % "aws-lambda-java-core" % "1.1.0" +"com.amazonaws" % "aws-lambda-java-core" % "1.2.0" "com.amazonaws" % "aws-lambda-java-events" % "2.2.5" "com.amazonaws" % "aws-lambda-java-log4j" % "1.0.0" "com.amazonaws" % "aws-lambda-java-log4j2" % "1.0.0" From 74060dc18c3c2835a8962472704f656d26816dcc Mon Sep 17 00:00:00 2001 From: vbellotto Date: Thu, 21 Feb 2019 20:26:39 +0000 Subject: [PATCH 10/65] Adding customData to CommitEvent.Record (#79) --- .../runtime/events/CodeCommitEvent.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CodeCommitEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CodeCommitEvent.java index cd12ffdc..d76cba29 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CodeCommitEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CodeCommitEvent.java @@ -290,6 +290,8 @@ public static class Record implements Serializable, Cloneable { private String awsRegion; + private String customData; + private Integer eventTotalParts; /** @@ -596,6 +598,27 @@ public Record withEventTotalParts(Integer eventTotalParts) { return this; } + /** + * + * @return custom data + */ + public String getCustomData(){ return this.customData;} + + /** + * + * @param customData event custom data + */ + public void setCustomData(String customData) { this.customData = customData;} + + /** + * @param customData event + * @return Record + */ + public Record withCustomData(String customData) { + setCustomData(customData); + return this; + } + /** * Returns a string representation of this object; useful for testing and debugging. * @@ -631,6 +654,8 @@ public String toString() { sb.append("eventSource: ").append(getEventSource()).append(","); if (getAwsRegion() != null) sb.append("awsRegion: ").append(getAwsRegion()).append(","); + if (getCustomData() != null) + sb.append("customData: ").append(getCustomData()).append(","); if (getEventTotalParts() != null) sb.append("eventTotalParts: ").append(getEventTotalParts()); sb.append("}"); @@ -699,6 +724,10 @@ public boolean equals(Object obj) { return false; if (other.getEventTotalParts() != null && other.getEventTotalParts().equals(this.getEventTotalParts()) == false) return false; + if (other.getCustomData() == null ^ this.getCustomData() == null) + return false; + if (other.getCustomData() != null && other.getCustomData().equals(this.getCustomData()) == false) + return false; return true; } @@ -720,6 +749,7 @@ public int hashCode() { hashCode = prime * hashCode + ((getEventSource() == null) ? 0 : getEventSource().hashCode()); hashCode = prime * hashCode + ((getAwsRegion() == null) ? 0 : getAwsRegion().hashCode()); hashCode = prime * hashCode + ((getEventTotalParts() == null) ? 0 : getEventTotalParts().hashCode()); + hashCode = prime * hashCode + ((getCustomData() == null) ? 0 : getCustomData().hashCode()); return hashCode; } From 110442168d2b0d453fab0c140a53ec38df7affc1 Mon Sep 17 00:00:00 2001 From: Miere Teixeira Date: Thu, 21 Feb 2019 17:32:33 -0300 Subject: [PATCH 11/65] Added missing 'isBase64Encoded' field to APIGatewayProxyResponseEvent.java (#48) --- .../events/APIGatewayProxyResponseEvent.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyResponseEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyResponseEvent.java index 7a3581b0..da6220bd 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyResponseEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyResponseEvent.java @@ -16,6 +16,8 @@ public class APIGatewayProxyResponseEvent implements Serializable, Cloneable { private String body; + private Boolean isBase64Encoded; + /** * default constructor */ @@ -90,6 +92,29 @@ public APIGatewayProxyResponseEvent withBody(String body) { return this; } + /** + * @return whether the body String is base64 encoded. + */ + public Boolean getIsBase64Encoded() { + return this.isBase64Encoded; + } + + /** + * @param isBase64Encoded Whether the body String is base64 encoded + */ + public void setIsBase64Encoded(Boolean isBase64Encoded) { + this.isBase64Encoded = isBase64Encoded; + } + + /** + * @param isBase64Encoded Whether the body String is base64 encoded + * @return APIGatewayProxyRequestEvent + */ + public APIGatewayProxyResponseEvent withIsBase64Encoded(Boolean isBase64Encoded) { + this.setIsBase64Encoded(isBase64Encoded); + return this; + } + /** * Returns a string representation of this object; useful for testing and debugging. * From a618443e16655f43c83c015391c77535e3730fed Mon Sep 17 00:00:00 2001 From: Arun Avanathan Date: Thu, 21 Feb 2019 12:33:44 -0800 Subject: [PATCH 12/65] Adding authorizer field to collect context properties from authorizer (#77) * Adding authorizer field to collect context properites from authorizer * Updating toString() method * Adding authorizer to equals() & hashCode() * Moving authorizer under ProxyRequestContext * Switching to Map for authorizer --- .../events/APIGatewayProxyRequestEvent.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java index 71ea238d..68ca91da 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java @@ -60,6 +60,8 @@ public static class ProxyRequestContext implements Serializable, Cloneable { private String path; + private Map authorizer; + /** * default constructor */ @@ -88,6 +90,14 @@ public ProxyRequestContext withAccountId(String accountId) { return this; } + public Map getAuthorizer() { + return authorizer; + } + + public void setAuthorizer(final Map authorizer) { + this.authorizer = authorizer; + } + /** * @return API Gateway stage name */ @@ -300,7 +310,9 @@ public String toString() { if (getApiId() != null) sb.append("apiId: ").append(getApiId()).append(","); if (getPath() != null) - sb.append("path: ").append(getPath()); + sb.append("path: ").append(getPath()).append(","); + if (getAuthorizer() != null) + sb.append("authorizer: ").append(getAuthorizer().toString()); sb.append("}"); return sb.toString(); } @@ -351,6 +363,10 @@ public boolean equals(Object obj) { return false; if (other.getPath() != null && other.getPath().equals(this.getPath()) == false) return false; + if (other.getAuthorizer() == null ^ this.getAuthorizer() == null) + return false; + if (other.getAuthorizer() != null && !other.getAuthorizer().equals(this.getAuthorizer())) + return false; return true; } @@ -368,6 +384,7 @@ public int hashCode() { hashCode = prime * hashCode + ((getHttpMethod() == null) ? 0 : getHttpMethod().hashCode()); hashCode = prime * hashCode + ((getApiId() == null) ? 0 : getApiId().hashCode()); hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); + hashCode = prime * hashCode + ((getAuthorizer() == null) ? 0 : getAuthorizer().hashCode()); return hashCode; } @@ -941,7 +958,7 @@ public APIGatewayProxyRequestEvent withMultiValueHeaders(Map Date: Mon, 11 Mar 2019 14:52:04 +0000 Subject: [PATCH 13/65] Version bump event library to 2.2.6 (#83) --- README.md | 8 ++++---- aws-lambda-java-events/README.md | 8 ++++---- aws-lambda-java-events/pom.xml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d2b58e60..610cf82d 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ ___ com.amazonaws aws-lambda-java-events - 2.2.5 + 2.2.6 com.amazonaws @@ -50,7 +50,7 @@ ___ ```groovy 'com.amazonaws:aws-lambda-java-core:1.2.0' -'com.amazonaws:aws-lambda-java-events:2.2.5' +'com.amazonaws:aws-lambda-java-events:2.2.6' 'com.amazonaws:aws-lambda-java-log4j:1.0.0' 'com.amazonaws:aws-lambda-java-log4j2:1.0.0' ``` @@ -59,7 +59,7 @@ ___ ```clojure [com.amazonaws/aws-lambda-java-core "1.2.0"] -[com.amazonaws/aws-lambda-java-events "2.2.5"] +[com.amazonaws/aws-lambda-java-events "2.2.6"] [com.amazonaws/aws-lambda-java-log4j "1.0.0"] [com.amazonaws/aws-lambda-java-log4j2 "1.0.0"] ``` @@ -68,7 +68,7 @@ ___ ```scala "com.amazonaws" % "aws-lambda-java-core" % "1.2.0" -"com.amazonaws" % "aws-lambda-java-events" % "2.2.5" +"com.amazonaws" % "aws-lambda-java-events" % "2.2.6" "com.amazonaws" % "aws-lambda-java-log4j" % "1.0.0" "com.amazonaws" % "aws-lambda-java-log4j2" % "1.0.0" ``` diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index e44c2724..25b58447 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -44,7 +44,7 @@ so the dependencies section in the pom.xml file would like this com.amazonaws aws-lambda-java-events - 2.2.5 + 2.2.6 ... @@ -65,7 +65,7 @@ For the S3 event the pom would look like this: com.amazonaws aws-lambda-java-events - 2.2.5 + 2.2.6 com.amazonaws @@ -91,7 +91,7 @@ For the Kinesis event com.amazonaws aws-lambda-java-events - 2.2.5 + 2.2.6 com.amazonaws @@ -117,7 +117,7 @@ For the Dynamodb event com.amazonaws aws-lambda-java-events - 2.2.5 + 2.2.6 com.amazonaws diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index f66124c2..93105bea 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -3,7 +3,7 @@ com.amazonaws aws-lambda-java-events - 2.2.5 + 2.2.6 jar AWS Lambda Java Events Library From 1ee847d1df31c6177a733bf9574f82827a63994c Mon Sep 17 00:00:00 2001 From: Tim Gustafson Date: Tue, 30 Jul 2019 22:02:49 +0200 Subject: [PATCH 14/65] Adding support for APIGatewayV2 (Web Sockets) (#92) --- aws-lambda-java-events/README.md | 4 + .../events/APIGatewayV2ProxyRequestEvent.java | 726 ++++++++++++++++++ .../APIGatewayV2ProxyResponseEvent.java | 110 +++ 3 files changed, 840 insertions(+) create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyRequestEvent.java create mode 100644 aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyResponseEvent.java diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index 25b58447..76032ea7 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -3,6 +3,8 @@ ### New Event Models Supported * APIGatewayProxyRequestEvent * APIGatewayProxyResponseEvent +* APIGatewayV2ProxyRequestEvent +* APIGatewayV2ProxyResponseEvent * CloudFrontEvent * CloudWatchLogsEvent * CodeCommitEvent @@ -20,6 +22,8 @@ versions do not need to make any changes to their existing code. The following event models do not require any SDK dependencies * APIGatewayProxyRequestEvent * APIGatewayProxyResponseEvent +* APIGatewayV2ProxyRequestEvent +* APIGatewayV2ProxyResponseEvent * CloudFrontEvent * CloudWatchLogsEvent * CodeCommitEvent diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyRequestEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyRequestEvent.java new file mode 100644 index 00000000..0f2cbb18 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyRequestEvent.java @@ -0,0 +1,726 @@ +package com.amazonaws.services.lambda.runtime.events; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @author Tim Gustafson + */ +public class APIGatewayV2ProxyRequestEvent implements Serializable, Cloneable { + + private static final long serialVersionUID = 5695319264103347099L; + + public static class RequestIdentity implements Serializable, Cloneable { + + private static final long serialVersionUID = -3276649362684921217L; + + private String cognitoIdentityPoolId; + private String accountId; + private String cognitoIdentityId; + private String caller; + private String apiKey; + private String sourceIp; + private String cognitoAuthenticationType; + private String cognitoAuthenticationProvider; + private String userArn; + private String userAgent; + private String user; + private String accessKey; + + public String getCognitoIdentityPoolId() { + return cognitoIdentityPoolId; + } + + public void setCognitoIdentityPoolId(String cognitoIdentityPoolId) { + this.cognitoIdentityPoolId = cognitoIdentityPoolId; + } + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getCognitoIdentityId() { + return cognitoIdentityId; + } + + public void setCognitoIdentityId(String cognitoIdentityId) { + this.cognitoIdentityId = cognitoIdentityId; + } + + public String getCaller() { + return caller; + } + + public void setCaller(String caller) { + this.caller = caller; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getSourceIp() { + return sourceIp; + } + + public void setSourceIp(String sourceIp) { + this.sourceIp = sourceIp; + } + + public String getCognitoAuthenticationType() { + return cognitoAuthenticationType; + } + + public void setCognitoAuthenticationType(String cognitoAuthenticationType) { + this.cognitoAuthenticationType = cognitoAuthenticationType; + } + + public String getCognitoAuthenticationProvider() { + return cognitoAuthenticationProvider; + } + + public void setCognitoAuthenticationProvider(String cognitoAuthenticationProvider) { + this.cognitoAuthenticationProvider = cognitoAuthenticationProvider; + } + + public String getUserArn() { + return userArn; + } + + public void setUserArn(String userArn) { + this.userArn = userArn; + } + + public String getUserAgent() { + return userAgent; + } + + public void setUserAgent(String userAgent) { + this.userAgent = userAgent; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getAccessKey() { + return accessKey; + } + + public void setAccessKey(String accessKey) { + this.accessKey = accessKey; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 29 * hash + (this.cognitoIdentityPoolId != null ? this.cognitoIdentityPoolId.hashCode() : 0); + hash = 29 * hash + (this.accountId != null ? this.accountId.hashCode() : 0); + hash = 29 * hash + (this.cognitoIdentityId != null ? this.cognitoIdentityId.hashCode() : 0); + hash = 29 * hash + (this.caller != null ? this.caller.hashCode() : 0); + hash = 29 * hash + (this.apiKey != null ? this.apiKey.hashCode() : 0); + hash = 29 * hash + (this.sourceIp != null ? this.sourceIp.hashCode() : 0); + hash = 29 * hash + (this.cognitoAuthenticationType != null ? this.cognitoAuthenticationType.hashCode() : 0); + hash = 29 * hash + (this.cognitoAuthenticationProvider != null ? this.cognitoAuthenticationProvider.hashCode() : 0); + hash = 29 * hash + (this.userArn != null ? this.userArn.hashCode() : 0); + hash = 29 * hash + (this.userAgent != null ? this.userAgent.hashCode() : 0); + hash = 29 * hash + (this.user != null ? this.user.hashCode() : 0); + hash = 29 * hash + (this.accessKey != null ? this.accessKey.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final RequestIdentity other = (RequestIdentity) obj; + if ((this.cognitoIdentityPoolId == null) ? (other.cognitoIdentityPoolId != null) : !this.cognitoIdentityPoolId.equals(other.cognitoIdentityPoolId)) { + return false; + } + if ((this.accountId == null) ? (other.accountId != null) : !this.accountId.equals(other.accountId)) { + return false; + } + if ((this.cognitoIdentityId == null) ? (other.cognitoIdentityId != null) : !this.cognitoIdentityId.equals(other.cognitoIdentityId)) { + return false; + } + if ((this.caller == null) ? (other.caller != null) : !this.caller.equals(other.caller)) { + return false; + } + if ((this.apiKey == null) ? (other.apiKey != null) : !this.apiKey.equals(other.apiKey)) { + return false; + } + if ((this.sourceIp == null) ? (other.sourceIp != null) : !this.sourceIp.equals(other.sourceIp)) { + return false; + } + if ((this.cognitoAuthenticationType == null) ? (other.cognitoAuthenticationType != null) : !this.cognitoAuthenticationType.equals(other.cognitoAuthenticationType)) { + return false; + } + if ((this.cognitoAuthenticationProvider == null) ? (other.cognitoAuthenticationProvider != null) : !this.cognitoAuthenticationProvider.equals(other.cognitoAuthenticationProvider)) { + return false; + } + if ((this.userArn == null) ? (other.userArn != null) : !this.userArn.equals(other.userArn)) { + return false; + } + if ((this.userAgent == null) ? (other.userAgent != null) : !this.userAgent.equals(other.userAgent)) { + return false; + } + if ((this.user == null) ? (other.user != null) : !this.user.equals(other.user)) { + return false; + } + if ((this.accessKey == null) ? (other.accessKey != null) : !this.accessKey.equals(other.accessKey)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "{cognitoIdentityPoolId=" + cognitoIdentityPoolId + + ", accountId=" + accountId + + ", cognitoIdentityId=" + cognitoIdentityId + + ", caller=" + caller + + ", apiKey=" + apiKey + + ", sourceIp=" + sourceIp + + ", cognitoAuthenticationType=" + cognitoAuthenticationType + + ", cognitoAuthenticationProvider=" + cognitoAuthenticationProvider + + ", userArn=" + userArn + + ", userAgent=" + userAgent + + ", user=" + user + + ", accessKey=" + accessKey + + "}"; + } + } + + public static class RequestContext implements Serializable, Cloneable { + + private static final long serialVersionUID = -6641935365992304860L; + + private String accountId; + private String resourceId; + private String stage; + private String requestId; + private RequestIdentity identity; + private String ResourcePath; + private Map authorizer; + private String httpMethod; + private String apiId; + private long connectedAt; + private String connectionId; + private String domainName; + private String error; + private String eventType; + private String extendedRequestId; + private String integrationLatency; + private String messageDirection; + private String messageId; + private String requestTime; + private long requestTimeEpoch; + private String routeKey; + private String status; + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getStage() { + return stage; + } + + public void setStage(String stage) { + this.stage = stage; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public RequestIdentity getIdentity() { + return identity; + } + + public void setIdentity(RequestIdentity identity) { + this.identity = identity; + } + + public String getResourcePath() { + return ResourcePath; + } + + public void setResourcePath(String ResourcePath) { + this.ResourcePath = ResourcePath; + } + + public Map getAuthorizer() { + return authorizer; + } + + public void setAuthorizer(Map authorizer) { + this.authorizer = authorizer; + } + + public String getHttpMethod() { + return httpMethod; + } + + public void setHttpMethod(String httpMethod) { + this.httpMethod = httpMethod; + } + + public String getApiId() { + return apiId; + } + + public void setApiId(String apiId) { + this.apiId = apiId; + } + + public long getConnectedAt() { + return connectedAt; + } + + public void setConnectedAt(long connectedAt) { + this.connectedAt = connectedAt; + } + + public String getConnectionId() { + return connectionId; + } + + public void setConnectionId(String connectionId) { + this.connectionId = connectionId; + } + + public String getDomainName() { + return domainName; + } + + public void setDomainName(String domainName) { + this.domainName = domainName; + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String getExtendedRequestId() { + return extendedRequestId; + } + + public void setExtendedRequestId(String extendedRequestId) { + this.extendedRequestId = extendedRequestId; + } + + public String getIntegrationLatency() { + return integrationLatency; + } + + public void setIntegrationLatency(String integrationLatency) { + this.integrationLatency = integrationLatency; + } + + public String getMessageDirection() { + return messageDirection; + } + + public void setMessageDirection(String messageDirection) { + this.messageDirection = messageDirection; + } + + public String getMessageId() { + return messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getRequestTime() { + return requestTime; + } + + public void setRequestTime(String requestTime) { + this.requestTime = requestTime; + } + + public long getRequestTimeEpoch() { + return requestTimeEpoch; + } + + public void setRequestTimeEpoch(long requestTimeEpoch) { + this.requestTimeEpoch = requestTimeEpoch; + } + + public String getRouteKey() { + return routeKey; + } + + public void setRouteKey(String routeKey) { + this.routeKey = routeKey; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 59 * hash + (this.accountId != null ? this.accountId.hashCode() : 0); + hash = 59 * hash + (this.resourceId != null ? this.resourceId.hashCode() : 0); + hash = 59 * hash + (this.stage != null ? this.stage.hashCode() : 0); + hash = 59 * hash + (this.requestId != null ? this.requestId.hashCode() : 0); + hash = 59 * hash + (this.identity != null ? this.identity.hashCode() : 0); + hash = 59 * hash + (this.ResourcePath != null ? this.ResourcePath.hashCode() : 0); + hash = 59 * hash + (this.authorizer != null ? this.authorizer.hashCode() : 0); + hash = 59 * hash + (this.httpMethod != null ? this.httpMethod.hashCode() : 0); + hash = 59 * hash + (this.apiId != null ? this.apiId.hashCode() : 0); + hash = 59 * hash + (int) (this.connectedAt ^ (this.connectedAt >>> 32)); + hash = 59 * hash + (this.connectionId != null ? this.connectionId.hashCode() : 0); + hash = 59 * hash + (this.domainName != null ? this.domainName.hashCode() : 0); + hash = 59 * hash + (this.error != null ? this.error.hashCode() : 0); + hash = 59 * hash + (this.eventType != null ? this.eventType.hashCode() : 0); + hash = 59 * hash + (this.extendedRequestId != null ? this.extendedRequestId.hashCode() : 0); + hash = 59 * hash + (this.integrationLatency != null ? this.integrationLatency.hashCode() : 0); + hash = 59 * hash + (this.messageDirection != null ? this.messageDirection.hashCode() : 0); + hash = 59 * hash + (this.messageId != null ? this.messageId.hashCode() : 0); + hash = 59 * hash + (this.requestTime != null ? this.requestTime.hashCode() : 0); + hash = 59 * hash + (int) (this.requestTimeEpoch ^ (this.requestTimeEpoch >>> 32)); + hash = 59 * hash + (this.routeKey != null ? this.routeKey.hashCode() : 0); + hash = 59 * hash + (this.status != null ? this.status.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + return "{accountId=" + accountId + + ", resourceId=" + resourceId + + ", stage=" + stage + + ", requestId=" + requestId + + ", identity=" + identity + + ", ResourcePath=" + ResourcePath + + ", authorizer=" + authorizer + + ", httpMethod=" + httpMethod + + ", apiId=" + apiId + + ", connectedAt=" + connectedAt + + ", connectionId=" + connectionId + + ", domainName=" + domainName + + ", error=" + error + + ", eventType=" + eventType + + ", extendedRequestId=" + extendedRequestId + + ", integrationLatency=" + integrationLatency + + ", messageDirection=" + messageDirection + + ", messageId=" + messageId + + ", requestTime=" + requestTime + + ", requestTimeEpoch=" + requestTimeEpoch + + ", routeKey=" + routeKey + + ", status=" + status + + "}"; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final RequestContext other = (RequestContext) obj; + if (this.connectedAt != other.connectedAt) { + return false; + } + if (this.requestTimeEpoch != other.requestTimeEpoch) { + return false; + } + if ((this.accountId == null) ? (other.accountId != null) : !this.accountId.equals(other.accountId)) { + return false; + } + if ((this.resourceId == null) ? (other.resourceId != null) : !this.resourceId.equals(other.resourceId)) { + return false; + } + if ((this.stage == null) ? (other.stage != null) : !this.stage.equals(other.stage)) { + return false; + } + if ((this.requestId == null) ? (other.requestId != null) : !this.requestId.equals(other.requestId)) { + return false; + } + if ((this.ResourcePath == null) ? (other.ResourcePath != null) : !this.ResourcePath.equals(other.ResourcePath)) { + return false; + } + if ((this.authorizer == null) ? (other.authorizer != null) : !this.authorizer.equals(other.authorizer)) { + return false; + } + if ((this.httpMethod == null) ? (other.httpMethod != null) : !this.httpMethod.equals(other.httpMethod)) { + return false; + } + if ((this.apiId == null) ? (other.apiId != null) : !this.apiId.equals(other.apiId)) { + return false; + } + if ((this.connectionId == null) ? (other.connectionId != null) : !this.connectionId.equals(other.connectionId)) { + return false; + } + if ((this.domainName == null) ? (other.domainName != null) : !this.domainName.equals(other.domainName)) { + return false; + } + if ((this.error == null) ? (other.error != null) : !this.error.equals(other.error)) { + return false; + } + if ((this.eventType == null) ? (other.eventType != null) : !this.eventType.equals(other.eventType)) { + return false; + } + if ((this.extendedRequestId == null) ? (other.extendedRequestId != null) : !this.extendedRequestId.equals(other.extendedRequestId)) { + return false; + } + if ((this.integrationLatency == null) ? (other.integrationLatency != null) : !this.integrationLatency.equals(other.integrationLatency)) { + return false; + } + if ((this.messageDirection == null) ? (other.messageDirection != null) : !this.messageDirection.equals(other.messageDirection)) { + return false; + } + if ((this.messageId == null) ? (other.messageId != null) : !this.messageId.equals(other.messageId)) { + return false; + } + if ((this.requestTime == null) ? (other.requestTime != null) : !this.requestTime.equals(other.requestTime)) { + return false; + } + if ((this.routeKey == null) ? (other.routeKey != null) : !this.routeKey.equals(other.routeKey)) { + return false; + } + if ((this.status == null) ? (other.status != null) : !this.status.equals(other.status)) { + return false; + } + if (this.identity != other.identity && (this.identity == null || !this.identity.equals(other.identity))) { + return false; + } + return true; + } + + } + + private String resource; + private String path; + private String httpMethod; + private Map headers; + private Map> multiValueHeaders; + private Map queryStringParameters; + private Map> multiValueQueryStringParameters; + private Map pathParameters; + private Map stageVariables; + private RequestContext requestContext; + private String body; + private boolean isBase64Encoded = false; + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getHttpMethod() { + return httpMethod; + } + + public void setHttpMethod(String httpMethod) { + this.httpMethod = httpMethod; + } + + public Map getHeaders() { + return headers; + } + + public void setHeaders(Map headers) { + this.headers = headers; + } + + public Map> getMultiValueHeaders() { + return multiValueHeaders; + } + + public void setMultiValueHeaders(Map> multiValueHeaders) { + this.multiValueHeaders = multiValueHeaders; + } + + public Map getQueryStringParameters() { + return queryStringParameters; + } + + public void setQueryStringParameters(Map queryStringParameters) { + this.queryStringParameters = queryStringParameters; + } + + public Map> getMultiValueQueryStringParameters() { + return multiValueQueryStringParameters; + } + + public void setMultiValueQueryStringParameters(Map> multiValueQueryStringParameters) { + this.multiValueQueryStringParameters = multiValueQueryStringParameters; + } + + public Map getPathParameters() { + return pathParameters; + } + + public void setPathParameters(Map pathParameters) { + this.pathParameters = pathParameters; + } + + public Map getStageVariables() { + return stageVariables; + } + + public void setStageVariables(Map stageVariables) { + this.stageVariables = stageVariables; + } + + public RequestContext getRequestContext() { + return requestContext; + } + + public void setRequestContext(RequestContext requestContext) { + this.requestContext = requestContext; + } + + public String getBody() { + return body; + } + + public void setBody(String body) { + this.body = body; + } + + public boolean isIsBase64Encoded() { + return isBase64Encoded; + } + + public void setIsBase64Encoded(boolean isBase64Encoded) { + this.isBase64Encoded = isBase64Encoded; + } + + @Override + public int hashCode() { + int hash = 7; + + hash = 43 * hash + Objects.hashCode(this.requestContext); + hash = 43 * hash + Objects.hashCode(this.body); + hash = 43 * hash + (this.isBase64Encoded ? 1 : 0); + + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj == null) { + return false; + } + + if (getClass() != obj.getClass()) { + return false; + } + + final APIGatewayV2ProxyRequestEvent other = (APIGatewayV2ProxyRequestEvent) obj; + + if (this.isBase64Encoded != other.isBase64Encoded) { + return false; + } + + if (!Objects.equals(this.body, other.body)) { + return false; + } + + if (!Objects.equals(this.requestContext, other.requestContext)) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + + if (requestContext != null) { + sb.append("requestContext: ").append(requestContext).append(","); + } + + if (body != null) { + sb.append("body: ").append(body).append(","); + } + + sb.append("isBase64Encoded: ").append(isBase64Encoded).append(","); + + sb.append("}"); + + return sb.toString(); + } + +} diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyResponseEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyResponseEvent.java new file mode 100644 index 00000000..c3ecff89 --- /dev/null +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyResponseEvent.java @@ -0,0 +1,110 @@ +package com.amazonaws.services.lambda.runtime.events; + +import java.io.Serializable; +import java.util.Map; + +/** + * @author Tim Gustafson + */ +public class APIGatewayV2ProxyResponseEvent implements Serializable, Cloneable { + + private static final long serialVersionUID = -5155789062248356200L; + + private boolean isBase64Encoded = false; + private int statusCode; + private Map headers; + private Map multiValueHeaders; + private String body; + + public boolean isIsBase64Encoded() { + return isBase64Encoded; + } + + public void setIsBase64Encoded(boolean isBase64Encoded) { + this.isBase64Encoded = isBase64Encoded; + } + + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + + public Map getHeaders() { + return headers; + } + + public void setHeaders(Map headers) { + this.headers = headers; + } + + public Map getMultiValueHeaders() { + return multiValueHeaders; + } + + public void setMultiValueHeaders(Map multiValueHeaders) { + this.multiValueHeaders = multiValueHeaders; + } + + public String getBody() { + return body; + } + + public void setBody(String body) { + this.body = body; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 71 * hash + (this.isBase64Encoded ? 1 : 0); + hash = 71 * hash + this.statusCode; + hash = 71 * hash + (this.headers != null ? this.headers.hashCode() : 0); + hash = 71 * hash + (this.multiValueHeaders != null ? this.multiValueHeaders.hashCode() : 0); + hash = 71 * hash + (this.body != null ? this.body.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final APIGatewayV2ProxyResponseEvent other = (APIGatewayV2ProxyResponseEvent) obj; + if (this.isBase64Encoded != other.isBase64Encoded) { + return false; + } + if (this.statusCode != other.statusCode) { + return false; + } + if ((this.body == null) ? (other.body != null) : !this.body.equals(other.body)) { + return false; + } + if (this.headers != other.headers && (this.headers == null || !this.headers.equals(other.headers))) { + return false; + } + if (this.multiValueHeaders != other.multiValueHeaders && (this.multiValueHeaders == null || !this.multiValueHeaders.equals(other.multiValueHeaders))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "{isBase64Encoded=" + isBase64Encoded + + ", statusCode=" + statusCode + + ", headers=" + headers + + ", multiValueHeaders=" + multiValueHeaders + + ", body=" + body + + "}"; + } + +} From f50df3bdd54d96df668a5065d339dcd7b2600f20 Mon Sep 17 00:00:00 2001 From: JC Carrillo Date: Wed, 7 Aug 2019 14:40:05 -0400 Subject: [PATCH 15/65] Fixed Congnito to Cognito java doc in CognitoEvent (#87) --- .../amazonaws/services/lambda/runtime/events/CognitoEvent.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/CognitoEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoEvent.java index d250dc17..452d3d6f 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoEvent.java @@ -18,7 +18,7 @@ /** * - * Represents an Amazon Congnito event sent to Lambda Functions + * Represents an Amazon Cognito event sent to Lambda Functions * */ public class CognitoEvent implements Serializable, Cloneable { From 190a1d655afe607a3702819f0b135cf09e9bebc9 Mon Sep 17 00:00:00 2001 From: brlyman Date: Tue, 13 Aug 2019 11:52:12 +0100 Subject: [PATCH 16/65] Version Bump Events Library To 2.2.7 --- README.md | 8 ++++---- aws-lambda-java-events/README.md | 8 ++++---- aws-lambda-java-events/pom.xml | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 610cf82d..3243ff51 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ ___ com.amazonaws aws-lambda-java-events - 2.2.6 + 2.2.7 com.amazonaws @@ -50,7 +50,7 @@ ___ ```groovy 'com.amazonaws:aws-lambda-java-core:1.2.0' -'com.amazonaws:aws-lambda-java-events:2.2.6' +'com.amazonaws:aws-lambda-java-events:2.2.7' 'com.amazonaws:aws-lambda-java-log4j:1.0.0' 'com.amazonaws:aws-lambda-java-log4j2:1.0.0' ``` @@ -59,7 +59,7 @@ ___ ```clojure [com.amazonaws/aws-lambda-java-core "1.2.0"] -[com.amazonaws/aws-lambda-java-events "2.2.6"] +[com.amazonaws/aws-lambda-java-events "2.2.7"] [com.amazonaws/aws-lambda-java-log4j "1.0.0"] [com.amazonaws/aws-lambda-java-log4j2 "1.0.0"] ``` @@ -68,7 +68,7 @@ ___ ```scala "com.amazonaws" % "aws-lambda-java-core" % "1.2.0" -"com.amazonaws" % "aws-lambda-java-events" % "2.2.6" +"com.amazonaws" % "aws-lambda-java-events" % "2.2.7" "com.amazonaws" % "aws-lambda-java-log4j" % "1.0.0" "com.amazonaws" % "aws-lambda-java-log4j2" % "1.0.0" ``` diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index 76032ea7..7c7d3171 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -48,7 +48,7 @@ so the dependencies section in the pom.xml file would like this com.amazonaws aws-lambda-java-events - 2.2.6 + 2.2.7 ... @@ -69,7 +69,7 @@ For the S3 event the pom would look like this: com.amazonaws aws-lambda-java-events - 2.2.6 + 2.2.7 com.amazonaws @@ -95,7 +95,7 @@ For the Kinesis event com.amazonaws aws-lambda-java-events - 2.2.6 + 2.2.7 com.amazonaws @@ -121,7 +121,7 @@ For the Dynamodb event com.amazonaws aws-lambda-java-events - 2.2.6 + 2.2.7 com.amazonaws diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index 93105bea..03662d1c 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -1,9 +1,9 @@ 4.0.0 - + com.amazonaws aws-lambda-java-events - 2.2.6 + 2.2.7 jar AWS Lambda Java Events Library @@ -61,7 +61,7 @@ provided - + dev @@ -147,5 +147,5 @@ - + From 9d526820100f6afb214442af80d05b967e441127 Mon Sep 17 00:00:00 2001 From: Ivo Anjo Date: Mon, 2 Sep 2019 11:37:28 +0100 Subject: [PATCH 17/65] Add missing xml namespace declarations to POM files (#97) Without these declarations, the XML file cannot be validated correctly. See examples: * * The tool I'm using actually tries to validate these before using them ( -- Amazon internal link), so that's why I ran into issues. I'm assuming most tools don't have the validation enabled, so this is why others haven't reported this before. The same issue can be easily replicated by pasting the current POM files in as well as just trying to open them with Firefox. (P.s: Hello there Lambda team! We recently met in your Dublin office!) --- aws-lambda-java-core/pom.xml | 4 +++- aws-lambda-java-events/pom.xml | 4 +++- aws-lambda-java-log4j/pom.xml | 4 +++- aws-lambda-java-log4j2/pom.xml | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/aws-lambda-java-core/pom.xml b/aws-lambda-java-core/pom.xml index 7fc787bc..59b648f6 100644 --- a/aws-lambda-java-core/pom.xml +++ b/aws-lambda-java-core/pom.xml @@ -1,4 +1,6 @@ - + 4.0.0 com.amazonaws diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index 03662d1c..43724dd9 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -1,4 +1,6 @@ - + 4.0.0 com.amazonaws diff --git a/aws-lambda-java-log4j/pom.xml b/aws-lambda-java-log4j/pom.xml index 006ee39c..0a765e03 100644 --- a/aws-lambda-java-log4j/pom.xml +++ b/aws-lambda-java-log4j/pom.xml @@ -1,4 +1,6 @@ - + 4.0.0 com.amazonaws diff --git a/aws-lambda-java-log4j2/pom.xml b/aws-lambda-java-log4j2/pom.xml index 42a8c991..1a9fb2a2 100644 --- a/aws-lambda-java-log4j2/pom.xml +++ b/aws-lambda-java-log4j2/pom.xml @@ -1,4 +1,6 @@ - + 4.0.0 com.amazonaws From 98b9b323adae039f690c345128859e44b051ac86 Mon Sep 17 00:00:00 2001 From: Bryan Moffatt Date: Wed, 12 Feb 2020 15:39:43 +0000 Subject: [PATCH 18/65] Update nexusUrl in all pom.xml (#108) --- aws-lambda-java-core/pom.xml | 2 +- aws-lambda-java-events/pom.xml | 2 +- aws-lambda-java-log4j/pom.xml | 2 +- aws-lambda-java-log4j2/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aws-lambda-java-core/pom.xml b/aws-lambda-java-core/pom.xml index 59b648f6..30f4cbdc 100644 --- a/aws-lambda-java-core/pom.xml +++ b/aws-lambda-java-core/pom.xml @@ -116,7 +116,7 @@ true sonatype-nexus-staging - https://oss.sonatype.org/ + https://aws.oss.sonatype.org/ false diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index 43724dd9..e02da240 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -142,7 +142,7 @@ true sonatype-nexus-staging - https://oss.sonatype.org/ + https://aws.oss.sonatype.org/ false diff --git a/aws-lambda-java-log4j/pom.xml b/aws-lambda-java-log4j/pom.xml index 0a765e03..3e7405e5 100644 --- a/aws-lambda-java-log4j/pom.xml +++ b/aws-lambda-java-log4j/pom.xml @@ -127,7 +127,7 @@ true sonatype-nexus-staging - https://oss.sonatype.org/ + https://aws.oss.sonatype.org/ false diff --git a/aws-lambda-java-log4j2/pom.xml b/aws-lambda-java-log4j2/pom.xml index 1a9fb2a2..08daa6fe 100644 --- a/aws-lambda-java-log4j2/pom.xml +++ b/aws-lambda-java-log4j2/pom.xml @@ -132,7 +132,7 @@ true sonatype-nexus-staging - https://oss.sonatype.org/ + https://aws.oss.sonatype.org/ false From 34718f5441b6923cdff41787b32f0d09b35aa999 Mon Sep 17 00:00:00 2001 From: Carl Zogheib <11421173+carlzogh@users.noreply.github.com> Date: Tue, 28 Apr 2020 15:44:21 +0100 Subject: [PATCH 19/65] Bump all packages to new patch version, add maven.compiler properties, update docs (#116) --- README.md | 32 ++++++++++++++++---------------- aws-lambda-java-core/pom.xml | 7 ++++++- aws-lambda-java-events/README.md | 16 ++++++++-------- aws-lambda-java-events/pom.xml | 7 ++++++- aws-lambda-java-log4j/pom.xml | 23 +++++++++++++++-------- aws-lambda-java-log4j2/README.md | 2 +- aws-lambda-java-log4j2/pom.xml | 23 +++++++++++++++-------- 7 files changed, 67 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 3243ff51..c563b816 100644 --- a/README.md +++ b/README.md @@ -27,50 +27,50 @@ ___ com.amazonaws aws-lambda-java-core - 1.2.0 + 1.2.1 com.amazonaws aws-lambda-java-events - 2.2.7 + 2.2.8 com.amazonaws aws-lambda-java-log4j - 1.0.0 + 1.0.1 com.amazonaws aws-lambda-java-log4j2 - 1.0.0 + 1.1.1 ``` [Gradle](https://gradle.org) ```groovy -'com.amazonaws:aws-lambda-java-core:1.2.0' -'com.amazonaws:aws-lambda-java-events:2.2.7' -'com.amazonaws:aws-lambda-java-log4j:1.0.0' -'com.amazonaws:aws-lambda-java-log4j2:1.0.0' +'com.amazonaws:aws-lambda-java-core:1.2.1' +'com.amazonaws:aws-lambda-java-events:2.2.8' +'com.amazonaws:aws-lambda-java-log4j:1.0.1' +'com.amazonaws:aws-lambda-java-log4j2:1.1.1' ``` [Leiningen](http://leiningen.org) and [Boot](http://boot-clj.com) ```clojure -[com.amazonaws/aws-lambda-java-core "1.2.0"] -[com.amazonaws/aws-lambda-java-events "2.2.7"] -[com.amazonaws/aws-lambda-java-log4j "1.0.0"] -[com.amazonaws/aws-lambda-java-log4j2 "1.0.0"] +[com.amazonaws/aws-lambda-java-core "1.2.1"] +[com.amazonaws/aws-lambda-java-events "2.2.8"] +[com.amazonaws/aws-lambda-java-log4j "1.0.1"] +[com.amazonaws/aws-lambda-java-log4j2 "1.1.1"] ``` [sbt](http://www.scala-sbt.org) ```scala -"com.amazonaws" % "aws-lambda-java-core" % "1.2.0" -"com.amazonaws" % "aws-lambda-java-events" % "2.2.7" -"com.amazonaws" % "aws-lambda-java-log4j" % "1.0.0" -"com.amazonaws" % "aws-lambda-java-log4j2" % "1.0.0" +"com.amazonaws" % "aws-lambda-java-core" % "1.2.1" +"com.amazonaws" % "aws-lambda-java-events" % "2.2.8" +"com.amazonaws" % "aws-lambda-java-log4j" % "1.0.1" +"com.amazonaws" % "aws-lambda-java-log4j2" % "1.1.1" ``` # Using aws-lambda-java-core diff --git a/aws-lambda-java-core/pom.xml b/aws-lambda-java-core/pom.xml index 30f4cbdc..52d2976f 100644 --- a/aws-lambda-java-core/pom.xml +++ b/aws-lambda-java-core/pom.xml @@ -5,7 +5,7 @@ com.amazonaws aws-lambda-java-core - 1.2.0 + 1.2.1 jar AWS Lambda Java Core Library @@ -31,6 +31,11 @@ + + 1.8 + 1.8 + + sonatype-nexus-staging diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index 7c7d3171..47993ac4 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -43,12 +43,12 @@ so the dependencies section in the pom.xml file would like this com.amazonaws aws-lambda-java-core - 1.1.0 + 1.2.1 com.amazonaws aws-lambda-java-events - 2.2.7 + 2.2.8 ... @@ -64,12 +64,12 @@ For the S3 event the pom would look like this: com.amazonaws aws-lambda-java-core - 1.1.0 + 1.2.1 com.amazonaws aws-lambda-java-events - 2.2.7 + 2.2.8 com.amazonaws @@ -90,12 +90,12 @@ For the Kinesis event com.amazonaws aws-lambda-java-core - 1.1.0 + 1.2.1 com.amazonaws aws-lambda-java-events - 2.2.7 + 2.2.8 com.amazonaws @@ -116,12 +116,12 @@ For the Dynamodb event com.amazonaws aws-lambda-java-core - 1.1.0 + 1.2.1 com.amazonaws aws-lambda-java-events - 2.2.7 + 2.2.8 com.amazonaws diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index e02da240..7c4a4ec1 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.7 + 2.2.8 jar AWS Lambda Java Events Library @@ -31,6 +31,11 @@ + + 1.8 + 1.8 + + sonatype-nexus-staging diff --git a/aws-lambda-java-log4j/pom.xml b/aws-lambda-java-log4j/pom.xml index 3e7405e5..6b1a2b36 100644 --- a/aws-lambda-java-log4j/pom.xml +++ b/aws-lambda-java-log4j/pom.xml @@ -5,7 +5,7 @@ com.amazonaws aws-lambda-java-log4j - 1.0.0 + 1.0.1 jar AWS Lambda Java Log4j 1.2 Library @@ -30,11 +30,24 @@ https://aws.amazon.com/ + + + 1.8 + 1.8 + + + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + com.amazonaws aws-lambda-java-core - 1.1.0 + 1.2.1 log4j @@ -42,12 +55,6 @@ 1.2.17 - - - sonatype-nexus-staging - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - diff --git a/aws-lambda-java-log4j2/README.md b/aws-lambda-java-log4j2/README.md index f5449d8c..b040e85f 100644 --- a/aws-lambda-java-log4j2/README.md +++ b/aws-lambda-java-log4j2/README.md @@ -10,7 +10,7 @@ Example for Maven pom.xml com.amazonaws aws-lambda-java-log4j2 - 1.0.0 + 1.1.1 org.apache.logging.log4j diff --git a/aws-lambda-java-log4j2/pom.xml b/aws-lambda-java-log4j2/pom.xml index 08daa6fe..7bfdbc19 100644 --- a/aws-lambda-java-log4j2/pom.xml +++ b/aws-lambda-java-log4j2/pom.xml @@ -5,7 +5,7 @@ com.amazonaws aws-lambda-java-log4j2 - 1.1.0 + 1.1.1 jar AWS Lambda Java Log4j 2.8 Libraries @@ -30,11 +30,24 @@ https://aws.amazon.com/ + + + 1.8 + 1.8 + + + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + com.amazonaws aws-lambda-java-core - 1.2.0 + 1.2.1 org.apache.logging.log4j @@ -47,12 +60,6 @@ 2.8.2 - - - sonatype-nexus-staging - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - From 11722a982353dfd61342775d7935231988961ff2 Mon Sep 17 00:00:00 2001 From: Carl Zogheib <11421173+carlzogh@users.noreply.github.com> Date: Tue, 28 Apr 2020 16:47:12 +0100 Subject: [PATCH 20/65] Add per-module release changelog files, update main readme (#117) --- README.md | 31 +++--- aws-lambda-java-core/RELEASE.CHANGELOG.md | 18 ++++ aws-lambda-java-events/RELEASE.CHANGELOG.md | 100 ++++++++++++++++++++ aws-lambda-java-log4j/RELEASE.CHANGELOG.md | 9 ++ aws-lambda-java-log4j2/RELEASE.CHANGELOG.md | 13 +++ 5 files changed, 157 insertions(+), 14 deletions(-) create mode 100644 aws-lambda-java-core/RELEASE.CHANGELOG.md create mode 100644 aws-lambda-java-events/RELEASE.CHANGELOG.md create mode 100644 aws-lambda-java-log4j/RELEASE.CHANGELOG.md create mode 100644 aws-lambda-java-log4j2/RELEASE.CHANGELOG.md diff --git a/README.md b/README.md index c563b816..f7eb06de 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # AWS Lambda Java Support Libraries Interface definitions for Java code running on the AWS Lambda platform. -For issues and questions, you can start with our [FAQ](https://aws.amazon.com/lambda/faqs/) and the [AWS forums](https://forums.aws.amazon.com/forum.jspa?forumID=186) +For issues and questions, you can start with our [FAQ](https://aws.amazon.com/lambda/faqs/) + and the [AWS forums](https://forums.aws.amazon.com/forum.jspa?forumID=186) -To get started writing AWS Lambda functions in Java, check out the [official documentation] (http://docs.aws.amazon.com/lambda/latest/dg/java-gs.html). +To get started writing AWS Lambda functions in Java, check out the [official documentation](http://docs.aws.amazon.com/lambda/latest/dg/java-gs.html). # Disclaimer of use @@ -11,12 +12,13 @@ Each of the supplied packages should be used without modification. Removing dependencies, adding conflicting dependencies, or selectively including classes from the packages can result in unexpected behavior. -# Recent Updates! +# Release Notes -* ### [SQS Support](https://github.com/aws/aws-lambda-java-libs/commit/9a74fdc9d92b5d7f73ae05660090e65cbd098360) -* ### [Kinesis Analytics Support](https://github.com/aws/aws-lambda-java-libs/commit/943352c7f0256afe82773e664e887e1593303508) -* ### [2017 Java Events Update](https://github.com/aws/aws-lambda-java-libs/tree/master/aws-lambda-java-events) -* ### [Log4j2 Support](https://github.com/aws/aws-lambda-java-libs/tree/master/aws-lambda-java-log4j2) +Check out the per-module release notes: +- [aws-lambda-java-core](aws-lambda-java-core/RELEASE.CHANGELOG.md) +- [aws-lambda-java-events](aws-lambda-java-events/RELEASE.CHANGELOG.md) +- [aws-lambda-java-log4j](aws-lambda-java-log4j/RELEASE.CHANGELOG.md) +- [aws-lambda-java-log4j2](aws-lambda-java-log4j2/RELEASE.CHANGELOG.md) # Where to get packages ___ @@ -75,19 +77,20 @@ ___ # Using aws-lambda-java-core -This package defines the Lambda [Context](http://docs.aws.amazon.com/lambda/latest/dg/java-context-object.html) -object as well as [interfaces](http://docs.aws.amazon.com/lambda/latest/dg/java-handler-using-predefined-interfaces.html) that Lambda accepts. +This package defines the Lambda [Context](http://docs.aws.amazon.com/lambda/latest/dg/java-context-object.html) object + as well as [interfaces](http://docs.aws.amazon.com/lambda/latest/dg/java-handler-using-predefined-interfaces.html) that Lambda accepts. # Using aws-lambda-java-events -This package defines [event sources](http://docs.aws.amazon.com/lambda/latest/dg/intro-invocation-modes.html) that AWS Lambda natively accepts. See the [documentation](https://github.com/aws/aws-lambda-java-libs/tree/master/aws-lambda-java-events) for more information. +This package defines [event sources](http://docs.aws.amazon.com/lambda/latest/dg/intro-invocation-modes.html) that AWS Lambda natively accepts. +See the [documentation](aws-lambda-java-events/README.md) for more information. # Using aws-lambda-java-log4j2 -This package defines the Lambda adapter to use with log4j version 2. See -[documentation](https://github.com/aws/aws-lambda-java-libs/tree/master/aws-lambda-java-log4j2) for how to use the adapter. +This package defines the Lambda adapter to use with log4j version 2. +See the [documentation](aws-lambda-java-log4j2/README.md) for information on how to use the adapter. # Using aws-lambda-java-log4j (Not recommended) -This package defines the Lambda adapter to use with log4j version 1. See -the [official documentation](http://docs.aws.amazon.com/lambda/latest/dg/java-logging.html#java-wt-logging-using-log4j) for how to use this adapter. +This package defines the Lambda adapter to use with log4j version 1. +See the [official documentation](http://docs.aws.amazon.com/lambda/latest/dg/java-logging.html#java-wt-logging-using-log4j) for information on how to use this adapter. diff --git a/aws-lambda-java-core/RELEASE.CHANGELOG.md b/aws-lambda-java-core/RELEASE.CHANGELOG.md new file mode 100644 index 00000000..0309da57 --- /dev/null +++ b/aws-lambda-java-core/RELEASE.CHANGELOG.md @@ -0,0 +1,18 @@ +### Apr 28, 2020 +`1.2.1`: +- Added missing XML namespace declarations to `pom.xml` file ([#97](https://github.com/aws/aws-lambda-java-libs/issues/97)) +- Updated `nexusUrl` in `pom.xml` file ([#108](https://github.com/aws/aws-lambda-java-libs/issues/108)) + +### Nov 21, 2017 +`1.2.0`: +- Added method to log byte array to `LambdaLogger` + +### Oct 07, 2015 +`1.1.0`: +- Added `LambdaRuntime` and `LambdaRuntimeInternal` +- Added `getInstallationId()` to `Client` +- Added `getFunctionVersion()` and `getInvokedFunctionArn()` to `Context` + +### Jun 15, 2015 +`1.0.0`: +- Initial support for java in AWS Lambda diff --git a/aws-lambda-java-events/RELEASE.CHANGELOG.md b/aws-lambda-java-events/RELEASE.CHANGELOG.md new file mode 100644 index 00000000..29afb994 --- /dev/null +++ b/aws-lambda-java-events/RELEASE.CHANGELOG.md @@ -0,0 +1,100 @@ +### Apr 28, 2020 +`2.2.8`: +- Added missing XML namespace declarations to `pom.xml` file ([#97](https://github.com/aws/aws-lambda-java-libs/issues/97)) +- Updated `nexusUrl` in `pom.xml` file ([#108](https://github.com/aws/aws-lambda-java-libs/issues/108)) + +### Aug 13, 2019 +`2.2.7`: +- Added support for APIGatewayV2 (Web Sockets) ([#92](https://github.com/aws/aws-lambda-java-libs/issues/92)) + - `APIGatewayV2ProxyRequestEvent` + - `APIGatewayV2ProxyResponseEvent` +- Fixed typo in `CognitoEvent` javadoc ([#87](https://github.com/aws/aws-lambda-java-libs/issues/87)) + +### Mar 11, 2019 +`2.2.6`: +- Added field `customData` to `CommitEvent.Record` ([#79](https://github.com/aws/aws-lambda-java-libs/issues/79)) +- Added field `isBase64Encoded` to `APIGatewayProxyResponseEvent` ([#48](https://github.com/aws/aws-lambda-java-libs/issues/48)) +- Added field `authorizer` to `APIGatewayProxyRequestEvent` ([#77](https://github.com/aws/aws-lambda-java-libs/issues/77)) + +### Jan 03, 2019 +`2.2.5`: +- Fixed "Paramters" typo in `APIGatewayProxyRequestEvent` and `ConfigEvent` ([#65](https://github.com/aws/aws-lambda-java-libs/issues/65)) + +### Nov 14, 2018 +`2.2.4`: +- Added default constructor for `S3Event` for easier deserialization + +### Nov 05, 2018 +`2.2.3`: +- Added support for Multi-Value Headers and Query String Parameters to `APIGatewayProxyRequestEvent` ([#60](https://github.com/aws/aws-lambda-java-libs/issues/60)) + +### Jul 02, 2018 +`2.2.2`: +- Made `SQSEvent.SQSMessage` default constructor public ([#51](https://github.com/aws/aws-lambda-java-libs/issues/51)) + +### Jun 29, 2018 +`2.2.1`: +- Made `SQSEvent.SQSMessage` public ([#51](https://github.com/aws/aws-lambda-java-libs/issues/51)) + +### Jun 28, 2018 +`2.2.0`: +- Added `SQSEvent` + +### Mar 09, 2018 +`2.1.0`: +- Added Kinesis Analytics events + - `KinesisAnalyticsFirehoseInputPreprocessingEvent` + - `KinesisAnalyticsInputPreprocessingResponse` + - `KinesisAnalyticsOutputDeliveryEvent` + - `KinesisAnalyticsOutputDeliveryResponse` + - `KinesisAnalyticsStreamsInputPreprocessingEvent` + +### Nov 21, 2017 +`2.0.2`: +- Added missing fields to `APIGatewayProxyRequestEvent` ([#46](https://github.com/aws/aws-lambda-java-libs/issues/46)) + +### Oct 07, 2017 +`2.0.1`: +- Updated KinesisFirehose event schema. + - `approximateArrivalTimestamp` is now represented as a millisecond epoch instead of an `org.joda.time.DateTime` object. + +### Sep 20, 2017 +`2.0`: +- Added the following events: + - `APIGatewayProxyRequestEvent` + - `APIGatewayProxyResponseEvent` + - `CloudFrontEvent` + - `CloudWatchLogsEvent` + - `CodeCommitEvent` + - `IoTButtonEvent` + - `KinesisFirehoseEvent` + - `LexEvent` + - `ScheduledEvent` +- Changed dependency management; Users must now supply the SDK package if they are using an event that is connected to an SDK library. + - These events are `S3Event`, `KinesisEvemt`, and `DynamodbEvent`. +- Bumped AWS SDK versions to `1.11.163` + + +### May 16, 2016 +`1.3.0`: +- Bumped AWS SDK versions to `1.11.0` + +### May 16, 2016 +`1.2.1`: +- Bumped AWS SDK versions to `1.10.77` + +### Apr 22, 2016 +`1.2.0`: +- Added `ConfigEvent` + +### Aug 21, 2015 +`1.1.0`: +- Added `DynamodbEvent` + +### Jun 15, 2015 +`1.0.0`: +- Initial support for java in AWS Lambda, includes the following events: + - `CognitoEvent` + - `KinesisEvent` + - `S3Event` + - `SNSEvent` diff --git a/aws-lambda-java-log4j/RELEASE.CHANGELOG.md b/aws-lambda-java-log4j/RELEASE.CHANGELOG.md new file mode 100644 index 00000000..b009b21f --- /dev/null +++ b/aws-lambda-java-log4j/RELEASE.CHANGELOG.md @@ -0,0 +1,9 @@ +### Apr 28, 2020 +`1.0.1`: +- Added missing XML namespace declarations to `pom.xml` file ([#97](https://github.com/aws/aws-lambda-java-libs/issues/97)) +- Updated `nexusUrl` in `pom.xml` file ([#108](https://github.com/aws/aws-lambda-java-libs/issues/108)) +- Updated `aws-lambda-java-core` to `1.2.1` + +### Oct 07, 2015 +`1.0.0`: +- Initial release of AWS Lambda Log4j support diff --git a/aws-lambda-java-log4j2/RELEASE.CHANGELOG.md b/aws-lambda-java-log4j2/RELEASE.CHANGELOG.md new file mode 100644 index 00000000..ae75fb0e --- /dev/null +++ b/aws-lambda-java-log4j2/RELEASE.CHANGELOG.md @@ -0,0 +1,13 @@ +### Apr 28, 2020 +`1.1.1`: +- Added missing XML namespace declarations to `pom.xml` file ([#97](https://github.com/aws/aws-lambda-java-libs/issues/97)) +- Updated `nexusUrl` in `pom.xml` file ([#108](https://github.com/aws/aws-lambda-java-libs/issues/108)) +- Updated `aws-lambda-java-core` to `1.2.1` + +### Nov 21, 2017 +`1.1.0`: +- Changed `LambdaAppender.append()` to make use of `LambdaLogger` from `com.amazonaws:aws-lambda-java-core:1.2.0` + +### Jun 29, 2017 +`1.0.0`: +- Initial release of AWS Lambda Log4j2 support \ No newline at end of file From 6849518cc1aaf82494015f9a892a9e2cc44207d8 Mon Sep 17 00:00:00 2001 From: Orestis Gkorgkas Date: Tue, 5 May 2020 12:16:51 +0200 Subject: [PATCH 21/65] #114: Update README.md file for Gradle and SAM tools (#115) --- aws-lambda-java-log4j2/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/aws-lambda-java-log4j2/README.md b/aws-lambda-java-log4j2/README.md index b040e85f..42976338 100644 --- a/aws-lambda-java-log4j2/README.md +++ b/aws-lambda-java-log4j2/README.md @@ -62,6 +62,32 @@ If using maven shade plugin, set the plugin configuration as follows ``` +If you are using the [John Rengelman](https://github.com/johnrengelman/shadow) Gradle shadow plugin, then the plugin configuration is as follows: + +```groovy + +dependencies{ + ... + implementation group: 'com.amazonaws', name: 'aws-lambda-java-log4j2', version: '1.1.0' + implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4jVersion + implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4jVersion +} + +jar { + enabled = false +} +shadowJar { + transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer) +} + +build.dependsOn(shadowJar) + +``` + +If you are using the `sam build` and `sam deploy` commands to deploy your lambda function, then you don't +need to use the shadow jar plugin. The `sam` cli-tool merges itself the `Log4j2Plugins.dat` +files. + ### 2. Configure log4j2 using log4j2.xml file Add the following file `/src/main/resources/log4j2.xml` From cdf760c6fe06e67cf65ad26d5f015a2ea568d2d1 Mon Sep 17 00:00:00 2001 From: Carl Zogheib <11421173+carlzogh@users.noreply.github.com> Date: Tue, 5 May 2020 14:18:48 +0100 Subject: [PATCH 22/65] Add action to build all packages in project (#121) --- .github/workflows/maven-pkg-all.yml | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/maven-pkg-all.yml diff --git a/.github/workflows/maven-pkg-all.yml b/.github/workflows/maven-pkg-all.yml new file mode 100644 index 00000000..3296fe9e --- /dev/null +++ b/.github/workflows/maven-pkg-all.yml @@ -0,0 +1,30 @@ +# This workflow will build all Java packages in this project with Maven (Java 8) + +name: Java CI with Maven + +on: + push: + branches: [ master ] + pull_request: + branches: [ '*' ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Build core with Maven + run: mvn -B package --file aws-lambda-java-core/pom.xml + - name: Build events with Maven + run: mvn -B package --file aws-lambda-java-events/pom.xml + - name: Build log4j with Maven + run: mvn -B package --file aws-lambda-java-log4j/pom.xml + - name: Build log4j2 with Maven + run: mvn -B package --file aws-lambda-java-log4j2/pom.xml From 8e39c35628044859afc061d2670b389ba839013a Mon Sep 17 00:00:00 2001 From: Carl Zogheib <11421173+carlzogh@users.noreply.github.com> Date: Tue, 5 May 2020 14:44:55 +0100 Subject: [PATCH 23/65] Update `log4j-core` and `log4j-api` to `2.13.2`, bump log4j2 to `1.2.0` (#122) --- README.md | 8 ++++---- aws-lambda-java-log4j2/README.md | 6 +++--- aws-lambda-java-log4j2/RELEASE.CHANGELOG.md | 4 ++++ aws-lambda-java-log4j2/pom.xml | 11 ++++++----- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f7eb06de..efa21260 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ ___ com.amazonaws aws-lambda-java-log4j2 - 1.1.1 + 1.2.0 ``` @@ -54,7 +54,7 @@ ___ 'com.amazonaws:aws-lambda-java-core:1.2.1' 'com.amazonaws:aws-lambda-java-events:2.2.8' 'com.amazonaws:aws-lambda-java-log4j:1.0.1' -'com.amazonaws:aws-lambda-java-log4j2:1.1.1' +'com.amazonaws:aws-lambda-java-log4j2:1.2.0' ``` [Leiningen](http://leiningen.org) and [Boot](http://boot-clj.com) @@ -63,7 +63,7 @@ ___ [com.amazonaws/aws-lambda-java-core "1.2.1"] [com.amazonaws/aws-lambda-java-events "2.2.8"] [com.amazonaws/aws-lambda-java-log4j "1.0.1"] -[com.amazonaws/aws-lambda-java-log4j2 "1.1.1"] +[com.amazonaws/aws-lambda-java-log4j2 "1.2.0"] ``` [sbt](http://www.scala-sbt.org) @@ -72,7 +72,7 @@ ___ "com.amazonaws" % "aws-lambda-java-core" % "1.2.1" "com.amazonaws" % "aws-lambda-java-events" % "2.2.8" "com.amazonaws" % "aws-lambda-java-log4j" % "1.0.1" -"com.amazonaws" % "aws-lambda-java-log4j2" % "1.1.1" +"com.amazonaws" % "aws-lambda-java-log4j2" % "1.2.0" ``` # Using aws-lambda-java-core diff --git a/aws-lambda-java-log4j2/README.md b/aws-lambda-java-log4j2/README.md index 42976338..40ca3c3a 100644 --- a/aws-lambda-java-log4j2/README.md +++ b/aws-lambda-java-log4j2/README.md @@ -10,17 +10,17 @@ Example for Maven pom.xml com.amazonaws aws-lambda-java-log4j2 - 1.1.1 + 1.2.0 org.apache.logging.log4j log4j-core - 2.8.2 + 2.13.2 org.apache.logging.log4j log4j-api - 2.8.2 + 2.13.2 .... diff --git a/aws-lambda-java-log4j2/RELEASE.CHANGELOG.md b/aws-lambda-java-log4j2/RELEASE.CHANGELOG.md index ae75fb0e..09dbc918 100644 --- a/aws-lambda-java-log4j2/RELEASE.CHANGELOG.md +++ b/aws-lambda-java-log4j2/RELEASE.CHANGELOG.md @@ -1,3 +1,7 @@ +### May 05, 2020 +`1.2.0`: +- Updated `log4j-core` and `log4j-api` dependencies to `2.13.2` + ### Apr 28, 2020 `1.1.1`: - Added missing XML namespace declarations to `pom.xml` file ([#97](https://github.com/aws/aws-lambda-java-libs/issues/97)) diff --git a/aws-lambda-java-log4j2/pom.xml b/aws-lambda-java-log4j2/pom.xml index 7bfdbc19..c060f8e3 100644 --- a/aws-lambda-java-log4j2/pom.xml +++ b/aws-lambda-java-log4j2/pom.xml @@ -5,12 +5,12 @@ com.amazonaws aws-lambda-java-log4j2 - 1.1.1 + 1.2.0 jar - AWS Lambda Java Log4j 2.8 Libraries + AWS Lambda Java Log4j 2.x Libraries - Support for using log4j 2.8 with AWS Lambda. + Support for using Log4j 2.x with AWS Lambda. https://aws.amazon.com/lambda/ @@ -34,6 +34,7 @@ 1.8 1.8 + 2.13.2 @@ -52,12 +53,12 @@ org.apache.logging.log4j log4j-core - 2.8.2 + ${log4j.version} org.apache.logging.log4j log4j-api - 2.8.2 + ${log4j.version} From 6ea9428ad704a075496f8a85eac02c637d14b54b Mon Sep 17 00:00:00 2001 From: Carl Zogheib <11421173+carlzogh@users.noreply.github.com> Date: Tue, 5 May 2020 14:49:36 +0100 Subject: [PATCH 24/65] Add aws-lambda-java-events-sdk-transformer library with DynamodbEvent v2.2.8 support (#118) --- README.md | 15 + .../README.md | 121 +++++++ .../RELEASE.CHANGELOG.md | 3 + .../pom.xml | 175 ++++++++++ .../DynamodbEventTransformer.java | 21 ++ .../DynamodbAttributeValueTransformer.java | 84 +++++ .../dynamodb/DynamodbIdentityTransformer.java | 13 + .../dynamodb/DynamodbRecordTransformer.java | 23 ++ .../DynamodbStreamRecordTransformer.java | 26 ++ .../DynamodbEventTransformerTest.java | 42 +++ ...DynamodbAttributeValueTransformerTest.java | 317 ++++++++++++++++++ .../DynamodbIdentityTransformerTest.java | 31 ++ .../DynamodbRecordTransformerTest.java | 53 +++ .../DynamodbStreamRecordTransformerTest.java | 103 ++++++ 14 files changed, 1027 insertions(+) create mode 100644 aws-lambda-java-events-sdk-transformer/README.md create mode 100644 aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md create mode 100644 aws-lambda-java-events-sdk-transformer/pom.xml create mode 100644 aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/DynamodbEventTransformer.java create mode 100644 aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbAttributeValueTransformer.java create mode 100644 aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbIdentityTransformer.java create mode 100644 aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbRecordTransformer.java create mode 100644 aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbStreamRecordTransformer.java create mode 100644 aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/DynamodbEventTransformerTest.java create mode 100644 aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbAttributeValueTransformerTest.java create mode 100644 aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbIdentityTransformerTest.java create mode 100644 aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbRecordTransformerTest.java create mode 100644 aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbStreamRecordTransformerTest.java diff --git a/README.md b/README.md index efa21260..df86bfff 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ from the packages can result in unexpected behavior. Check out the per-module release notes: - [aws-lambda-java-core](aws-lambda-java-core/RELEASE.CHANGELOG.md) - [aws-lambda-java-events](aws-lambda-java-events/RELEASE.CHANGELOG.md) +- [aws-lambda-java-events-sdk-transformer](aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md) - [aws-lambda-java-log4j](aws-lambda-java-log4j/RELEASE.CHANGELOG.md) - [aws-lambda-java-log4j2](aws-lambda-java-log4j2/RELEASE.CHANGELOG.md) @@ -36,6 +37,11 @@ ___ aws-lambda-java-events 2.2.8 + + com.amazonaws + aws-lambda-java-events-sdk-transformer + 1.0.0 + com.amazonaws aws-lambda-java-log4j @@ -53,6 +59,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-sdk-transformer:1.0.0' 'com.amazonaws:aws-lambda-java-log4j:1.0.1' 'com.amazonaws:aws-lambda-java-log4j2:1.2.0' ``` @@ -62,6 +69,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-sdk-transformer "1.0.0"] [com.amazonaws/aws-lambda-java-log4j "1.0.1"] [com.amazonaws/aws-lambda-java-log4j2 "1.2.0"] ``` @@ -71,6 +79,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-sdk-transformer" % "1.0.0" "com.amazonaws" % "aws-lambda-java-log4j" % "1.0.1" "com.amazonaws" % "aws-lambda-java-log4j2" % "1.2.0" ``` @@ -85,6 +94,12 @@ This package defines the Lambda [Context](http://docs.aws.amazon.com/lambda/late This package defines [event sources](http://docs.aws.amazon.com/lambda/latest/dg/intro-invocation-modes.html) that AWS Lambda natively accepts. See the [documentation](aws-lambda-java-events/README.md) for more information. +# Using aws-lambda-java-events-sdk-transformer + +This package provides helper classes/methods to use alongside `aws-lambda-java-events` in order to transform + Lambda input event model objects into SDK-compatible output model objects. +See the [documentation](aws-lambda-java-events-sdk-transformer/README.md) for more information. + # Using aws-lambda-java-log4j2 This package defines the Lambda adapter to use with log4j version 2. diff --git a/aws-lambda-java-events-sdk-transformer/README.md b/aws-lambda-java-events-sdk-transformer/README.md new file mode 100644 index 00000000..572021ba --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/README.md @@ -0,0 +1,121 @@ +# AWS Lambda Java Events SDK Transformer Library + +### About + +Provides helper classes/methods to use alongside `aws-lambda-java-events` in order to transform Lambda input event model + objects into SDK-compatible output model objects + (eg. DynamodbEvent to a List of records writable back to DynamoDB through the AWS DynamoDB SDK v2). + + +### Getting started + +Add the following Apache Maven dependencies to your `pom.xml` file: + +```xml + + + com.amazonaws + aws-lambda-java-events-sdk-transformer + 1.0.0 + + + com.amazonaws + aws-lambda-java-events + 2.2.8 + + +``` + +To use this library as a transformer to the AWS DynamoDB Java SDK v2, also add the following dependencies to your `pom.xml` file: + +```xml + + + software.amazon.awssdk + dynamodb + 2.11.12 + + + com.amazonaws + aws-java-sdk-dynamodb + 1.11.163 + + +``` +*Note that because `aws-lambda-java-events` version 2 requires the DynamoDB v1 SDK, this is also required for this library.* + + +### Example Usage + +To convert a full `DynamodbEvent` object to an SDK v2 compatible `List`: +```java +import com.amazonaws.services.lambda.runtime.events.transformers.DynamodbEventTransformer; + +public class DDBEventProcessor implements RequestHandler { + + public String handleRequest(DynamodbEvent ddbEvent, Context context) { + // Process input event + List convertedRecords = DynamodbEventTransformer.toRecordsV2(ddbEvent); + // Modify records as needed and write back to DynamoDB using the DynamoDB AWS SDK for Java 2.0 + } +} +``` + +To convert a single `DynamodbEvent.DynamodbStreamRecord` object to an SDK v2 compatible `Record`: +```java +import com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbRecordTransformer; + +public class MyClass { + + public void myMethod(DynamodbEvent.DynamodbStreamRecord record) { + // ... + Record convertedRecord = DynamodbRecordTransformer.toRecordV2(record); + // ... + } +} +``` + +To convert a `StreamRecord` object originating from a `DynamodbEvent` to an SDK v2 compatible `StreamRecord`: +```java +import com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbStreamRecordTransformer; + +public class MyClass { + + public void myMethod(StreamRecord streamRecord) { + // ... + software.amazon.awssdk.services.dynamodb.model.StreamRecord convertedStreamRecord = + DynamodbStreamRecordTransformer.toStreamRecordV2(streamRecord); + // ... + } +} +``` + +To convert an `AttributeValue` object originating from a `DynamodbEvent` to an SDK v2 compatible `AttributeValue`: +```java +import com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbAttributeValueTransformer; + +public class MyClass { + + public void myMethod(AttributeValue attributeValue) { + // ... + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValue = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValue); + // ... + } +} +``` + +To convert an `Identity` object originating from a `DynamodbEvent` to an SDK v2 compatible `Identity`: +```java +import com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbIdentityTransformer; + +public class MyClass { + + public void myMethod(Identity identity) { + // ... + software.amazon.awssdk.services.dynamodb.model.Identity convertedIdentity = + DynamodbIdentityTransformer.toIdentityV2(identity); + // ... + } +} +``` \ No newline at end of file diff --git a/aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md b/aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md new file mode 100644 index 00000000..3f33134b --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md @@ -0,0 +1,3 @@ +### Apr 29, 2020 +`1.0.0`: +- Added AWS SDK V2 transformers for `DynamodbEvent` in `aws-lambda-java-events` versions up to and including `2.2.8` diff --git a/aws-lambda-java-events-sdk-transformer/pom.xml b/aws-lambda-java-events-sdk-transformer/pom.xml new file mode 100644 index 00000000..8f345b6f --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/pom.xml @@ -0,0 +1,175 @@ + + 4.0.0 + + com.amazonaws + aws-lambda-java-events-sdk-transformer + 1.0.0 + jar + + AWS Lambda Java Events SDK Transformer Library + + Provides helper classes/methods to use alongside aws-lambda-java-events in order to transform Lambda input event model + objects into SDK-compatible output model objects (eg. DynamodbEvent to a List of records writable back to DynamoDB + through the AWS DynamoDB SDK v2) + + https://aws.amazon.com/lambda/ + + + Apache License, Version 2.0 + https://aws.amazon.com/apache2.0 + repo + + + + https://github.com/aws/aws-lambda-java-libs.git + + + + AWS Lambda team + Amazon Web Services + https://aws.amazon.com/ + + + + + 1.8 + 1.8 + + + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + software.amazon.awssdk + dynamodb + 2.11.12 + provided + + + com.amazonaws + aws-java-sdk-dynamodb + 1.11.163 + provided + + + com.amazonaws + aws-lambda-java-events + 2.2.8 + provided + + + + org.junit.jupiter + junit-jupiter-engine + 5.6.2 + test + + + + + + + maven-surefire-plugin + 2.22.2 + + + maven-failsafe-plugin + 2.22.2 + + + + + + + dev + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + -Xdoclint:none + + + + attach-javadocs + + jar + + + + + + + + + release + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + -Xdoclint:none + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.3 + true + + sonatype-nexus-staging + https://aws.oss.sonatype.org/ + false + + + + + + + diff --git a/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/DynamodbEventTransformer.java b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/DynamodbEventTransformer.java new file mode 100644 index 00000000..c2c81ec5 --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/DynamodbEventTransformer.java @@ -0,0 +1,21 @@ +package com.amazonaws.services.lambda.runtime.events.transformers; + +import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; +import com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbRecordTransformer; +import software.amazon.awssdk.services.dynamodb.model.Record; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class DynamodbEventTransformer { + + public static List toRecordsV2(final DynamodbEvent dynamodbEvent) { + return dynamodbEvent + .getRecords() + .stream() + .filter(record -> !Objects.isNull(record)) + .map(DynamodbRecordTransformer::toRecordV2) + .collect(Collectors.toList()); + } +} diff --git a/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbAttributeValueTransformer.java b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbAttributeValueTransformer.java new file mode 100644 index 00000000..b4275173 --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbAttributeValueTransformer.java @@ -0,0 +1,84 @@ +package com.amazonaws.services.lambda.runtime.events.transformers.dynamodb; + +import software.amazon.awssdk.core.SdkBytes; +import software.amazon.awssdk.services.dynamodb.model.AttributeValue; + +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +public class DynamodbAttributeValueTransformer { + + public static AttributeValue toAttributeValueV2(final com.amazonaws.services.dynamodbv2.model.AttributeValue value) { + if (Objects.nonNull(value.getS())) { + return AttributeValue.builder() + .s(value.getS()) + .build(); + + } else if (Objects.nonNull(value.getSS())) { + return AttributeValue.builder() + .ss(value.getSS()) + .build(); + + } else if (Objects.nonNull(value.getN())) { + return AttributeValue.builder() + .n(value.getN()) + .build(); + + } else if (Objects.nonNull(value.getNS())) { + return AttributeValue.builder() + .ns(value.getNS()) + .build(); + + } else if (Objects.nonNull(value.getB())) { + return AttributeValue.builder() + .b(SdkBytes.fromByteBuffer(value.getB())) + .build(); + + } else if (Objects.nonNull(value.getBS())) { + return AttributeValue.builder() + .bs(value.getBS().stream() + .map(SdkBytes::fromByteBuffer) + .collect(Collectors.toList())) + .build(); + + } else if (Objects.nonNull(value.getBOOL())) { + return AttributeValue.builder() + .bool(value.getBOOL()) + .build(); + + } else if (Objects.nonNull(value.getL())) { + return AttributeValue.builder() + .l(value.getL().stream() + .map(DynamodbAttributeValueTransformer::toAttributeValueV2) + .collect(Collectors.toList())) + .build(); + + } else if (Objects.nonNull(value.getM())) { + return AttributeValue.builder() + .m(toAttributeValueMapV2(value.getM())) + .build(); + + } else if (Objects.nonNull(value.getNULL())) { + return AttributeValue.builder() + .nul(value.getNULL()) + .build(); + + } else { + throw new IllegalArgumentException( + String.format("Unsupported attributeValue type: %s", value)); + } + } + + static Map toAttributeValueMapV2( + final Map attributeValueMap + ) { + return attributeValueMap + .entrySet() + .stream() + .collect(Collectors.toMap( + Map.Entry::getKey, + entry -> toAttributeValueV2(entry.getValue()) + )); + } +} diff --git a/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbIdentityTransformer.java b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbIdentityTransformer.java new file mode 100644 index 00000000..4bab4a85 --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbIdentityTransformer.java @@ -0,0 +1,13 @@ +package com.amazonaws.services.lambda.runtime.events.transformers.dynamodb; + +import software.amazon.awssdk.services.dynamodb.model.Identity; + +public class DynamodbIdentityTransformer { + + public static Identity toIdentityV2(final com.amazonaws.services.dynamodbv2.model.Identity identity) { + return Identity.builder() + .principalId(identity.getPrincipalId()) + .type(identity.getType()) + .build(); + } +} diff --git a/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbRecordTransformer.java b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbRecordTransformer.java new file mode 100644 index 00000000..d9547a76 --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbRecordTransformer.java @@ -0,0 +1,23 @@ +package com.amazonaws.services.lambda.runtime.events.transformers.dynamodb; + +import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; +import software.amazon.awssdk.services.dynamodb.model.Record; + +public class DynamodbRecordTransformer { + + public static Record toRecordV2(final DynamodbEvent.DynamodbStreamRecord record) { + return Record.builder() + .awsRegion(record.getAwsRegion()) + .dynamodb( + DynamodbStreamRecordTransformer.toStreamRecordV2(record.getDynamodb()) + ) + .eventID(record.getEventID()) + .eventName(record.getEventName()) + .eventSource(record.getEventSource()) + .eventVersion(record.getEventVersion()) + .userIdentity( + DynamodbIdentityTransformer.toIdentityV2(record.getUserIdentity()) + ) + .build(); + } +} diff --git a/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbStreamRecordTransformer.java b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbStreamRecordTransformer.java new file mode 100644 index 00000000..160e7ab0 --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbStreamRecordTransformer.java @@ -0,0 +1,26 @@ +package com.amazonaws.services.lambda.runtime.events.transformers.dynamodb; + +import software.amazon.awssdk.services.dynamodb.model.StreamRecord; + +public class DynamodbStreamRecordTransformer { + + public static StreamRecord toStreamRecordV2(final com.amazonaws.services.dynamodbv2.model.StreamRecord streamRecord) { + return StreamRecord.builder() + .approximateCreationDateTime( + streamRecord.getApproximateCreationDateTime().toInstant() + ) + .keys( + DynamodbAttributeValueTransformer.toAttributeValueMapV2(streamRecord.getKeys()) + ) + .newImage( + DynamodbAttributeValueTransformer.toAttributeValueMapV2(streamRecord.getNewImage()) + ) + .oldImage( + DynamodbAttributeValueTransformer.toAttributeValueMapV2(streamRecord.getOldImage()) + ) + .sequenceNumber(streamRecord.getSequenceNumber()) + .sizeBytes(streamRecord.getSizeBytes()) + .streamViewType(streamRecord.getStreamViewType()) + .build(); + } +} diff --git a/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/DynamodbEventTransformerTest.java b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/DynamodbEventTransformerTest.java new file mode 100644 index 00000000..6fedb3fe --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/DynamodbEventTransformerTest.java @@ -0,0 +1,42 @@ +package com.amazonaws.services.lambda.runtime.events.transformers; + +import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import software.amazon.awssdk.services.dynamodb.model.Record; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbRecordTransformerTest.record_event; +import static com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbRecordTransformerTest.record_v2; + +public class DynamodbEventTransformerTest { + + private final DynamodbEvent dynamodbEvent; + { + record_event.setEventSourceARN("arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899"); + dynamodbEvent = new DynamodbEvent(); + dynamodbEvent.setRecords(Collections.singletonList(record_event)); + } + + private final List expectedRecordsV2 = Collections.singletonList(record_v2); + + @Test + public void testDynamodbEventToRecordsV2() { + List convertedRecords = DynamodbEventTransformer.toRecordsV2(dynamodbEvent); + Assertions.assertEquals(expectedRecordsV2, convertedRecords); + } + + @Test + public void testDynamodbEventToRecordsV2_FiltersNullRecords() { + DynamodbEvent event = dynamodbEvent.clone(); + event.setRecords(Arrays.asList(record_event, null)); + Assertions.assertEquals(2, event.getRecords().size()); + + List convertedRecords = DynamodbEventTransformer.toRecordsV2(event); + Assertions.assertEquals(expectedRecordsV2, convertedRecords); + Assertions.assertEquals(1, convertedRecords.size()); + } +} \ No newline at end of file diff --git a/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbAttributeValueTransformerTest.java b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbAttributeValueTransformerTest.java new file mode 100644 index 00000000..b3dcfa86 --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbAttributeValueTransformerTest.java @@ -0,0 +1,317 @@ +package com.amazonaws.services.lambda.runtime.events.transformers.dynamodb; + +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import software.amazon.awssdk.core.SdkBytes; +import software.amazon.awssdk.utils.ImmutableMap; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +class DynamodbAttributeValueTransformerTest { + + private static final String valueN = "101"; + private static final List valueNS = Arrays.asList("1", "2", "3"); + private static final String valueS = "SVal"; + private static final List valueSS = Arrays.asList("first", "second", "third"); + private static final ByteBuffer valueB = ByteBuffer.wrap("BVal".getBytes()); + private static final List valueBS = Arrays.asList( + ByteBuffer.wrap("first".getBytes()), + ByteBuffer.wrap("second".getBytes()), + ByteBuffer.wrap("third".getBytes())); + private static final boolean valueBOOL = true; + private static final boolean valueNUL = true; + + private static final String keyM1 = "NestedMapKey1"; + private static final String keyM2 = "NestedMapKey2"; + + //region AttributeValue_event + public static final AttributeValue attributeValueN_event = new AttributeValue().withN(valueN); + public static final AttributeValue attributeValueNS_event = new AttributeValue().withNS(valueNS); + public static final AttributeValue attributeValueS_event = new AttributeValue().withS(valueS); + public static final AttributeValue attributeValueSS_event = new AttributeValue().withSS(valueSS); + public static final AttributeValue attributeValueB_event = new AttributeValue().withB(valueB); + public static final AttributeValue attributeValueBS_event = new AttributeValue().withBS(valueBS); + public static final AttributeValue attributeValueBOOL_event = new AttributeValue().withBOOL(valueBOOL); + public static final AttributeValue attributeValueNUL_event = new AttributeValue().withNULL(valueNUL); + public static final AttributeValue attributeValueM_event = new AttributeValue().withM(ImmutableMap.of( + keyM1, attributeValueN_event, + keyM2, attributeValueS_event + )); + public static final AttributeValue attributeValueL_event = new AttributeValue().withL(Arrays.asList( + attributeValueN_event, + attributeValueNS_event, + attributeValueS_event, + attributeValueSS_event, + attributeValueB_event, + attributeValueBS_event, + attributeValueBOOL_event, + attributeValueNUL_event, + attributeValueM_event, + new AttributeValue().withL(Arrays.asList( + attributeValueN_event, + attributeValueNS_event, + attributeValueS_event, + attributeValueSS_event, + attributeValueB_event, + attributeValueBS_event, + attributeValueBOOL_event, + attributeValueNUL_event, + attributeValueM_event + )) + )); + //endregion + + //region AttributeValue_v2 + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueN_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().n(valueN).build(); + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueNS_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().ns(valueNS).build(); + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueS_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().s(valueS).build(); + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueSS_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().ss(valueSS).build(); + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueB_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().b(SdkBytes.fromByteBuffer(valueB)).build(); + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueBS_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().bs(valueBS.stream() + .map(SdkBytes::fromByteBuffer) + .collect(Collectors.toList())).build(); + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueBOOL_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().bool(valueBOOL).build(); + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueNUL_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().nul(valueNUL).build(); + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueM_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().m(ImmutableMap.of( + keyM1, attributeValueN_v2, + keyM2, attributeValueS_v2 + )).build(); + public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueL_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().l(Arrays.asList( + attributeValueN_v2, + attributeValueNS_v2, + attributeValueS_v2, + attributeValueSS_v2, + attributeValueB_v2, + attributeValueBS_v2, + attributeValueBOOL_v2, + attributeValueNUL_v2, + attributeValueM_v2, + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().l(Arrays.asList( + attributeValueN_v2, + attributeValueNS_v2, + attributeValueS_v2, + attributeValueSS_v2, + attributeValueB_v2, + attributeValueBS_v2, + attributeValueBOOL_v2, + attributeValueNUL_v2, + attributeValueM_v2 + )).build() + )).build(); + //endregion + + @Test + public void testToAttributeValueV2_N() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueN = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueN_event); + Assertions.assertEquals(attributeValueN_v2, convertedAttributeValueN); + } + + @Test + public void testToAttributeValueV2_NS() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueNS = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueNS_event); + Assertions.assertEquals(attributeValueNS_v2, convertedAttributeValueNS); + } + + @Test + public void testToAttributeValueV2_S() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueS = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueS_event); + Assertions.assertEquals(attributeValueS_v2, convertedAttributeValueS); + } + + @Test + public void testToAttributeValueV2_SS() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueSS = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueSS_event); + Assertions.assertEquals(attributeValueSS_v2, convertedAttributeValueSS); + } + + @Test + public void testToAttributeValueV2_B() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueB = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueB_event); + Assertions.assertEquals(attributeValueB_v2, convertedAttributeValueB); + } + + @Test + public void testToAttributeValueV2_BS() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueBS = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueBS_event); + Assertions.assertEquals(attributeValueBS_v2, convertedAttributeValueBS); + } + + @Test + public void testToAttributeValueV2_BOOL() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueBOOL = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueBOOL_event); + Assertions.assertEquals(attributeValueBOOL_v2, convertedAttributeValueBOOL); + } + + @Test + public void testToAttributeValueV2_NUL() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueNUL = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueNUL_event); + Assertions.assertEquals(attributeValueNUL_v2, convertedAttributeValueNUL); + } + + @Test + public void testToAttributeValueV2_M() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueM = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueM_event); + Assertions.assertEquals(attributeValueM_v2, convertedAttributeValueM); + } + + @Test + public void testToAttributeValueV2_L() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueL = + DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueL_event); + Assertions.assertEquals(attributeValueL_v2, convertedAttributeValueL); + } + + @Test + public void testToAttributeValueV2_IllegalArgumentWhenNull() { + Assertions.assertThrows(IllegalArgumentException.class, () -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue()) + ); + } + + @Test + public void testToAttributeValueV2_IllegalArgumentWhenNull_N() { + Assertions.assertThrows(IllegalArgumentException.class, () -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withN(null)) + ); + } + + @Test + public void testToAttributeValueV2_IllegalArgumentWhenNull_S() { + Assertions.assertThrows(IllegalArgumentException.class, () -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withS(null)) + ); + } + + @Test + public void testToAttributeValueV2_IllegalArgumentWhenNull_B() { + Assertions.assertThrows(IllegalArgumentException.class, () -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withB(null)) + ); + } + + @Test + public void testToAttributeValueV2_IllegalArgumentWhenNull_BOOL() { + Assertions.assertThrows(IllegalArgumentException.class, () -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBOOL(null)) + ); + } + + @Test + public void testToAttributeValueV2_IllegalArgumentWhenNull_NUL() { + Assertions.assertThrows(IllegalArgumentException.class, () -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNULL(null)) + ); + } + + @Test + public void testToAttributeValueV2_IllegalArgumentWhenNull_M() { + Assertions.assertThrows(IllegalArgumentException.class, () -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withM(null)) + ); + } + + @Test + public void testToAttributeValueV2_DoesNotThrowWhenEmpty_NS() { + Assertions.assertDoesNotThrow(() -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNS()) + ); + Assertions.assertDoesNotThrow(() -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNS(Collections.emptyList())) + ); + } + + @Test + public void testToAttributeValueV2_DoesNotThrowWhenEmpty_SS() { + Assertions.assertDoesNotThrow(() -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withSS()) + ); + Assertions.assertDoesNotThrow(() -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withSS(Collections.emptyList())) + ); + } + + @Test + public void testToAttributeValueV2_DoesNotThrowWhenEmpty_BS() { + Assertions.assertDoesNotThrow(() -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBS()) + ); + Assertions.assertDoesNotThrow(() -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBS(Collections.emptyList())) + ); + } + + @Test + public void testToAttributeValueV2_DoesNotThrowWhenEmpty_L() { + Assertions.assertDoesNotThrow(() -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL()) + ); + Assertions.assertDoesNotThrow(() -> + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL(Collections.emptyList())) + ); + } + + @Test + public void testToAttributeValueV2_EmptyV2ObjectWhenEmpty_NS() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue expectedAttributeValue_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().build(); + Assertions.assertEquals(expectedAttributeValue_v2, + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNS())); + Assertions.assertEquals(expectedAttributeValue_v2, + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNS(Collections.emptyList()))); + } + + @Test + public void testToAttributeValueV2_EmptyV2ObjectWhenEmpty_SS() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue expectedAttributeValue_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().build(); + Assertions.assertEquals(expectedAttributeValue_v2, + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withSS())); + Assertions.assertEquals(expectedAttributeValue_v2, + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withSS(Collections.emptyList()))); + } + + @Test + public void testToAttributeValueV2_EmptyV2ObjectWhenEmpty_BS() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue expectedAttributeValue_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().build(); + Assertions.assertEquals(expectedAttributeValue_v2, + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBS())); + Assertions.assertEquals(expectedAttributeValue_v2, + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBS(Collections.emptyList()))); + } + + @Test + public void testToAttributeValueV2_EmptyV2ObjectWhenEmpty_L() { + software.amazon.awssdk.services.dynamodb.model.AttributeValue expectedAttributeValue_v2 = + software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().build(); + Assertions.assertEquals(expectedAttributeValue_v2, + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL())); + Assertions.assertEquals(expectedAttributeValue_v2, + DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL(Collections.emptyList()))); + } + +} \ No newline at end of file diff --git a/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbIdentityTransformerTest.java b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbIdentityTransformerTest.java new file mode 100644 index 00000000..05356095 --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbIdentityTransformerTest.java @@ -0,0 +1,31 @@ +package com.amazonaws.services.lambda.runtime.events.transformers.dynamodb; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import software.amazon.awssdk.services.dynamodb.model.Identity; + +class DynamodbIdentityTransformerTest { + + private static final String principalId = "1234567890"; + private static final String identityType = "type"; + + //region Identity_event + public static final com.amazonaws.services.dynamodbv2.model.Identity identity_event = new com.amazonaws.services.dynamodbv2.model.Identity() + .withPrincipalId(principalId) + .withType(identityType); + //endregion + + //region Identity_v2 + public static final Identity identity_v2 = Identity.builder() + .principalId(principalId) + .type(identityType) + .build(); + //endregion + + @Test + public void testToIdentityV2() { + Identity convertedIdentity = DynamodbIdentityTransformer.toIdentityV2(identity_event); + Assertions.assertEquals(identity_v2, convertedIdentity); + } + +} \ No newline at end of file diff --git a/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbRecordTransformerTest.java b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbRecordTransformerTest.java new file mode 100644 index 00000000..69645844 --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbRecordTransformerTest.java @@ -0,0 +1,53 @@ +package com.amazonaws.services.lambda.runtime.events.transformers.dynamodb; + +import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import software.amazon.awssdk.services.dynamodb.model.OperationType; +import software.amazon.awssdk.services.dynamodb.model.Record; + +import static com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbIdentityTransformerTest.identity_event; +import static com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbIdentityTransformerTest.identity_v2; +import static com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbStreamRecordTransformerTest.streamRecord_event; +import static com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbStreamRecordTransformerTest.streamRecord_v2; + +public class DynamodbRecordTransformerTest { + + private static final String eventId = "2"; + private static final String eventName = OperationType.MODIFY.toString(); + private static final String eventVersion = "1.0"; + private static final String eventSource = "aws:dynamodb"; + private static final String awsRegion = "us-west-2"; + + //region Record_event + public static final DynamodbEvent.DynamodbStreamRecord record_event = (DynamodbEvent.DynamodbStreamRecord) + new DynamodbEvent.DynamodbStreamRecord() + .withEventID(eventId) + .withEventName(eventName) + .withEventVersion(eventVersion) + .withEventSource(eventSource) + .withAwsRegion(awsRegion) + .withDynamodb(streamRecord_event) + .withUserIdentity(identity_event); + //endregion + + //region Record_v2 + public static final Record record_v2 = + Record.builder() + .eventID(eventId) + .eventName(eventName) + .eventVersion(eventVersion) + .eventSource(eventSource) + .awsRegion(awsRegion) + .dynamodb(streamRecord_v2) + .userIdentity(identity_v2) + .build(); + //endregion + + @Test + public void testToRecordV2() { + Record convertedRecord = DynamodbRecordTransformer.toRecordV2(record_event); + Assertions.assertEquals(record_v2, convertedRecord); + } + +} \ No newline at end of file diff --git a/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbStreamRecordTransformerTest.java b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbStreamRecordTransformerTest.java new file mode 100644 index 00000000..774f0648 --- /dev/null +++ b/aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/dynamodb/DynamodbStreamRecordTransformerTest.java @@ -0,0 +1,103 @@ +package com.amazonaws.services.lambda.runtime.events.transformers.dynamodb; + +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import com.amazonaws.services.dynamodbv2.model.StreamViewType; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import software.amazon.awssdk.services.dynamodb.model.StreamRecord; +import software.amazon.awssdk.utils.ImmutableMap; + +import java.util.Date; + +import static com.amazonaws.services.lambda.runtime.events.transformers.dynamodb.DynamodbAttributeValueTransformerTest.*; + +class DynamodbStreamRecordTransformerTest { + + private static final String keyNK = "Id"; + private static final String keyNSK = "KeyNS"; + + private static final String keySK = "SKey"; + private static final String keySSK = "KeySS"; + + private static final String keyBK = "BKey"; + private static final String keyBSK = "KeyBS"; + + private static final String keyBOOLK = "IsBool"; + private static final String keyNULK = "nil"; + + private static final String keyMK = "MapKey"; + + private static final String keyLK = "LongNum"; + + private static final String oldImageSK = "Message"; + private static final String newImageSK = "Message"; + private static final String streamViewType = StreamViewType.NEW_AND_OLD_IMAGES.toString(); + private static final String sequenceNumber = "222"; + private static final Long sizeBytes = 59L; + private static final Date approximateCreationDateTime = new Date(); + + //region StreamRecord_event + public static final com.amazonaws.services.dynamodbv2.model.StreamRecord streamRecord_event = new com.amazonaws.services.dynamodbv2.model.StreamRecord() + .withKeys(ImmutableMap. builder() + .put(keyNK, attributeValueN_event) + .put(keyNSK, attributeValueNS_event) + .put(keySK, attributeValueS_event) + .put(keySSK, attributeValueSS_event) + .put(keyBK, attributeValueB_event) + .put(keyBSK, attributeValueBS_event) + .put(keyBOOLK, attributeValueBOOL_event) + .put(keyNULK, attributeValueNUL_event) + .put(keyMK, attributeValueM_event) + .put(keyLK, attributeValueL_event) + .build() + ) + .withOldImage(ImmutableMap.of( + oldImageSK, attributeValueS_event, + keyNK, attributeValueN_event + )) + .withNewImage(ImmutableMap.of( + newImageSK, attributeValueS_event, + keyNK, attributeValueN_event + )) + .withStreamViewType(StreamViewType.fromValue(streamViewType)) + .withSequenceNumber(sequenceNumber) + .withSizeBytes(sizeBytes) + .withApproximateCreationDateTime(approximateCreationDateTime); + //endregion + + //region StreamRecord_v2 + public static final StreamRecord streamRecord_v2 = StreamRecord.builder() + .approximateCreationDateTime(approximateCreationDateTime.toInstant()) + .keys(ImmutableMap. builder() + .put(keyNK, attributeValueN_v2) + .put(keyNSK, attributeValueNS_v2) + .put(keySK, attributeValueS_v2) + .put(keySSK, attributeValueSS_v2) + .put(keyBK, attributeValueB_v2) + .put(keyBSK, attributeValueBS_v2) + .put(keyBOOLK, attributeValueBOOL_v2) + .put(keyNULK, attributeValueNUL_v2) + .put(keyMK, attributeValueM_v2) + .put(keyLK, attributeValueL_v2) + .build() + ) + .oldImage(ImmutableMap.of( + oldImageSK, attributeValueS_v2, + keyNK, attributeValueN_v2 + )) + .newImage(ImmutableMap.of( + newImageSK, attributeValueS_v2, + keyNK, attributeValueN_v2 + )) + .sequenceNumber(sequenceNumber) + .sizeBytes(sizeBytes) + .streamViewType(streamViewType) + .build(); + //endregion + + @Test + public void testToStreamRecordV2() { + StreamRecord convertedStreamRecord = DynamodbStreamRecordTransformer.toStreamRecordV2(streamRecord_event); + Assertions.assertEquals(streamRecord_v2, convertedStreamRecord); + } +} \ No newline at end of file From 26b11a57ebdb00186615f8fc6195f03bbe17b01e Mon Sep 17 00:00:00 2001 From: Carl Zogheib <11421173+carlzogh@users.noreply.github.com> Date: Tue, 5 May 2020 15:07:45 +0100 Subject: [PATCH 25/65] Add events-sdk-transformer to build workflow (#124) --- .github/workflows/maven-pkg-all.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/maven-pkg-all.yml b/.github/workflows/maven-pkg-all.yml index 3296fe9e..81e9a8ec 100644 --- a/.github/workflows/maven-pkg-all.yml +++ b/.github/workflows/maven-pkg-all.yml @@ -24,6 +24,8 @@ jobs: run: mvn -B package --file aws-lambda-java-core/pom.xml - name: Build events with Maven run: mvn -B package --file aws-lambda-java-events/pom.xml + - name: Build events-sdk-transformer with Maven + run: mvn -B package --file aws-lambda-java-events-sdk-transformer/pom.xml - name: Build log4j with Maven run: mvn -B package --file aws-lambda-java-log4j/pom.xml - name: Build log4j2 with Maven From 7ef1338f8dfe2c34340e142076f0e88c49323783 Mon Sep 17 00:00:00 2001 From: hercules90 Date: Fri, 8 May 2020 03:25:58 -0700 Subject: [PATCH 26/65] Adding support for OperationName in the APIGatewayProxyRequestEvent (#126) Co-authored-by: Swarnim Kulkarni --- .../events/APIGatewayProxyRequestEvent.java | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java index 68ca91da..f9c118ca 100644 --- a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java +++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java @@ -50,6 +50,8 @@ public static class ProxyRequestContext implements Serializable, Cloneable { private String requestId; + private String operationName; + private RequestIdentity identity; private String resourcePath; @@ -282,6 +284,25 @@ public ProxyRequestContext withPath(String path) { return this; } + /** + * @return The name of the operation being performed + * */ + public String getOperationName() { + return operationName; + } + + /** + * @param operationName The name of the operation being performed + * */ + public void setOperationName(String operationName) { + this.operationName = operationName; + } + + public ProxyRequestContext withOperationName(String operationName) { + this.setOperationName(operationName); + return this; + } + /** * Returns a string representation of this object; useful for testing and debugging. * @@ -313,6 +334,8 @@ public String toString() { sb.append("path: ").append(getPath()).append(","); if (getAuthorizer() != null) sb.append("authorizer: ").append(getAuthorizer().toString()); + if (getOperationName() != null) + sb.append("operationName: ").append(getOperationName().toString()); sb.append("}"); return sb.toString(); } @@ -367,6 +390,10 @@ public boolean equals(Object obj) { return false; if (other.getAuthorizer() != null && !other.getAuthorizer().equals(this.getAuthorizer())) return false; + if (other.getOperationName() == null ^ this.getOperationName() == null) + return false; + if (other.getOperationName() != null && !other.getOperationName().equals(this.getOperationName())) + return false; return true; } @@ -385,6 +412,7 @@ public int hashCode() { hashCode = prime * hashCode + ((getApiId() == null) ? 0 : getApiId().hashCode()); hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); hashCode = prime * hashCode + ((getAuthorizer() == null) ? 0 : getAuthorizer().hashCode()); + hashCode = prime * hashCode + ((getOperationName() == null) ? 0: getOperationName().hashCode()); return hashCode; } @@ -396,7 +424,6 @@ public ProxyRequestContext clone() { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } - } public static class RequestIdentity implements Serializable, Cloneable { @@ -958,7 +985,7 @@ public APIGatewayProxyRequestEvent withMultiValueHeaders(Map Date: Wed, 13 May 2020 12:12:42 +0100 Subject: [PATCH 27/65] Update build workflow to install instead of package (#129) This ensures inter-package dependencies are resolved locally --- .../workflows/{maven-pkg-all.yml => maven-build-all.yml} | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) rename .github/workflows/{maven-pkg-all.yml => maven-build-all.yml} (78%) diff --git a/.github/workflows/maven-pkg-all.yml b/.github/workflows/maven-build-all.yml similarity index 78% rename from .github/workflows/maven-pkg-all.yml rename to .github/workflows/maven-build-all.yml index 81e9a8ec..66821eba 100644 --- a/.github/workflows/maven-pkg-all.yml +++ b/.github/workflows/maven-build-all.yml @@ -19,11 +19,14 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 - + + # Install base modules - name: Build core with Maven - run: mvn -B package --file aws-lambda-java-core/pom.xml + run: mvn -B install --file aws-lambda-java-core/pom.xml - name: Build events with Maven - run: mvn -B package --file aws-lambda-java-events/pom.xml + run: mvn -B install --file aws-lambda-java-events/pom.xml + + # Package modules that depend on base modules - name: Build events-sdk-transformer with Maven run: mvn -B package --file aws-lambda-java-events-sdk-transformer/pom.xml - name: Build log4j with Maven From f974e67d4ef49d640537e37a6edab619d68ce310 Mon Sep 17 00:00:00 2001 From: Carl Zogheib <11421173+carlzogh@users.noreply.github.com> Date: Wed, 13 May 2020 14:30:30 +0100 Subject: [PATCH 28/65] Bump events lib version to 2.2.9 (#128) --- aws-lambda-java-events-sdk-transformer/README.md | 2 +- .../RELEASE.CHANGELOG.md | 2 +- aws-lambda-java-events-sdk-transformer/pom.xml | 2 +- aws-lambda-java-events/README.md | 8 ++++---- aws-lambda-java-events/RELEASE.CHANGELOG.md | 4 ++++ aws-lambda-java-events/pom.xml | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/aws-lambda-java-events-sdk-transformer/README.md b/aws-lambda-java-events-sdk-transformer/README.md index 572021ba..49103d81 100644 --- a/aws-lambda-java-events-sdk-transformer/README.md +++ b/aws-lambda-java-events-sdk-transformer/README.md @@ -21,7 +21,7 @@ Add the following Apache Maven dependencies to your `pom.xml` file: com.amazonaws aws-lambda-java-events - 2.2.8 + 2.2.9 ``` diff --git a/aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md b/aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md index 3f33134b..38a3b704 100644 --- a/aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md +++ b/aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md @@ -1,3 +1,3 @@ ### Apr 29, 2020 `1.0.0`: -- Added AWS SDK V2 transformers for `DynamodbEvent` in `aws-lambda-java-events` versions up to and including `2.2.8` +- Added AWS SDK V2 transformers for `DynamodbEvent` in `aws-lambda-java-events` versions up to and including `2.x` diff --git a/aws-lambda-java-events-sdk-transformer/pom.xml b/aws-lambda-java-events-sdk-transformer/pom.xml index 8f345b6f..531aba2b 100644 --- a/aws-lambda-java-events-sdk-transformer/pom.xml +++ b/aws-lambda-java-events-sdk-transformer/pom.xml @@ -61,7 +61,7 @@ com.amazonaws aws-lambda-java-events - 2.2.8 + 2.2.9 provided diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md index 47993ac4..acf53c02 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -48,7 +48,7 @@ so the dependencies section in the pom.xml file would like this com.amazonaws aws-lambda-java-events - 2.2.8 + 2.2.9 ... @@ -69,7 +69,7 @@ For the S3 event the pom would look like this: com.amazonaws aws-lambda-java-events - 2.2.8 + 2.2.9 com.amazonaws @@ -95,7 +95,7 @@ For the Kinesis event com.amazonaws aws-lambda-java-events - 2.2.8 + 2.2.9 com.amazonaws @@ -121,7 +121,7 @@ For the Dynamodb event com.amazonaws aws-lambda-java-events - 2.2.8 + 2.2.9 com.amazonaws diff --git a/aws-lambda-java-events/RELEASE.CHANGELOG.md b/aws-lambda-java-events/RELEASE.CHANGELOG.md index 29afb994..d332599a 100644 --- a/aws-lambda-java-events/RELEASE.CHANGELOG.md +++ b/aws-lambda-java-events/RELEASE.CHANGELOG.md @@ -1,3 +1,7 @@ +### May 13, 2020 +`2.2.9`: +- Added field `operationName` to `APIGatewayProxyRequestEvent` ([#126](https://github.com/aws/aws-lambda-java-libs/pull/126)) + ### Apr 28, 2020 `2.2.8`: - Added missing XML namespace declarations to `pom.xml` file ([#97](https://github.com/aws/aws-lambda-java-libs/issues/97)) diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index 7c4a4ec1..5f9e15eb 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.8 + 2.2.9 jar AWS Lambda Java Events Library From b36cf54924140470a61bb2beff19101735aadab9 Mon Sep 17 00:00:00 2001 From: Carl Zogheib <11421173+carlzogh@users.noreply.github.com> Date: Mon, 18 May 2020 10:12:50 +0100 Subject: [PATCH 29/65] Remove SDK dependencies from events library (#127) * Bump to 3.0.0 * Update Docs and Release Notes --- README.md | 8 +- aws-lambda-java-events/README.md | 148 +-- 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 +- .../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 + 18 files changed, 3948 insertions(+), 143 deletions(-) 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..f7c7db8b 100644 --- a/aws-lambda-java-events/README.md +++ b/aws-lambda-java-events/README.md @@ -1,41 +1,36 @@ -# 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` +* `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 +43,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..e5c4cd79 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,23 +49,12 @@ joda-time 2.6 + - com.amazonaws - aws-java-sdk-s3 - 1.11.163 - provided - - - com.amazonaws - aws-java-sdk-kinesis - 1.11.163 - provided - - - com.amazonaws - aws-java-sdk-dynamodb - 1.11.163 - provided + org.junit.jupiter + junit-jupiter-engine + 5.5.2 + test 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/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:

+ *