software.amazon.awssdk.services.cloudformation.model.StackInstance 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.io.Serializable;
import java.time.Instant;
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.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;
/**
*
* An AWS CloudFormation stack, in a specific account and Region, that's part of a stack set operation. A stack instance
* is a reference to an attempted or actual stack in a given account within a given Region. A stack instance can exist
* without a stack—for example, if the stack couldn't be created for some reason. A stack instance is associated with
* only one stack set. Each stack instance contains the ID of its associated stack set, as well as the ID of the actual
* stack and the stack status.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class StackInstance implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField STACK_SET_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackInstance::stackSetId)).setter(setter(Builder::stackSetId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StackSetId").build()).build();
private static final SdkField REGION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackInstance::region)).setter(setter(Builder::region))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Region").build()).build();
private static final SdkField ACCOUNT_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackInstance::account)).setter(setter(Builder::account))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Account").build()).build();
private static final SdkField STACK_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackInstance::stackId)).setter(setter(Builder::stackId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StackId").build()).build();
private static final SdkField> PARAMETER_OVERRIDES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(StackInstance::parameterOverrides))
.setter(setter(Builder::parameterOverrides))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ParameterOverrides").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Parameter::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackInstance::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField STATUS_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackInstance::statusReason)).setter(setter(Builder::statusReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusReason").build()).build();
private static final SdkField ORGANIZATIONAL_UNIT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackInstance::organizationalUnitId)).setter(setter(Builder::organizationalUnitId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OrganizationalUnitId").build())
.build();
private static final SdkField DRIFT_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackInstance::driftStatusAsString)).setter(setter(Builder::driftStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DriftStatus").build()).build();
private static final SdkField LAST_DRIFT_CHECK_TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(StackInstance::lastDriftCheckTimestamp)).setter(setter(Builder::lastDriftCheckTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastDriftCheckTimestamp").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STACK_SET_ID_FIELD,
REGION_FIELD, ACCOUNT_FIELD, STACK_ID_FIELD, PARAMETER_OVERRIDES_FIELD, STATUS_FIELD, STATUS_REASON_FIELD,
ORGANIZATIONAL_UNIT_ID_FIELD, DRIFT_STATUS_FIELD, LAST_DRIFT_CHECK_TIMESTAMP_FIELD));
private static final long serialVersionUID = 1L;
private final String stackSetId;
private final String region;
private final String account;
private final String stackId;
private final List parameterOverrides;
private final String status;
private final String statusReason;
private final String organizationalUnitId;
private final String driftStatus;
private final Instant lastDriftCheckTimestamp;
private StackInstance(BuilderImpl builder) {
this.stackSetId = builder.stackSetId;
this.region = builder.region;
this.account = builder.account;
this.stackId = builder.stackId;
this.parameterOverrides = builder.parameterOverrides;
this.status = builder.status;
this.statusReason = builder.statusReason;
this.organizationalUnitId = builder.organizationalUnitId;
this.driftStatus = builder.driftStatus;
this.lastDriftCheckTimestamp = builder.lastDriftCheckTimestamp;
}
/**
*
* The name or unique ID of the stack set that the stack instance is associated with.
*
*
* @return The name or unique ID of the stack set that the stack instance is associated with.
*/
public String stackSetId() {
return stackSetId;
}
/**
*
* The name of the AWS Region that the stack instance is associated with.
*
*
* @return The name of the AWS Region that the stack instance is associated with.
*/
public String region() {
return region;
}
/**
*
* [Self-managed
permissions] The name of the AWS account that the stack instance is associated with.
*
*
* @return [Self-managed
permissions] The name of the AWS account that the stack instance is associated
* with.
*/
public String account() {
return account;
}
/**
*
* The ID of the stack instance.
*
*
* @return The ID of the stack instance.
*/
public String stackId() {
return stackId;
}
/**
* Returns true if the ParameterOverrides property was specified by the sender (it may be empty), or false if the
* sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
* service.
*/
public boolean hasParameterOverrides() {
return parameterOverrides != null && !(parameterOverrides instanceof SdkAutoConstructList);
}
/**
*
* A list of parameters from the stack set template whose values have been overridden in this stack instance.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasParameterOverrides()} to see if a value was sent in this field.
*
*
* @return A list of parameters from the stack set template whose values have been overridden in this stack
* instance.
*/
public List parameterOverrides() {
return parameterOverrides;
}
/**
*
* The status of the stack instance, in terms of its synchronization with its associated stack set.
*
*
* -
*
* INOPERABLE
: A DeleteStackInstances
operation has failed and left the stack in an
* unstable state. Stacks in this state are excluded from further UpdateStackSet
operations. You might
* need to perform a DeleteStackInstances
operation, with RetainStacks
set to
* true
, to delete the stack instance, and then delete the stack manually.
*
*
* -
*
* OUTDATED
: The stack isn't currently up to date with the stack set because:
*
*
* -
*
* The associated stack failed during a CreateStackSet
or UpdateStackSet
operation.
*
*
* -
*
* The stack was part of a CreateStackSet
or UpdateStackSet
operation that failed or was
* stopped before the stack was created or updated.
*
*
*
*
* -
*
* CURRENT
: The stack is currently up to date with the stack set.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link StackInstanceStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the stack instance, in terms of its synchronization with its associated stack set.
*
* -
*
* INOPERABLE
: A DeleteStackInstances
operation has failed and left the stack in
* an unstable state. Stacks in this state are excluded from further UpdateStackSet
operations.
* You might need to perform a DeleteStackInstances
operation, with RetainStacks
* set to true
, to delete the stack instance, and then delete the stack manually.
*
*
* -
*
* OUTDATED
: The stack isn't currently up to date with the stack set because:
*
*
* -
*
* The associated stack failed during a CreateStackSet
or UpdateStackSet
* operation.
*
*
* -
*
* The stack was part of a CreateStackSet
or UpdateStackSet
operation that failed
* or was stopped before the stack was created or updated.
*
*
*
*
* -
*
* CURRENT
: The stack is currently up to date with the stack set.
*
*
* @see StackInstanceStatus
*/
public StackInstanceStatus status() {
return StackInstanceStatus.fromValue(status);
}
/**
*
* The status of the stack instance, in terms of its synchronization with its associated stack set.
*
*
* -
*
* INOPERABLE
: A DeleteStackInstances
operation has failed and left the stack in an
* unstable state. Stacks in this state are excluded from further UpdateStackSet
operations. You might
* need to perform a DeleteStackInstances
operation, with RetainStacks
set to
* true
, to delete the stack instance, and then delete the stack manually.
*
*
* -
*
* OUTDATED
: The stack isn't currently up to date with the stack set because:
*
*
* -
*
* The associated stack failed during a CreateStackSet
or UpdateStackSet
operation.
*
*
* -
*
* The stack was part of a CreateStackSet
or UpdateStackSet
operation that failed or was
* stopped before the stack was created or updated.
*
*
*
*
* -
*
* CURRENT
: The stack is currently up to date with the stack set.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link StackInstanceStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the stack instance, in terms of its synchronization with its associated stack set.
*
* -
*
* INOPERABLE
: A DeleteStackInstances
operation has failed and left the stack in
* an unstable state. Stacks in this state are excluded from further UpdateStackSet
operations.
* You might need to perform a DeleteStackInstances
operation, with RetainStacks
* set to true
, to delete the stack instance, and then delete the stack manually.
*
*
* -
*
* OUTDATED
: The stack isn't currently up to date with the stack set because:
*
*
* -
*
* The associated stack failed during a CreateStackSet
or UpdateStackSet
* operation.
*
*
* -
*
* The stack was part of a CreateStackSet
or UpdateStackSet
operation that failed
* or was stopped before the stack was created or updated.
*
*
*
*
* -
*
* CURRENT
: The stack is currently up to date with the stack set.
*
*
* @see StackInstanceStatus
*/
public String statusAsString() {
return status;
}
/**
*
* The explanation for the specific status code that is assigned to this stack instance.
*
*
* @return The explanation for the specific status code that is assigned to this stack instance.
*/
public String statusReason() {
return statusReason;
}
/**
*
* [Service-managed
permissions] The organization root ID or organizational unit (OU) IDs that you
* specified for DeploymentTargets.
*
*
* @return [Service-managed
permissions] The organization root ID or organizational unit (OU) IDs that
* you specified for DeploymentTargets.
*/
public String organizationalUnitId() {
return organizationalUnitId;
}
/**
*
* Status of the stack instance's actual configuration compared to the expected template and parameter configuration
* of the stack set to which it belongs.
*
*
* -
*
* DRIFTED
: The stack differs from the expected template and parameter configuration of the stack set
* to which it belongs. A stack instance is considered to have drifted if one or more of the resources in the
* associated stack have drifted.
*
*
* -
*
* NOT_CHECKED
: AWS CloudFormation has not checked if the stack instance differs from its expected
* stack set configuration.
*
*
* -
*
* IN_SYNC
: The stack instance's actual configuration matches its expected stack set configuration.
*
*
* -
*
* UNKNOWN
: This value is reserved for future use.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #driftStatus} will
* return {@link StackDriftStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #driftStatusAsString}.
*
*
* @return Status of the stack instance's actual configuration compared to the expected template and parameter
* configuration of the stack set to which it belongs.
*
* -
*
* DRIFTED
: The stack differs from the expected template and parameter configuration of the
* stack set to which it belongs. A stack instance is considered to have drifted if one or more of the
* resources in the associated stack have drifted.
*
*
* -
*
* NOT_CHECKED
: AWS CloudFormation has not checked if the stack instance differs from its
* expected stack set configuration.
*
*
* -
*
* IN_SYNC
: The stack instance's actual configuration matches its expected stack set
* configuration.
*
*
* -
*
* UNKNOWN
: This value is reserved for future use.
*
*
* @see StackDriftStatus
*/
public StackDriftStatus driftStatus() {
return StackDriftStatus.fromValue(driftStatus);
}
/**
*
* Status of the stack instance's actual configuration compared to the expected template and parameter configuration
* of the stack set to which it belongs.
*
*
* -
*
* DRIFTED
: The stack differs from the expected template and parameter configuration of the stack set
* to which it belongs. A stack instance is considered to have drifted if one or more of the resources in the
* associated stack have drifted.
*
*
* -
*
* NOT_CHECKED
: AWS CloudFormation has not checked if the stack instance differs from its expected
* stack set configuration.
*
*
* -
*
* IN_SYNC
: The stack instance's actual configuration matches its expected stack set configuration.
*
*
* -
*
* UNKNOWN
: This value is reserved for future use.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #driftStatus} will
* return {@link StackDriftStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #driftStatusAsString}.
*
*
* @return Status of the stack instance's actual configuration compared to the expected template and parameter
* configuration of the stack set to which it belongs.
*
* -
*
* DRIFTED
: The stack differs from the expected template and parameter configuration of the
* stack set to which it belongs. A stack instance is considered to have drifted if one or more of the
* resources in the associated stack have drifted.
*
*
* -
*
* NOT_CHECKED
: AWS CloudFormation has not checked if the stack instance differs from its
* expected stack set configuration.
*
*
* -
*
* IN_SYNC
: The stack instance's actual configuration matches its expected stack set
* configuration.
*
*
* -
*
* UNKNOWN
: This value is reserved for future use.
*
*
* @see StackDriftStatus
*/
public String driftStatusAsString() {
return driftStatus;
}
/**
*
* Most recent time when CloudFormation performed a drift detection operation on the stack instance. This value will
* be NULL
for any stack instance on which drift detection has not yet been performed.
*
*
* @return Most recent time when CloudFormation performed a drift detection operation on the stack instance. This
* value will be NULL
for any stack instance on which drift detection has not yet been
* performed.
*/
public Instant lastDriftCheckTimestamp() {
return lastDriftCheckTimestamp;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(stackSetId());
hashCode = 31 * hashCode + Objects.hashCode(region());
hashCode = 31 * hashCode + Objects.hashCode(account());
hashCode = 31 * hashCode + Objects.hashCode(stackId());
hashCode = 31 * hashCode + Objects.hashCode(parameterOverrides());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(statusReason());
hashCode = 31 * hashCode + Objects.hashCode(organizationalUnitId());
hashCode = 31 * hashCode + Objects.hashCode(driftStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(lastDriftCheckTimestamp());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof StackInstance)) {
return false;
}
StackInstance other = (StackInstance) obj;
return Objects.equals(stackSetId(), other.stackSetId()) && Objects.equals(region(), other.region())
&& Objects.equals(account(), other.account()) && Objects.equals(stackId(), other.stackId())
&& Objects.equals(parameterOverrides(), other.parameterOverrides())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(statusReason(), other.statusReason())
&& Objects.equals(organizationalUnitId(), other.organizationalUnitId())
&& Objects.equals(driftStatusAsString(), other.driftStatusAsString())
&& Objects.equals(lastDriftCheckTimestamp(), other.lastDriftCheckTimestamp());
}
/**
* 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 String toString() {
return ToString.builder("StackInstance").add("StackSetId", stackSetId()).add("Region", region())
.add("Account", account()).add("StackId", stackId()).add("ParameterOverrides", parameterOverrides())
.add("Status", statusAsString()).add("StatusReason", statusReason())
.add("OrganizationalUnitId", organizationalUnitId()).add("DriftStatus", driftStatusAsString())
.add("LastDriftCheckTimestamp", lastDriftCheckTimestamp()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "StackSetId":
return Optional.ofNullable(clazz.cast(stackSetId()));
case "Region":
return Optional.ofNullable(clazz.cast(region()));
case "Account":
return Optional.ofNullable(clazz.cast(account()));
case "StackId":
return Optional.ofNullable(clazz.cast(stackId()));
case "ParameterOverrides":
return Optional.ofNullable(clazz.cast(parameterOverrides()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "StatusReason":
return Optional.ofNullable(clazz.cast(statusReason()));
case "OrganizationalUnitId":
return Optional.ofNullable(clazz.cast(organizationalUnitId()));
case "DriftStatus":
return Optional.ofNullable(clazz.cast(driftStatusAsString()));
case "LastDriftCheckTimestamp":
return Optional.ofNullable(clazz.cast(lastDriftCheckTimestamp()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function