
software.amazon.awssdk.services.proton.model.UpdateServiceTemplateVersionRequest 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.proton.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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class UpdateServiceTemplateVersionRequest extends ProtonRequest implements
ToCopyableBuilder {
private static final SdkField> COMPATIBLE_ENVIRONMENT_TEMPLATES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("compatibleEnvironmentTemplates")
.getter(getter(UpdateServiceTemplateVersionRequest::compatibleEnvironmentTemplates))
.setter(setter(Builder::compatibleEnvironmentTemplates))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("compatibleEnvironmentTemplates")
.build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(CompatibleEnvironmentTemplateInput::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(UpdateServiceTemplateVersionRequest::description))
.setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField MAJOR_VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("majorVersion").getter(getter(UpdateServiceTemplateVersionRequest::majorVersion))
.setter(setter(Builder::majorVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("majorVersion").build()).build();
private static final SdkField MINOR_VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("minorVersion").getter(getter(UpdateServiceTemplateVersionRequest::minorVersion))
.setter(setter(Builder::minorVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("minorVersion").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
.getter(getter(UpdateServiceTemplateVersionRequest::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField> SUPPORTED_COMPONENT_SOURCES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("supportedComponentSources")
.getter(getter(UpdateServiceTemplateVersionRequest::supportedComponentSourcesAsStrings))
.setter(setter(Builder::supportedComponentSourcesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("supportedComponentSources").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 TEMPLATE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("templateName").getter(getter(UpdateServiceTemplateVersionRequest::templateName))
.setter(setter(Builder::templateName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("templateName").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
COMPATIBLE_ENVIRONMENT_TEMPLATES_FIELD, DESCRIPTION_FIELD, MAJOR_VERSION_FIELD, MINOR_VERSION_FIELD, STATUS_FIELD,
SUPPORTED_COMPONENT_SOURCES_FIELD, TEMPLATE_NAME_FIELD));
private final List compatibleEnvironmentTemplates;
private final String description;
private final String majorVersion;
private final String minorVersion;
private final String status;
private final List supportedComponentSources;
private final String templateName;
private UpdateServiceTemplateVersionRequest(BuilderImpl builder) {
super(builder);
this.compatibleEnvironmentTemplates = builder.compatibleEnvironmentTemplates;
this.description = builder.description;
this.majorVersion = builder.majorVersion;
this.minorVersion = builder.minorVersion;
this.status = builder.status;
this.supportedComponentSources = builder.supportedComponentSources;
this.templateName = builder.templateName;
}
/**
* For responses, this returns true if the service returned a value for the CompatibleEnvironmentTemplates 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 hasCompatibleEnvironmentTemplates() {
return compatibleEnvironmentTemplates != null && !(compatibleEnvironmentTemplates instanceof SdkAutoConstructList);
}
/**
*
* An array of environment template objects that are compatible with this service template version. A service
* instance based on this service template version can run in environments based on compatible templates.
*
*
* 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 #hasCompatibleEnvironmentTemplates} method.
*
*
* @return An array of environment template objects that are compatible with this service template version. A
* service instance based on this service template version can run in environments based on compatible
* templates.
*/
public final List compatibleEnvironmentTemplates() {
return compatibleEnvironmentTemplates;
}
/**
*
* A description of a service template version to update.
*
*
* @return A description of a service template version to update.
*/
public final String description() {
return description;
}
/**
*
* To update a major version of a service template, include major Version
.
*
*
* @return To update a major version of a service template, include major Version
.
*/
public final String majorVersion() {
return majorVersion;
}
/**
*
* To update a minor version of a service template, include minorVersion
.
*
*
* @return To update a minor version of a service template, include minorVersion
.
*/
public final String minorVersion() {
return minorVersion;
}
/**
*
* The status of the service template minor version to update.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link TemplateVersionStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the service template minor version to update.
* @see TemplateVersionStatus
*/
public final TemplateVersionStatus status() {
return TemplateVersionStatus.fromValue(status);
}
/**
*
* The status of the service template minor version to update.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link TemplateVersionStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the service template minor version to update.
* @see TemplateVersionStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* An array of supported component sources. Components with supported sources can be attached to service instances
* based on this service template version.
*
*
*
* A change to supportedComponentSources
doesn't impact existing component attachments to instances
* based on this template version. A change only affects later associations.
*
*
*
* For more information about components, see Proton components in the
* Proton User Guide.
*
*
* 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 #hasSupportedComponentSources} method.
*
*
* @return An array of supported component sources. Components with supported sources can be attached to service
* instances based on this service template version.
*
* A change to supportedComponentSources
doesn't impact existing component attachments to
* instances based on this template version. A change only affects later associations.
*
*
*
* For more information about components, see Proton components in
* the Proton User Guide.
*/
public final List supportedComponentSources() {
return ServiceTemplateSupportedComponentSourceInputListCopier.copyStringToEnum(supportedComponentSources);
}
/**
* For responses, this returns true if the service returned a value for the SupportedComponentSources 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 hasSupportedComponentSources() {
return supportedComponentSources != null && !(supportedComponentSources instanceof SdkAutoConstructList);
}
/**
*
* An array of supported component sources. Components with supported sources can be attached to service instances
* based on this service template version.
*
*
*
* A change to supportedComponentSources
doesn't impact existing component attachments to instances
* based on this template version. A change only affects later associations.
*
*
*
* For more information about components, see Proton components in the
* Proton User Guide.
*
*
* 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 #hasSupportedComponentSources} method.
*
*
* @return An array of supported component sources. Components with supported sources can be attached to service
* instances based on this service template version.
*
* A change to supportedComponentSources
doesn't impact existing component attachments to
* instances based on this template version. A change only affects later associations.
*
*
*
* For more information about components, see Proton components in
* the Proton User Guide.
*/
public final List supportedComponentSourcesAsStrings() {
return supportedComponentSources;
}
/**
*
* The name of the service template.
*
*
* @return The name of the service template.
*/
public final String templateName() {
return templateName;
}
@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(hasCompatibleEnvironmentTemplates() ? compatibleEnvironmentTemplates() : null);
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(majorVersion());
hashCode = 31 * hashCode + Objects.hashCode(minorVersion());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasSupportedComponentSources() ? supportedComponentSourcesAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(templateName());
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 UpdateServiceTemplateVersionRequest)) {
return false;
}
UpdateServiceTemplateVersionRequest other = (UpdateServiceTemplateVersionRequest) obj;
return hasCompatibleEnvironmentTemplates() == other.hasCompatibleEnvironmentTemplates()
&& Objects.equals(compatibleEnvironmentTemplates(), other.compatibleEnvironmentTemplates())
&& Objects.equals(description(), other.description()) && Objects.equals(majorVersion(), other.majorVersion())
&& Objects.equals(minorVersion(), other.minorVersion())
&& Objects.equals(statusAsString(), other.statusAsString())
&& hasSupportedComponentSources() == other.hasSupportedComponentSources()
&& Objects.equals(supportedComponentSourcesAsStrings(), other.supportedComponentSourcesAsStrings())
&& Objects.equals(templateName(), other.templateName());
}
/**
* 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("UpdateServiceTemplateVersionRequest")
.add("CompatibleEnvironmentTemplates",
hasCompatibleEnvironmentTemplates() ? compatibleEnvironmentTemplates() : null)
.add("Description", description() == null ? null : "*** Sensitive Data Redacted ***")
.add("MajorVersion", majorVersion()).add("MinorVersion", minorVersion()).add("Status", statusAsString())
.add("SupportedComponentSources", hasSupportedComponentSources() ? supportedComponentSourcesAsStrings() : null)
.add("TemplateName", templateName()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "compatibleEnvironmentTemplates":
return Optional.ofNullable(clazz.cast(compatibleEnvironmentTemplates()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "majorVersion":
return Optional.ofNullable(clazz.cast(majorVersion()));
case "minorVersion":
return Optional.ofNullable(clazz.cast(minorVersion()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "supportedComponentSources":
return Optional.ofNullable(clazz.cast(supportedComponentSourcesAsStrings()));
case "templateName":
return Optional.ofNullable(clazz.cast(templateName()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* A change to supportedComponentSources
doesn't impact existing component attachments to
* instances based on this template version. A change only affects later associations.
*
*
*
* For more information about components, see Proton components in
* the Proton User Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder supportedComponentSources(Collection supportedComponentSources);
/**
*
* An array of supported component sources. Components with supported sources can be attached to service
* instances based on this service template version.
*
*
*
* A change to supportedComponentSources
doesn't impact existing component attachments to instances
* based on this template version. A change only affects later associations.
*
*
*
* For more information about components, see Proton components in the
* Proton User Guide.
*
*
* @param supportedComponentSources
* An array of supported component sources. Components with supported sources can be attached to service
* instances based on this service template version.
*
* A change to supportedComponentSources
doesn't impact existing component attachments to
* instances based on this template version. A change only affects later associations.
*
*
*
* For more information about components, see Proton components in
* the Proton User Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder supportedComponentSources(ServiceTemplateSupportedComponentSourceType... supportedComponentSources);
/**
*
* The name of the service template.
*
*
* @param templateName
* The name of the service template.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder templateName(String templateName);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends ProtonRequest.BuilderImpl implements Builder {
private List compatibleEnvironmentTemplates = DefaultSdkAutoConstructList
.getInstance();
private String description;
private String majorVersion;
private String minorVersion;
private String status;
private List supportedComponentSources = DefaultSdkAutoConstructList.getInstance();
private String templateName;
private BuilderImpl() {
}
private BuilderImpl(UpdateServiceTemplateVersionRequest model) {
super(model);
compatibleEnvironmentTemplates(model.compatibleEnvironmentTemplates);
description(model.description);
majorVersion(model.majorVersion);
minorVersion(model.minorVersion);
status(model.status);
supportedComponentSourcesWithStrings(model.supportedComponentSources);
templateName(model.templateName);
}
public final List getCompatibleEnvironmentTemplates() {
List result = CompatibleEnvironmentTemplateInputListCopier
.copyToBuilder(this.compatibleEnvironmentTemplates);
if (result instanceof SdkAutoConstructList) {
return null;
}
return result;
}
public final void setCompatibleEnvironmentTemplates(
Collection compatibleEnvironmentTemplates) {
this.compatibleEnvironmentTemplates = CompatibleEnvironmentTemplateInputListCopier
.copyFromBuilder(compatibleEnvironmentTemplates);
}
@Override
public final Builder compatibleEnvironmentTemplates(
Collection compatibleEnvironmentTemplates) {
this.compatibleEnvironmentTemplates = CompatibleEnvironmentTemplateInputListCopier
.copy(compatibleEnvironmentTemplates);
return this;
}
@Override
@SafeVarargs
public final Builder compatibleEnvironmentTemplates(CompatibleEnvironmentTemplateInput... compatibleEnvironmentTemplates) {
compatibleEnvironmentTemplates(Arrays.asList(compatibleEnvironmentTemplates));
return this;
}
@Override
@SafeVarargs
public final Builder compatibleEnvironmentTemplates(
Consumer... compatibleEnvironmentTemplates) {
compatibleEnvironmentTemplates(Stream.of(compatibleEnvironmentTemplates)
.map(c -> CompatibleEnvironmentTemplateInput.builder().applyMutation(c).build()).collect(Collectors.toList()));
return this;
}
public final String getDescription() {
return description;
}
public final void setDescription(String description) {
this.description = description;
}
@Override
public final Builder description(String description) {
this.description = description;
return this;
}
public final String getMajorVersion() {
return majorVersion;
}
public final void setMajorVersion(String majorVersion) {
this.majorVersion = majorVersion;
}
@Override
public final Builder majorVersion(String majorVersion) {
this.majorVersion = majorVersion;
return this;
}
public final String getMinorVersion() {
return minorVersion;
}
public final void setMinorVersion(String minorVersion) {
this.minorVersion = minorVersion;
}
@Override
public final Builder minorVersion(String minorVersion) {
this.minorVersion = minorVersion;
return this;
}
public final String getStatus() {
return status;
}
public final void setStatus(String status) {
this.status = status;
}
@Override
public final Builder status(String status) {
this.status = status;
return this;
}
@Override
public final Builder status(TemplateVersionStatus status) {
this.status(status == null ? null : status.toString());
return this;
}
public final Collection getSupportedComponentSources() {
if (supportedComponentSources instanceof SdkAutoConstructList) {
return null;
}
return supportedComponentSources;
}
public final void setSupportedComponentSources(Collection supportedComponentSources) {
this.supportedComponentSources = ServiceTemplateSupportedComponentSourceInputListCopier
.copy(supportedComponentSources);
}
@Override
public final Builder supportedComponentSourcesWithStrings(Collection supportedComponentSources) {
this.supportedComponentSources = ServiceTemplateSupportedComponentSourceInputListCopier
.copy(supportedComponentSources);
return this;
}
@Override
@SafeVarargs
public final Builder supportedComponentSourcesWithStrings(String... supportedComponentSources) {
supportedComponentSourcesWithStrings(Arrays.asList(supportedComponentSources));
return this;
}
@Override
public final Builder supportedComponentSources(
Collection supportedComponentSources) {
this.supportedComponentSources = ServiceTemplateSupportedComponentSourceInputListCopier
.copyEnumToString(supportedComponentSources);
return this;
}
@Override
@SafeVarargs
public final Builder supportedComponentSources(ServiceTemplateSupportedComponentSourceType... supportedComponentSources) {
supportedComponentSources(Arrays.asList(supportedComponentSources));
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;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public UpdateServiceTemplateVersionRequest build() {
return new UpdateServiceTemplateVersionRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}