All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.ses.model.RecipientDsnFields 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.io.Serializable;
import java.time.Instant;
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.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;

/**
 * 

* Recipient-related information to include in the Delivery Status Notification (DSN) when an email that Amazon SES * receives on your behalf bounces. *

*

* For information about receiving email through Amazon SES, see the Amazon SES Developer Guide. *

*/ @Generated("software.amazon.awssdk:codegen") public final class RecipientDsnFields implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField FINAL_RECIPIENT_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("FinalRecipient").getter(getter(RecipientDsnFields::finalRecipient)) .setter(setter(Builder::finalRecipient)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FinalRecipient").build()).build(); private static final SdkField ACTION_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Action") .getter(getter(RecipientDsnFields::actionAsString)).setter(setter(Builder::action)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Action").build()).build(); private static final SdkField REMOTE_MTA_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("RemoteMta").getter(getter(RecipientDsnFields::remoteMta)).setter(setter(Builder::remoteMta)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RemoteMta").build()).build(); private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status") .getter(getter(RecipientDsnFields::status)).setter(setter(Builder::status)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build(); private static final SdkField DIAGNOSTIC_CODE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("DiagnosticCode").getter(getter(RecipientDsnFields::diagnosticCode)) .setter(setter(Builder::diagnosticCode)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DiagnosticCode").build()).build(); private static final SdkField LAST_ATTEMPT_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("LastAttemptDate").getter(getter(RecipientDsnFields::lastAttemptDate)) .setter(setter(Builder::lastAttemptDate)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastAttemptDate").build()).build(); private static final SdkField> EXTENSION_FIELDS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("ExtensionFields") .getter(getter(RecipientDsnFields::extensionFields)) .setter(setter(Builder::extensionFields)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExtensionFields").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(ExtensionField::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections .unmodifiableList(Arrays.asList(FINAL_RECIPIENT_FIELD, ACTION_FIELD, REMOTE_MTA_FIELD, STATUS_FIELD, DIAGNOSTIC_CODE_FIELD, LAST_ATTEMPT_DATE_FIELD, EXTENSION_FIELDS_FIELD)); private static final long serialVersionUID = 1L; private final String finalRecipient; private final String action; private final String remoteMta; private final String status; private final String diagnosticCode; private final Instant lastAttemptDate; private final List extensionFields; private RecipientDsnFields(BuilderImpl builder) { this.finalRecipient = builder.finalRecipient; this.action = builder.action; this.remoteMta = builder.remoteMta; this.status = builder.status; this.diagnosticCode = builder.diagnosticCode; this.lastAttemptDate = builder.lastAttemptDate; this.extensionFields = builder.extensionFields; } /** *

* The email address that the message was ultimately delivered to. This corresponds to the * Final-Recipient in the DSN. If not specified, FinalRecipient will be set to the * Recipient specified in the BouncedRecipientInfo structure. Either * FinalRecipient or the recipient in BouncedRecipientInfo must be a recipient of the * original bounced message. *

* *

* Do not prepend the FinalRecipient email address with rfc 822;, as described in RFC 3798. *

*
* * @return The email address that the message was ultimately delivered to. This corresponds to the * Final-Recipient in the DSN. If not specified, FinalRecipient will be set to the * Recipient specified in the BouncedRecipientInfo structure. Either * FinalRecipient or the recipient in BouncedRecipientInfo must be a recipient of * the original bounced message.

*

* Do not prepend the FinalRecipient email address with rfc 822;, as described in * RFC 3798. *

*/ public final String finalRecipient() { return finalRecipient; } /** *

* The action performed by the reporting mail transfer agent (MTA) as a result of its attempt to deliver the message * to the recipient address. This is required by RFC 3464. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #action} will * return {@link DsnAction#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #actionAsString}. *

* * @return The action performed by the reporting mail transfer agent (MTA) as a result of its attempt to deliver the * message to the recipient address. This is required by RFC * 3464. * @see DsnAction */ public final DsnAction action() { return DsnAction.fromValue(action); } /** *

* The action performed by the reporting mail transfer agent (MTA) as a result of its attempt to deliver the message * to the recipient address. This is required by RFC 3464. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #action} will * return {@link DsnAction#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #actionAsString}. *

* * @return The action performed by the reporting mail transfer agent (MTA) as a result of its attempt to deliver the * message to the recipient address. This is required by RFC * 3464. * @see DsnAction */ public final String actionAsString() { return action; } /** *

* The MTA to which the remote MTA attempted to deliver the message, formatted as specified in RFC 3464 (mta-name-type; mta-name). This parameter * typically applies only to propagating synchronous bounces. *

* * @return The MTA to which the remote MTA attempted to deliver the message, formatted as specified in RFC 3464 (mta-name-type; mta-name). This * parameter typically applies only to propagating synchronous bounces. */ public final String remoteMta() { return remoteMta; } /** *

* The status code that indicates what went wrong. This is required by RFC 3464. *

* * @return The status code that indicates what went wrong. This is required by RFC 3464. */ public final String status() { return status; } /** *

* An extended explanation of what went wrong; this is usually an SMTP response. See RFC 3463 for the correct formatting of this parameter. *

* * @return An extended explanation of what went wrong; this is usually an SMTP response. See RFC 3463 for the correct formatting of this parameter. */ public final String diagnosticCode() { return diagnosticCode; } /** *

* The time the final delivery attempt was made, in RFC 822 * date-time format. *

* * @return The time the final delivery attempt was made, in RFC * 822 date-time format. */ public final Instant lastAttemptDate() { return lastAttemptDate; } /** * Returns true if the ExtensionFields property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasExtensionFields() { return extensionFields != null && !(extensionFields instanceof SdkAutoConstructList); } /** *

* Additional X-headers to include in the DSN. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasExtensionFields()} to see if a value was sent in this field. *

* * @return Additional X-headers to include in the DSN. */ public final List extensionFields() { return extensionFields; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(finalRecipient()); hashCode = 31 * hashCode + Objects.hashCode(actionAsString()); hashCode = 31 * hashCode + Objects.hashCode(remoteMta()); hashCode = 31 * hashCode + Objects.hashCode(status()); hashCode = 31 * hashCode + Objects.hashCode(diagnosticCode()); hashCode = 31 * hashCode + Objects.hashCode(lastAttemptDate()); hashCode = 31 * hashCode + Objects.hashCode(hasExtensionFields() ? extensionFields() : null); 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 RecipientDsnFields)) { return false; } RecipientDsnFields other = (RecipientDsnFields) obj; return Objects.equals(finalRecipient(), other.finalRecipient()) && Objects.equals(actionAsString(), other.actionAsString()) && Objects.equals(remoteMta(), other.remoteMta()) && Objects.equals(status(), other.status()) && Objects.equals(diagnosticCode(), other.diagnosticCode()) && Objects.equals(lastAttemptDate(), other.lastAttemptDate()) && hasExtensionFields() == other.hasExtensionFields() && Objects.equals(extensionFields(), other.extensionFields()); } /** * 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("RecipientDsnFields").add("FinalRecipient", finalRecipient()).add("Action", actionAsString()) .add("RemoteMta", remoteMta()).add("Status", status()).add("DiagnosticCode", diagnosticCode()) .add("LastAttemptDate", lastAttemptDate()) .add("ExtensionFields", hasExtensionFields() ? extensionFields() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "FinalRecipient": return Optional.ofNullable(clazz.cast(finalRecipient())); case "Action": return Optional.ofNullable(clazz.cast(actionAsString())); case "RemoteMta": return Optional.ofNullable(clazz.cast(remoteMta())); case "Status": return Optional.ofNullable(clazz.cast(status())); case "DiagnosticCode": return Optional.ofNullable(clazz.cast(diagnosticCode())); case "LastAttemptDate": return Optional.ofNullable(clazz.cast(lastAttemptDate())); case "ExtensionFields": return Optional.ofNullable(clazz.cast(extensionFields())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((RecipientDsnFields) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The email address that the message was ultimately delivered to. This corresponds to the * Final-Recipient in the DSN. If not specified, FinalRecipient will be set to the * Recipient specified in the BouncedRecipientInfo structure. Either * FinalRecipient or the recipient in BouncedRecipientInfo must be a recipient of the * original bounced message. *

* *

* Do not prepend the FinalRecipient email address with rfc 822;, as described in RFC 3798. *

*
* * @param finalRecipient * The email address that the message was ultimately delivered to. This corresponds to the * Final-Recipient in the DSN. If not specified, FinalRecipient will be set to * the Recipient specified in the BouncedRecipientInfo structure. Either * FinalRecipient or the recipient in BouncedRecipientInfo must be a recipient * of the original bounced message.

*

* Do not prepend the FinalRecipient email address with rfc 822;, as described * in RFC 3798. *

* @return Returns a reference to this object so that method calls can be chained together. */ Builder finalRecipient(String finalRecipient); /** *

* The action performed by the reporting mail transfer agent (MTA) as a result of its attempt to deliver the * message to the recipient address. This is required by RFC * 3464. *

* * @param action * The action performed by the reporting mail transfer agent (MTA) as a result of its attempt to deliver * the message to the recipient address. This is required by RFC 3464. * @see DsnAction * @return Returns a reference to this object so that method calls can be chained together. * @see DsnAction */ Builder action(String action); /** *

* The action performed by the reporting mail transfer agent (MTA) as a result of its attempt to deliver the * message to the recipient address. This is required by RFC * 3464. *

* * @param action * The action performed by the reporting mail transfer agent (MTA) as a result of its attempt to deliver * the message to the recipient address. This is required by RFC 3464. * @see DsnAction * @return Returns a reference to this object so that method calls can be chained together. * @see DsnAction */ Builder action(DsnAction action); /** *

* The MTA to which the remote MTA attempted to deliver the message, formatted as specified in RFC 3464 (mta-name-type; mta-name). This * parameter typically applies only to propagating synchronous bounces. *

* * @param remoteMta * The MTA to which the remote MTA attempted to deliver the message, formatted as specified in RFC 3464 (mta-name-type; mta-name). This * parameter typically applies only to propagating synchronous bounces. * @return Returns a reference to this object so that method calls can be chained together. */ Builder remoteMta(String remoteMta); /** *

* The status code that indicates what went wrong. This is required by RFC 3464. *

* * @param status * The status code that indicates what went wrong. This is required by RFC 3464. * @return Returns a reference to this object so that method calls can be chained together. */ Builder status(String status); /** *

* An extended explanation of what went wrong; this is usually an SMTP response. See RFC 3463 for the correct formatting of this parameter. *

* * @param diagnosticCode * An extended explanation of what went wrong; this is usually an SMTP response. See RFC 3463 for the correct formatting of this parameter. * @return Returns a reference to this object so that method calls can be chained together. */ Builder diagnosticCode(String diagnosticCode); /** *

* The time the final delivery attempt was made, in RFC 822 * date-time format. *

* * @param lastAttemptDate * The time the final delivery attempt was made, in RFC * 822 date-time format. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lastAttemptDate(Instant lastAttemptDate); /** *

* Additional X-headers to include in the DSN. *

* * @param extensionFields * Additional X-headers to include in the DSN. * @return Returns a reference to this object so that method calls can be chained together. */ Builder extensionFields(Collection extensionFields); /** *

* Additional X-headers to include in the DSN. *

* * @param extensionFields * Additional X-headers to include in the DSN. * @return Returns a reference to this object so that method calls can be chained together. */ Builder extensionFields(ExtensionField... extensionFields); /** *

* Additional X-headers to include in the DSN. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the need * to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and * its result is passed to {@link #extensionFields(List)}. * * @param extensionFields * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #extensionFields(List) */ Builder extensionFields(Consumer... extensionFields); } static final class BuilderImpl implements Builder { private String finalRecipient; private String action; private String remoteMta; private String status; private String diagnosticCode; private Instant lastAttemptDate; private List extensionFields = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(RecipientDsnFields model) { finalRecipient(model.finalRecipient); action(model.action); remoteMta(model.remoteMta); status(model.status); diagnosticCode(model.diagnosticCode); lastAttemptDate(model.lastAttemptDate); extensionFields(model.extensionFields); } public final String getFinalRecipient() { return finalRecipient; } @Override public final Builder finalRecipient(String finalRecipient) { this.finalRecipient = finalRecipient; return this; } public final void setFinalRecipient(String finalRecipient) { this.finalRecipient = finalRecipient; } public final String getAction() { return action; } @Override public final Builder action(String action) { this.action = action; return this; } @Override public final Builder action(DsnAction action) { this.action(action == null ? null : action.toString()); return this; } public final void setAction(String action) { this.action = action; } public final String getRemoteMta() { return remoteMta; } @Override public final Builder remoteMta(String remoteMta) { this.remoteMta = remoteMta; return this; } public final void setRemoteMta(String remoteMta) { this.remoteMta = remoteMta; } public final String getStatus() { return status; } @Override public final Builder status(String status) { this.status = status; return this; } public final void setStatus(String status) { this.status = status; } public final String getDiagnosticCode() { return diagnosticCode; } @Override public final Builder diagnosticCode(String diagnosticCode) { this.diagnosticCode = diagnosticCode; return this; } public final void setDiagnosticCode(String diagnosticCode) { this.diagnosticCode = diagnosticCode; } public final Instant getLastAttemptDate() { return lastAttemptDate; } @Override public final Builder lastAttemptDate(Instant lastAttemptDate) { this.lastAttemptDate = lastAttemptDate; return this; } public final void setLastAttemptDate(Instant lastAttemptDate) { this.lastAttemptDate = lastAttemptDate; } public final List getExtensionFields() { List result = ExtensionFieldListCopier.copyToBuilder(this.extensionFields); if (result instanceof SdkAutoConstructList) { return null; } return result; } @Override public final Builder extensionFields(Collection extensionFields) { this.extensionFields = ExtensionFieldListCopier.copy(extensionFields); return this; } @Override @SafeVarargs public final Builder extensionFields(ExtensionField... extensionFields) { extensionFields(Arrays.asList(extensionFields)); return this; } @Override @SafeVarargs public final Builder extensionFields(Consumer... extensionFields) { extensionFields(Stream.of(extensionFields).map(c -> ExtensionField.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setExtensionFields(Collection extensionFields) { this.extensionFields = ExtensionFieldListCopier.copyFromBuilder(extensionFields); } @Override public RecipientDsnFields build() { return new RecipientDsnFields(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy