software.amazon.awssdk.services.pinpoint.model.CustomMessageActivity Maven / Gradle / Ivy
Show all versions of pinpoint Show documentation
/*
* 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.pinpoint.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
*
* The settings for a custom message activity. This type of activity calls an AWS Lambda function or web hook that sends
* messages to participants.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CustomMessageActivity implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField DELIVERY_URI_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DeliveryUri").getter(getter(CustomMessageActivity::deliveryUri)).setter(setter(Builder::deliveryUri))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeliveryUri").build()).build();
private static final SdkField> ENDPOINT_TYPES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("EndpointTypes")
.getter(getter(CustomMessageActivity::endpointTypesAsStrings))
.setter(setter(Builder::endpointTypesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndpointTypes").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 MESSAGE_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("MessageConfig")
.getter(getter(CustomMessageActivity::messageConfig)).setter(setter(Builder::messageConfig))
.constructor(JourneyCustomMessage::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MessageConfig").build()).build();
private static final SdkField NEXT_ACTIVITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NextActivity").getter(getter(CustomMessageActivity::nextActivity)).setter(setter(Builder::nextActivity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextActivity").build()).build();
private static final SdkField TEMPLATE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TemplateName").getter(getter(CustomMessageActivity::templateName)).setter(setter(Builder::templateName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TemplateName").build()).build();
private static final SdkField TEMPLATE_VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TemplateVersion").getter(getter(CustomMessageActivity::templateVersion))
.setter(setter(Builder::templateVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TemplateVersion").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DELIVERY_URI_FIELD,
ENDPOINT_TYPES_FIELD, MESSAGE_CONFIG_FIELD, NEXT_ACTIVITY_FIELD, TEMPLATE_NAME_FIELD, TEMPLATE_VERSION_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("DeliveryUri", DELIVERY_URI_FIELD);
put("EndpointTypes", ENDPOINT_TYPES_FIELD);
put("MessageConfig", MESSAGE_CONFIG_FIELD);
put("NextActivity", NEXT_ACTIVITY_FIELD);
put("TemplateName", TEMPLATE_NAME_FIELD);
put("TemplateVersion", TEMPLATE_VERSION_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String deliveryUri;
private final List endpointTypes;
private final JourneyCustomMessage messageConfig;
private final String nextActivity;
private final String templateName;
private final String templateVersion;
private CustomMessageActivity(BuilderImpl builder) {
this.deliveryUri = builder.deliveryUri;
this.endpointTypes = builder.endpointTypes;
this.messageConfig = builder.messageConfig;
this.nextActivity = builder.nextActivity;
this.templateName = builder.templateName;
this.templateVersion = builder.templateVersion;
}
/**
*
* The destination to send the campaign or treatment to. This value can be one of the following:
*
*
* -
*
* The name or Amazon Resource Name (ARN) of an AWS Lambda function to invoke to handle delivery of the campaign or
* treatment.
*
*
* -
*
* The URL for a web application or service that supports HTTPS and can receive the message. The URL has to be a
* full URL, including the HTTPS protocol.
*
*
*
*
* @return The destination to send the campaign or treatment to. This value can be one of the following:
*
* -
*
* The name or Amazon Resource Name (ARN) of an AWS Lambda function to invoke to handle delivery of the
* campaign or treatment.
*
*
* -
*
* The URL for a web application or service that supports HTTPS and can receive the message. The URL has to
* be a full URL, including the HTTPS protocol.
*
*
*/
public final String deliveryUri() {
return deliveryUri;
}
/**
*
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that you can
* associate with an endpoint by using the ChannelType property of an endpoint.
*
*
* 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 #hasEndpointTypes} method.
*
*
* @return The types of endpoints to send the custom message to. Each valid value maps to a type of channel that you
* can associate with an endpoint by using the ChannelType property of an endpoint.
*/
public final List endpointTypes() {
return ListOf__EndpointTypesElementCopier.copyStringToEnum(endpointTypes);
}
/**
* For responses, this returns true if the service returned a value for the EndpointTypes 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 hasEndpointTypes() {
return endpointTypes != null && !(endpointTypes instanceof SdkAutoConstructList);
}
/**
*
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that you can
* associate with an endpoint by using the ChannelType property of an endpoint.
*
*
* 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 #hasEndpointTypes} method.
*
*
* @return The types of endpoints to send the custom message to. Each valid value maps to a type of channel that you
* can associate with an endpoint by using the ChannelType property of an endpoint.
*/
public final List endpointTypesAsStrings() {
return endpointTypes;
}
/**
*
* Specifies the message data included in a custom channel message that's sent to participants in a journey.
*
*
* @return Specifies the message data included in a custom channel message that's sent to participants in a journey.
*/
public final JourneyCustomMessage messageConfig() {
return messageConfig;
}
/**
*
* The unique identifier for the next activity to perform, after Amazon Pinpoint calls the AWS Lambda function or
* web hook.
*
*
* @return The unique identifier for the next activity to perform, after Amazon Pinpoint calls the AWS Lambda
* function or web hook.
*/
public final String nextActivity() {
return nextActivity;
}
/**
*
* The name of the custom message template to use for the message. If specified, this value must match the name of
* an existing message template.
*
*
* @return The name of the custom message template to use for the message. If specified, this value must match the
* name of an existing message template.
*/
public final String templateName() {
return templateName;
}
/**
*
* The unique identifier for the version of the message template to use for the message. If specified, this value
* must match the identifier for an existing template version. To retrieve a list of versions and version
* identifiers for a template, use the Template
* Versions resource.
*
*
* If you don't specify a value for this property, Amazon Pinpoint uses the active version of the template.
* The active version is typically the version of a template that's been most recently reviewed and approved
* for use, depending on your workflow. It isn't necessarily the latest version of a template.
*
*
* @return The unique identifier for the version of the message template to use for the message. If specified, this
* value must match the identifier for an existing template version. To retrieve a list of versions and
* version identifiers for a template, use the Template Versions resource.
*
* If you don't specify a value for this property, Amazon Pinpoint uses the active version of the
* template. The active version is typically the version of a template that's been most recently
* reviewed and approved for use, depending on your workflow. It isn't necessarily the latest version of a
* template.
*/
public final String templateVersion() {
return templateVersion;
}
@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 + Objects.hashCode(deliveryUri());
hashCode = 31 * hashCode + Objects.hashCode(hasEndpointTypes() ? endpointTypesAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(messageConfig());
hashCode = 31 * hashCode + Objects.hashCode(nextActivity());
hashCode = 31 * hashCode + Objects.hashCode(templateName());
hashCode = 31 * hashCode + Objects.hashCode(templateVersion());
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 CustomMessageActivity)) {
return false;
}
CustomMessageActivity other = (CustomMessageActivity) obj;
return Objects.equals(deliveryUri(), other.deliveryUri()) && hasEndpointTypes() == other.hasEndpointTypes()
&& Objects.equals(endpointTypesAsStrings(), other.endpointTypesAsStrings())
&& Objects.equals(messageConfig(), other.messageConfig()) && Objects.equals(nextActivity(), other.nextActivity())
&& Objects.equals(templateName(), other.templateName())
&& Objects.equals(templateVersion(), other.templateVersion());
}
/**
* 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("CustomMessageActivity").add("DeliveryUri", deliveryUri())
.add("EndpointTypes", hasEndpointTypes() ? endpointTypesAsStrings() : null).add("MessageConfig", messageConfig())
.add("NextActivity", nextActivity()).add("TemplateName", templateName())
.add("TemplateVersion", templateVersion()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "DeliveryUri":
return Optional.ofNullable(clazz.cast(deliveryUri()));
case "EndpointTypes":
return Optional.ofNullable(clazz.cast(endpointTypesAsStrings()));
case "MessageConfig":
return Optional.ofNullable(clazz.cast(messageConfig()));
case "NextActivity":
return Optional.ofNullable(clazz.cast(nextActivity()));
case "TemplateName":
return Optional.ofNullable(clazz.cast(templateName()));
case "TemplateVersion":
return Optional.ofNullable(clazz.cast(templateVersion()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function
*
* -
*
* The name or Amazon Resource Name (ARN) of an AWS Lambda function to invoke to handle delivery of the
* campaign or treatment.
*
*
* -
*
* The URL for a web application or service that supports HTTPS and can receive the message. The URL has
* to be a full URL, including the HTTPS protocol.
*
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder deliveryUri(String deliveryUri);
/**
*
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that you can
* associate with an endpoint by using the ChannelType property of an endpoint.
*
*
* @param endpointTypes
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that
* you can associate with an endpoint by using the ChannelType property of an endpoint.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder endpointTypesWithStrings(Collection endpointTypes);
/**
*
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that you can
* associate with an endpoint by using the ChannelType property of an endpoint.
*
*
* @param endpointTypes
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that
* you can associate with an endpoint by using the ChannelType property of an endpoint.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder endpointTypesWithStrings(String... endpointTypes);
/**
*
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that you can
* associate with an endpoint by using the ChannelType property of an endpoint.
*
*
* @param endpointTypes
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that
* you can associate with an endpoint by using the ChannelType property of an endpoint.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder endpointTypes(Collection endpointTypes);
/**
*
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that you can
* associate with an endpoint by using the ChannelType property of an endpoint.
*
*
* @param endpointTypes
* The types of endpoints to send the custom message to. Each valid value maps to a type of channel that
* you can associate with an endpoint by using the ChannelType property of an endpoint.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder endpointTypes(EndpointTypesElement... endpointTypes);
/**
*
* Specifies the message data included in a custom channel message that's sent to participants in a journey.
*
*
* @param messageConfig
* Specifies the message data included in a custom channel message that's sent to participants in a
* journey.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder messageConfig(JourneyCustomMessage messageConfig);
/**
*
* Specifies the message data included in a custom channel message that's sent to participants in a journey.
*
* This is a convenience method that creates an instance of the {@link JourneyCustomMessage.Builder} avoiding
* the need to create one manually via {@link JourneyCustomMessage#builder()}.
*
*
* When the {@link Consumer} completes, {@link JourneyCustomMessage.Builder#build()} is called immediately and
* its result is passed to {@link #messageConfig(JourneyCustomMessage)}.
*
* @param messageConfig
* a consumer that will call methods on {@link JourneyCustomMessage.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #messageConfig(JourneyCustomMessage)
*/
default Builder messageConfig(Consumer messageConfig) {
return messageConfig(JourneyCustomMessage.builder().applyMutation(messageConfig).build());
}
/**
*
* The unique identifier for the next activity to perform, after Amazon Pinpoint calls the AWS Lambda function
* or web hook.
*
*
* @param nextActivity
* The unique identifier for the next activity to perform, after Amazon Pinpoint calls the AWS Lambda
* function or web hook.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder nextActivity(String nextActivity);
/**
*
* The name of the custom message template to use for the message. If specified, this value must match the name
* of an existing message template.
*
*
* @param templateName
* The name of the custom message template to use for the message. If specified, this value must match
* the name of an existing message template.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder templateName(String templateName);
/**
*
* The unique identifier for the version of the message template to use for the message. If specified, this
* value must match the identifier for an existing template version. To retrieve a list of versions and version
* identifiers for a template, use the Template
* Versions resource.
*
*
* If you don't specify a value for this property, Amazon Pinpoint uses the active version of the
* template. The active version is typically the version of a template that's been most recently reviewed
* and approved for use, depending on your workflow. It isn't necessarily the latest version of a template.
*
*
* @param templateVersion
* The unique identifier for the version of the message template to use for the message. If specified,
* this value must match the identifier for an existing template version. To retrieve a list of versions
* and version identifiers for a template, use the Template Versions resource.
*
* If you don't specify a value for this property, Amazon Pinpoint uses the active version of the
* template. The active version is typically the version of a template that's been most recently
* reviewed and approved for use, depending on your workflow. It isn't necessarily the latest version of
* a template.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder templateVersion(String templateVersion);
}
static final class BuilderImpl implements Builder {
private String deliveryUri;
private List endpointTypes = DefaultSdkAutoConstructList.getInstance();
private JourneyCustomMessage messageConfig;
private String nextActivity;
private String templateName;
private String templateVersion;
private BuilderImpl() {
}
private BuilderImpl(CustomMessageActivity model) {
deliveryUri(model.deliveryUri);
endpointTypesWithStrings(model.endpointTypes);
messageConfig(model.messageConfig);
nextActivity(model.nextActivity);
templateName(model.templateName);
templateVersion(model.templateVersion);
}
public final String getDeliveryUri() {
return deliveryUri;
}
public final void setDeliveryUri(String deliveryUri) {
this.deliveryUri = deliveryUri;
}
@Override
public final Builder deliveryUri(String deliveryUri) {
this.deliveryUri = deliveryUri;
return this;
}
public final Collection getEndpointTypes() {
if (endpointTypes instanceof SdkAutoConstructList) {
return null;
}
return endpointTypes;
}
public final void setEndpointTypes(Collection endpointTypes) {
this.endpointTypes = ListOf__EndpointTypesElementCopier.copy(endpointTypes);
}
@Override
public final Builder endpointTypesWithStrings(Collection endpointTypes) {
this.endpointTypes = ListOf__EndpointTypesElementCopier.copy(endpointTypes);
return this;
}
@Override
@SafeVarargs
public final Builder endpointTypesWithStrings(String... endpointTypes) {
endpointTypesWithStrings(Arrays.asList(endpointTypes));
return this;
}
@Override
public final Builder endpointTypes(Collection endpointTypes) {
this.endpointTypes = ListOf__EndpointTypesElementCopier.copyEnumToString(endpointTypes);
return this;
}
@Override
@SafeVarargs
public final Builder endpointTypes(EndpointTypesElement... endpointTypes) {
endpointTypes(Arrays.asList(endpointTypes));
return this;
}
public final JourneyCustomMessage.Builder getMessageConfig() {
return messageConfig != null ? messageConfig.toBuilder() : null;
}
public final void setMessageConfig(JourneyCustomMessage.BuilderImpl messageConfig) {
this.messageConfig = messageConfig != null ? messageConfig.build() : null;
}
@Override
public final Builder messageConfig(JourneyCustomMessage messageConfig) {
this.messageConfig = messageConfig;
return this;
}
public final String getNextActivity() {
return nextActivity;
}
public final void setNextActivity(String nextActivity) {
this.nextActivity = nextActivity;
}
@Override
public final Builder nextActivity(String nextActivity) {
this.nextActivity = nextActivity;
return this;
}
public final String getTemplateName() {
return templateName;
}
public final void setTemplateName(String templateName) {
this.templateName = templateName;
}
@Override
public final Builder templateName(String templateName) {
this.templateName = templateName;
return this;
}
public final String getTemplateVersion() {
return templateVersion;
}
public final void setTemplateVersion(String templateVersion) {
this.templateVersion = templateVersion;
}
@Override
public final Builder templateVersion(String templateVersion) {
this.templateVersion = templateVersion;
return this;
}
@Override
public CustomMessageActivity build() {
return new CustomMessageActivity(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
@Override
public Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
}
}