software.amazon.awssdk.services.cloudformation.model.ValidateTemplateResponse Maven / Gradle / Ivy
Show all versions of cloudformation 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.cloudformation.model;
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 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;
/**
*
* The output for ValidateTemplate action.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ValidateTemplateResponse extends CloudFormationResponse implements
ToCopyableBuilder {
private static final SdkField> PARAMETERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Parameters")
.getter(getter(ValidateTemplateResponse::parameters))
.setter(setter(Builder::parameters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Parameters").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(TemplateParameter::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(ValidateTemplateResponse::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField> CAPABILITIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Capabilities")
.getter(getter(ValidateTemplateResponse::capabilitiesAsStrings))
.setter(setter(Builder::capabilitiesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Capabilities").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 CAPABILITIES_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CapabilitiesReason").getter(getter(ValidateTemplateResponse::capabilitiesReason))
.setter(setter(Builder::capabilitiesReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CapabilitiesReason").build())
.build();
private static final SdkField> DECLARED_TRANSFORMS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("DeclaredTransforms")
.getter(getter(ValidateTemplateResponse::declaredTransforms))
.setter(setter(Builder::declaredTransforms))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeclaredTransforms").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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PARAMETERS_FIELD,
DESCRIPTION_FIELD, CAPABILITIES_FIELD, CAPABILITIES_REASON_FIELD, DECLARED_TRANSFORMS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("Parameters", PARAMETERS_FIELD);
put("Description", DESCRIPTION_FIELD);
put("Capabilities", CAPABILITIES_FIELD);
put("CapabilitiesReason", CAPABILITIES_REASON_FIELD);
put("DeclaredTransforms", DECLARED_TRANSFORMS_FIELD);
}
});
private final List parameters;
private final String description;
private final List capabilities;
private final String capabilitiesReason;
private final List declaredTransforms;
private ValidateTemplateResponse(BuilderImpl builder) {
super(builder);
this.parameters = builder.parameters;
this.description = builder.description;
this.capabilities = builder.capabilities;
this.capabilitiesReason = builder.capabilitiesReason;
this.declaredTransforms = builder.declaredTransforms;
}
/**
* For responses, this returns true if the service returned a value for the Parameters 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 hasParameters() {
return parameters != null && !(parameters instanceof SdkAutoConstructList);
}
/**
*
* A list of TemplateParameter
structures.
*
*
* 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 #hasParameters} method.
*
*
* @return A list of TemplateParameter
structures.
*/
public final List parameters() {
return parameters;
}
/**
*
* The description found within the template.
*
*
* @return The description found within the template.
*/
public final String description() {
return description;
}
/**
*
* The capabilities found within the template. If your template contains IAM resources, you must specify the
* CAPABILITY_IAM or CAPABILITY_NAMED_IAM value for this parameter when you use the CreateStack or
* UpdateStack actions with your template; otherwise, those actions return an InsufficientCapabilities error.
*
*
* For more information, see Acknowledging IAM resources in CloudFormation 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 #hasCapabilities} method.
*
*
* @return The capabilities found within the template. If your template contains IAM resources, you must specify the
* CAPABILITY_IAM or CAPABILITY_NAMED_IAM value for this parameter when you use the CreateStack or
* UpdateStack actions with your template; otherwise, those actions return an
* InsufficientCapabilities error.
*
* For more information, see Acknowledging IAM resources in CloudFormation templates.
*/
public final List capabilities() {
return CapabilitiesCopier.copyStringToEnum(capabilities);
}
/**
* For responses, this returns true if the service returned a value for the Capabilities 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 hasCapabilities() {
return capabilities != null && !(capabilities instanceof SdkAutoConstructList);
}
/**
*
* The capabilities found within the template. If your template contains IAM resources, you must specify the
* CAPABILITY_IAM or CAPABILITY_NAMED_IAM value for this parameter when you use the CreateStack or
* UpdateStack actions with your template; otherwise, those actions return an InsufficientCapabilities error.
*
*
* For more information, see Acknowledging IAM resources in CloudFormation 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 #hasCapabilities} method.
*
*
* @return The capabilities found within the template. If your template contains IAM resources, you must specify the
* CAPABILITY_IAM or CAPABILITY_NAMED_IAM value for this parameter when you use the CreateStack or
* UpdateStack actions with your template; otherwise, those actions return an
* InsufficientCapabilities error.
*
* For more information, see Acknowledging IAM resources in CloudFormation templates.
*/
public final List capabilitiesAsStrings() {
return capabilities;
}
/**
*
* The list of resources that generated the values in the Capabilities
response element.
*
*
* @return The list of resources that generated the values in the Capabilities
response element.
*/
public final String capabilitiesReason() {
return capabilitiesReason;
}
/**
* For responses, this returns true if the service returned a value for the DeclaredTransforms 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 hasDeclaredTransforms() {
return declaredTransforms != null && !(declaredTransforms instanceof SdkAutoConstructList);
}
/**
*
* A list of the transforms that are declared in the template.
*
*
* 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 #hasDeclaredTransforms} method.
*
*
* @return A list of the transforms that are declared in the template.
*/
public final List declaredTransforms() {
return declaredTransforms;
}
@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(hasParameters() ? parameters() : null);
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(hasCapabilities() ? capabilitiesAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(capabilitiesReason());
hashCode = 31 * hashCode + Objects.hashCode(hasDeclaredTransforms() ? declaredTransforms() : null);
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 ValidateTemplateResponse)) {
return false;
}
ValidateTemplateResponse other = (ValidateTemplateResponse) obj;
return hasParameters() == other.hasParameters() && Objects.equals(parameters(), other.parameters())
&& Objects.equals(description(), other.description()) && hasCapabilities() == other.hasCapabilities()
&& Objects.equals(capabilitiesAsStrings(), other.capabilitiesAsStrings())
&& Objects.equals(capabilitiesReason(), other.capabilitiesReason())
&& hasDeclaredTransforms() == other.hasDeclaredTransforms()
&& Objects.equals(declaredTransforms(), other.declaredTransforms());
}
/**
* 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("ValidateTemplateResponse").add("Parameters", hasParameters() ? parameters() : null)
.add("Description", description()).add("Capabilities", hasCapabilities() ? capabilitiesAsStrings() : null)
.add("CapabilitiesReason", capabilitiesReason())
.add("DeclaredTransforms", hasDeclaredTransforms() ? declaredTransforms() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Parameters":
return Optional.ofNullable(clazz.cast(parameters()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "Capabilities":
return Optional.ofNullable(clazz.cast(capabilitiesAsStrings()));
case "CapabilitiesReason":
return Optional.ofNullable(clazz.cast(capabilitiesReason()));
case "DeclaredTransforms":
return Optional.ofNullable(clazz.cast(declaredTransforms()));
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
*
* For more information, see Acknowledging IAM resources in CloudFormation templates.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder capabilities(Collection capabilities);
/**
*
* The capabilities found within the template. If your template contains IAM resources, you must specify the
* CAPABILITY_IAM or CAPABILITY_NAMED_IAM value for this parameter when you use the CreateStack or
* UpdateStack actions with your template; otherwise, those actions return an InsufficientCapabilities
* error.
*
*
* For more information, see Acknowledging IAM resources in CloudFormation templates.
*
*
* @param capabilities
* The capabilities found within the template. If your template contains IAM resources, you must specify
* the CAPABILITY_IAM or CAPABILITY_NAMED_IAM value for this parameter when you use the
* CreateStack or UpdateStack actions with your template; otherwise, those actions return
* an InsufficientCapabilities error.
*
* For more information, see Acknowledging IAM resources in CloudFormation templates.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder capabilities(Capability... capabilities);
/**
*
* The list of resources that generated the values in the Capabilities
response element.
*
*
* @param capabilitiesReason
* The list of resources that generated the values in the Capabilities
response element.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder capabilitiesReason(String capabilitiesReason);
/**
*
* A list of the transforms that are declared in the template.
*
*
* @param declaredTransforms
* A list of the transforms that are declared in the template.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder declaredTransforms(Collection declaredTransforms);
/**
*
* A list of the transforms that are declared in the template.
*
*
* @param declaredTransforms
* A list of the transforms that are declared in the template.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder declaredTransforms(String... declaredTransforms);
}
static final class BuilderImpl extends CloudFormationResponse.BuilderImpl implements Builder {
private List parameters = DefaultSdkAutoConstructList.getInstance();
private String description;
private List capabilities = DefaultSdkAutoConstructList.getInstance();
private String capabilitiesReason;
private List declaredTransforms = DefaultSdkAutoConstructList.getInstance();
private BuilderImpl() {
}
private BuilderImpl(ValidateTemplateResponse model) {
super(model);
parameters(model.parameters);
description(model.description);
capabilitiesWithStrings(model.capabilities);
capabilitiesReason(model.capabilitiesReason);
declaredTransforms(model.declaredTransforms);
}
public final List getParameters() {
List result = TemplateParametersCopier.copyToBuilder(this.parameters);
if (result instanceof SdkAutoConstructList) {
return null;
}
return result;
}
public final void setParameters(Collection parameters) {
this.parameters = TemplateParametersCopier.copyFromBuilder(parameters);
}
@Override
public final Builder parameters(Collection parameters) {
this.parameters = TemplateParametersCopier.copy(parameters);
return this;
}
@Override
@SafeVarargs
public final Builder parameters(TemplateParameter... parameters) {
parameters(Arrays.asList(parameters));
return this;
}
@Override
@SafeVarargs
public final Builder parameters(Consumer... parameters) {
parameters(Stream.of(parameters).map(c -> TemplateParameter.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 Collection getCapabilities() {
if (capabilities instanceof SdkAutoConstructList) {
return null;
}
return capabilities;
}
public final void setCapabilities(Collection capabilities) {
this.capabilities = CapabilitiesCopier.copy(capabilities);
}
@Override
public final Builder capabilitiesWithStrings(Collection capabilities) {
this.capabilities = CapabilitiesCopier.copy(capabilities);
return this;
}
@Override
@SafeVarargs
public final Builder capabilitiesWithStrings(String... capabilities) {
capabilitiesWithStrings(Arrays.asList(capabilities));
return this;
}
@Override
public final Builder capabilities(Collection capabilities) {
this.capabilities = CapabilitiesCopier.copyEnumToString(capabilities);
return this;
}
@Override
@SafeVarargs
public final Builder capabilities(Capability... capabilities) {
capabilities(Arrays.asList(capabilities));
return this;
}
public final String getCapabilitiesReason() {
return capabilitiesReason;
}
public final void setCapabilitiesReason(String capabilitiesReason) {
this.capabilitiesReason = capabilitiesReason;
}
@Override
public final Builder capabilitiesReason(String capabilitiesReason) {
this.capabilitiesReason = capabilitiesReason;
return this;
}
public final Collection getDeclaredTransforms() {
if (declaredTransforms instanceof SdkAutoConstructList) {
return null;
}
return declaredTransforms;
}
public final void setDeclaredTransforms(Collection declaredTransforms) {
this.declaredTransforms = TransformsListCopier.copy(declaredTransforms);
}
@Override
public final Builder declaredTransforms(Collection declaredTransforms) {
this.declaredTransforms = TransformsListCopier.copy(declaredTransforms);
return this;
}
@Override
@SafeVarargs
public final Builder declaredTransforms(String... declaredTransforms) {
declaredTransforms(Arrays.asList(declaredTransforms));
return this;
}
@Override
public ValidateTemplateResponse build() {
return new ValidateTemplateResponse(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
@Override
public Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
}
}