
software.amazon.awssdk.services.lambda.model.EventSourceMappingConfiguration Maven / Gradle / Ivy
/*
* 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 software.amazon.awssdk.services.lambda.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A mapping between an AWS resource and an AWS Lambda function. See CreateEventSourceMapping for details.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class EventSourceMappingConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField UUID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EventSourceMappingConfiguration::uuid)).setter(setter(Builder::uuid))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UUID").build()).build();
private static final SdkField BATCH_SIZE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(EventSourceMappingConfiguration::batchSize)).setter(setter(Builder::batchSize))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BatchSize").build()).build();
private static final SdkField MAXIMUM_BATCHING_WINDOW_IN_SECONDS_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.getter(getter(EventSourceMappingConfiguration::maximumBatchingWindowInSeconds))
.setter(setter(Builder::maximumBatchingWindowInSeconds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaximumBatchingWindowInSeconds")
.build()).build();
private static final SdkField PARALLELIZATION_FACTOR_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(EventSourceMappingConfiguration::parallelizationFactor))
.setter(setter(Builder::parallelizationFactor))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ParallelizationFactor").build())
.build();
private static final SdkField EVENT_SOURCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EventSourceMappingConfiguration::eventSourceArn)).setter(setter(Builder::eventSourceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventSourceArn").build()).build();
private static final SdkField FUNCTION_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EventSourceMappingConfiguration::functionArn)).setter(setter(Builder::functionArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FunctionArn").build()).build();
private static final SdkField LAST_MODIFIED_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(EventSourceMappingConfiguration::lastModified)).setter(setter(Builder::lastModified))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastModified").build()).build();
private static final SdkField LAST_PROCESSING_RESULT_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EventSourceMappingConfiguration::lastProcessingResult)).setter(setter(Builder::lastProcessingResult))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastProcessingResult").build())
.build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EventSourceMappingConfiguration::state)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField STATE_TRANSITION_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EventSourceMappingConfiguration::stateTransitionReason))
.setter(setter(Builder::stateTransitionReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StateTransitionReason").build())
.build();
private static final SdkField DESTINATION_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.getter(getter(EventSourceMappingConfiguration::destinationConfig)).setter(setter(Builder::destinationConfig))
.constructor(DestinationConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DestinationConfig").build()).build();
private static final SdkField MAXIMUM_RECORD_AGE_IN_SECONDS_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.getter(getter(EventSourceMappingConfiguration::maximumRecordAgeInSeconds))
.setter(setter(Builder::maximumRecordAgeInSeconds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaximumRecordAgeInSeconds").build())
.build();
private static final SdkField BISECT_BATCH_ON_FUNCTION_ERROR_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.getter(getter(EventSourceMappingConfiguration::bisectBatchOnFunctionError))
.setter(setter(Builder::bisectBatchOnFunctionError))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BisectBatchOnFunctionError").build())
.build();
private static final SdkField MAXIMUM_RETRY_ATTEMPTS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(EventSourceMappingConfiguration::maximumRetryAttempts)).setter(setter(Builder::maximumRetryAttempts))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaximumRetryAttempts").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(UUID_FIELD, BATCH_SIZE_FIELD,
MAXIMUM_BATCHING_WINDOW_IN_SECONDS_FIELD, PARALLELIZATION_FACTOR_FIELD, EVENT_SOURCE_ARN_FIELD, FUNCTION_ARN_FIELD,
LAST_MODIFIED_FIELD, LAST_PROCESSING_RESULT_FIELD, STATE_FIELD, STATE_TRANSITION_REASON_FIELD,
DESTINATION_CONFIG_FIELD, MAXIMUM_RECORD_AGE_IN_SECONDS_FIELD, BISECT_BATCH_ON_FUNCTION_ERROR_FIELD,
MAXIMUM_RETRY_ATTEMPTS_FIELD));
private static final long serialVersionUID = 1L;
private final String uuid;
private final Integer batchSize;
private final Integer maximumBatchingWindowInSeconds;
private final Integer parallelizationFactor;
private final String eventSourceArn;
private final String functionArn;
private final Instant lastModified;
private final String lastProcessingResult;
private final String state;
private final String stateTransitionReason;
private final DestinationConfig destinationConfig;
private final Integer maximumRecordAgeInSeconds;
private final Boolean bisectBatchOnFunctionError;
private final Integer maximumRetryAttempts;
private EventSourceMappingConfiguration(BuilderImpl builder) {
this.uuid = builder.uuid;
this.batchSize = builder.batchSize;
this.maximumBatchingWindowInSeconds = builder.maximumBatchingWindowInSeconds;
this.parallelizationFactor = builder.parallelizationFactor;
this.eventSourceArn = builder.eventSourceArn;
this.functionArn = builder.functionArn;
this.lastModified = builder.lastModified;
this.lastProcessingResult = builder.lastProcessingResult;
this.state = builder.state;
this.stateTransitionReason = builder.stateTransitionReason;
this.destinationConfig = builder.destinationConfig;
this.maximumRecordAgeInSeconds = builder.maximumRecordAgeInSeconds;
this.bisectBatchOnFunctionError = builder.bisectBatchOnFunctionError;
this.maximumRetryAttempts = builder.maximumRetryAttempts;
}
/**
*
* The identifier of the event source mapping.
*
*
* @return The identifier of the event source mapping.
*/
public String uuid() {
return uuid;
}
/**
*
* The maximum number of items to retrieve in a single batch.
*
*
* @return The maximum number of items to retrieve in a single batch.
*/
public Integer batchSize() {
return batchSize;
}
/**
*
* The maximum amount of time to gather records before invoking the function, in seconds.
*
*
* @return The maximum amount of time to gather records before invoking the function, in seconds.
*/
public Integer maximumBatchingWindowInSeconds() {
return maximumBatchingWindowInSeconds;
}
/**
*
* (Streams) The number of batches to process from each shard concurrently.
*
*
* @return (Streams) The number of batches to process from each shard concurrently.
*/
public Integer parallelizationFactor() {
return parallelizationFactor;
}
/**
*
* The Amazon Resource Name (ARN) of the event source.
*
*
* @return The Amazon Resource Name (ARN) of the event source.
*/
public String eventSourceArn() {
return eventSourceArn;
}
/**
*
* The ARN of the Lambda function.
*
*
* @return The ARN of the Lambda function.
*/
public String functionArn() {
return functionArn;
}
/**
*
* The date that the event source mapping was last updated, or its state changed.
*
*
* @return The date that the event source mapping was last updated, or its state changed.
*/
public Instant lastModified() {
return lastModified;
}
/**
*
* The result of the last AWS Lambda invocation of your Lambda function.
*
*
* @return The result of the last AWS Lambda invocation of your Lambda function.
*/
public String lastProcessingResult() {
return lastProcessingResult;
}
/**
*
* The state of the event source mapping. It can be one of the following: Creating
,
* Enabling
, Enabled
, Disabling
, Disabled
, Updating
* , or Deleting
.
*
*
* @return The state of the event source mapping. It can be one of the following: Creating
,
* Enabling
, Enabled
, Disabling
, Disabled
,
* Updating
, or Deleting
.
*/
public String state() {
return state;
}
/**
*
* Indicates whether the last change to the event source mapping was made by a user, or by the Lambda service.
*
*
* @return Indicates whether the last change to the event source mapping was made by a user, or by the Lambda
* service.
*/
public String stateTransitionReason() {
return stateTransitionReason;
}
/**
*
* (Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.
*
*
* @return (Streams) An Amazon SQS queue or Amazon SNS topic destination for discarded records.
*/
public DestinationConfig destinationConfig() {
return destinationConfig;
}
/**
*
* (Streams) The maximum age of a record that Lambda sends to a function for processing.
*
*
* @return (Streams) The maximum age of a record that Lambda sends to a function for processing.
*/
public Integer maximumRecordAgeInSeconds() {
return maximumRecordAgeInSeconds;
}
/**
*
* (Streams) If the function returns an error, split the batch in two and retry.
*
*
* @return (Streams) If the function returns an error, split the batch in two and retry.
*/
public Boolean bisectBatchOnFunctionError() {
return bisectBatchOnFunctionError;
}
/**
*
* (Streams) The maximum number of times to retry when the function returns an error.
*
*
* @return (Streams) The maximum number of times to retry when the function returns an error.
*/
public Integer maximumRetryAttempts() {
return maximumRetryAttempts;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(uuid());
hashCode = 31 * hashCode + Objects.hashCode(batchSize());
hashCode = 31 * hashCode + Objects.hashCode(maximumBatchingWindowInSeconds());
hashCode = 31 * hashCode + Objects.hashCode(parallelizationFactor());
hashCode = 31 * hashCode + Objects.hashCode(eventSourceArn());
hashCode = 31 * hashCode + Objects.hashCode(functionArn());
hashCode = 31 * hashCode + Objects.hashCode(lastModified());
hashCode = 31 * hashCode + Objects.hashCode(lastProcessingResult());
hashCode = 31 * hashCode + Objects.hashCode(state());
hashCode = 31 * hashCode + Objects.hashCode(stateTransitionReason());
hashCode = 31 * hashCode + Objects.hashCode(destinationConfig());
hashCode = 31 * hashCode + Objects.hashCode(maximumRecordAgeInSeconds());
hashCode = 31 * hashCode + Objects.hashCode(bisectBatchOnFunctionError());
hashCode = 31 * hashCode + Objects.hashCode(maximumRetryAttempts());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof EventSourceMappingConfiguration)) {
return false;
}
EventSourceMappingConfiguration other = (EventSourceMappingConfiguration) obj;
return Objects.equals(uuid(), other.uuid()) && Objects.equals(batchSize(), other.batchSize())
&& Objects.equals(maximumBatchingWindowInSeconds(), other.maximumBatchingWindowInSeconds())
&& Objects.equals(parallelizationFactor(), other.parallelizationFactor())
&& Objects.equals(eventSourceArn(), other.eventSourceArn()) && Objects.equals(functionArn(), other.functionArn())
&& Objects.equals(lastModified(), other.lastModified())
&& Objects.equals(lastProcessingResult(), other.lastProcessingResult()) && Objects.equals(state(), other.state())
&& Objects.equals(stateTransitionReason(), other.stateTransitionReason())
&& Objects.equals(destinationConfig(), other.destinationConfig())
&& Objects.equals(maximumRecordAgeInSeconds(), other.maximumRecordAgeInSeconds())
&& Objects.equals(bisectBatchOnFunctionError(), other.bisectBatchOnFunctionError())
&& Objects.equals(maximumRetryAttempts(), other.maximumRetryAttempts());
}
/**
* 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.
*/
@Override
public String toString() {
return ToString.builder("EventSourceMappingConfiguration").add("UUID", uuid()).add("BatchSize", batchSize())
.add("MaximumBatchingWindowInSeconds", maximumBatchingWindowInSeconds())
.add("ParallelizationFactor", parallelizationFactor()).add("EventSourceArn", eventSourceArn())
.add("FunctionArn", functionArn()).add("LastModified", lastModified())
.add("LastProcessingResult", lastProcessingResult()).add("State", state())
.add("StateTransitionReason", stateTransitionReason()).add("DestinationConfig", destinationConfig())
.add("MaximumRecordAgeInSeconds", maximumRecordAgeInSeconds())
.add("BisectBatchOnFunctionError", bisectBatchOnFunctionError())
.add("MaximumRetryAttempts", maximumRetryAttempts()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "UUID":
return Optional.ofNullable(clazz.cast(uuid()));
case "BatchSize":
return Optional.ofNullable(clazz.cast(batchSize()));
case "MaximumBatchingWindowInSeconds":
return Optional.ofNullable(clazz.cast(maximumBatchingWindowInSeconds()));
case "ParallelizationFactor":
return Optional.ofNullable(clazz.cast(parallelizationFactor()));
case "EventSourceArn":
return Optional.ofNullable(clazz.cast(eventSourceArn()));
case "FunctionArn":
return Optional.ofNullable(clazz.cast(functionArn()));
case "LastModified":
return Optional.ofNullable(clazz.cast(lastModified()));
case "LastProcessingResult":
return Optional.ofNullable(clazz.cast(lastProcessingResult()));
case "State":
return Optional.ofNullable(clazz.cast(state()));
case "StateTransitionReason":
return Optional.ofNullable(clazz.cast(stateTransitionReason()));
case "DestinationConfig":
return Optional.ofNullable(clazz.cast(destinationConfig()));
case "MaximumRecordAgeInSeconds":
return Optional.ofNullable(clazz.cast(maximumRecordAgeInSeconds()));
case "BisectBatchOnFunctionError":
return Optional.ofNullable(clazz.cast(bisectBatchOnFunctionError()));
case "MaximumRetryAttempts":
return Optional.ofNullable(clazz.cast(maximumRetryAttempts()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function