
software.amazon.awssdk.services.lambda.model.CreateEventSourceMappingRequest Maven / Gradle / Ivy
/*
* Copyright 2014-2019 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.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.awscore.AwsRequestOverrideConfiguration;
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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateEventSourceMappingRequest extends LambdaRequest implements
ToCopyableBuilder {
private static final SdkField EVENT_SOURCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(CreateEventSourceMappingRequest::eventSourceArn)).setter(setter(Builder::eventSourceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventSourceArn").build()).build();
private static final SdkField FUNCTION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(CreateEventSourceMappingRequest::functionName)).setter(setter(Builder::functionName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FunctionName").build()).build();
private static final SdkField ENABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.getter(getter(CreateEventSourceMappingRequest::enabled)).setter(setter(Builder::enabled))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Enabled").build()).build();
private static final SdkField BATCH_SIZE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(CreateEventSourceMappingRequest::batchSize)).setter(setter(Builder::batchSize))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BatchSize").build()).build();
private static final SdkField STARTING_POSITION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(CreateEventSourceMappingRequest::startingPositionAsString)).setter(setter(Builder::startingPosition))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartingPosition").build()).build();
private static final SdkField STARTING_POSITION_TIMESTAMP_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.getter(getter(CreateEventSourceMappingRequest::startingPositionTimestamp))
.setter(setter(Builder::startingPositionTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartingPositionTimestamp").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(EVENT_SOURCE_ARN_FIELD,
FUNCTION_NAME_FIELD, ENABLED_FIELD, BATCH_SIZE_FIELD, STARTING_POSITION_FIELD, STARTING_POSITION_TIMESTAMP_FIELD));
private final String eventSourceArn;
private final String functionName;
private final Boolean enabled;
private final Integer batchSize;
private final String startingPosition;
private final Instant startingPositionTimestamp;
private CreateEventSourceMappingRequest(BuilderImpl builder) {
super(builder);
this.eventSourceArn = builder.eventSourceArn;
this.functionName = builder.functionName;
this.enabled = builder.enabled;
this.batchSize = builder.batchSize;
this.startingPosition = builder.startingPosition;
this.startingPositionTimestamp = builder.startingPositionTimestamp;
}
/**
*
* The Amazon Resource Name (ARN) of the event source.
*
*
* -
*
* Amazon Kinesis - The ARN of the data stream or a stream consumer.
*
*
* -
*
* Amazon DynamoDB Streams - The ARN of the stream.
*
*
* -
*
* Amazon Simple Queue Service - The ARN of the queue.
*
*
*
*
* @return The Amazon Resource Name (ARN) of the event source.
*
* -
*
* Amazon Kinesis - The ARN of the data stream or a stream consumer.
*
*
* -
*
* Amazon DynamoDB Streams - The ARN of the stream.
*
*
* -
*
* Amazon Simple Queue Service - The ARN of the queue.
*
*
*/
public String eventSourceArn() {
return eventSourceArn;
}
/**
*
* The name of the Lambda function.
*
*
* Name formats
*
*
* -
*
* Function name - MyFunction
.
*
*
* -
*
* Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction
.
*
*
* -
*
* Version or Alias ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD
.
*
*
* -
*
* Partial ARN - 123456789012:function:MyFunction
.
*
*
*
*
* The length constraint applies only to the full ARN. If you specify only the function name, it's limited to 64
* characters in length.
*
*
* @return The name of the Lambda function.
*
* Name formats
*
*
* -
*
* Function name - MyFunction
.
*
*
* -
*
* Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction
.
*
*
* -
*
* Version or Alias ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD
* .
*
*
* -
*
* Partial ARN - 123456789012:function:MyFunction
.
*
*
*
*
* The length constraint applies only to the full ARN. If you specify only the function name, it's limited
* to 64 characters in length.
*/
public String functionName() {
return functionName;
}
/**
*
* Disables the event source mapping to pause polling and invocation.
*
*
* @return Disables the event source mapping to pause polling and invocation.
*/
public Boolean enabled() {
return enabled;
}
/**
*
* The maximum number of items to retrieve in a single batch.
*
*
* -
*
* Amazon Kinesis - Default 100. Max 10,000.
*
*
* -
*
* Amazon DynamoDB Streams - Default 100. Max 1,000.
*
*
* -
*
* Amazon Simple Queue Service - Default 10. Max 10.
*
*
*
*
* @return The maximum number of items to retrieve in a single batch.
*
* -
*
* Amazon Kinesis - Default 100. Max 10,000.
*
*
* -
*
* Amazon DynamoDB Streams - Default 100. Max 1,000.
*
*
* -
*
* Amazon Simple Queue Service - Default 10. Max 10.
*
*
*/
public Integer batchSize() {
return batchSize;
}
/**
*
* The position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB Streams
* sources. AT_TIMESTAMP
is only supported for Amazon Kinesis streams.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #startingPosition}
* will return {@link EventSourcePosition#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #startingPositionAsString}.
*
*
* @return The position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB
* Streams sources. AT_TIMESTAMP
is only supported for Amazon Kinesis streams.
* @see EventSourcePosition
*/
public EventSourcePosition startingPosition() {
return EventSourcePosition.fromValue(startingPosition);
}
/**
*
* The position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB Streams
* sources. AT_TIMESTAMP
is only supported for Amazon Kinesis streams.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #startingPosition}
* will return {@link EventSourcePosition#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #startingPositionAsString}.
*
*
* @return The position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB
* Streams sources. AT_TIMESTAMP
is only supported for Amazon Kinesis streams.
* @see EventSourcePosition
*/
public String startingPositionAsString() {
return startingPosition;
}
/**
*
* With StartingPosition
set to AT_TIMESTAMP
, the time from which to start reading.
*
*
* @return With StartingPosition
set to AT_TIMESTAMP
, the time from which to start
* reading.
*/
public Instant startingPositionTimestamp() {
return startingPositionTimestamp;
}
@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(eventSourceArn());
hashCode = 31 * hashCode + Objects.hashCode(functionName());
hashCode = 31 * hashCode + Objects.hashCode(enabled());
hashCode = 31 * hashCode + Objects.hashCode(batchSize());
hashCode = 31 * hashCode + Objects.hashCode(startingPositionAsString());
hashCode = 31 * hashCode + Objects.hashCode(startingPositionTimestamp());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof CreateEventSourceMappingRequest)) {
return false;
}
CreateEventSourceMappingRequest other = (CreateEventSourceMappingRequest) obj;
return Objects.equals(eventSourceArn(), other.eventSourceArn()) && Objects.equals(functionName(), other.functionName())
&& Objects.equals(enabled(), other.enabled()) && Objects.equals(batchSize(), other.batchSize())
&& Objects.equals(startingPositionAsString(), other.startingPositionAsString())
&& Objects.equals(startingPositionTimestamp(), other.startingPositionTimestamp());
}
/**
* 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("CreateEventSourceMappingRequest").add("EventSourceArn", eventSourceArn())
.add("FunctionName", functionName()).add("Enabled", enabled()).add("BatchSize", batchSize())
.add("StartingPosition", startingPositionAsString())
.add("StartingPositionTimestamp", startingPositionTimestamp()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "EventSourceArn":
return Optional.ofNullable(clazz.cast(eventSourceArn()));
case "FunctionName":
return Optional.ofNullable(clazz.cast(functionName()));
case "Enabled":
return Optional.ofNullable(clazz.cast(enabled()));
case "BatchSize":
return Optional.ofNullable(clazz.cast(batchSize()));
case "StartingPosition":
return Optional.ofNullable(clazz.cast(startingPositionAsString()));
case "StartingPositionTimestamp":
return Optional.ofNullable(clazz.cast(startingPositionTimestamp()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function