datasetRecords;
+
+ private String identityPoolId;
+
+ private String identityId;
+
+ private String datasetName;
+
+ private String eventType;
+
+ private Integer version;
/**
* DatasetRecord contains the information about each record in a data set.
*
*/
- public static class DatasetRecord {
-
+ public static class DatasetRecord implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = -8853471047466644850L;
+
private String oldValue;
private String newValue;
private String op;
+ /**
+ * default constructor
+ * (Not available in v1)
+ */
+ public DatasetRecord() {}
+
/**
* Get the record's old value
+ * @return old value
*/
public String getOldValue() {
return oldValue;
@@ -38,8 +75,18 @@ public void setOldValue(String oldValue) {
this.oldValue = oldValue;
}
+ /**
+ * @param oldValue String with old value
+ * @return DatasetRecord object
+ */
+ public DatasetRecord withOldValue(String oldValue) {
+ setOldValue(oldValue);
+ return this;
+ }
+
/**
* Gets the record's new value
+ * @return new value
*/
public String getNewValue() {
return newValue;
@@ -53,6 +100,15 @@ public void setNewValue(String newValue) {
this.newValue = newValue;
}
+ /**
+ * @param newValue new value for record
+ * @return DatasetRecord object
+ */
+ public DatasetRecord withNewValue(String newValue) {
+ setNewValue(newValue);
+ return this;
+ }
+
/**
* Gets the operation associated with the record
*
@@ -87,24 +143,92 @@ public String getOp() {
public void setOp(String op) {
this.op = op;
}
- }
- private String region;
+ /**
+ * @param op String operation
+ * @return DatasetRecord object
+ */
+ public DatasetRecord withOp(String op) {
+ setOp(op);
+ return this;
+ }
- private Map datasetRecords;
+ /**
+ * Returns a string representation of this object; useful for testing and debugging.
+ *
+ * @return A string representation of this object.
+ *
+ * @see Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{");
+ if (getOldValue() != null)
+ sb.append("oldValue: ").append(getOldValue()).append(",");
+ if (getNewValue() != null)
+ sb.append("newValue: ").append(getNewValue()).append(",");
+ if (getOp() != null)
+ sb.append("op: ").append(getOp());
+ sb.append("}");
+ return sb.toString();
+ }
- private String identityPoolId;
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
- private String identityId;
+ if (obj instanceof DatasetRecord == false)
+ return false;
+ DatasetRecord other = (DatasetRecord) obj;
+ if (other.getOldValue() == null ^ this.getOldValue() == null)
+ return false;
+ if (other.getOldValue() != null && other.getOldValue().equals(this.getOldValue()) == false)
+ return false;
+ if (other.getNewValue() == null ^ this.getNewValue() == null)
+ return false;
+ if (other.getNewValue() != null && other.getNewValue().equals(this.getNewValue()) == false)
+ return false;
+ if (other.getOp() == null ^ this.getOp() == null)
+ return false;
+ if (other.getOp() != null && other.getOp().equals(this.getOp()) == false)
+ return false;
+ return true;
+ }
- private String datasetName;
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int hashCode = 1;
- private String eventType;
+ hashCode = prime * hashCode + ((getOldValue() == null) ? 0 : getOldValue().hashCode());
+ hashCode = prime * hashCode + ((getNewValue() == null) ? 0 : getNewValue().hashCode());
+ hashCode = prime * hashCode + ((getOp() == null) ? 0 : getOp().hashCode());
+ return hashCode;
+ }
- private Integer version;
+ @Override
+ public DatasetRecord clone() {
+ try {
+ return (DatasetRecord) super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e);
+ }
+ }
+ }
+
+ /**
+ * default constructor
+ * (Not available in v1)
+ */
+ public CognitoEvent() {}
/**
* Gets the region in which data set resides.
+ * @return aws region
*/
public String getRegion() {
return region;
@@ -118,8 +242,18 @@ public void setRegion(String region) {
this.region = region;
}
+ /**
+ * @param region String of region name
+ * @return CognitoEvent
+ */
+ public CognitoEvent withRegion(String region) {
+ setRegion(region);
+ return this;
+ }
+
/**
* Gets the map of data set records for the event
+ * @return map of dataset records
*/
public Map getDatasetRecords() {
return datasetRecords;
@@ -128,13 +262,23 @@ public Map getDatasetRecords() {
/**
* Sets the map of data set records for the event
* @param datasetRecords A map of string & data set record key/value pairs
- */
+ */
public void setDatasetRecords(Map datasetRecords) {
this.datasetRecords = datasetRecords;
}
+ /**
+ * @param datasetRecords a map of string & data set record key/value pairs
+ * @return CognitoEvent
+ */
+ public CognitoEvent withDatasetRecords(Map datasetRecords) {
+ setDatasetRecords(datasetRecords);
+ return this;
+ }
+
/**
* Gets the identity pool ID associated with the data set
+ * @return identity pool id
*/
public String getIdentityPoolId() {
return identityPoolId;
@@ -148,8 +292,18 @@ public void setIdentityPoolId(String identityPoolId) {
this.identityPoolId = identityPoolId;
}
+ /**
+ * @param identityPoolId a string containing the identity pool ID
+ * @return CognitoEvent
+ */
+ public CognitoEvent withIdentityPoolId(String identityPoolId) {
+ setIdentityPoolId(identityPoolId);
+ return this;
+ }
+
/**
* Gets the identity pool ID associated with the data set
+ * @return identity id
*/
public String getIdentityId() {
return identityId;
@@ -163,8 +317,18 @@ public void setIdentityId(String identityId) {
this.identityId = identityId;
}
+ /**
+ * @param identityId a string containing identity id
+ * @return CognitoEvent
+ */
+ public CognitoEvent withIdentityId(String identityId) {
+ setIdentityId(identityId);
+ return this;
+ }
+
/**
* Gets the data set name of the event
+ * @return dataset name
*/
public String getDatasetName() {
return datasetName;
@@ -178,8 +342,18 @@ public void setDatasetName(String datasetName) {
this.datasetName = datasetName;
}
+ /**
+ * @param datasetName String with data set name
+ * @return CognitoEvent
+ */
+ public CognitoEvent withDatasetName(String datasetName) {
+ setDatasetName(datasetName);
+ return this;
+ }
+
/**
* Gets the event type
+ * @return event type
*/
public String getEventType() {
return eventType;
@@ -193,8 +367,18 @@ public void setEventType(String eventType) {
this.eventType = eventType;
}
+ /**
+ * @param eventType String with event type
+ * @return CognitoEvent
+ */
+ public CognitoEvent withEventType(String eventType) {
+ setEventType(eventType);
+ return this;
+ }
+
/**
* Gets the event version
+ * @return version as integer
*/
public Integer getVersion() {
return version;
@@ -207,4 +391,107 @@ public Integer getVersion() {
public void setVersion(Integer version) {
this.version = version;
}
+
+ /**
+ * @param version Integer with version
+ * @return CognitoEvent
+ */
+ public CognitoEvent withVersion(Integer version) {
+ setVersion(version);
+ return this;
+ }
+
+ /**
+ * Returns a string representation of this object; useful for testing and debugging.
+ *
+ * @return A string representation of this object.
+ *
+ * @see Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{");
+ if (getRegion() != null)
+ sb.append("region: ").append(getRegion()).append(",");
+ if (getDatasetRecords() != null)
+ sb.append("datasetRecords: ").append(getDatasetRecords().toString()).append(",");
+ if (getIdentityPoolId() != null)
+ sb.append("identityPoolId: ").append(getIdentityPoolId()).append(",");
+ if (getIdentityId() != null)
+ sb.append("identityId: ").append(getIdentityId()).append(",");
+ if (getDatasetName() != null)
+ sb.append("datasetName: ").append(getDatasetName()).append(",");
+ if (getEventType() != null)
+ sb.append("eventType: ").append(getEventType()).append(",");
+ if (getVersion() != null)
+ sb.append("version: ").append(getVersion().toString());
+ sb.append("}");
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+
+ if (obj instanceof CognitoEvent == false)
+ return false;
+ CognitoEvent other = (CognitoEvent) obj;
+ if (other.getRegion() == null ^ this.getRegion() == null)
+ return false;
+ if (other.getRegion() != null && other.getRegion().equals(this.getRegion()) == false)
+ return false;
+ if (other.getDatasetRecords() == null ^ this.getDatasetRecords() == null)
+ return false;
+ if (other.getDatasetRecords() != null && other.getDatasetRecords().equals(this.getDatasetRecords()) == false)
+ return false;
+ if (other.getIdentityPoolId() == null ^ this.getIdentityPoolId() == null)
+ return false;
+ if (other.getIdentityPoolId() != null && other.getIdentityPoolId().equals(this.getIdentityPoolId()) == false)
+ return false;
+ if (other.getIdentityId() == null ^ this.getIdentityId() == null)
+ return false;
+ if (other.getIdentityId() != null && other.getIdentityId().equals(this.getIdentityId()) == false)
+ return false;
+ if (other.getDatasetName() == null ^ this.getDatasetName() == null)
+ return false;
+ if (other.getDatasetName() != null && other.getDatasetName().equals(this.getDatasetName()) == false)
+ return false;
+ if (other.getEventType() == null ^ this.getEventType() == null)
+ return false;
+ if (other.getEventType() != null && other.getEventType().equals(this.getEventType()) == false)
+ return false;
+ if (other.getVersion() == null ^ this.getVersion() == null)
+ return false;
+ if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int hashCode = 1;
+ hashCode = prime * hashCode + ((getRegion() == null) ? 0 : getRegion().hashCode());
+ hashCode = prime * hashCode + ((getDatasetRecords() == null) ? 0 : getDatasetRecords().hashCode());
+ hashCode = prime * hashCode + ((getIdentityPoolId() == null) ? 0 : getIdentityPoolId().hashCode());
+ hashCode = prime * hashCode + ((getIdentityId() == null) ? 0 : getIdentityId().hashCode());
+ hashCode = prime * hashCode + ((getDatasetName() == null) ? 0 : getDatasetName().hashCode());
+ hashCode = prime * hashCode + ((getEventType() == null) ? 0 : getEventType().hashCode());
+ hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode());
+ return hashCode;
+ }
+
+ @Override
+ public CognitoEvent clone() {
+ try {
+ return (CognitoEvent) super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e);
+ }
+ }
+
}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCreateAuthChallengeEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCreateAuthChallengeEvent.java
new file mode 100644
index 000000000..6074ca9b5
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCreateAuthChallengeEvent.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.*;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Create Auth Challenge Lambda Trigger
+ *
+ * See Create Auth Challenge Lambda Trigger
+ *
+ * @author jvdl
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolCreateAuthChallengeEvent extends CognitoUserPoolEvent {
+
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ /**
+ * The response from your Lambda trigger.
+ */
+ private Response response;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolCreateAuthChallengeEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request,
+ Response response) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ this.response = response;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the create auth challenge trigger.
+ */
+ private Map clientMetadata;
+ /**
+ * The name of the new challenge.
+ */
+ private String challengeName;
+ private ChallengeResult[] session;
+ /**
+ * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client.
+ */
+ private boolean userNotFound;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, Map clientMetadata, String challengeName, ChallengeResult[] session, boolean userNotFound) {
+ super(userAttributes);
+ this.clientMetadata = clientMetadata;
+ this.session = session;
+ this.userNotFound = userNotFound;
+ this.challengeName = challengeName;
+ }
+ }
+
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @Data
+ @NoArgsConstructor
+ public static class ChallengeResult {
+ /**
+ * The challenge type. One of: "CUSTOM_CHALLENGE", "PASSWORD_VERIFIER", "SMS_MFA", "DEVICE_SRP_AUTH", "DEVICE_PASSWORD_VERIFIER", or "ADMIN_NO_SRP_AUTH".
+ */
+ private String challengeName;
+ /**
+ * Set to true if the user successfully completed the challenge, or false otherwise.
+ */
+ private boolean challengeResult;
+ /**
+ * Your name for the custom challenge. Used only if challengeName is CUSTOM_CHALLENGE.
+ */
+ private String challengeMetadata;
+ }
+
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @Data
+ @NoArgsConstructor
+ public static class Response {
+ /**
+ * One or more key-value pairs for the client app to use in the challenge to be presented to the user.
+ * Contains the question that is presented to the user.
+ */
+ private Map publicChallengeParameters;
+ /**
+ * Contains the valid answers for the question in publicChallengeParameters
+ */
+ private Map privateChallengeParameters;
+ /**
+ * Your name for the custom challenge, if this is a custom challenge.
+ */
+ private String challengeMetadata;
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCustomMessageEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCustomMessageEvent.java
new file mode 100644
index 000000000..403f85393
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCustomMessageEvent.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.*;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Custom Message Lambda Trigger
+ *
+ * See Custom Message Lambda Trigger
+ *
+ * @author jvdl
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolCustomMessageEvent extends CognitoUserPoolEvent {
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ /**
+ * The response from your Lambda trigger.
+ */
+ private Response response;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolCustomMessageEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request,
+ Response response) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ this.response = response;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the custom message trigger.
+ */
+ private Map clientMetadata;
+ /**
+ * A string for you to use as the placeholder for the verification code in the custom message.
+ */
+ private String codeParameter;
+ /**
+ * The username parameter. It is a required request parameter for the admin create user flow.
+ */
+ private String usernameParameter;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, Map clientMetadata, String codeParameter, String usernameParameter) {
+ super(userAttributes);
+ this.clientMetadata = clientMetadata;
+ this.codeParameter = codeParameter;
+ this.usernameParameter = usernameParameter;
+ }
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class Response {
+ /**
+ * The custom SMS message to be sent to your users. Must include the codeParameter value received in the request.
+ */
+ private String smsMessage;
+ /**
+ * The custom email message to be sent to your users. Must include the codeParameter value received in the request.
+ */
+ private String emailMessage;
+ /**
+ * The subject line for the custom message.
+ */
+ private String emailSubject;
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolDefineAuthChallengeEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolDefineAuthChallengeEvent.java
new file mode 100644
index 000000000..8577c9f7a
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolDefineAuthChallengeEvent.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.*;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Define Auth Challenge Lambda Trigger
+ *
+ * See Define Auth Challenge Lambda Trigger
+ *
+ * @author jvdl
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolDefineAuthChallengeEvent extends CognitoUserPoolEvent {
+
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ /**
+ * The response from your Lambda trigger.
+ */
+ private Response response;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolDefineAuthChallengeEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request,
+ Response response) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ this.response = response;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the define auth challenge trigger.
+ */
+ private Map clientMetadata;
+
+ private ChallengeResult[] session;
+
+ /**
+ * A Boolean that is populated when PreventUserExistenceErrors is set to ENABLED for your user pool client.
+ * A value of true means that the user id (user name, email address, etc.) did not match any existing users.
+ */
+ private boolean userNotFound;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, Map clientMetadata, ChallengeResult[] session, boolean userNotFound) {
+ super(userAttributes);
+ this.clientMetadata = clientMetadata;
+ this.session = session;
+ this.userNotFound = userNotFound;
+ }
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class ChallengeResult {
+ /**
+ * The challenge type. One of: CUSTOM_CHALLENGE, SRP_A, PASSWORD_VERIFIER, SMS_MFA, DEVICE_SRP_AUTH, DEVICE_PASSWORD_VERIFIER, or ADMIN_NO_SRP_AUTH.
+ */
+ private String challengeName;
+ /**
+ * Set to true if the user successfully completed the challenge, or false otherwise.
+ */
+ private boolean challengeResult;
+ /**
+ * Your name for the custom challenge. Used only if challengeName is CUSTOM_CHALLENGE.
+ */
+ private String challengeMetadata;
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class Response {
+ /**
+ * Name of the next challenge, if you want to present a new challenge to your user.
+ */
+ private String challengeName;
+
+ /**
+ * Set to true if you determine that the user has been sufficiently authenticated by completing the challenges, or false otherwise.
+ */
+ private boolean issueTokens;
+
+ /**
+ * Set to true if you want to terminate the current authentication process, or false otherwise.
+ */
+ private boolean failAuthentication;
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolEvent.java
new file mode 100644
index 000000000..17c4b409d
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolEvent.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Map;
+
+/**
+ * Represent the base class for all Cognito User Pool Events
+ *
+ * See Customizing User Pool Workflows with Lambda Triggers
+ *
+ * @author jvdl
+ */
+@AllArgsConstructor
+@Data
+@NoArgsConstructor
+public abstract class CognitoUserPoolEvent {
+
+ /**
+ * The version number of your Lambda function.
+ */
+ private String version;
+
+ /**
+ * The name of the event that triggered the Lambda function.
+ */
+ private String triggerSource;
+
+ /**
+ * The AWS Region.
+ */
+ private String region;
+
+ /**
+ * The user pool ID for the user pool.
+ */
+ private String userPoolId;
+
+ /**
+ * The username of the current user.
+ */
+ private String userName;
+
+ /**
+ * The caller context.
+ */
+ private CallerContext callerContext;
+
+ @AllArgsConstructor
+ @Data
+ @NoArgsConstructor
+ public static abstract class Request {
+ /**
+ * One or more pairs of user attribute names and values.
+ */
+ private Map userAttributes;
+ }
+
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @Data
+ @NoArgsConstructor
+ public static class CallerContext {
+ /**
+ * The AWS SDK version number.
+ */
+ private String awsSdkVersion;
+
+ /**
+ * The ID of the client associated with the user pool.
+ */
+ private String clientId;
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolMigrateUserEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolMigrateUserEvent.java
new file mode 100644
index 000000000..381010a76
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolMigrateUserEvent.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.*;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Migrate User Lambda Trigger
+ *
+ * See Migrate User Lambda Trigger
+ *
+ * @author jvdl
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolMigrateUserEvent extends CognitoUserPoolEvent {
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ /**
+ * The response from your Lambda trigger.
+ */
+ private Response response;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolMigrateUserEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request,
+ Response response) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ this.response = response;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * The username entered by the user.
+ */
+ private String userName;
+ /**
+ * The password entered by the user for sign-in. It is not set in the forgot-password flow.
+ */
+ private String password;
+ /**
+ * One or more key-value pairs containing the validation data in the user's sign-in request.
+ */
+ private Map validationData;
+ /**
+ * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the migrate user trigger.
+ */
+ private Map clientMetadata;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, Map validationData, Map clientMetadata, String userName, String password) {
+ super(userAttributes);
+ this.validationData = validationData;
+ this.clientMetadata = clientMetadata;
+ this.userName = userName;
+ this.password = password;
+ }
+ }
+
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @Data
+ @NoArgsConstructor
+ public static class Response {
+
+ /**
+ * It must contain one or more name-value pairs representing user attributes to be stored in the user profile in your user pool.
+ */
+ private Map userAttributes;
+
+ /**
+ * During sign-in, this attribute can be set to CONFIRMED, or not set, to auto-confirm your users and allow them to sign-in with their previous passwords.
+ */
+ private String finalUserStatus;
+
+ /**
+ * This attribute can be set to "SUPPRESS" to suppress the welcome message usually sent by Amazon Cognito to new users.
+ * If this attribute is not returned, the welcome message will be sent.
+ */
+ private String messageAction;
+
+ /**
+ * This attribute can be set to "EMAIL" to send the welcome message by email, or "SMS" to send the welcome message by SMS.
+ * If this attribute is not returned, the welcome message will be sent by SMS.
+ */
+ private String[] desiredDeliveryMediums;
+
+ /**
+ * If this parameter is set to "true" and the phone number or email address specified in the UserAttributes parameter already exists as an alias with a different user, the API call will migrate the alias from the previous user to the newly created user.
+ */
+ private boolean forceAliasCreation;
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostAuthenticationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostAuthenticationEvent.java
new file mode 100644
index 000000000..de1af6565
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostAuthenticationEvent.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Post Authentication Lambda Trigger
+ *
+ * See Post Authentication Lambda Trigger
+ *
+ * @author jvdl
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolPostAuthenticationEvent extends CognitoUserPoolEvent {
+
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolPostAuthenticationEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the post authentication trigger.
+ */
+ private Map clientMetadata;
+
+ /**
+ * This flag indicates if the user has signed in on a new device.
+ */
+ private boolean newDeviceUsed;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, Map clientMetadata, boolean newDeviceUsed) {
+ super(userAttributes);
+ this.clientMetadata = clientMetadata;
+ this.newDeviceUsed = newDeviceUsed;
+ }
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostConfirmationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostConfirmationEvent.java
new file mode 100644
index 000000000..4a835489d
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostConfirmationEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Post Confirmation Lambda Trigger
+ *
+ * See Post Confirmation Lambda Trigger
+ *
+ * @author jvdl
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolPostConfirmationEvent extends CognitoUserPoolEvent {
+
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolPostConfirmationEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the post confirmation trigger.
+ */
+ private Map clientMetadata;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, Map clientMetadata) {
+ super(userAttributes);
+ this.clientMetadata = clientMetadata;
+ }
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreAuthenticationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreAuthenticationEvent.java
new file mode 100644
index 000000000..110160415
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreAuthenticationEvent.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Pre Authentication Lambda Trigger
+ *
+ * See Pre Authentication Lambda Trigger
+ *
+ * @author jvdl
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolPreAuthenticationEvent extends CognitoUserPoolEvent {
+
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolPreAuthenticationEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * One or more name-value pairs containing the validation data in the request to register a user.
+ * The validation data is set and then passed from the client in the request to register a user.
+ */
+ private Map validationData;
+
+ /**
+ * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client.
+ */
+ private boolean userNotFound;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, Map validationData, boolean userNotFound) {
+ super(userAttributes);
+ this.validationData = validationData;
+ this.userNotFound = userNotFound;
+ }
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreSignUpEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreSignUpEvent.java
new file mode 100644
index 000000000..da7a848e5
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreSignUpEvent.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.*;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Pre Sign-up Lambda Trigger
+ *
+ * See Pre Sign-up Lambda Trigger
+ *
+ * @author jvdl
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolPreSignUpEvent extends CognitoUserPoolEvent {
+
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ /**
+ * The response from your Lambda trigger.
+ */
+ private Response response;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolPreSignUpEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request,
+ Response response) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ this.response = response;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * One or more name-value pairs containing the validation data in the request to register a user.
+ * The validation data is set and then passed from the client in the request to register a user.
+ */
+ private Map validationData;
+
+ /**
+ * One or more key-value pairs that you can provide as custom input
+ * to the Lambda function that you specify for the pre sign-up trigger.
+ */
+ private Map clientMetadata;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, Map validationData, Map clientMetadata) {
+ super(userAttributes);
+ this.validationData = validationData;
+ this.clientMetadata = clientMetadata;
+ }
+ }
+
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @Data
+ @NoArgsConstructor
+ public static class Response {
+ /**
+ * Set to true to auto-confirm the user, or false otherwise.
+ */
+ private boolean autoConfirmUser;
+
+ /**
+ * Set to true to set as verified the phone number of a user who is signing up, or false otherwise.
+ * If autoVerifyPhone is set to true, the phone_number attribute must have a valid, non-null value.
+ */
+ private boolean autoVerifyPhone;
+
+ /**
+ * Set to true to set as verified the email of a user who is signing up, or false otherwise.
+ * If autoVerifyEmail is set to true, the email attribute must have a valid, non-null value.
+ */
+ private boolean autoVerifyEmail;
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEvent.java
new file mode 100644
index 000000000..e49ce3c40
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEvent.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.*;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Pre Token Generation Lambda Trigger
+ *
+ * See Pre Token Generation Lambda Trigger
+ *
+ * @author jvdl
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolPreTokenGenerationEvent extends CognitoUserPoolEvent {
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ /**
+ * The response from your Lambda trigger.
+ */
+ private Response response;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolPreTokenGenerationEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request,
+ Response response) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ this.response = response;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the pre token generation trigger.
+ */
+ private Map clientMetadata;
+
+ /**
+ * The input object containing the current group configuration.
+ */
+ private GroupConfiguration groupConfiguration;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, Map clientMetadata, GroupConfiguration groupConfiguration) {
+ super(userAttributes);
+ this.clientMetadata = clientMetadata;
+ this.groupConfiguration = groupConfiguration;
+ }
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class GroupConfiguration {
+ /**
+ * A list of the group names that are associated with the user that the identity token is issued for.
+ */
+ private String[] groupsToOverride;
+ /**
+ * A list of the current IAM roles associated with these groups.
+ */
+ private String[] iamRolesToOverride;
+ /**
+ * Indicates the preferred IAM role.
+ */
+ private String preferredRole;
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class Response {
+ private ClaimsOverrideDetails claimsOverrideDetails;
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class ClaimsOverrideDetails {
+ /**
+ * A map of one or more key-value pairs of claims to add or override.
+ * For group related claims, use groupOverrideDetails instead.
+ */
+ private Map claimsToAddOrOverride;
+ /**
+ * A list that contains claims to be suppressed from the identity token.
+ */
+ private String[] claimsToSuppress;
+ /**
+ * The output object containing the current group configuration.
+ */
+ private GroupConfiguration groupOverrideDetails;
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEventV2.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEventV2.java
new file mode 100644
index 000000000..9faeb9704
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEventV2.java
@@ -0,0 +1,134 @@
+/* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
+
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Pre Token Generation Lambda Trigger V2
+ *
+ * See Pre Token Generation Lambda Trigger
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolPreTokenGenerationEventV2 extends CognitoUserPoolEvent {
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ /**
+ * The response from your Lambda trigger.
+ */
+ private Response response;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolPreTokenGenerationEventV2(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request,
+ Response response) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ this.response = response;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+
+ private String[] scopes;
+ private GroupConfiguration groupConfiguration;
+ private Map clientMetadata;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes, String[] scopes, GroupConfiguration groupConfiguration, Map clientMetadata) {
+ super(userAttributes);
+ this.scopes = scopes;
+ this.groupConfiguration = groupConfiguration;
+ this.clientMetadata = clientMetadata;
+ }
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class GroupConfiguration {
+ /**
+ * A list of the group names that are associated with the user that the identity token is issued for.
+ */
+ private String[] groupsToOverride;
+ /**
+ * A list of the current IAM roles associated with these groups.
+ */
+ private String[] iamRolesToOverride;
+ /**
+ * Indicates the preferred IAM role.
+ */
+ private String preferredRole;
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class Response {
+ private ClaimsAndScopeOverrideDetails claimsAndScopeOverrideDetails;
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class ClaimsAndScopeOverrideDetails {
+ private IdTokenGeneration idTokenGeneration;
+ private AccessTokenGeneration accessTokenGeneration;
+ private GroupOverrideDetails groupOverrideDetails;
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class IdTokenGeneration {
+ private Map claimsToAddOrOverride;
+ private String[] claimsToSuppress;
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class AccessTokenGeneration {
+ private Map claimsToAddOrOverride;
+ private String[] claimsToSuppress;
+ private String[] scopesToAdd;
+ private String[] scopesToSuppress;
+ }
+
+ @Data
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ public static class GroupOverrideDetails {
+ private String[] groupsToOverride;
+ private String[] iamRolesToOverride;
+ private String preferredRole;
+ }
+}
\ No newline at end of file
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolVerifyAuthChallengeResponseEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolVerifyAuthChallengeResponseEvent.java
new file mode 100644
index 000000000..982ff72fd
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolVerifyAuthChallengeResponseEvent.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.*;
+
+import java.util.Map;
+
+/**
+ * Represent the class for the Cognito User Pool Verify Auth Challenge Response Lambda Trigger
+ *
+ * See Verify Auth Challenge Response Lambda Trigger
+ *
+ * @author jvdl
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class CognitoUserPoolVerifyAuthChallengeResponseEvent extends CognitoUserPoolEvent {
+ /**
+ * The request from the Amazon Cognito service.
+ */
+ private Request request;
+
+ /**
+ * The response from your Lambda trigger.
+ */
+ private Response response;
+
+ @Builder(setterPrefix = "with")
+ public CognitoUserPoolVerifyAuthChallengeResponseEvent(
+ String version,
+ String triggerSource,
+ String region,
+ String userPoolId,
+ String userName,
+ CallerContext callerContext,
+ Request request,
+ Response response) {
+ super(version, triggerSource, region, userPoolId, userName, callerContext);
+ this.request = request;
+ this.response = response;
+ }
+
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @NoArgsConstructor
+ @ToString(callSuper = true)
+ public static class Request extends CognitoUserPoolEvent.Request {
+ /**
+ * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the verify auth challenge trigger.
+ */
+ private Map clientMetadata;
+ /**
+ * This parameter comes from the Create Auth Challenge trigger, and is compared against a user's challengeAnswer to determine whether the user passed the challenge.
+ */
+ private Map privateChallengeParameters;
+ /**
+ * The answer from the user's response to the challenge.
+ */
+ private String challengeAnswer;
+ /**
+ * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client
+ */
+ private boolean userNotFound;
+
+ @Builder(setterPrefix = "with")
+ public Request(Map userAttributes,
+ Map clientMetadata,
+ String challengeAnswer,
+ Map privateChallengeParameters,
+ boolean userNotFound) {
+ super(userAttributes);
+ this.clientMetadata = clientMetadata;
+ this.userNotFound = userNotFound;
+ this.challengeAnswer = challengeAnswer;
+ this.privateChallengeParameters = privateChallengeParameters;
+ }
+ }
+
+ @AllArgsConstructor
+ @Builder(setterPrefix = "with")
+ @Data
+ @NoArgsConstructor
+ public static class Response {
+ /**
+ * Set to true if the user has successfully completed the challenge, or false otherwise.
+ */
+ private boolean answerCorrect;
+ }
+}
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 ac17d3400..b2bb9b006 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
@@ -1,30 +1,52 @@
+/*
+ * Copyright 2012-2017 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;
+
/**
* Represents an event for an AWS Config rule's function.
*/
-public class ConfigEvent {
+public class ConfigEvent implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = -3484211708255634243L;
private String version;
-
+
private String invokingEvent;
-
+
private String ruleParameters;
-
+
private String resultToken;
-
+
private String configRuleArn;
-
+
private String configRuleId;
-
+
private String configRuleName;
-
+
private String accountId;
-
+
private String executionRoleArn;
-
+
private boolean eventLeftScope;
+ /**
+ * default constructor
+ */
+ public ConfigEvent() {}
+
/**
* Gets the AWS Config event version.
*
@@ -41,6 +63,15 @@ public void setVersion(String version) {
this.version = version;
}
+ /**
+ * @param version config event version
+ * @return Config Event
+ */
+ public ConfigEvent withVersion(String version) {
+ setVersion(version);
+ return this;
+ }
+
/**
* Gets the JSON-encoded notification published by AWS Config.
*
@@ -57,6 +88,15 @@ public void setInvokingEvent(String invokingEvent) {
this.invokingEvent = invokingEvent;
}
+ /**
+ * @param invokingEvent invoking event
+ * @return Config Event
+ */
+ public ConfigEvent withInvokingEvent(String invokingEvent) {
+ setInvokingEvent(invokingEvent);
+ return this;
+ }
+
/**
* Gets the JSON-encoded map containing the AWS Config rule parameters.
*
@@ -73,6 +113,15 @@ public void setRuleParameters(String ruleParameters) {
this.ruleParameters = ruleParameters;
}
+ /**
+ * @param ruleParameters String with rule parameters
+ * @return ConfigEvent
+ */
+ public ConfigEvent withRuleParameters(String ruleParameters) {
+ setRuleParameters(ruleParameters);
+ return this;
+ }
+
/**
* Gets the token associated with the invocation of the AWS Config rule's Lambda function.
*
@@ -89,6 +138,15 @@ public void setResultToken(String resultToken) {
this.resultToken = resultToken;
}
+ /**
+ * @param resultToken result token
+ * @return ConfigEvent
+ */
+ public ConfigEvent withResultToken(String resultToken) {
+ setResultToken(resultToken);
+ return this;
+ }
+
/**
* Gets the ARN of the AWS Config rule that triggered the event.
*
@@ -105,6 +163,15 @@ public void setConfigRuleArn(String configRuleArn) {
this.configRuleArn = configRuleArn;
}
+ /**
+ * @param configRuleArn config rule for arn
+ * @return ConfigEvent
+ */
+ public ConfigEvent withConfigRuleArn(String configRuleArn) {
+ setConfigRuleArn(configRuleArn);
+ return this;
+ }
+
/**
* Gets the ID of the AWS Config rule that triggered the event.
*
@@ -121,6 +188,15 @@ public void setConfigRuleId(String configRuleId) {
this.configRuleId = configRuleId;
}
+ /**
+ * @param configRuleId config rule id
+ * @return ConfigEvent
+ */
+ public ConfigEvent withConfigRuleId(String configRuleId) {
+ setConfigRuleId(configRuleId);
+ return this;
+ }
+
/**
* Gets the name of the AWS Config rule that triggered the event.
*
@@ -137,6 +213,15 @@ public void setConfigRuleName(String configRuleName) {
this.configRuleName = configRuleName;
}
+ /**
+ * @param configRuleName config rule name
+ * @return ConfigEvent
+ */
+ public ConfigEvent withConfigRuleName(String configRuleName) {
+ setConfigRuleName(configRuleName);
+ return this;
+ }
+
/**
* Gets the account ID of the AWS Config rule that triggered the event.
*
@@ -153,6 +238,15 @@ public void setAccountId(String accountId) {
this.accountId = accountId;
}
+ /**
+ * @param accountId Account id
+ * @return Config Event
+ */
+ public ConfigEvent withAccountId(String accountId) {
+ setAccountId(accountId);
+ return this;
+ }
+
/**
* Gets the ARN of the IAM role that is assigned to AWS Config.
*
@@ -169,11 +263,20 @@ public void setExecutionRoleArn(String executionRoleArn) {
this.executionRoleArn = executionRoleArn;
}
+ /**
+ * @param executionRoleArn execution role arn
+ * @return ConfigEvent
+ */
+ public ConfigEvent withExecutionRoleArn(String executionRoleArn) {
+ setExecutionRoleArn(executionRoleArn);
+ return this;
+ }
+
/**
* Whether the AWS resource to be evaluated has been removed from the AWS Config rule's scope.
*
*/
- public boolean isEventLeftScope() {
+ public boolean getEventLeftScope() {
return eventLeftScope;
}
@@ -185,6 +288,49 @@ public void setEventLeftScope(boolean eventLeftScope) {
this.eventLeftScope = eventLeftScope;
}
+ /**
+ * @param eventLeftScope event left scope
+ * @return ConfigEvent
+ */
+ public ConfigEvent withEventLeftScope(Boolean eventLeftScope) {
+ setEventLeftScope(eventLeftScope);
+ return this;
+ }
+
+ /**
+ * Returns a string representation of this object; useful for testing and debugging.
+ *
+ * @return A string representation of this object.
+ *
+ * @see Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{");
+ if (getAccountId() != null)
+ sb.append("accountId: ").append(getAccountId()).append(",");
+ if (getConfigRuleArn() != null)
+ sb.append("configRuleArn: ").append(getConfigRuleArn()).append(",");
+ if (getConfigRuleId() != null)
+ sb.append("configRulelId: ").append(getConfigRuleId()).append(",");
+ if (getConfigRuleName() != null)
+ sb.append("configRuleName: ").append(getConfigRuleName()).append(",");
+ sb.append("eventLeftScope: ").append(getEventLeftScope()).append(",");
+ if (getExecutionRoleArn() != null)
+ sb.append("executionRoleArn: ").append(getExecutionRoleArn()).append(",");
+ if (getInvokingEvent() != null)
+ sb.append("invokingEvent: ").append(getInvokingEvent()).append(",");
+ if (getResultToken() != null)
+ sb.append("resultToken: ").append(getResultToken()).append(",");
+ if (getRuleParameters() != null)
+ sb.append("ruleParameters: ").append(getRuleParameters()).append(",");
+ if (getVersion() != null)
+ sb.append("version: ").append(getVersion());
+ sb.append("}");
+ return sb.toString();
+ }
+
@Override
public int hashCode() {
@@ -262,4 +408,13 @@ public boolean equals(Object obj) {
return true;
}
+ @Override
+ public ConfigEvent clone() {
+ try {
+ return (ConfigEvent) super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e);
+ }
+ }
+
}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ConnectEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ConnectEvent.java
new file mode 100644
index 000000000..e94875614
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ConnectEvent.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Class to represent an Amazon Connect contact flow event.
+ *
+ * @see parameters;
+ }
+
+ @Data
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class ContactData implements Serializable, Cloneable {
+ private Map attributes;
+ private String channel;
+ private String contactId;
+ private CustomerEndpoint customerEndpoint;
+ private String initialContactId;
+ private String initiationMethod;
+ private String instanceArn;
+ private String previousContactId;
+ private Queue queue;
+ private SystemEndpoint systemEndpoint;
+ }
+
+ @Data
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class CustomerEndpoint implements Serializable, Cloneable {
+ private String address;
+ private String type;
+ }
+
+ @Data
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class SystemEndpoint implements Serializable, Cloneable {
+ private String address;
+ private String type;
+ }
+ @Data
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class Queue implements Serializable, Cloneable {
+ private String name;
+ private String ARN;
+ }
+
+}
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 89f715941..353f587f0 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,19 +1,161 @@
-/* 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.util.List;
-import com.amazonaws.services.dynamodbv2.model.Record;
+import java.io.Serializable;
+import java.util.List;
/**
* Represents an Amazon DynamoDB event
*/
-public class DynamodbEvent {
+public class DynamodbEvent implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = -2354616079899981231L;
+
private List records;
-
+
+ /**
+ * The unit of data of an Amazon DynamoDB event
+ */
+ public static class DynamodbStreamRecord extends com.amazonaws.services.lambda.runtime.events.models.dynamodb.Record {
+
+ private static final long serialVersionUID = 3638381544604354963L;
+
+ private String eventSourceARN;
+
+ /**
+ * default constructor
+ * (Not available in v1)
+ */
+ public DynamodbStreamRecord() {}
+
+ /**
+ * Gets the event source arn of DynamoDB
+ * @return event source arn
+ */
+ public String getEventSourceARN() {
+ return eventSourceARN;
+ }
+
+ /**
+ * Sets the event source arn of DynamoDB
+ * @param eventSourceARN A string containing the event source arn
+ */
+ public void setEventSourceARN(String eventSourceARN) {
+ this.eventSourceARN = eventSourceARN;
+ }
+
+ /**
+ * Returns a string representation of this object; useful for testing and debugging.
+ *
+ * @return A string representation of this object.
+ *
+ * @see Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{");
+ if (getEventID() != null)
+ sb.append("eventID: ").append(getEventID()).append(",");
+ if (getEventName() != null)
+ sb.append("eventName: ").append(getEventName()).append(",");
+ if (getEventVersion() != null)
+ sb.append("eventVersion: ").append(getEventVersion()).append(",");
+ if (getEventSource() != null)
+ sb.append("eventSource: ").append(getEventSource()).append(",");
+ if (getAwsRegion() != null)
+ sb.append("awsRegion: ").append(getAwsRegion()).append(",");
+ if (getDynamodb() != null)
+ sb.append("dynamodb: ").append(getDynamodb()).append(",");
+ if (getUserIdentity() != null)
+ sb.append("userIdentity: ").append(getUserIdentity()).append(",");
+ if (getEventSourceARN() != null)
+ sb.append("eventSourceArn: ").append(getEventSourceARN());
+ sb.append("}");
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+
+ if (obj instanceof DynamodbStreamRecord == false)
+ return false;
+ DynamodbStreamRecord other = (DynamodbStreamRecord) obj;
+ if (other.getEventID() == null ^ this.getEventID() == null)
+ return false;
+ if (other.getEventID() != null && other.getEventID().equals(this.getEventID()) == false)
+ return false;
+ if (other.getEventName() == null ^ this.getEventName() == null)
+ return false;
+ if (other.getEventName() != null && other.getEventName().equals(this.getEventName()) == false)
+ return false;
+ if (other.getEventVersion() == null ^ this.getEventVersion() == null)
+ return false;
+ if (other.getEventVersion() != null && other.getEventVersion().equals(this.getEventVersion()) == false)
+ return false;
+ if (other.getEventSource() == null ^ this.getEventSource() == null)
+ return false;
+ if (other.getEventSource() != null && other.getEventSource().equals(this.getEventSource()) == false)
+ return false;
+ if (other.getAwsRegion() == null ^ this.getAwsRegion() == null)
+ return false;
+ if (other.getAwsRegion() != null && other.getAwsRegion().equals(this.getAwsRegion()) == false)
+ return false;
+ if (other.getDynamodb() == null ^ this.getDynamodb() == null)
+ return false;
+ if (other.getDynamodb() != null && other.getDynamodb().equals(this.getDynamodb()) == false)
+ return false;
+ if (other.getUserIdentity() == null ^ this.getUserIdentity() == null)
+ return false;
+ if (other.getUserIdentity() != null && other.getUserIdentity().equals(this.getUserIdentity()) == false)
+ return false;
+ if (other.getEventSourceARN() == null ^ this.getEventSourceARN() == null)
+ return false;
+ if (other.getEventSourceARN() != null && other.getEventSourceARN().equals(this.getEventSourceARN()) == false)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int hashCode = super.hashCode();
+
+ hashCode = prime * hashCode + ((getEventSourceARN() == null) ? 0 : getEventSourceARN().hashCode());
+ return hashCode;
+ }
+
+ @Override
+ public DynamodbStreamRecord clone() {
+ return (DynamodbStreamRecord) super.clone();
+ }
+
+ }
+
+ /**
+ * default constructor
+ * (Not available in v1)
+ */
+ public DynamodbEvent() {}
+
/**
* Gets the list of DynamoDB event records
- *
+ * @return list of dynamodb event records
*/
public List getRecords() {
return records;
@@ -28,26 +170,55 @@ public void setRecords(List records) {
}
/**
- * The unit of data of an Amazon DynamoDB event
+ * Returns a string representation of this object; useful for testing and debugging.
+ *
+ * @return A string representation of this object.
+ *
+ * @see Object#toString()
*/
- @SuppressWarnings("serial")
- public static class DynamodbStreamRecord extends Record{
- private String eventSourceARN;
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{");
+ if (getRecords() != null)
+ sb.append(getRecords());
+ sb.append("}");
+ return sb.toString();
+ }
- /**
- * Gets the event source arn of DynamoDB
- *
- */
- public String getEventSourceARN() {
- return eventSourceARN;
- }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
- /**
- * Sets the event source arn of DynamoDB
- * @param eventSourceArn A string containing the event source arn
- */
- public void setEventSourceARN(String eventSourceARN) {
- this.eventSourceARN = eventSourceARN;
+ if (obj instanceof DynamodbEvent == false)
+ return false;
+ DynamodbEvent other = (DynamodbEvent) obj;
+ if (other.getRecords() == null ^ this.getRecords() == null)
+ return false;
+ if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false)
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int hashCode = 1;
+
+ hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode());
+ return hashCode;
+ }
+
+ @Override
+ public DynamodbEvent clone() {
+ try {
+ return (DynamodbEvent) super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e);
}
}
+
}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbTimeWindowEvent.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbTimeWindowEvent.java
new file mode 100644
index 000000000..64ed9fb29
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbTimeWindowEvent.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
+ * the License. A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+
+package com.amazonaws.services.lambda.runtime.events;
+
+import com.amazonaws.services.lambda.runtime.events.models.TimeWindow;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents an Amazon Dynamodb event when using time windows.
+ */
+@Data
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+public class DynamodbTimeWindowEvent extends DynamodbEvent implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = -5449871161108629510L;
+
+ /**
+ * Time window for the records in the event.
+ */
+ private TimeWindow window;
+
+ /**
+ * State being built up to this invoke in the time window.
+ */
+ private Map state;
+
+ /**
+ * Shard id of the records
+ */
+ private String shardId;
+
+ /**
+ * Dynamodb stream arn.
+ */
+ private String eventSourceArn;
+
+ /**
+ * Set to true for the last invoke of the time window. Subsequent invoke will start a new time window along with a fresh state.
+ */
+ private Boolean isFinalInvokeForWindow;
+
+ /**
+ * Set to true if window is terminated prematurely. Subsequent invoke will continue the same window with a fresh state.
+ */
+ private Boolean isWindowTerminatedEarly;
+
+ @Builder(setterPrefix = "with")
+ public DynamodbTimeWindowEvent(
+ final List records,
+ final TimeWindow window,
+ final Map state,
+ final String shardId,
+ final String eventSourceArn,
+ final Boolean isFinalInvokeForWindow,
+ final Boolean isWindowTerminatedEarly) {
+ this.setRecords(records);
+ this.window = window;
+ this.state = state;
+ this.shardId = shardId;
+ this.eventSourceArn = eventSourceArn;
+ this.isFinalInvokeForWindow = isFinalInvokeForWindow;
+ this.isWindowTerminatedEarly = isWindowTerminatedEarly;
+ }
+}
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponse.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponse.java
new file mode 100644
index 000000000..e8d3b13d9
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponse.java
@@ -0,0 +1,92 @@
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The IAM Policy Response required for API Gateway HTTP APIs
+ *
+ * https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html
+ *
+ */
+
+@Data
+@Builder(setterPrefix = "with")
+@NoArgsConstructor
+@AllArgsConstructor
+public class IamPolicyResponse implements Serializable, Cloneable {
+
+ public static final String EXECUTE_API_INVOKE = "execute-api:Invoke";
+ public static final String VERSION_2012_10_17 = "2012-10-17";
+ public static final String ALLOW = "Allow";
+ public static final String DENY = "Deny";
+
+ private String principalId;
+ private PolicyDocument policyDocument;
+ private Map context;
+
+ public Map getPolicyDocument() {
+ Map serializablePolicy = new HashMap<>();
+ serializablePolicy.put("Version", policyDocument.getVersion());
+
+ int numberOfStatements = policyDocument.getStatement().size();
+ Map[] serializableStatementArray = new Map[numberOfStatements];
+ for (int i = 0; i < numberOfStatements; i++) {
+ Statement statement = policyDocument.getStatement().get(i);
+ Map serializableStatement = new HashMap<>();
+ serializableStatement.put("Effect", statement.getEffect());
+ serializableStatement.put("Action", statement.getAction());
+ serializableStatement.put("Resource", statement.getResource().toArray(new String[0]));
+ serializableStatement.put("Condition", statement.getCondition());
+ serializableStatementArray[i] = serializableStatement;
+ }
+ serializablePolicy.put("Statement", serializableStatementArray);
+ return serializablePolicy;
+ }
+
+ public static Statement allowStatement(String resource) {
+ return Statement.builder()
+ .withEffect(ALLOW)
+ .withResource(Collections.singletonList(resource))
+ .withAction(EXECUTE_API_INVOKE)
+ .build();
+ }
+
+ public static Statement denyStatement(String resource) {
+ return Statement.builder()
+ .withEffect(DENY)
+ .withResource(Collections.singletonList(resource))
+ .withAction(EXECUTE_API_INVOKE)
+ .build();
+ }
+
+ @Data
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class PolicyDocument implements Serializable, Cloneable {
+
+ private String version;
+ private List statement;
+ }
+
+ @Data
+ @Builder(setterPrefix = "with")
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class Statement implements Serializable, Cloneable {
+
+ private String action;
+ private String effect;
+ private List resource;
+ private Map> condition;
+ }
+}
\ No newline at end of file
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponseV1.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponseV1.java
new file mode 100644
index 000000000..a4316536f
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponseV1.java
@@ -0,0 +1,93 @@
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The IAM Policy Response required for API Gateway REST APIs
+ *
+ * https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html
+ *
+ */
+
+@Data
+@Builder(setterPrefix = "with")
+@NoArgsConstructor
+@AllArgsConstructor
+public class IamPolicyResponseV1 implements Serializable, Cloneable {
+
+ public static final String EXECUTE_API_INVOKE = "execute-api:Invoke";
+ public static final String VERSION_2012_10_17 = "2012-10-17";
+ public static final String ALLOW = "Allow";
+ public static final String DENY = "Deny";
+
+ private String principalId;
+ private PolicyDocument policyDocument;
+ private Map context;
+ private String usageIdentifierKey;
+
+ public Map getPolicyDocument() {
+ Map serializablePolicy = new HashMap<>();
+ serializablePolicy.put("Version", policyDocument.getVersion());
+
+ int numberOfStatements = policyDocument.getStatement().size();
+ Map