software.amazon.awssdk.services.ses.model.SendTemplatedEmailRequest 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.beans.Transient;
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 templated email using Amazon SES. For more information, see the Amazon SES Developer
* Guide.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SendTemplatedEmailRequest extends SesRequest implements
ToCopyableBuilder {
private static final SdkField SOURCE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Source")
.getter(getter(SendTemplatedEmailRequest::source)).setter(setter(Builder::source))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Source").build()).build();
private static final SdkField DESTINATION_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Destination").getter(getter(SendTemplatedEmailRequest::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(SendTemplatedEmailRequest::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 RETURN_PATH_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReturnPath").getter(getter(SendTemplatedEmailRequest::returnPath)).setter(setter(Builder::returnPath))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReturnPath").build()).build();
private static final SdkField SOURCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SourceArn").getter(getter(SendTemplatedEmailRequest::sourceArn)).setter(setter(Builder::sourceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceArn").build()).build();
private static final SdkField RETURN_PATH_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReturnPathArn").getter(getter(SendTemplatedEmailRequest::returnPathArn))
.setter(setter(Builder::returnPathArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReturnPathArn").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Tags")
.getter(getter(SendTemplatedEmailRequest::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").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(SendTemplatedEmailRequest::configurationSetName))
.setter(setter(Builder::configurationSetName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConfigurationSetName").build())
.build();
private static final SdkField TEMPLATE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Template").getter(getter(SendTemplatedEmailRequest::template)).setter(setter(Builder::template))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Template").build()).build();
private static final SdkField TEMPLATE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TemplateArn").getter(getter(SendTemplatedEmailRequest::templateArn))
.setter(setter(Builder::templateArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TemplateArn").build()).build();
private static final SdkField TEMPLATE_DATA_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TemplateData").getter(getter(SendTemplatedEmailRequest::templateData))
.setter(setter(Builder::templateData))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TemplateData").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SOURCE_FIELD,
DESTINATION_FIELD, REPLY_TO_ADDRESSES_FIELD, RETURN_PATH_FIELD, SOURCE_ARN_FIELD, RETURN_PATH_ARN_FIELD, TAGS_FIELD,
CONFIGURATION_SET_NAME_FIELD, TEMPLATE_FIELD, TEMPLATE_ARN_FIELD, TEMPLATE_DATA_FIELD));
private final String source;
private final Destination destination;
private final List replyToAddresses;
private final String returnPath;
private final String sourceArn;
private final String returnPathArn;
private final List tags;
private final String configurationSetName;
private final String template;
private final String templateArn;
private final String templateData;
private SendTemplatedEmailRequest(BuilderImpl builder) {
super(builder);
this.source = builder.source;
this.destination = builder.destination;
this.replyToAddresses = builder.replyToAddresses;
this.returnPath = builder.returnPath;
this.sourceArn = builder.sourceArn;
this.returnPathArn = builder.returnPathArn;
this.tags = builder.tags;
this.configurationSetName = builder.configurationSetName;
this.template = builder.template;
this.templateArn = builder.templateArn;
this.templateData = builder.templateData;
}
/**
*
* The email address that is sending the email. This email address must be either individually verified with Amazon
* SES, or from a domain that has been verified with Amazon SES. For information about verifying identities, see the
* Amazon SES
* Developer Guide.
*
*
* If you are sending on behalf of another user and have been permitted to do so by a sending authorization policy,
* then you must also specify the SourceArn
parameter. For more information about sending
* authorization, see the Amazon SES Developer
* Guide.
*
*
*
* Amazon SES does not support the SMTPUTF8 extension, as described in RFC6531. For this reason, the local part of a source email
* address (the part of the email address that precedes the @ sign) may only contain 7-bit ASCII characters. If the domain
* part of an address (the part after the @ sign) contains non-ASCII characters, they must be encoded using
* Punycode, as described in RFC3492. The sender name (also
* known as the friendly name) may contain non-ASCII characters. These characters must be encoded using MIME
* encoded-word syntax, as described inRFC 2047. MIME encoded-word
* syntax uses the following form: =?charset?encoding?encoded-text?=
.
*
*
*
* @return The email address that is sending the email. This email address must be either individually verified with
* Amazon SES, or from a domain that has been verified with Amazon SES. For information about verifying
* identities, see the Amazon SES
* Developer Guide.
*
* If you are sending on behalf of another user and have been permitted to do so by a sending authorization
* policy, then you must also specify the SourceArn
parameter. For more information about
* sending authorization, see the Amazon SES
* Developer Guide.
*
*
*
* Amazon SES does not support the SMTPUTF8 extension, as described in RFC6531. For this reason, the local part of a
* source email address (the part of the email address that precedes the @ sign) may only contain 7-bit ASCII characters. If the
* domain part of an address (the part after the @ sign) contains non-ASCII characters, they must be
* encoded using Punycode, as described in RFC3492.
* The sender name (also known as the friendly name) may contain non-ASCII characters. These
* characters must be encoded using MIME encoded-word syntax, as described inRFC 2047. MIME encoded-word syntax uses the following
* form: =?charset?encoding?encoded-text?=
.
*
*/
public final String source() {
return source;
}
/**
*
* The destination for this email, composed of To:, CC:, and BCC: fields. A Destination can include up to 50
* recipients across these three fields.
*
*
* @return The destination for this email, composed of To:, CC:, and BCC: fields. A Destination can include up to 50
* recipients across these three fields.
*/
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 address(es) for the message. If the recipient replies to the message, each reply-to address
* will receive 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 address(es) for the message. If the recipient replies to the message, each reply-to
* address will receive the reply.
*/
public final List replyToAddresses() {
return replyToAddresses;
}
/**
*
* The email address that bounces and complaints will be forwarded to when feedback forwarding is enabled. If the
* message cannot be delivered to the recipient, then an error message will be returned from the recipient's ISP;
* this message will then be forwarded to the email address specified by the ReturnPath
parameter. The
* ReturnPath
parameter is never overwritten. This email address must be either individually verified
* with Amazon SES, or from a domain that has been verified with Amazon SES.
*
*
* @return The email address that bounces and complaints will be forwarded to when feedback forwarding is enabled.
* If the message cannot be delivered to the recipient, then an error message will be returned from the
* recipient's ISP; this message will then be forwarded to the email address specified by the
* ReturnPath
parameter. The ReturnPath
parameter is never overwritten. This email
* address must be either individually verified with Amazon SES, or from a domain that has been verified
* with Amazon SES.
*/
public final String returnPath() {
return returnPath;
}
/**
*
* 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 send for the email address specified in the Source
* 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 send from [email protected]
, then you would specify the SourceArn
to be
* arn:aws:ses:us-east-1:123456789012:identity/example.com
, and the Source
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 send for the email address specified in the
* Source
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 send from [email protected]
, then you would specify the
* SourceArn
to be arn:aws:ses:us-east-1:123456789012:identity/example.com
, and
* the Source
to be [email protected]
.
*
*
* For more information about sending authorization, see the Amazon SES
* Developer Guide.
*/
public final String sourceArn() {
return sourceArn;
}
/**
*
* 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 ReturnPath
* 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 ReturnPathArn
to be
* arn:aws:ses:us-east-1:123456789012:identity/example.com
, and the ReturnPath
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
* ReturnPath
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
* ReturnPathArn
to be arn:aws:ses:us-east-1:123456789012:identity/example.com
,
* and the ReturnPath
to be [email protected]
.
*
*
* For more information about sending authorization, see the Amazon SES
* Developer Guide.
*/
public final String returnPathArn() {
return returnPathArn;
}
/**
* For responses, this returns true if the service returned a value for the Tags 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 hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructList);
}
/**
*
* A list of tags, in the form of name/value pairs, to apply to an email that you send using
* SendTemplatedEmail
. 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 #hasTags} method.
*
*
* @return A list of tags, in the form of name/value pairs, to apply to an email that you send using
* SendTemplatedEmail
. Tags correspond to characteristics of the email that you define, so that
* you can publish email sending events.
*/
public final List tags() {
return tags;
}
/**
*
* The name of the configuration set to use when you send an email using SendTemplatedEmail
.
*
*
* @return The name of the configuration set to use when you send an email using SendTemplatedEmail
.
*/
public final String configurationSetName() {
return configurationSetName;
}
/**
*
* The template to use when sending this email.
*
*
* @return The template to use when sending this email.
*/
public final String template() {
return template;
}
/**
*
* The ARN of the template to use when sending this email.
*
*
* @return The ARN of the template to use when sending this email.
*/
public final String templateArn() {
return templateArn;
}
/**
*
* A list of replacement values to apply to the template. This parameter is a JSON object, typically consisting of
* key-value pairs in which the keys correspond to replacement tags in the email template.
*
*
* @return A list of replacement values to apply to the template. This parameter is a JSON object, typically
* consisting of key-value pairs in which the keys correspond to replacement tags in the email template.
*/
public final String templateData() {
return templateData;
}
@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(source());
hashCode = 31 * hashCode + Objects.hashCode(destination());
hashCode = 31 * hashCode + Objects.hashCode(hasReplyToAddresses() ? replyToAddresses() : null);
hashCode = 31 * hashCode + Objects.hashCode(returnPath());
hashCode = 31 * hashCode + Objects.hashCode(sourceArn());
hashCode = 31 * hashCode + Objects.hashCode(returnPathArn());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
hashCode = 31 * hashCode + Objects.hashCode(configurationSetName());
hashCode = 31 * hashCode + Objects.hashCode(template());
hashCode = 31 * hashCode + Objects.hashCode(templateArn());
hashCode = 31 * hashCode + Objects.hashCode(templateData());
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 SendTemplatedEmailRequest)) {
return false;
}
SendTemplatedEmailRequest other = (SendTemplatedEmailRequest) obj;
return Objects.equals(source(), other.source()) && Objects.equals(destination(), other.destination())
&& hasReplyToAddresses() == other.hasReplyToAddresses()
&& Objects.equals(replyToAddresses(), other.replyToAddresses())
&& Objects.equals(returnPath(), other.returnPath()) && Objects.equals(sourceArn(), other.sourceArn())
&& Objects.equals(returnPathArn(), other.returnPathArn()) && hasTags() == other.hasTags()
&& Objects.equals(tags(), other.tags()) && Objects.equals(configurationSetName(), other.configurationSetName())
&& Objects.equals(template(), other.template()) && Objects.equals(templateArn(), other.templateArn())
&& Objects.equals(templateData(), other.templateData());
}
/**
* 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("SendTemplatedEmailRequest").add("Source", source()).add("Destination", destination())
.add("ReplyToAddresses", hasReplyToAddresses() ? replyToAddresses() : null).add("ReturnPath", returnPath())
.add("SourceArn", sourceArn()).add("ReturnPathArn", returnPathArn()).add("Tags", hasTags() ? tags() : null)
.add("ConfigurationSetName", configurationSetName()).add("Template", template())
.add("TemplateArn", templateArn()).add("TemplateData", templateData()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Source":
return Optional.ofNullable(clazz.cast(source()));
case "Destination":
return Optional.ofNullable(clazz.cast(destination()));
case "ReplyToAddresses":
return Optional.ofNullable(clazz.cast(replyToAddresses()));
case "ReturnPath":
return Optional.ofNullable(clazz.cast(returnPath()));
case "SourceArn":
return Optional.ofNullable(clazz.cast(sourceArn()));
case "ReturnPathArn":
return Optional.ofNullable(clazz.cast(returnPathArn()));
case "Tags":
return Optional.ofNullable(clazz.cast(tags()));
case "ConfigurationSetName":
return Optional.ofNullable(clazz.cast(configurationSetName()));
case "Template":
return Optional.ofNullable(clazz.cast(template()));
case "TemplateArn":
return Optional.ofNullable(clazz.cast(templateArn()));
case "TemplateData":
return Optional.ofNullable(clazz.cast(templateData()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function