
software.amazon.awssdk.services.sesv2.model.EventDestinationDefinition 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.io.Serializable;
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 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;
/**
*
* An object that defines the event destination. Specifically, it defines which services receive events from emails sent
* using the configuration set that the event destination is associated with. Also defines the types of events that are
* sent to the event destination.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class EventDestinationDefinition implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ENABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.getter(getter(EventDestinationDefinition::enabled)).setter(setter(Builder::enabled))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Enabled").build()).build();
private static final SdkField> MATCHING_EVENT_TYPES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(EventDestinationDefinition::matchingEventTypesAsStrings))
.setter(setter(Builder::matchingEventTypesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MatchingEventTypes").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 KINESIS_FIREHOSE_DESTINATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.getter(getter(EventDestinationDefinition::kinesisFirehoseDestination))
.setter(setter(Builder::kinesisFirehoseDestination))
.constructor(KinesisFirehoseDestination::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KinesisFirehoseDestination").build())
.build();
private static final SdkField CLOUD_WATCH_DESTINATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.getter(getter(EventDestinationDefinition::cloudWatchDestination)).setter(setter(Builder::cloudWatchDestination))
.constructor(CloudWatchDestination::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CloudWatchDestination").build())
.build();
private static final SdkField SNS_DESTINATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(EventDestinationDefinition::snsDestination))
.setter(setter(Builder::snsDestination)).constructor(SnsDestination::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SnsDestination").build()).build();
private static final SdkField PINPOINT_DESTINATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.getter(getter(EventDestinationDefinition::pinpointDestination)).setter(setter(Builder::pinpointDestination))
.constructor(PinpointDestination::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PinpointDestination").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ENABLED_FIELD,
MATCHING_EVENT_TYPES_FIELD, KINESIS_FIREHOSE_DESTINATION_FIELD, CLOUD_WATCH_DESTINATION_FIELD, SNS_DESTINATION_FIELD,
PINPOINT_DESTINATION_FIELD));
private static final long serialVersionUID = 1L;
private final Boolean enabled;
private final List matchingEventTypes;
private final KinesisFirehoseDestination kinesisFirehoseDestination;
private final CloudWatchDestination cloudWatchDestination;
private final SnsDestination snsDestination;
private final PinpointDestination pinpointDestination;
private EventDestinationDefinition(BuilderImpl builder) {
this.enabled = builder.enabled;
this.matchingEventTypes = builder.matchingEventTypes;
this.kinesisFirehoseDestination = builder.kinesisFirehoseDestination;
this.cloudWatchDestination = builder.cloudWatchDestination;
this.snsDestination = builder.snsDestination;
this.pinpointDestination = builder.pinpointDestination;
}
/**
*
* If true
, the event destination is enabled. When the event destination is enabled, the specified
* event types are sent to the destinations in this EventDestinationDefinition
.
*
*
* If false
, the event destination is disabled. When the event destination is disabled, events aren't
* sent to the specified destinations.
*
*
* @return If true
, the event destination is enabled. When the event destination is enabled, the
* specified event types are sent to the destinations in this EventDestinationDefinition
.
*
* If false
, the event destination is disabled. When the event destination is disabled, events
* aren't sent to the specified destinations.
*/
public Boolean enabled() {
return enabled;
}
/**
*
* An array that specifies which events the Amazon SES API v2 should send to the destinations in this
* EventDestinationDefinition
.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasMatchingEventTypes()} to see if a value was sent in this field.
*
*
* @return An array that specifies which events the Amazon SES API v2 should send to the destinations in this
* EventDestinationDefinition
.
*/
public List matchingEventTypes() {
return EventTypesCopier.copyStringToEnum(matchingEventTypes);
}
/**
* Returns true if the MatchingEventTypes 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 boolean hasMatchingEventTypes() {
return matchingEventTypes != null && !(matchingEventTypes instanceof SdkAutoConstructList);
}
/**
*
* An array that specifies which events the Amazon SES API v2 should send to the destinations in this
* EventDestinationDefinition
.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasMatchingEventTypes()} to see if a value was sent in this field.
*
*
* @return An array that specifies which events the Amazon SES API v2 should send to the destinations in this
* EventDestinationDefinition
.
*/
public List matchingEventTypesAsStrings() {
return matchingEventTypes;
}
/**
*
* An object that defines an Amazon Kinesis Data Firehose destination for email events. You can use Amazon Kinesis
* Data Firehose to stream data to other services, such as Amazon S3 and Amazon Redshift.
*
*
* @return An object that defines an Amazon Kinesis Data Firehose destination for email events. You can use Amazon
* Kinesis Data Firehose to stream data to other services, such as Amazon S3 and Amazon Redshift.
*/
public KinesisFirehoseDestination kinesisFirehoseDestination() {
return kinesisFirehoseDestination;
}
/**
*
* An object that defines an Amazon CloudWatch destination for email events. You can use Amazon CloudWatch to
* monitor and gain insights on your email sending metrics.
*
*
* @return An object that defines an Amazon CloudWatch destination for email events. You can use Amazon CloudWatch
* to monitor and gain insights on your email sending metrics.
*/
public CloudWatchDestination cloudWatchDestination() {
return cloudWatchDestination;
}
/**
*
* An object that defines an Amazon SNS destination for email events. You can use Amazon SNS to send notification
* when certain email events occur.
*
*
* @return An object that defines an Amazon SNS destination for email events. You can use Amazon SNS to send
* notification when certain email events occur.
*/
public SnsDestination snsDestination() {
return snsDestination;
}
/**
*
* An object that defines an Amazon Pinpoint project destination for email events. You can send email event data to
* a Amazon Pinpoint project to view metrics using the Transactional Messaging dashboards that are built in to
* Amazon Pinpoint. For more information, see Transactional
* Messaging Charts in the Amazon Pinpoint User Guide.
*
*
* @return An object that defines an Amazon Pinpoint project destination for email events. You can send email event
* data to a Amazon Pinpoint project to view metrics using the Transactional Messaging dashboards that are
* built in to Amazon Pinpoint. For more information, see Transactional Messaging Charts in the Amazon Pinpoint User Guide.
*/
public PinpointDestination pinpointDestination() {
return pinpointDestination;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(enabled());
hashCode = 31 * hashCode + Objects.hashCode(matchingEventTypesAsStrings());
hashCode = 31 * hashCode + Objects.hashCode(kinesisFirehoseDestination());
hashCode = 31 * hashCode + Objects.hashCode(cloudWatchDestination());
hashCode = 31 * hashCode + Objects.hashCode(snsDestination());
hashCode = 31 * hashCode + Objects.hashCode(pinpointDestination());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof EventDestinationDefinition)) {
return false;
}
EventDestinationDefinition other = (EventDestinationDefinition) obj;
return Objects.equals(enabled(), other.enabled())
&& Objects.equals(matchingEventTypesAsStrings(), other.matchingEventTypesAsStrings())
&& Objects.equals(kinesisFirehoseDestination(), other.kinesisFirehoseDestination())
&& Objects.equals(cloudWatchDestination(), other.cloudWatchDestination())
&& Objects.equals(snsDestination(), other.snsDestination())
&& Objects.equals(pinpointDestination(), other.pinpointDestination());
}
/**
* 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 String toString() {
return ToString.builder("EventDestinationDefinition").add("Enabled", enabled())
.add("MatchingEventTypes", matchingEventTypesAsStrings())
.add("KinesisFirehoseDestination", kinesisFirehoseDestination())
.add("CloudWatchDestination", cloudWatchDestination()).add("SnsDestination", snsDestination())
.add("PinpointDestination", pinpointDestination()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Enabled":
return Optional.ofNullable(clazz.cast(enabled()));
case "MatchingEventTypes":
return Optional.ofNullable(clazz.cast(matchingEventTypesAsStrings()));
case "KinesisFirehoseDestination":
return Optional.ofNullable(clazz.cast(kinesisFirehoseDestination()));
case "CloudWatchDestination":
return Optional.ofNullable(clazz.cast(cloudWatchDestination()));
case "SnsDestination":
return Optional.ofNullable(clazz.cast(snsDestination()));
case "PinpointDestination":
return Optional.ofNullable(clazz.cast(pinpointDestination()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function