
software.amazon.awssdk.services.sesv2.model.SendBulkEmailRequest 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 email messages to multiple destinations using Amazon SES. For more information, see the
* Amazon SES Developer
* Guide.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SendBulkEmailRequest extends SesV2Request implements
ToCopyableBuilder {
private static final SdkField FROM_EMAIL_ADDRESS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("FromEmailAddress").getter(getter(SendBulkEmailRequest::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(SendBulkEmailRequest::fromEmailAddressIdentityArn))
.setter(setter(Builder::fromEmailAddressIdentityArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FromEmailAddressIdentityArn")
.build()).build();
private static final SdkField> REPLY_TO_ADDRESSES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ReplyToAddresses")
.getter(getter(SendBulkEmailRequest::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(SendBulkEmailRequest::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(SendBulkEmailRequest::feedbackForwardingEmailAddressIdentityArn))
.setter(setter(Builder::feedbackForwardingEmailAddressIdentityArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("FeedbackForwardingEmailAddressIdentityArn").build()).build();
private static final SdkField> DEFAULT_EMAIL_TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("DefaultEmailTags")
.getter(getter(SendBulkEmailRequest::defaultEmailTags))
.setter(setter(Builder::defaultEmailTags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DefaultEmailTags").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 DEFAULT_CONTENT_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("DefaultContent")
.getter(getter(SendBulkEmailRequest::defaultContent)).setter(setter(Builder::defaultContent))
.constructor(BulkEmailContent::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DefaultContent").build()).build();
private static final SdkField> BULK_EMAIL_ENTRIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("BulkEmailEntries")
.getter(getter(SendBulkEmailRequest::bulkEmailEntries))
.setter(setter(Builder::bulkEmailEntries))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BulkEmailEntries").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(BulkEmailEntry::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(SendBulkEmailRequest::configurationSetName))
.setter(setter(Builder::configurationSetName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConfigurationSetName").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FROM_EMAIL_ADDRESS_FIELD,
FROM_EMAIL_ADDRESS_IDENTITY_ARN_FIELD, REPLY_TO_ADDRESSES_FIELD, FEEDBACK_FORWARDING_EMAIL_ADDRESS_FIELD,
FEEDBACK_FORWARDING_EMAIL_ADDRESS_IDENTITY_ARN_FIELD, DEFAULT_EMAIL_TAGS_FIELD, DEFAULT_CONTENT_FIELD,
BULK_EMAIL_ENTRIES_FIELD, CONFIGURATION_SET_NAME_FIELD));
private final String fromEmailAddress;
private final String fromEmailAddressIdentityArn;
private final List replyToAddresses;
private final String feedbackForwardingEmailAddress;
private final String feedbackForwardingEmailAddressIdentityArn;
private final List defaultEmailTags;
private final BulkEmailContent defaultContent;
private final List bulkEmailEntries;
private final String configurationSetName;
private SendBulkEmailRequest(BuilderImpl builder) {
super(builder);
this.fromEmailAddress = builder.fromEmailAddress;
this.fromEmailAddressIdentityArn = builder.fromEmailAddressIdentityArn;
this.replyToAddresses = builder.replyToAddresses;
this.feedbackForwardingEmailAddress = builder.feedbackForwardingEmailAddress;
this.feedbackForwardingEmailAddressIdentityArn = builder.feedbackForwardingEmailAddressIdentityArn;
this.defaultEmailTags = builder.defaultEmailTags;
this.defaultContent = builder.defaultContent;
this.bulkEmailEntries = builder.bulkEmailEntries;
this.configurationSetName = builder.configurationSetName;
}
/**
*
* 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.
*
*
* @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.
*/
public final String fromEmailAddressIdentityArn() {
return fromEmailAddressIdentityArn;
}
/**
* 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;
}
/**
* For responses, this returns true if the service returned a value for the DefaultEmailTags 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 hasDefaultEmailTags() {
return defaultEmailTags != null && !(defaultEmailTags 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 #hasDefaultEmailTags} 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 defaultEmailTags() {
return defaultEmailTags;
}
/**
*
* An object that contains the body of the message. You can specify a template message.
*
*
* @return An object that contains the body of the message. You can specify a template message.
*/
public final BulkEmailContent defaultContent() {
return defaultContent;
}
/**
* For responses, this returns true if the service returned a value for the BulkEmailEntries 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 hasBulkEmailEntries() {
return bulkEmailEntries != null && !(bulkEmailEntries instanceof SdkAutoConstructList);
}
/**
*
* The list of bulk email entry objects.
*
*
* 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 #hasBulkEmailEntries} method.
*
*
* @return The list of bulk email entry objects.
*/
public final List bulkEmailEntries() {
return bulkEmailEntries;
}
/**
*
* 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;
}
@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(hasReplyToAddresses() ? replyToAddresses() : null);
hashCode = 31 * hashCode + Objects.hashCode(feedbackForwardingEmailAddress());
hashCode = 31 * hashCode + Objects.hashCode(feedbackForwardingEmailAddressIdentityArn());
hashCode = 31 * hashCode + Objects.hashCode(hasDefaultEmailTags() ? defaultEmailTags() : null);
hashCode = 31 * hashCode + Objects.hashCode(defaultContent());
hashCode = 31 * hashCode + Objects.hashCode(hasBulkEmailEntries() ? bulkEmailEntries() : null);
hashCode = 31 * hashCode + Objects.hashCode(configurationSetName());
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 SendBulkEmailRequest)) {
return false;
}
SendBulkEmailRequest other = (SendBulkEmailRequest) obj;
return Objects.equals(fromEmailAddress(), other.fromEmailAddress())
&& Objects.equals(fromEmailAddressIdentityArn(), other.fromEmailAddressIdentityArn())
&& hasReplyToAddresses() == other.hasReplyToAddresses()
&& Objects.equals(replyToAddresses(), other.replyToAddresses())
&& Objects.equals(feedbackForwardingEmailAddress(), other.feedbackForwardingEmailAddress())
&& Objects.equals(feedbackForwardingEmailAddressIdentityArn(), other.feedbackForwardingEmailAddressIdentityArn())
&& hasDefaultEmailTags() == other.hasDefaultEmailTags()
&& Objects.equals(defaultEmailTags(), other.defaultEmailTags())
&& Objects.equals(defaultContent(), other.defaultContent())
&& hasBulkEmailEntries() == other.hasBulkEmailEntries()
&& Objects.equals(bulkEmailEntries(), other.bulkEmailEntries())
&& Objects.equals(configurationSetName(), other.configurationSetName());
}
/**
* 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("SendBulkEmailRequest").add("FromEmailAddress", fromEmailAddress())
.add("FromEmailAddressIdentityArn", fromEmailAddressIdentityArn())
.add("ReplyToAddresses", hasReplyToAddresses() ? replyToAddresses() : null)
.add("FeedbackForwardingEmailAddress", feedbackForwardingEmailAddress())
.add("FeedbackForwardingEmailAddressIdentityArn", feedbackForwardingEmailAddressIdentityArn())
.add("DefaultEmailTags", hasDefaultEmailTags() ? defaultEmailTags() : null)
.add("DefaultContent", defaultContent())
.add("BulkEmailEntries", hasBulkEmailEntries() ? bulkEmailEntries() : null)
.add("ConfigurationSetName", configurationSetName()).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 "ReplyToAddresses":
return Optional.ofNullable(clazz.cast(replyToAddresses()));
case "FeedbackForwardingEmailAddress":
return Optional.ofNullable(clazz.cast(feedbackForwardingEmailAddress()));
case "FeedbackForwardingEmailAddressIdentityArn":
return Optional.ofNullable(clazz.cast(feedbackForwardingEmailAddressIdentityArn()));
case "DefaultEmailTags":
return Optional.ofNullable(clazz.cast(defaultEmailTags()));
case "DefaultContent":
return Optional.ofNullable(clazz.cast(defaultContent()));
case "BulkEmailEntries":
return Optional.ofNullable(clazz.cast(bulkEmailEntries()));
case "ConfigurationSetName":
return Optional.ofNullable(clazz.cast(configurationSetName()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function