software.amazon.awssdk.services.cloudformation.model.UpdateGeneratedTemplateRequest 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.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 UpdateGeneratedTemplateRequest extends CloudFormationRequest implements
ToCopyableBuilder {
private static final SdkField GENERATED_TEMPLATE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("GeneratedTemplateName").getter(getter(UpdateGeneratedTemplateRequest::generatedTemplateName))
.setter(setter(Builder::generatedTemplateName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GeneratedTemplateName").build())
.build();
private static final SdkField NEW_GENERATED_TEMPLATE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NewGeneratedTemplateName").getter(getter(UpdateGeneratedTemplateRequest::newGeneratedTemplateName))
.setter(setter(Builder::newGeneratedTemplateName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NewGeneratedTemplateName").build())
.build();
private static final SdkField> ADD_RESOURCES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("AddResources")
.getter(getter(UpdateGeneratedTemplateRequest::addResources))
.setter(setter(Builder::addResources))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AddResources").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ResourceDefinition::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> REMOVE_RESOURCES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("RemoveResources")
.getter(getter(UpdateGeneratedTemplateRequest::removeResources))
.setter(setter(Builder::removeResources))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RemoveResources").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 REFRESH_ALL_RESOURCES_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("RefreshAllResources").getter(getter(UpdateGeneratedTemplateRequest::refreshAllResources))
.setter(setter(Builder::refreshAllResources))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RefreshAllResources").build())
.build();
private static final SdkField TEMPLATE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("TemplateConfiguration")
.getter(getter(UpdateGeneratedTemplateRequest::templateConfiguration)).setter(setter(Builder::templateConfiguration))
.constructor(TemplateConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TemplateConfiguration").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(GENERATED_TEMPLATE_NAME_FIELD,
NEW_GENERATED_TEMPLATE_NAME_FIELD, ADD_RESOURCES_FIELD, REMOVE_RESOURCES_FIELD, REFRESH_ALL_RESOURCES_FIELD,
TEMPLATE_CONFIGURATION_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("GeneratedTemplateName", GENERATED_TEMPLATE_NAME_FIELD);
put("NewGeneratedTemplateName", NEW_GENERATED_TEMPLATE_NAME_FIELD);
put("AddResources", ADD_RESOURCES_FIELD);
put("RemoveResources", REMOVE_RESOURCES_FIELD);
put("RefreshAllResources", REFRESH_ALL_RESOURCES_FIELD);
put("TemplateConfiguration", TEMPLATE_CONFIGURATION_FIELD);
}
});
private final String generatedTemplateName;
private final String newGeneratedTemplateName;
private final List addResources;
private final List removeResources;
private final Boolean refreshAllResources;
private final TemplateConfiguration templateConfiguration;
private UpdateGeneratedTemplateRequest(BuilderImpl builder) {
super(builder);
this.generatedTemplateName = builder.generatedTemplateName;
this.newGeneratedTemplateName = builder.newGeneratedTemplateName;
this.addResources = builder.addResources;
this.removeResources = builder.removeResources;
this.refreshAllResources = builder.refreshAllResources;
this.templateConfiguration = builder.templateConfiguration;
}
/**
*
* The name or Amazon Resource Name (ARN) of a generated template.
*
*
* @return The name or Amazon Resource Name (ARN) of a generated template.
*/
public final String generatedTemplateName() {
return generatedTemplateName;
}
/**
*
* An optional new name to assign to the generated template.
*
*
* @return An optional new name to assign to the generated template.
*/
public final String newGeneratedTemplateName() {
return newGeneratedTemplateName;
}
/**
* For responses, this returns true if the service returned a value for the AddResources 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 hasAddResources() {
return addResources != null && !(addResources instanceof SdkAutoConstructList);
}
/**
*
* An optional list of resources to be added to the generated 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 #hasAddResources} method.
*
*
* @return An optional list of resources to be added to the generated template.
*/
public final List addResources() {
return addResources;
}
/**
* For responses, this returns true if the service returned a value for the RemoveResources 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 hasRemoveResources() {
return removeResources != null && !(removeResources instanceof SdkAutoConstructList);
}
/**
*
* A list of logical ids for resources to remove from the generated 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 #hasRemoveResources} method.
*
*
* @return A list of logical ids for resources to remove from the generated template.
*/
public final List removeResources() {
return removeResources;
}
/**
*
* If true
, update the resource properties in the generated template with their current live state.
* This feature is useful when the resource properties in your generated a template does not reflect the live state
* of the resource properties. This happens when a user update the resource properties after generating a template.
*
*
* @return If true
, update the resource properties in the generated template with their current live
* state. This feature is useful when the resource properties in your generated a template does not reflect
* the live state of the resource properties. This happens when a user update the resource properties after
* generating a template.
*/
public final Boolean refreshAllResources() {
return refreshAllResources;
}
/**
*
* The configuration details of the generated template, including the DeletionPolicy
and
* UpdateReplacePolicy
.
*
*
* @return The configuration details of the generated template, including the DeletionPolicy
and
* UpdateReplacePolicy
.
*/
public final TemplateConfiguration templateConfiguration() {
return templateConfiguration;
}
@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(generatedTemplateName());
hashCode = 31 * hashCode + Objects.hashCode(newGeneratedTemplateName());
hashCode = 31 * hashCode + Objects.hashCode(hasAddResources() ? addResources() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasRemoveResources() ? removeResources() : null);
hashCode = 31 * hashCode + Objects.hashCode(refreshAllResources());
hashCode = 31 * hashCode + Objects.hashCode(templateConfiguration());
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 UpdateGeneratedTemplateRequest)) {
return false;
}
UpdateGeneratedTemplateRequest other = (UpdateGeneratedTemplateRequest) obj;
return Objects.equals(generatedTemplateName(), other.generatedTemplateName())
&& Objects.equals(newGeneratedTemplateName(), other.newGeneratedTemplateName())
&& hasAddResources() == other.hasAddResources() && Objects.equals(addResources(), other.addResources())
&& hasRemoveResources() == other.hasRemoveResources()
&& Objects.equals(removeResources(), other.removeResources())
&& Objects.equals(refreshAllResources(), other.refreshAllResources())
&& Objects.equals(templateConfiguration(), other.templateConfiguration());
}
/**
* 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("UpdateGeneratedTemplateRequest").add("GeneratedTemplateName", generatedTemplateName())
.add("NewGeneratedTemplateName", newGeneratedTemplateName())
.add("AddResources", hasAddResources() ? addResources() : null)
.add("RemoveResources", hasRemoveResources() ? removeResources() : null)
.add("RefreshAllResources", refreshAllResources()).add("TemplateConfiguration", templateConfiguration()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "GeneratedTemplateName":
return Optional.ofNullable(clazz.cast(generatedTemplateName()));
case "NewGeneratedTemplateName":
return Optional.ofNullable(clazz.cast(newGeneratedTemplateName()));
case "AddResources":
return Optional.ofNullable(clazz.cast(addResources()));
case "RemoveResources":
return Optional.ofNullable(clazz.cast(removeResources()));
case "RefreshAllResources":
return Optional.ofNullable(clazz.cast(refreshAllResources()));
case "TemplateConfiguration":
return Optional.ofNullable(clazz.cast(templateConfiguration()));
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