software.amazon.awssdk.services.ses.model.LambdaAction Maven / Gradle / Ivy
/*
* Copyright 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.ses.model;
import java.io.Serializable;
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.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;
/**
*
* When included in a receipt rule, this action calls an Amazon Web Services Lambda function and, optionally, publishes
* a notification to Amazon Simple Notification Service (Amazon SNS).
*
*
* To enable Amazon SES to call your Amazon Web Services Lambda function or to publish to an Amazon SNS topic of another
* account, Amazon SES must have permission to access those resources. For information about giving permissions, see the
* Amazon SES Developer Guide.
*
*
* For information about using Amazon Web Services Lambda actions in receipt rules, see the Amazon SES Developer Guide.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class LambdaAction implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField TOPIC_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TopicArn").getter(getter(LambdaAction::topicArn)).setter(setter(Builder::topicArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TopicArn").build()).build();
private static final SdkField FUNCTION_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("FunctionArn").getter(getter(LambdaAction::functionArn)).setter(setter(Builder::functionArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FunctionArn").build()).build();
private static final SdkField INVOCATION_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InvocationType").getter(getter(LambdaAction::invocationTypeAsString))
.setter(setter(Builder::invocationType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InvocationType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TOPIC_ARN_FIELD,
FUNCTION_ARN_FIELD, INVOCATION_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String topicArn;
private final String functionArn;
private final String invocationType;
private LambdaAction(BuilderImpl builder) {
this.topicArn = builder.topicArn;
this.functionArn = builder.functionArn;
this.invocationType = builder.invocationType;
}
/**
*
* The Amazon Resource Name (ARN) of the Amazon SNS topic to notify when the Lambda action is executed. You can find
* the ARN of a topic by using the ListTopics operation in Amazon SNS.
*
*
* For more information about Amazon SNS topics, see the Amazon SNS Developer Guide.
*
*
* @return The Amazon Resource Name (ARN) of the Amazon SNS topic to notify when the Lambda action is executed. You
* can find the ARN of a topic by using the ListTopics operation in Amazon
* SNS.
*
* For more information about Amazon SNS topics, see the Amazon SNS Developer Guide.
*/
public final String topicArn() {
return topicArn;
}
/**
*
* The Amazon Resource Name (ARN) of the Amazon Web Services Lambda function. An example of an Amazon Web Services
* Lambda function ARN is arn:aws:lambda:us-west-2:account-id:function:MyFunction
. For more information
* about Amazon Web Services Lambda, see the Amazon Web Services Lambda Developer Guide.
*
*
* @return The Amazon Resource Name (ARN) of the Amazon Web Services Lambda function. An example of an Amazon Web
* Services Lambda function ARN is arn:aws:lambda:us-west-2:account-id:function:MyFunction
. For
* more information about Amazon Web Services Lambda, see the Amazon Web Services Lambda Developer
* Guide.
*/
public final String functionArn() {
return functionArn;
}
/**
*
* The invocation type of the Amazon Web Services Lambda function. An invocation type of
* RequestResponse
means that the execution of the function immediately results in a response, and a
* value of Event
means that the function is invoked asynchronously. The default value is
* Event
. For information about Amazon Web Services Lambda invocation types, see the Amazon Web Services Lambda Developer
* Guide.
*
*
*
* There is a 30-second timeout on RequestResponse
invocations. You should use Event
* invocation in most cases. Use RequestResponse
only to make a mail flow decision, such as whether to
* stop the receipt rule or the receipt rule set.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #invocationType}
* will return {@link InvocationType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #invocationTypeAsString}.
*
*
* @return The invocation type of the Amazon Web Services Lambda function. An invocation type of
* RequestResponse
means that the execution of the function immediately results in a response,
* and a value of Event
means that the function is invoked asynchronously. The default value is
* Event
. For information about Amazon Web Services Lambda invocation types, see the Amazon Web Services Lambda Developer
* Guide.
*
* There is a 30-second timeout on RequestResponse
invocations. You should use
* Event
invocation in most cases. Use RequestResponse
only to make a mail flow
* decision, such as whether to stop the receipt rule or the receipt rule set.
*
* @see InvocationType
*/
public final InvocationType invocationType() {
return InvocationType.fromValue(invocationType);
}
/**
*
* The invocation type of the Amazon Web Services Lambda function. An invocation type of
* RequestResponse
means that the execution of the function immediately results in a response, and a
* value of Event
means that the function is invoked asynchronously. The default value is
* Event
. For information about Amazon Web Services Lambda invocation types, see the Amazon Web Services Lambda Developer
* Guide.
*
*
*
* There is a 30-second timeout on RequestResponse
invocations. You should use Event
* invocation in most cases. Use RequestResponse
only to make a mail flow decision, such as whether to
* stop the receipt rule or the receipt rule set.
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #invocationType}
* will return {@link InvocationType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #invocationTypeAsString}.
*
*
* @return The invocation type of the Amazon Web Services Lambda function. An invocation type of
* RequestResponse
means that the execution of the function immediately results in a response,
* and a value of Event
means that the function is invoked asynchronously. The default value is
* Event
. For information about Amazon Web Services Lambda invocation types, see the Amazon Web Services Lambda Developer
* Guide.
*
* There is a 30-second timeout on RequestResponse
invocations. You should use
* Event
invocation in most cases. Use RequestResponse
only to make a mail flow
* decision, such as whether to stop the receipt rule or the receipt rule set.
*
* @see InvocationType
*/
public final String invocationTypeAsString() {
return invocationType;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(topicArn());
hashCode = 31 * hashCode + Objects.hashCode(functionArn());
hashCode = 31 * hashCode + Objects.hashCode(invocationTypeAsString());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof LambdaAction)) {
return false;
}
LambdaAction other = (LambdaAction) obj;
return Objects.equals(topicArn(), other.topicArn()) && Objects.equals(functionArn(), other.functionArn())
&& Objects.equals(invocationTypeAsString(), other.invocationTypeAsString());
}
/**
* 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 final String toString() {
return ToString.builder("LambdaAction").add("TopicArn", topicArn()).add("FunctionArn", functionArn())
.add("InvocationType", invocationTypeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TopicArn":
return Optional.ofNullable(clazz.cast(topicArn()));
case "FunctionArn":
return Optional.ofNullable(clazz.cast(functionArn()));
case "InvocationType":
return Optional.ofNullable(clazz.cast(invocationTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function