All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 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 getter(Function g) { return obj -> g.apply((CreateEventSourceMappingRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends LambdaRequest.Builder, SdkPojo, CopyableBuilder { /** *

      * 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. *

        *
      • *
      * * @param eventSourceArn * 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 Returns a reference to this object so that method calls can be chained together. */ Builder eventSourceArn(String 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. *

        * * @param functionName * 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 Returns a reference to this object so that method calls can be chained together. */ Builder functionName(String functionName); /** *

        * Disables the event source mapping to pause polling and invocation. *

        * * @param enabled * Disables the event source mapping to pause polling and invocation. * @return Returns a reference to this object so that method calls can be chained together. */ Builder enabled(Boolean 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. *

          *
        • *
        * * @param batchSize * 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 Returns a reference to this object so that method calls can be chained together. */ Builder batchSize(Integer 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. *

          * * @param 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. * @see EventSourcePosition * @return Returns a reference to this object so that method calls can be chained together. * @see EventSourcePosition */ Builder startingPosition(String 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. *

          * * @param 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. * @see EventSourcePosition * @return Returns a reference to this object so that method calls can be chained together. * @see EventSourcePosition */ Builder startingPosition(EventSourcePosition startingPosition); /** *

          * With StartingPosition set to AT_TIMESTAMP, the time from which to start reading. *

          * * @param startingPositionTimestamp * With StartingPosition set to AT_TIMESTAMP, the time from which to start * reading. * @return Returns a reference to this object so that method calls can be chained together. */ Builder startingPositionTimestamp(Instant startingPositionTimestamp); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends LambdaRequest.BuilderImpl implements Builder { private String eventSourceArn; private String functionName; private Boolean enabled; private Integer batchSize; private String startingPosition; private Instant startingPositionTimestamp; private BuilderImpl() { } private BuilderImpl(CreateEventSourceMappingRequest model) { super(model); eventSourceArn(model.eventSourceArn); functionName(model.functionName); enabled(model.enabled); batchSize(model.batchSize); startingPosition(model.startingPosition); startingPositionTimestamp(model.startingPositionTimestamp); } public final String getEventSourceArn() { return eventSourceArn; } @Override public final Builder eventSourceArn(String eventSourceArn) { this.eventSourceArn = eventSourceArn; return this; } public final void setEventSourceArn(String eventSourceArn) { this.eventSourceArn = eventSourceArn; } public final String getFunctionName() { return functionName; } @Override public final Builder functionName(String functionName) { this.functionName = functionName; return this; } public final void setFunctionName(String functionName) { this.functionName = functionName; } public final Boolean getEnabled() { return enabled; } @Override public final Builder enabled(Boolean enabled) { this.enabled = enabled; return this; } public final void setEnabled(Boolean enabled) { this.enabled = enabled; } public final Integer getBatchSize() { return batchSize; } @Override public final Builder batchSize(Integer batchSize) { this.batchSize = batchSize; return this; } public final void setBatchSize(Integer batchSize) { this.batchSize = batchSize; } public final String getStartingPositionAsString() { return startingPosition; } @Override public final Builder startingPosition(String startingPosition) { this.startingPosition = startingPosition; return this; } @Override public final Builder startingPosition(EventSourcePosition startingPosition) { this.startingPosition(startingPosition.toString()); return this; } public final void setStartingPosition(String startingPosition) { this.startingPosition = startingPosition; } public final Instant getStartingPositionTimestamp() { return startingPositionTimestamp; } @Override public final Builder startingPositionTimestamp(Instant startingPositionTimestamp) { this.startingPositionTimestamp = startingPositionTimestamp; return this; } public final void setStartingPositionTimestamp(Instant startingPositionTimestamp) { this.startingPositionTimestamp = startingPositionTimestamp; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateEventSourceMappingRequest build() { return new CreateEventSourceMappingRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy