software.amazon.awssdk.services.ses.model.BounceAction Maven / Gradle / Ivy
Show all versions of ses Show documentation
/*
* 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.beans.Transient;
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 rejects the received email by returning a bounce response to the sender
* and, optionally, publishes a notification to Amazon Simple Notification Service (Amazon SNS).
*
*
* For information about sending a bounce message in response to a received email, see the Amazon SES Developer
* Guide.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class BounceAction implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField TOPIC_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TopicArn").getter(getter(BounceAction::topicArn)).setter(setter(Builder::topicArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TopicArn").build()).build();
private static final SdkField SMTP_REPLY_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SmtpReplyCode").getter(getter(BounceAction::smtpReplyCode)).setter(setter(Builder::smtpReplyCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SmtpReplyCode").build()).build();
private static final SdkField STATUS_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StatusCode").getter(getter(BounceAction::statusCode)).setter(setter(Builder::statusCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusCode").build()).build();
private static final SdkField MESSAGE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Message")
.getter(getter(BounceAction::message)).setter(setter(Builder::message))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Message").build()).build();
private static final SdkField SENDER_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Sender")
.getter(getter(BounceAction::sender)).setter(setter(Builder::sender))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Sender").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TOPIC_ARN_FIELD,
SMTP_REPLY_CODE_FIELD, STATUS_CODE_FIELD, MESSAGE_FIELD, SENDER_FIELD));
private static final long serialVersionUID = 1L;
private final String topicArn;
private final String smtpReplyCode;
private final String statusCode;
private final String message;
private final String sender;
private BounceAction(BuilderImpl builder) {
this.topicArn = builder.topicArn;
this.smtpReplyCode = builder.smtpReplyCode;
this.statusCode = builder.statusCode;
this.message = builder.message;
this.sender = builder.sender;
}
/**
*
* The Amazon Resource Name (ARN) of the Amazon SNS topic to notify when the bounce action is taken. An example of
* an Amazon SNS topic ARN is arn:aws:sns:us-west-2:123456789012:MyTopic
. 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 bounce action is taken. An
* example of an Amazon SNS topic ARN is arn:aws:sns:us-west-2:123456789012:MyTopic
. For more
* information about Amazon SNS topics, see the Amazon SNS Developer Guide.
*/
public final String topicArn() {
return topicArn;
}
/**
*
* The SMTP reply code, as defined by RFC 5321.
*
*
* @return The SMTP reply code, as defined by RFC 5321.
*/
public final String smtpReplyCode() {
return smtpReplyCode;
}
/**
*
* The SMTP enhanced status code, as defined by RFC 3463.
*
*
* @return The SMTP enhanced status code, as defined by RFC 3463.
*/
public final String statusCode() {
return statusCode;
}
/**
*
* Human-readable text to include in the bounce message.
*
*
* @return Human-readable text to include in the bounce message.
*/
public final String message() {
return message;
}
/**
*
* The email address of the sender of the bounced email. This is the address from which the bounce message will be
* sent.
*
*
* @return The email address of the sender of the bounced email. This is the address from which the bounce message
* will be sent.
*/
public final String sender() {
return sender;
}
@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(smtpReplyCode());
hashCode = 31 * hashCode + Objects.hashCode(statusCode());
hashCode = 31 * hashCode + Objects.hashCode(message());
hashCode = 31 * hashCode + Objects.hashCode(sender());
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 BounceAction)) {
return false;
}
BounceAction other = (BounceAction) obj;
return Objects.equals(topicArn(), other.topicArn()) && Objects.equals(smtpReplyCode(), other.smtpReplyCode())
&& Objects.equals(statusCode(), other.statusCode()) && Objects.equals(message(), other.message())
&& Objects.equals(sender(), other.sender());
}
/**
* 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("BounceAction").add("TopicArn", topicArn()).add("SmtpReplyCode", smtpReplyCode())
.add("StatusCode", statusCode()).add("Message", message()).add("Sender", sender()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "TopicArn":
return Optional.ofNullable(clazz.cast(topicArn()));
case "SmtpReplyCode":
return Optional.ofNullable(clazz.cast(smtpReplyCode()));
case "StatusCode":
return Optional.ofNullable(clazz.cast(statusCode()));
case "Message":
return Optional.ofNullable(clazz.cast(message()));
case "Sender":
return Optional.ofNullable(clazz.cast(sender()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function