
software.amazon.awssdk.services.sesv2.model.SendEmailRequest 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.sesv2.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 single formatted email using Amazon SES. For more information, see the Amazon SES Developer
* Guide.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SendEmailRequest extends SesV2Request implements ToCopyableBuilder {
private static final SdkField FROM_EMAIL_ADDRESS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("FromEmailAddress").getter(getter(SendEmailRequest::fromEmailAddress))
.setter(setter(Builder::fromEmailAddress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FromEmailAddress").build()).build();
private static final SdkField FROM_EMAIL_ADDRESS_IDENTITY_ARN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("FromEmailAddressIdentityArn")
.getter(getter(SendEmailRequest::fromEmailAddressIdentityArn))
.setter(setter(Builder::fromEmailAddressIdentityArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FromEmailAddressIdentityArn")
.build()).build();
private static final SdkField DESTINATION_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Destination").getter(getter(SendEmailRequest::destination)).setter(setter(Builder::destination))
.constructor(Destination::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Destination").build()).build();
private static final SdkField> REPLY_TO_ADDRESSES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ReplyToAddresses")
.getter(getter(SendEmailRequest::replyToAddresses))
.setter(setter(Builder::replyToAddresses))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplyToAddresses").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField FEEDBACK_FORWARDING_EMAIL_ADDRESS_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("FeedbackForwardingEmailAddress")
.getter(getter(SendEmailRequest::feedbackForwardingEmailAddress))
.setter(setter(Builder::feedbackForwardingEmailAddress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FeedbackForwardingEmailAddress")
.build()).build();
private static final SdkField FEEDBACK_FORWARDING_EMAIL_ADDRESS_IDENTITY_ARN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("FeedbackForwardingEmailAddressIdentityArn")
.getter(getter(SendEmailRequest::feedbackForwardingEmailAddressIdentityArn))
.setter(setter(Builder::feedbackForwardingEmailAddressIdentityArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("FeedbackForwardingEmailAddressIdentityArn").build()).build();
private static final SdkField CONTENT_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Content").getter(getter(SendEmailRequest::content)).setter(setter(Builder::content))
.constructor(EmailContent::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Content").build()).build();
private static final SdkField> EMAIL_TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("EmailTags")
.getter(getter(SendEmailRequest::emailTags))
.setter(setter(Builder::emailTags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EmailTags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(MessageTag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField CONFIGURATION_SET_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ConfigurationSetName").getter(getter(SendEmailRequest::configurationSetName))
.setter(setter(Builder::configurationSetName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConfigurationSetName").build())
.build();
private static final SdkField LIST_MANAGEMENT_OPTIONS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ListManagementOptions")
.getter(getter(SendEmailRequest::listManagementOptions)).setter(setter(Builder::listManagementOptions))
.constructor(ListManagementOptions::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListManagementOptions").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FROM_EMAIL_ADDRESS_FIELD,
FROM_EMAIL_ADDRESS_IDENTITY_ARN_FIELD, DESTINATION_FIELD, REPLY_TO_ADDRESSES_FIELD,
FEEDBACK_FORWARDING_EMAIL_ADDRESS_FIELD, FEEDBACK_FORWARDING_EMAIL_ADDRESS_IDENTITY_ARN_FIELD, CONTENT_FIELD,
EMAIL_TAGS_FIELD, CONFIGURATION_SET_NAME_FIELD, LIST_MANAGEMENT_OPTIONS_FIELD));
private final String fromEmailAddress;
private final String fromEmailAddressIdentityArn;
private final Destination destination;
private final List replyToAddresses;
private final String feedbackForwardingEmailAddress;
private final String feedbackForwardingEmailAddressIdentityArn;
private final EmailContent content;
private final List emailTags;
private final String configurationSetName;
private final ListManagementOptions listManagementOptions;
private SendEmailRequest(BuilderImpl builder) {
super(builder);
this.fromEmailAddress = builder.fromEmailAddress;
this.fromEmailAddressIdentityArn = builder.fromEmailAddressIdentityArn;
this.destination = builder.destination;
this.replyToAddresses = builder.replyToAddresses;
this.feedbackForwardingEmailAddress = builder.feedbackForwardingEmailAddress;
this.feedbackForwardingEmailAddressIdentityArn = builder.feedbackForwardingEmailAddressIdentityArn;
this.content = builder.content;
this.emailTags = builder.emailTags;
this.configurationSetName = builder.configurationSetName;
this.listManagementOptions = builder.listManagementOptions;
}
/**
*
* The email address to use as the "From" address for the email. The address that you specify has to be verified.
*
*
* @return The email address to use as the "From" address for the email. The address that you specify has to be
* verified.
*/
public final String fromEmailAddress() {
return fromEmailAddress;
}
/**
*
* 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 email address specified in the
* FromEmailAddress
parameter.
*
*
* For example, if the owner of example.com (which has ARN arn:aws:ses:us-east-1:123456789012:identity/example.com)
* attaches a policy to it that authorizes you to use [email protected], then you would specify the
* FromEmailAddressIdentityArn
to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and the
* FromEmailAddress
to be [email protected].
*
*
* For more information about sending authorization, see the Amazon SES Developer
* Guide.
*
*
* For Raw emails, the FromEmailAddressIdentityArn
value overrides the X-SES-SOURCE-ARN and
* X-SES-FROM-ARN headers specified in raw email message content.
*
*
* @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 email address specified in the
* FromEmailAddress
parameter.
*
* For example, if the owner of example.com (which has ARN
* arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it that authorizes you to
* use [email protected], then you would specify the FromEmailAddressIdentityArn
to be
* arn:aws:ses:us-east-1:123456789012:identity/example.com, and the FromEmailAddress
to be
* [email protected].
*
*
* For more information about sending authorization, see the Amazon SES
* Developer Guide.
*
*
* For Raw emails, the FromEmailAddressIdentityArn
value overrides the X-SES-SOURCE-ARN and
* X-SES-FROM-ARN headers specified in raw email message content.
*/
public final String fromEmailAddressIdentityArn() {
return fromEmailAddressIdentityArn;
}
/**
*
* An object that contains the recipients of the email message.
*
*
* @return An object that contains the recipients of the email message.
*/
public final Destination destination() {
return destination;
}
/**
* For responses, this returns true if the service returned a value for the ReplyToAddresses 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 hasReplyToAddresses() {
return replyToAddresses != null && !(replyToAddresses instanceof SdkAutoConstructList);
}
/**
*
* The "Reply-to" email addresses for the message. When the recipient replies to the message, each Reply-to address
* receives the reply.
*
*
* 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 #hasReplyToAddresses} method.
*
*
* @return The "Reply-to" email addresses for the message. When the recipient replies to the message, each Reply-to
* address receives the reply.
*/
public final List replyToAddresses() {
return replyToAddresses;
}
/**
*
* The address that you want bounce and complaint notifications to be sent to.
*
*
* @return The address that you want bounce and complaint notifications to be sent to.
*/
public final String feedbackForwardingEmailAddress() {
return feedbackForwardingEmailAddress;
}
/**
*
* 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 email address specified in the
* FeedbackForwardingEmailAddress
parameter.
*
*
* For example, if the owner of example.com (which has ARN arn:aws:ses:us-east-1:123456789012:identity/example.com)
* attaches a policy to it that authorizes you to use [email protected], then you would specify the
* FeedbackForwardingEmailAddressIdentityArn
to be
* arn:aws:ses:us-east-1:123456789012:identity/example.com, and the FeedbackForwardingEmailAddress
to
* be [email protected].
*
*
* 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 email address specified in the
* FeedbackForwardingEmailAddress
parameter.
*
* For example, if the owner of example.com (which has ARN
* arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it that authorizes you to
* use [email protected], then you would specify the
* FeedbackForwardingEmailAddressIdentityArn
to be
* arn:aws:ses:us-east-1:123456789012:identity/example.com, and the
* FeedbackForwardingEmailAddress
to be [email protected].
*
*
* For more information about sending authorization, see the Amazon SES
* Developer Guide.
*/
public final String feedbackForwardingEmailAddressIdentityArn() {
return feedbackForwardingEmailAddressIdentityArn;
}
/**
*
* An object that contains the body of the message. You can send either a Simple message Raw message or a template
* Message.
*
*
* @return An object that contains the body of the message. You can send either a Simple message Raw message or a
* template Message.
*/
public final EmailContent content() {
return content;
}
/**
* For responses, this returns true if the service returned a value for the EmailTags 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 hasEmailTags() {
return emailTags != null && !(emailTags instanceof SdkAutoConstructList);
}
/**
*
* A list of tags, in the form of name/value pairs, to apply to an email that you send using the
* SendEmail
operation. Tags correspond to characteristics of the email that you define, so that you
* can publish email sending events.
*
*
* 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 #hasEmailTags} method.
*
*
* @return A list of tags, in the form of name/value pairs, to apply to an email that you send using the
* SendEmail
operation. Tags correspond to characteristics of the email that you define, so
* that you can publish email sending events.
*/
public final List emailTags() {
return emailTags;
}
/**
*
* The name of the configuration set to use when sending the email.
*
*
* @return The name of the configuration set to use when sending the email.
*/
public final String configurationSetName() {
return configurationSetName;
}
/**
*
* An object used to specify a list or topic to which an email belongs, which will be used when a contact chooses to
* unsubscribe.
*
*
* @return An object used to specify a list or topic to which an email belongs, which will be used when a contact
* chooses to unsubscribe.
*/
public final ListManagementOptions listManagementOptions() {
return listManagementOptions;
}
@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(fromEmailAddress());
hashCode = 31 * hashCode + Objects.hashCode(fromEmailAddressIdentityArn());
hashCode = 31 * hashCode + Objects.hashCode(destination());
hashCode = 31 * hashCode + Objects.hashCode(hasReplyToAddresses() ? replyToAddresses() : null);
hashCode = 31 * hashCode + Objects.hashCode(feedbackForwardingEmailAddress());
hashCode = 31 * hashCode + Objects.hashCode(feedbackForwardingEmailAddressIdentityArn());
hashCode = 31 * hashCode + Objects.hashCode(content());
hashCode = 31 * hashCode + Objects.hashCode(hasEmailTags() ? emailTags() : null);
hashCode = 31 * hashCode + Objects.hashCode(configurationSetName());
hashCode = 31 * hashCode + Objects.hashCode(listManagementOptions());
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 SendEmailRequest)) {
return false;
}
SendEmailRequest other = (SendEmailRequest) obj;
return Objects.equals(fromEmailAddress(), other.fromEmailAddress())
&& Objects.equals(fromEmailAddressIdentityArn(), other.fromEmailAddressIdentityArn())
&& Objects.equals(destination(), other.destination()) && hasReplyToAddresses() == other.hasReplyToAddresses()
&& Objects.equals(replyToAddresses(), other.replyToAddresses())
&& Objects.equals(feedbackForwardingEmailAddress(), other.feedbackForwardingEmailAddress())
&& Objects.equals(feedbackForwardingEmailAddressIdentityArn(), other.feedbackForwardingEmailAddressIdentityArn())
&& Objects.equals(content(), other.content()) && hasEmailTags() == other.hasEmailTags()
&& Objects.equals(emailTags(), other.emailTags())
&& Objects.equals(configurationSetName(), other.configurationSetName())
&& Objects.equals(listManagementOptions(), other.listManagementOptions());
}
/**
* 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("SendEmailRequest").add("FromEmailAddress", fromEmailAddress())
.add("FromEmailAddressIdentityArn", fromEmailAddressIdentityArn()).add("Destination", destination())
.add("ReplyToAddresses", hasReplyToAddresses() ? replyToAddresses() : null)
.add("FeedbackForwardingEmailAddress", feedbackForwardingEmailAddress())
.add("FeedbackForwardingEmailAddressIdentityArn", feedbackForwardingEmailAddressIdentityArn())
.add("Content", content()).add("EmailTags", hasEmailTags() ? emailTags() : null)
.add("ConfigurationSetName", configurationSetName()).add("ListManagementOptions", listManagementOptions())
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "FromEmailAddress":
return Optional.ofNullable(clazz.cast(fromEmailAddress()));
case "FromEmailAddressIdentityArn":
return Optional.ofNullable(clazz.cast(fromEmailAddressIdentityArn()));
case "Destination":
return Optional.ofNullable(clazz.cast(destination()));
case "ReplyToAddresses":
return Optional.ofNullable(clazz.cast(replyToAddresses()));
case "FeedbackForwardingEmailAddress":
return Optional.ofNullable(clazz.cast(feedbackForwardingEmailAddress()));
case "FeedbackForwardingEmailAddressIdentityArn":
return Optional.ofNullable(clazz.cast(feedbackForwardingEmailAddressIdentityArn()));
case "Content":
return Optional.ofNullable(clazz.cast(content()));
case "EmailTags":
return Optional.ofNullable(clazz.cast(emailTags()));
case "ConfigurationSetName":
return Optional.ofNullable(clazz.cast(configurationSetName()));
case "ListManagementOptions":
return Optional.ofNullable(clazz.cast(listManagementOptions()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function