software.amazon.awssdk.services.cloudformation.model.StackResource 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.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 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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The StackResource data type.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class StackResource implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField STACK_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackResource::stackName)).setter(setter(Builder::stackName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StackName").build()).build();
private static final SdkField STACK_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackResource::stackId)).setter(setter(Builder::stackId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StackId").build()).build();
private static final SdkField LOGICAL_RESOURCE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackResource::logicalResourceId)).setter(setter(Builder::logicalResourceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LogicalResourceId").build()).build();
private static final SdkField PHYSICAL_RESOURCE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackResource::physicalResourceId)).setter(setter(Builder::physicalResourceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PhysicalResourceId").build())
.build();
private static final SdkField RESOURCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackResource::resourceType)).setter(setter(Builder::resourceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceType").build()).build();
private static final SdkField TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(StackResource::timestamp)).setter(setter(Builder::timestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Timestamp").build()).build();
private static final SdkField RESOURCE_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackResource::resourceStatusAsString)).setter(setter(Builder::resourceStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceStatus").build()).build();
private static final SdkField RESOURCE_STATUS_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackResource::resourceStatusReason)).setter(setter(Builder::resourceStatusReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceStatusReason").build())
.build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(StackResource::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField DRIFT_INFORMATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(StackResource::driftInformation))
.setter(setter(Builder::driftInformation)).constructor(StackResourceDriftInformation::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DriftInformation").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STACK_NAME_FIELD,
STACK_ID_FIELD, LOGICAL_RESOURCE_ID_FIELD, PHYSICAL_RESOURCE_ID_FIELD, RESOURCE_TYPE_FIELD, TIMESTAMP_FIELD,
RESOURCE_STATUS_FIELD, RESOURCE_STATUS_REASON_FIELD, DESCRIPTION_FIELD, DRIFT_INFORMATION_FIELD));
private static final long serialVersionUID = 1L;
private final String stackName;
private final String stackId;
private final String logicalResourceId;
private final String physicalResourceId;
private final String resourceType;
private final Instant timestamp;
private final String resourceStatus;
private final String resourceStatusReason;
private final String description;
private final StackResourceDriftInformation driftInformation;
private StackResource(BuilderImpl builder) {
this.stackName = builder.stackName;
this.stackId = builder.stackId;
this.logicalResourceId = builder.logicalResourceId;
this.physicalResourceId = builder.physicalResourceId;
this.resourceType = builder.resourceType;
this.timestamp = builder.timestamp;
this.resourceStatus = builder.resourceStatus;
this.resourceStatusReason = builder.resourceStatusReason;
this.description = builder.description;
this.driftInformation = builder.driftInformation;
}
/**
*
* The name associated with the stack.
*
*
* @return The name associated with the stack.
*/
public String stackName() {
return stackName;
}
/**
*
* Unique identifier of the stack.
*
*
* @return Unique identifier of the stack.
*/
public String stackId() {
return stackId;
}
/**
*
* The logical name of the resource specified in the template.
*
*
* @return The logical name of the resource specified in the template.
*/
public String logicalResourceId() {
return logicalResourceId;
}
/**
*
* The name or unique identifier that corresponds to a physical instance ID of a resource supported by AWS
* CloudFormation.
*
*
* @return The name or unique identifier that corresponds to a physical instance ID of a resource supported by AWS
* CloudFormation.
*/
public String physicalResourceId() {
return physicalResourceId;
}
/**
*
* Type of resource. (For more information, go to AWS
* Resource Types Reference in the AWS CloudFormation User Guide.)
*
*
* @return Type of resource. (For more information, go to AWS Resource Types Reference in the AWS CloudFormation User Guide.)
*/
public String resourceType() {
return resourceType;
}
/**
*
* Time the status was updated.
*
*
* @return Time the status was updated.
*/
public Instant timestamp() {
return timestamp;
}
/**
*
* Current status of the resource.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resourceStatus}
* will return {@link ResourceStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #resourceStatusAsString}.
*
*
* @return Current status of the resource.
* @see ResourceStatus
*/
public ResourceStatus resourceStatus() {
return ResourceStatus.fromValue(resourceStatus);
}
/**
*
* Current status of the resource.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #resourceStatus}
* will return {@link ResourceStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #resourceStatusAsString}.
*
*
* @return Current status of the resource.
* @see ResourceStatus
*/
public String resourceStatusAsString() {
return resourceStatus;
}
/**
*
* Success/failure message associated with the resource.
*
*
* @return Success/failure message associated with the resource.
*/
public String resourceStatusReason() {
return resourceStatusReason;
}
/**
*
* User defined description associated with the resource.
*
*
* @return User defined description associated with the resource.
*/
public String description() {
return description;
}
/**
*
* Information about whether the resource's actual configuration differs, or has drifted, from its expected
* configuration, as defined in the stack template and any values specified as template parameters. For more
* information, see Detecting
* Unregulated Configuration Changes to Stacks and Resources.
*
*
* @return Information about whether the resource's actual configuration differs, or has drifted, from its
* expected configuration, as defined in the stack template and any values specified as template parameters.
* For more information, see Detecting
* Unregulated Configuration Changes to Stacks and Resources.
*/
public StackResourceDriftInformation driftInformation() {
return driftInformation;
}
@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(stackName());
hashCode = 31 * hashCode + Objects.hashCode(stackId());
hashCode = 31 * hashCode + Objects.hashCode(logicalResourceId());
hashCode = 31 * hashCode + Objects.hashCode(physicalResourceId());
hashCode = 31 * hashCode + Objects.hashCode(resourceType());
hashCode = 31 * hashCode + Objects.hashCode(timestamp());
hashCode = 31 * hashCode + Objects.hashCode(resourceStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(resourceStatusReason());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(driftInformation());
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 StackResource)) {
return false;
}
StackResource other = (StackResource) obj;
return Objects.equals(stackName(), other.stackName()) && Objects.equals(stackId(), other.stackId())
&& Objects.equals(logicalResourceId(), other.logicalResourceId())
&& Objects.equals(physicalResourceId(), other.physicalResourceId())
&& Objects.equals(resourceType(), other.resourceType()) && Objects.equals(timestamp(), other.timestamp())
&& Objects.equals(resourceStatusAsString(), other.resourceStatusAsString())
&& Objects.equals(resourceStatusReason(), other.resourceStatusReason())
&& Objects.equals(description(), other.description())
&& Objects.equals(driftInformation(), other.driftInformation());
}
/**
* 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("StackResource").add("StackName", stackName()).add("StackId", stackId())
.add("LogicalResourceId", logicalResourceId()).add("PhysicalResourceId", physicalResourceId())
.add("ResourceType", resourceType()).add("Timestamp", timestamp())
.add("ResourceStatus", resourceStatusAsString()).add("ResourceStatusReason", resourceStatusReason())
.add("Description", description()).add("DriftInformation", driftInformation()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "StackName":
return Optional.ofNullable(clazz.cast(stackName()));
case "StackId":
return Optional.ofNullable(clazz.cast(stackId()));
case "LogicalResourceId":
return Optional.ofNullable(clazz.cast(logicalResourceId()));
case "PhysicalResourceId":
return Optional.ofNullable(clazz.cast(physicalResourceId()));
case "ResourceType":
return Optional.ofNullable(clazz.cast(resourceType()));
case "Timestamp":
return Optional.ofNullable(clazz.cast(timestamp()));
case "ResourceStatus":
return Optional.ofNullable(clazz.cast(resourceStatusAsString()));
case "ResourceStatusReason":
return Optional.ofNullable(clazz.cast(resourceStatusReason()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "DriftInformation":
return Optional.ofNullable(clazz.cast(driftInformation()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function