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 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, in addition to 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)
.memberName("StackSetId").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).memberName("Region")
.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).memberName("Account")
.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)
.memberName("StackId").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)
.memberName("ParameterOverrides")
.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).memberName("Status")
.getter(getter(StackInstance::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField STACK_INSTANCE_STATUS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("StackInstanceStatus")
.getter(getter(StackInstance::stackInstanceStatus)).setter(setter(Builder::stackInstanceStatus))
.constructor(StackInstanceComprehensiveStatus::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StackInstanceStatus").build())
.build();
private static final SdkField STATUS_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StatusReason").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)
.memberName("OrganizationalUnitId").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)
.memberName("DriftStatus").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)
.memberName("LastDriftCheckTimestamp").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, STACK_INSTANCE_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 StackInstanceComprehensiveStatus stackInstanceStatus;
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.stackInstanceStatus = builder.stackInstanceStatus;
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 final String stackSetId() {
return stackSetId;
}
/**
*
* The name of the Amazon Web Services Region that the stack instance is associated with.
*
*
* @return The name of the Amazon Web Services Region that the stack instance is associated with.
*/
public final String region() {
return region;
}
/**
*
* [Self-managed permissions] The name of the Amazon Web Services account that the stack instance is associated
* with.
*
*
* @return [Self-managed permissions] The name of the Amazon Web Services account that the stack instance is
* associated with.
*/
public final String account() {
return account;
}
/**
*
* The ID of the stack instance.
*
*
* @return The ID of the stack instance.
*/
public final String stackId() {
return stackId;
}
/**
* For responses, this returns true if the service returned a value for the ParameterOverrides 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 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.
*
*
* 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 #hasParameterOverrides} method.
*
*
* @return A list of parameters from the stack set template whose values have been overridden in this stack
* instance.
*/
public final 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 final 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 final String statusAsString() {
return status;
}
/**
*
* The detailed status of the stack instance.
*
*
* @return The detailed status of the stack instance.
*/
public final StackInstanceComprehensiveStatus stackInstanceStatus() {
return stackInstanceStatus;
}
/**
*
* The explanation for the specific status code that's assigned to this stack instance.
*
*
* @return The explanation for the specific status code that's assigned to this stack instance.
*/
public final 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 final 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
: CloudFormation hasn't 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
: CloudFormation hasn't 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 final 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
: CloudFormation hasn't 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
: CloudFormation hasn't 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 final 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 hasn't 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 hasn't yet been
* performed.
*/
public final 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 final 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(hasParameterOverrides() ? parameterOverrides() : null);
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(stackInstanceStatus());
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 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 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())
&& hasParameterOverrides() == other.hasParameterOverrides()
&& Objects.equals(parameterOverrides(), other.parameterOverrides())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(stackInstanceStatus(), other.stackInstanceStatus())
&& 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 final String toString() {
return ToString.builder("StackInstance").add("StackSetId", stackSetId()).add("Region", region())
.add("Account", account()).add("StackId", stackId())
.add("ParameterOverrides", hasParameterOverrides() ? parameterOverrides() : null).add("Status", statusAsString())
.add("StackInstanceStatus", stackInstanceStatus()).add("StatusReason", statusReason())
.add("OrganizationalUnitId", organizationalUnitId()).add("DriftStatus", driftStatusAsString())
.add("LastDriftCheckTimestamp", lastDriftCheckTimestamp()).build();
}
public final 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 "StackInstanceStatus":
return Optional.ofNullable(clazz.cast(stackInstanceStatus()));
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 final List> sdkFields() {
return SDK_FIELDS;
}
private static Function