All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.codedeploy.model.CloudFormationTarget Maven / Gradle / Ivy

/*
 * 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.codedeploy.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;

/**
 * 

* Information about the target to be updated by an CloudFormation blue/green deployment. This target type is used for * all deployments initiated by a CloudFormation stack update. *

*/ @Generated("software.amazon.awssdk:codegen") public final class CloudFormationTarget implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField DEPLOYMENT_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("deploymentId").getter(getter(CloudFormationTarget::deploymentId)).setter(setter(Builder::deploymentId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("deploymentId").build()).build(); private static final SdkField TARGET_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("targetId").getter(getter(CloudFormationTarget::targetId)).setter(setter(Builder::targetId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("targetId").build()).build(); private static final SdkField LAST_UPDATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("lastUpdatedAt").getter(getter(CloudFormationTarget::lastUpdatedAt)) .setter(setter(Builder::lastUpdatedAt)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastUpdatedAt").build()).build(); private static final SdkField> LIFECYCLE_EVENTS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("lifecycleEvents") .getter(getter(CloudFormationTarget::lifecycleEvents)) .setter(setter(Builder::lifecycleEvents)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lifecycleEvents").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(LifecycleEvent::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(CloudFormationTarget::statusAsString)).setter(setter(Builder::status)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build(); private static final SdkField RESOURCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("resourceType").getter(getter(CloudFormationTarget::resourceType)).setter(setter(Builder::resourceType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resourceType").build()).build(); private static final SdkField TARGET_VERSION_WEIGHT_FIELD = SdkField. builder(MarshallingType.DOUBLE) .memberName("targetVersionWeight").getter(getter(CloudFormationTarget::targetVersionWeight)) .setter(setter(Builder::targetVersionWeight)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("targetVersionWeight").build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DEPLOYMENT_ID_FIELD, TARGET_ID_FIELD, LAST_UPDATED_AT_FIELD, LIFECYCLE_EVENTS_FIELD, STATUS_FIELD, RESOURCE_TYPE_FIELD, TARGET_VERSION_WEIGHT_FIELD)); private static final long serialVersionUID = 1L; private final String deploymentId; private final String targetId; private final Instant lastUpdatedAt; private final List lifecycleEvents; private final String status; private final String resourceType; private final Double targetVersionWeight; private CloudFormationTarget(BuilderImpl builder) { this.deploymentId = builder.deploymentId; this.targetId = builder.targetId; this.lastUpdatedAt = builder.lastUpdatedAt; this.lifecycleEvents = builder.lifecycleEvents; this.status = builder.status; this.resourceType = builder.resourceType; this.targetVersionWeight = builder.targetVersionWeight; } /** *

* The unique ID of an CloudFormation blue/green deployment. *

* * @return The unique ID of an CloudFormation blue/green deployment. */ public final String deploymentId() { return deploymentId; } /** *

* The unique ID of a deployment target that has a type of CloudFormationTarget. *

* * @return The unique ID of a deployment target that has a type of CloudFormationTarget. */ public final String targetId() { return targetId; } /** *

* The date and time when the target application was updated by an CloudFormation blue/green deployment. *

* * @return The date and time when the target application was updated by an CloudFormation blue/green deployment. */ public final Instant lastUpdatedAt() { return lastUpdatedAt; } /** * For responses, this returns true if the service returned a value for the LifecycleEvents 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 hasLifecycleEvents() { return lifecycleEvents != null && !(lifecycleEvents instanceof SdkAutoConstructList); } /** *

* The lifecycle events of the CloudFormation blue/green deployment to this target application. *

*

* 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 #hasLifecycleEvents} method. *

* * @return The lifecycle events of the CloudFormation blue/green deployment to this target application. */ public final List lifecycleEvents() { return lifecycleEvents; } /** *

* The status of an CloudFormation blue/green deployment's target application. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #status} will * return {@link TargetStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statusAsString}. *

* * @return The status of an CloudFormation blue/green deployment's target application. * @see TargetStatus */ public final TargetStatus status() { return TargetStatus.fromValue(status); } /** *

* The status of an CloudFormation blue/green deployment's target application. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #status} will * return {@link TargetStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statusAsString}. *

* * @return The status of an CloudFormation blue/green deployment's target application. * @see TargetStatus */ public final String statusAsString() { return status; } /** *

* The resource type for the CloudFormation blue/green deployment. *

* * @return The resource type for the CloudFormation blue/green deployment. */ public final String resourceType() { return resourceType; } /** *

* The percentage of production traffic that the target version of an CloudFormation blue/green deployment receives. *

* * @return The percentage of production traffic that the target version of an CloudFormation blue/green deployment * receives. */ public final Double targetVersionWeight() { return targetVersionWeight; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(deploymentId()); hashCode = 31 * hashCode + Objects.hashCode(targetId()); hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedAt()); hashCode = 31 * hashCode + Objects.hashCode(hasLifecycleEvents() ? lifecycleEvents() : null); hashCode = 31 * hashCode + Objects.hashCode(statusAsString()); hashCode = 31 * hashCode + Objects.hashCode(resourceType()); hashCode = 31 * hashCode + Objects.hashCode(targetVersionWeight()); 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 CloudFormationTarget)) { return false; } CloudFormationTarget other = (CloudFormationTarget) obj; return Objects.equals(deploymentId(), other.deploymentId()) && Objects.equals(targetId(), other.targetId()) && Objects.equals(lastUpdatedAt(), other.lastUpdatedAt()) && hasLifecycleEvents() == other.hasLifecycleEvents() && Objects.equals(lifecycleEvents(), other.lifecycleEvents()) && Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(resourceType(), other.resourceType()) && Objects.equals(targetVersionWeight(), other.targetVersionWeight()); } /** * 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("CloudFormationTarget").add("DeploymentId", deploymentId()).add("TargetId", targetId()) .add("LastUpdatedAt", lastUpdatedAt()).add("LifecycleEvents", hasLifecycleEvents() ? lifecycleEvents() : null) .add("Status", statusAsString()).add("ResourceType", resourceType()) .add("TargetVersionWeight", targetVersionWeight()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "deploymentId": return Optional.ofNullable(clazz.cast(deploymentId())); case "targetId": return Optional.ofNullable(clazz.cast(targetId())); case "lastUpdatedAt": return Optional.ofNullable(clazz.cast(lastUpdatedAt())); case "lifecycleEvents": return Optional.ofNullable(clazz.cast(lifecycleEvents())); case "status": return Optional.ofNullable(clazz.cast(statusAsString())); case "resourceType": return Optional.ofNullable(clazz.cast(resourceType())); case "targetVersionWeight": return Optional.ofNullable(clazz.cast(targetVersionWeight())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CloudFormationTarget) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The unique ID of an CloudFormation blue/green deployment. *

* * @param deploymentId * The unique ID of an CloudFormation blue/green deployment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder deploymentId(String deploymentId); /** *

* The unique ID of a deployment target that has a type of CloudFormationTarget. *

* * @param targetId * The unique ID of a deployment target that has a type of CloudFormationTarget. * @return Returns a reference to this object so that method calls can be chained together. */ Builder targetId(String targetId); /** *

* The date and time when the target application was updated by an CloudFormation blue/green deployment. *

* * @param lastUpdatedAt * The date and time when the target application was updated by an CloudFormation blue/green deployment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lastUpdatedAt(Instant lastUpdatedAt); /** *

* The lifecycle events of the CloudFormation blue/green deployment to this target application. *

* * @param lifecycleEvents * The lifecycle events of the CloudFormation blue/green deployment to this target application. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lifecycleEvents(Collection lifecycleEvents); /** *

* The lifecycle events of the CloudFormation blue/green deployment to this target application. *

* * @param lifecycleEvents * The lifecycle events of the CloudFormation blue/green deployment to this target application. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lifecycleEvents(LifecycleEvent... lifecycleEvents); /** *

* The lifecycle events of the CloudFormation blue/green deployment to this target application. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.codedeploy.model.LifecycleEvent.Builder} avoiding the need to create * one manually via {@link software.amazon.awssdk.services.codedeploy.model.LifecycleEvent#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.codedeploy.model.LifecycleEvent.Builder#build()} is called immediately * and its result is passed to {@link #lifecycleEvents(List)}. * * @param lifecycleEvents * a consumer that will call methods on * {@link software.amazon.awssdk.services.codedeploy.model.LifecycleEvent.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #lifecycleEvents(java.util.Collection) */ Builder lifecycleEvents(Consumer... lifecycleEvents); /** *

* The status of an CloudFormation blue/green deployment's target application. *

* * @param status * The status of an CloudFormation blue/green deployment's target application. * @see TargetStatus * @return Returns a reference to this object so that method calls can be chained together. * @see TargetStatus */ Builder status(String status); /** *

* The status of an CloudFormation blue/green deployment's target application. *

* * @param status * The status of an CloudFormation blue/green deployment's target application. * @see TargetStatus * @return Returns a reference to this object so that method calls can be chained together. * @see TargetStatus */ Builder status(TargetStatus status); /** *

* The resource type for the CloudFormation blue/green deployment. *

* * @param resourceType * The resource type for the CloudFormation blue/green deployment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder resourceType(String resourceType); /** *

* The percentage of production traffic that the target version of an CloudFormation blue/green deployment * receives. *

* * @param targetVersionWeight * The percentage of production traffic that the target version of an CloudFormation blue/green * deployment receives. * @return Returns a reference to this object so that method calls can be chained together. */ Builder targetVersionWeight(Double targetVersionWeight); } static final class BuilderImpl implements Builder { private String deploymentId; private String targetId; private Instant lastUpdatedAt; private List lifecycleEvents = DefaultSdkAutoConstructList.getInstance(); private String status; private String resourceType; private Double targetVersionWeight; private BuilderImpl() { } private BuilderImpl(CloudFormationTarget model) { deploymentId(model.deploymentId); targetId(model.targetId); lastUpdatedAt(model.lastUpdatedAt); lifecycleEvents(model.lifecycleEvents); status(model.status); resourceType(model.resourceType); targetVersionWeight(model.targetVersionWeight); } public final String getDeploymentId() { return deploymentId; } public final void setDeploymentId(String deploymentId) { this.deploymentId = deploymentId; } @Override public final Builder deploymentId(String deploymentId) { this.deploymentId = deploymentId; return this; } public final String getTargetId() { return targetId; } public final void setTargetId(String targetId) { this.targetId = targetId; } @Override public final Builder targetId(String targetId) { this.targetId = targetId; return this; } public final Instant getLastUpdatedAt() { return lastUpdatedAt; } public final void setLastUpdatedAt(Instant lastUpdatedAt) { this.lastUpdatedAt = lastUpdatedAt; } @Override public final Builder lastUpdatedAt(Instant lastUpdatedAt) { this.lastUpdatedAt = lastUpdatedAt; return this; } public final List getLifecycleEvents() { List result = LifecycleEventListCopier.copyToBuilder(this.lifecycleEvents); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setLifecycleEvents(Collection lifecycleEvents) { this.lifecycleEvents = LifecycleEventListCopier.copyFromBuilder(lifecycleEvents); } @Override public final Builder lifecycleEvents(Collection lifecycleEvents) { this.lifecycleEvents = LifecycleEventListCopier.copy(lifecycleEvents); return this; } @Override @SafeVarargs public final Builder lifecycleEvents(LifecycleEvent... lifecycleEvents) { lifecycleEvents(Arrays.asList(lifecycleEvents)); return this; } @Override @SafeVarargs public final Builder lifecycleEvents(Consumer... lifecycleEvents) { lifecycleEvents(Stream.of(lifecycleEvents).map(c -> LifecycleEvent.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final String getStatus() { return status; } public final void setStatus(String status) { this.status = status; } @Override public final Builder status(String status) { this.status = status; return this; } @Override public final Builder status(TargetStatus status) { this.status(status == null ? null : status.toString()); return this; } public final String getResourceType() { return resourceType; } public final void setResourceType(String resourceType) { this.resourceType = resourceType; } @Override public final Builder resourceType(String resourceType) { this.resourceType = resourceType; return this; } public final Double getTargetVersionWeight() { return targetVersionWeight; } public final void setTargetVersionWeight(Double targetVersionWeight) { this.targetVersionWeight = targetVersionWeight; } @Override public final Builder targetVersionWeight(Double targetVersionWeight) { this.targetVersionWeight = targetVersionWeight; return this; } @Override public CloudFormationTarget build() { return new CloudFormationTarget(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy