software.amazon.awssdk.services.ses.model.SendBounceRequest 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.util.Arrays;
import java.util.Collection;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents a request to send a bounce message to the sender of an email you received through Amazon SES.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SendBounceRequest extends SesRequest implements
ToCopyableBuilder {
private static final SdkField ORIGINAL_MESSAGE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("OriginalMessageId").getter(getter(SendBounceRequest::originalMessageId))
.setter(setter(Builder::originalMessageId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginalMessageId").build()).build();
private static final SdkField BOUNCE_SENDER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("BounceSender").getter(getter(SendBounceRequest::bounceSender)).setter(setter(Builder::bounceSender))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BounceSender").build()).build();
private static final SdkField EXPLANATION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Explanation").getter(getter(SendBounceRequest::explanation)).setter(setter(Builder::explanation))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Explanation").build()).build();
private static final SdkField MESSAGE_DSN_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("MessageDsn").getter(getter(SendBounceRequest::messageDsn)).setter(setter(Builder::messageDsn))
.constructor(MessageDsn::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MessageDsn").build()).build();
private static final SdkField> BOUNCED_RECIPIENT_INFO_LIST_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("BouncedRecipientInfoList")
.getter(getter(SendBounceRequest::bouncedRecipientInfoList))
.setter(setter(Builder::bouncedRecipientInfoList))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BouncedRecipientInfoList").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(BouncedRecipientInfo::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField BOUNCE_SENDER_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("BounceSenderArn").getter(getter(SendBounceRequest::bounceSenderArn))
.setter(setter(Builder::bounceSenderArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BounceSenderArn").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays
.asList(ORIGINAL_MESSAGE_ID_FIELD, BOUNCE_SENDER_FIELD, EXPLANATION_FIELD, MESSAGE_DSN_FIELD,
BOUNCED_RECIPIENT_INFO_LIST_FIELD, BOUNCE_SENDER_ARN_FIELD));
private final String originalMessageId;
private final String bounceSender;
private final String explanation;
private final MessageDsn messageDsn;
private final List bouncedRecipientInfoList;
private final String bounceSenderArn;
private SendBounceRequest(BuilderImpl builder) {
super(builder);
this.originalMessageId = builder.originalMessageId;
this.bounceSender = builder.bounceSender;
this.explanation = builder.explanation;
this.messageDsn = builder.messageDsn;
this.bouncedRecipientInfoList = builder.bouncedRecipientInfoList;
this.bounceSenderArn = builder.bounceSenderArn;
}
/**
*
* The message ID of the message to be bounced.
*
*
* @return The message ID of the message to be bounced.
*/
public final String originalMessageId() {
return originalMessageId;
}
/**
*
* The address to use in the "From" header of the bounce message. This must be an identity that you have verified
* with Amazon SES.
*
*
* @return The address to use in the "From" header of the bounce message. This must be an identity that you have
* verified with Amazon SES.
*/
public final String bounceSender() {
return bounceSender;
}
/**
*
* Human-readable text for the bounce message to explain the failure. If not specified, the text will be
* auto-generated based on the bounced recipient information.
*
*
* @return Human-readable text for the bounce message to explain the failure. If not specified, the text will be
* auto-generated based on the bounced recipient information.
*/
public final String explanation() {
return explanation;
}
/**
*
* Message-related DSN fields. If not specified, Amazon SES will choose the values.
*
*
* @return Message-related DSN fields. If not specified, Amazon SES will choose the values.
*/
public final MessageDsn messageDsn() {
return messageDsn;
}
/**
* For responses, this returns true if the service returned a value for the BouncedRecipientInfoList property. This
* DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the
* property). This is useful because the SDK will never return a null collection or map, but you may need to
* differentiate between the service returning nothing (or null) and the service returning an empty collection or
* map. For requests, this returns true if a value for the property was specified in the request builder, and false
* if a value was not specified.
*/
public final boolean hasBouncedRecipientInfoList() {
return bouncedRecipientInfoList != null && !(bouncedRecipientInfoList instanceof SdkAutoConstructList);
}
/**
*
* A list of recipients of the bounced message, including the information required to create the Delivery Status
* Notifications (DSNs) for the recipients. You must specify at least one BouncedRecipientInfo
in the
* list.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasBouncedRecipientInfoList} method.
*
*
* @return A list of recipients of the bounced message, including the information required to create the Delivery
* Status Notifications (DSNs) for the recipients. You must specify at least one
* BouncedRecipientInfo
in the list.
*/
public final List bouncedRecipientInfoList() {
return bouncedRecipientInfoList;
}
/**
*
* This parameter is used only for sending authorization. It is the ARN of the identity that is associated with the
* sending authorization policy that permits you to use the address in the "From" header of the bounce. For more
* information about sending authorization, see the Amazon SES Developer
* Guide.
*
*
* @return This parameter is used only for sending authorization. It is the ARN of the identity that is associated
* with the sending authorization policy that permits you to use the address in the "From" header of the
* bounce. For more information about sending authorization, see the Amazon SES
* Developer Guide.
*/
public final String bounceSenderArn() {
return bounceSenderArn;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(originalMessageId());
hashCode = 31 * hashCode + Objects.hashCode(bounceSender());
hashCode = 31 * hashCode + Objects.hashCode(explanation());
hashCode = 31 * hashCode + Objects.hashCode(messageDsn());
hashCode = 31 * hashCode + Objects.hashCode(hasBouncedRecipientInfoList() ? bouncedRecipientInfoList() : null);
hashCode = 31 * hashCode + Objects.hashCode(bounceSenderArn());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SendBounceRequest)) {
return false;
}
SendBounceRequest other = (SendBounceRequest) obj;
return Objects.equals(originalMessageId(), other.originalMessageId())
&& Objects.equals(bounceSender(), other.bounceSender()) && Objects.equals(explanation(), other.explanation())
&& Objects.equals(messageDsn(), other.messageDsn())
&& hasBouncedRecipientInfoList() == other.hasBouncedRecipientInfoList()
&& Objects.equals(bouncedRecipientInfoList(), other.bouncedRecipientInfoList())
&& Objects.equals(bounceSenderArn(), other.bounceSenderArn());
}
/**
* 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("SendBounceRequest").add("OriginalMessageId", originalMessageId())
.add("BounceSender", bounceSender()).add("Explanation", explanation()).add("MessageDsn", messageDsn())
.add("BouncedRecipientInfoList", hasBouncedRecipientInfoList() ? bouncedRecipientInfoList() : null)
.add("BounceSenderArn", bounceSenderArn()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "OriginalMessageId":
return Optional.ofNullable(clazz.cast(originalMessageId()));
case "BounceSender":
return Optional.ofNullable(clazz.cast(bounceSender()));
case "Explanation":
return Optional.ofNullable(clazz.cast(explanation()));
case "MessageDsn":
return Optional.ofNullable(clazz.cast(messageDsn()));
case "BouncedRecipientInfoList":
return Optional.ofNullable(clazz.cast(bouncedRecipientInfoList()));
case "BounceSenderArn":
return Optional.ofNullable(clazz.cast(bounceSenderArn()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function