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

software.amazon.awssdk.services.pinpoint.model.SendUsersMessageRequest 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.pinpoint.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
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.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Specifies the configuration and other settings for a message to send to all the endpoints that are associated with a * list of users. *

*/ @Generated("software.amazon.awssdk:codegen") public final class SendUsersMessageRequest implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> CONTEXT_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("Context") .getter(getter(SendUsersMessageRequest::context)) .setter(setter(Builder::context)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Context").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField MESSAGE_CONFIGURATION_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("MessageConfiguration") .getter(getter(SendUsersMessageRequest::messageConfiguration)).setter(setter(Builder::messageConfiguration)) .constructor(DirectMessageConfiguration::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MessageConfiguration").build()) .build(); private static final SdkField TEMPLATE_CONFIGURATION_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("TemplateConfiguration") .getter(getter(SendUsersMessageRequest::templateConfiguration)).setter(setter(Builder::templateConfiguration)) .constructor(TemplateConfiguration::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TemplateConfiguration").build()) .build(); private static final SdkField TRACE_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("TraceId").getter(getter(SendUsersMessageRequest::traceId)).setter(setter(Builder::traceId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TraceId").build()).build(); private static final SdkField> USERS_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("Users") .getter(getter(SendUsersMessageRequest::users)) .setter(setter(Builder::users)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Users").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(EndpointSendConfiguration::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CONTEXT_FIELD, MESSAGE_CONFIGURATION_FIELD, TEMPLATE_CONFIGURATION_FIELD, TRACE_ID_FIELD, USERS_FIELD)); private static final long serialVersionUID = 1L; private final Map context; private final DirectMessageConfiguration messageConfiguration; private final TemplateConfiguration templateConfiguration; private final String traceId; private final Map users; private SendUsersMessageRequest(BuilderImpl builder) { this.context = builder.context; this.messageConfiguration = builder.messageConfiguration; this.templateConfiguration = builder.templateConfiguration; this.traceId = builder.traceId; this.users = builder.users; } /** * For responses, this returns true if the service returned a value for the Context 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 hasContext() { return context != null && !(context instanceof SdkAutoConstructMap); } /** *

* A map of custom attribute-value pairs. For a push notification, Amazon Pinpoint adds these attributes to the * data.pinpoint object in the body of the notification payload. Amazon Pinpoint also provides these attributes in * the events that it generates for users-messages deliveries. *

*

* 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 #hasContext} method. *

* * @return A map of custom attribute-value pairs. For a push notification, Amazon Pinpoint adds these attributes to * the data.pinpoint object in the body of the notification payload. Amazon Pinpoint also provides these * attributes in the events that it generates for users-messages deliveries. */ public final Map context() { return context; } /** *

* The settings and content for the default message and any default messages that you defined for specific channels. *

* * @return The settings and content for the default message and any default messages that you defined for specific * channels. */ public final DirectMessageConfiguration messageConfiguration() { return messageConfiguration; } /** *

* The message template to use for the message. *

* * @return The message template to use for the message. */ public final TemplateConfiguration templateConfiguration() { return templateConfiguration; } /** *

* The unique identifier for tracing the message. This identifier is visible to message recipients. *

* * @return The unique identifier for tracing the message. This identifier is visible to message recipients. */ public final String traceId() { return traceId; } /** * For responses, this returns true if the service returned a value for the Users 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 hasUsers() { return users != null && !(users instanceof SdkAutoConstructMap); } /** *

* A map that associates user IDs with EndpointSendConfiguration objects. You can use an EndpointSendConfiguration object to tailor the message for a user by specifying settings such as content * overrides and message variables. *

*

* 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 #hasUsers} method. *

* * @return A map that associates user IDs with EndpointSendConfiguration objects. You can use an EndpointSendConfiguration object to tailor the message for a user by specifying settings such as * content overrides and message variables. */ public final Map users() { return users; } @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(hasContext() ? context() : null); hashCode = 31 * hashCode + Objects.hashCode(messageConfiguration()); hashCode = 31 * hashCode + Objects.hashCode(templateConfiguration()); hashCode = 31 * hashCode + Objects.hashCode(traceId()); hashCode = 31 * hashCode + Objects.hashCode(hasUsers() ? users() : 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 SendUsersMessageRequest)) { return false; } SendUsersMessageRequest other = (SendUsersMessageRequest) obj; return hasContext() == other.hasContext() && Objects.equals(context(), other.context()) && Objects.equals(messageConfiguration(), other.messageConfiguration()) && Objects.equals(templateConfiguration(), other.templateConfiguration()) && Objects.equals(traceId(), other.traceId()) && hasUsers() == other.hasUsers() && Objects.equals(users(), other.users()); } /** * 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("SendUsersMessageRequest").add("Context", hasContext() ? context() : null) .add("MessageConfiguration", messageConfiguration()).add("TemplateConfiguration", templateConfiguration()) .add("TraceId", traceId()).add("Users", hasUsers() ? users() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Context": return Optional.ofNullable(clazz.cast(context())); case "MessageConfiguration": return Optional.ofNullable(clazz.cast(messageConfiguration())); case "TemplateConfiguration": return Optional.ofNullable(clazz.cast(templateConfiguration())); case "TraceId": return Optional.ofNullable(clazz.cast(traceId())); case "Users": return Optional.ofNullable(clazz.cast(users())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((SendUsersMessageRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* A map of custom attribute-value pairs. For a push notification, Amazon Pinpoint adds these attributes to the * data.pinpoint object in the body of the notification payload. Amazon Pinpoint also provides these attributes * in the events that it generates for users-messages deliveries. *

* * @param context * A map of custom attribute-value pairs. For a push notification, Amazon Pinpoint adds these attributes * to the data.pinpoint object in the body of the notification payload. Amazon Pinpoint also provides * these attributes in the events that it generates for users-messages deliveries. * @return Returns a reference to this object so that method calls can be chained together. */ Builder context(Map context); /** *

* The settings and content for the default message and any default messages that you defined for specific * channels. *

* * @param messageConfiguration * The settings and content for the default message and any default messages that you defined for * specific channels. * @return Returns a reference to this object so that method calls can be chained together. */ Builder messageConfiguration(DirectMessageConfiguration messageConfiguration); /** *

* The settings and content for the default message and any default messages that you defined for specific * channels. *

* This is a convenience method that creates an instance of the {@link DirectMessageConfiguration.Builder} * avoiding the need to create one manually via {@link DirectMessageConfiguration#builder()}. * *

* When the {@link Consumer} completes, {@link DirectMessageConfiguration.Builder#build()} is called immediately * and its result is passed to {@link #messageConfiguration(DirectMessageConfiguration)}. * * @param messageConfiguration * a consumer that will call methods on {@link DirectMessageConfiguration.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #messageConfiguration(DirectMessageConfiguration) */ default Builder messageConfiguration(Consumer messageConfiguration) { return messageConfiguration(DirectMessageConfiguration.builder().applyMutation(messageConfiguration).build()); } /** *

* The message template to use for the message. *

* * @param templateConfiguration * The message template to use for the message. * @return Returns a reference to this object so that method calls can be chained together. */ Builder templateConfiguration(TemplateConfiguration templateConfiguration); /** *

* The message template to use for the message. *

* This is a convenience method that creates an instance of the {@link TemplateConfiguration.Builder} avoiding * the need to create one manually via {@link TemplateConfiguration#builder()}. * *

* When the {@link Consumer} completes, {@link TemplateConfiguration.Builder#build()} is called immediately and * its result is passed to {@link #templateConfiguration(TemplateConfiguration)}. * * @param templateConfiguration * a consumer that will call methods on {@link TemplateConfiguration.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #templateConfiguration(TemplateConfiguration) */ default Builder templateConfiguration(Consumer templateConfiguration) { return templateConfiguration(TemplateConfiguration.builder().applyMutation(templateConfiguration).build()); } /** *

* The unique identifier for tracing the message. This identifier is visible to message recipients. *

* * @param traceId * The unique identifier for tracing the message. This identifier is visible to message recipients. * @return Returns a reference to this object so that method calls can be chained together. */ Builder traceId(String traceId); /** *

* A map that associates user IDs with EndpointSendConfiguration objects. You can use an EndpointSendConfiguration object to tailor the message for a user by specifying settings such as content * overrides and message variables. *

* * @param users * A map that associates user IDs with EndpointSendConfiguration objects. You can use an EndpointSendConfiguration object to tailor the message for a user by specifying settings such as * content overrides and message variables. * @return Returns a reference to this object so that method calls can be chained together. */ Builder users(Map users); } static final class BuilderImpl implements Builder { private Map context = DefaultSdkAutoConstructMap.getInstance(); private DirectMessageConfiguration messageConfiguration; private TemplateConfiguration templateConfiguration; private String traceId; private Map users = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(SendUsersMessageRequest model) { context(model.context); messageConfiguration(model.messageConfiguration); templateConfiguration(model.templateConfiguration); traceId(model.traceId); users(model.users); } public final Map getContext() { if (context instanceof SdkAutoConstructMap) { return null; } return context; } public final void setContext(Map context) { this.context = MapOf__stringCopier.copy(context); } @Override public final Builder context(Map context) { this.context = MapOf__stringCopier.copy(context); return this; } public final DirectMessageConfiguration.Builder getMessageConfiguration() { return messageConfiguration != null ? messageConfiguration.toBuilder() : null; } public final void setMessageConfiguration(DirectMessageConfiguration.BuilderImpl messageConfiguration) { this.messageConfiguration = messageConfiguration != null ? messageConfiguration.build() : null; } @Override public final Builder messageConfiguration(DirectMessageConfiguration messageConfiguration) { this.messageConfiguration = messageConfiguration; return this; } public final TemplateConfiguration.Builder getTemplateConfiguration() { return templateConfiguration != null ? templateConfiguration.toBuilder() : null; } public final void setTemplateConfiguration(TemplateConfiguration.BuilderImpl templateConfiguration) { this.templateConfiguration = templateConfiguration != null ? templateConfiguration.build() : null; } @Override public final Builder templateConfiguration(TemplateConfiguration templateConfiguration) { this.templateConfiguration = templateConfiguration; return this; } public final String getTraceId() { return traceId; } public final void setTraceId(String traceId) { this.traceId = traceId; } @Override public final Builder traceId(String traceId) { this.traceId = traceId; return this; } public final Map getUsers() { Map result = MapOfEndpointSendConfigurationCopier .copyToBuilder(this.users); if (result instanceof SdkAutoConstructMap) { return null; } return result; } public final void setUsers(Map users) { this.users = MapOfEndpointSendConfigurationCopier.copyFromBuilder(users); } @Override public final Builder users(Map users) { this.users = MapOfEndpointSendConfigurationCopier.copy(users); return this; } @Override public SendUsersMessageRequest build() { return new SendUsersMessageRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy