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

software.amazon.awssdk.services.codedeploy.model.TargetInstances 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.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 instances to be used in the replacement environment in a blue/green deployment. *

*/ @Generated("software.amazon.awssdk:codegen") public final class TargetInstances implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> TAG_FILTERS_FIELD = SdkField .> builder(MarshallingType.LIST) .getter(getter(TargetInstances::tagFilters)) .setter(setter(Builder::tagFilters)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tagFilters").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(EC2TagFilter::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField> AUTO_SCALING_GROUPS_FIELD = SdkField .> builder(MarshallingType.LIST) .getter(getter(TargetInstances::autoScalingGroups)) .setter(setter(Builder::autoScalingGroups)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("autoScalingGroups").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 EC2_TAG_SET_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .getter(getter(TargetInstances::ec2TagSet)).setter(setter(Builder::ec2TagSet)).constructor(EC2TagSet::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ec2TagSet").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TAG_FILTERS_FIELD, AUTO_SCALING_GROUPS_FIELD, EC2_TAG_SET_FIELD)); private static final long serialVersionUID = 1L; private final List tagFilters; private final List autoScalingGroups; private final EC2TagSet ec2TagSet; private TargetInstances(BuilderImpl builder) { this.tagFilters = builder.tagFilters; this.autoScalingGroups = builder.autoScalingGroups; this.ec2TagSet = builder.ec2TagSet; } /** * Returns true if the TagFilters 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 hasTagFilters() { return tagFilters != null && !(tagFilters instanceof SdkAutoConstructList); } /** *

* The tag filter key, type, and value used to identify Amazon EC2 instances in a replacement environment for a * blue/green deployment. Cannot be used in the same call as ec2TagSet. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasTagFilters()} to see if a value was sent in this field. *

* * @return The tag filter key, type, and value used to identify Amazon EC2 instances in a replacement environment * for a blue/green deployment. Cannot be used in the same call as ec2TagSet. */ public List tagFilters() { return tagFilters; } /** * Returns true if the AutoScalingGroups 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 hasAutoScalingGroups() { return autoScalingGroups != null && !(autoScalingGroups instanceof SdkAutoConstructList); } /** *

* The names of one or more Auto Scaling groups to identify a replacement environment for a blue/green deployment. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasAutoScalingGroups()} to see if a value was sent in this field. *

* * @return The names of one or more Auto Scaling groups to identify a replacement environment for a blue/green * deployment. */ public List autoScalingGroups() { return autoScalingGroups; } /** *

* Information about the groups of EC2 instance tags that an instance must be identified by in order for it to be * included in the replacement environment for a blue/green deployment. Cannot be used in the same call as * tagFilters. *

* * @return Information about the groups of EC2 instance tags that an instance must be identified by in order for it * to be included in the replacement environment for a blue/green deployment. Cannot be used in the same * call as tagFilters. */ public EC2TagSet ec2TagSet() { return ec2TagSet; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(tagFilters()); hashCode = 31 * hashCode + Objects.hashCode(autoScalingGroups()); hashCode = 31 * hashCode + Objects.hashCode(ec2TagSet()); 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 TargetInstances)) { return false; } TargetInstances other = (TargetInstances) obj; return Objects.equals(tagFilters(), other.tagFilters()) && Objects.equals(autoScalingGroups(), other.autoScalingGroups()) && Objects.equals(ec2TagSet(), other.ec2TagSet()); } /** * 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("TargetInstances").add("TagFilters", tagFilters()).add("AutoScalingGroups", autoScalingGroups()) .add("Ec2TagSet", ec2TagSet()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "tagFilters": return Optional.ofNullable(clazz.cast(tagFilters())); case "autoScalingGroups": return Optional.ofNullable(clazz.cast(autoScalingGroups())); case "ec2TagSet": return Optional.ofNullable(clazz.cast(ec2TagSet())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((TargetInstances) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The tag filter key, type, and value used to identify Amazon EC2 instances in a replacement environment for a * blue/green deployment. Cannot be used in the same call as ec2TagSet. *

* * @param tagFilters * The tag filter key, type, and value used to identify Amazon EC2 instances in a replacement environment * for a blue/green deployment. Cannot be used in the same call as ec2TagSet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tagFilters(Collection tagFilters); /** *

* The tag filter key, type, and value used to identify Amazon EC2 instances in a replacement environment for a * blue/green deployment. Cannot be used in the same call as ec2TagSet. *

* * @param tagFilters * The tag filter key, type, and value used to identify Amazon EC2 instances in a replacement environment * for a blue/green deployment. Cannot be used in the same call as ec2TagSet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tagFilters(EC2TagFilter... tagFilters); /** *

* The tag filter key, type, and value used to identify Amazon EC2 instances in a replacement environment for a * blue/green deployment. Cannot be used in the same call as ec2TagSet. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the need to * create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and its * result is passed to {@link #tagFilters(List)}. * * @param tagFilters * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #tagFilters(List) */ Builder tagFilters(Consumer... tagFilters); /** *

* The names of one or more Auto Scaling groups to identify a replacement environment for a blue/green * deployment. *

* * @param autoScalingGroups * The names of one or more Auto Scaling groups to identify a replacement environment for a blue/green * deployment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder autoScalingGroups(Collection autoScalingGroups); /** *

* The names of one or more Auto Scaling groups to identify a replacement environment for a blue/green * deployment. *

* * @param autoScalingGroups * The names of one or more Auto Scaling groups to identify a replacement environment for a blue/green * deployment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder autoScalingGroups(String... autoScalingGroups); /** *

* Information about the groups of EC2 instance tags that an instance must be identified by in order for it to * be included in the replacement environment for a blue/green deployment. Cannot be used in the same call as * tagFilters. *

* * @param ec2TagSet * Information about the groups of EC2 instance tags that an instance must be identified by in order for * it to be included in the replacement environment for a blue/green deployment. Cannot be used in the * same call as tagFilters. * @return Returns a reference to this object so that method calls can be chained together. */ Builder ec2TagSet(EC2TagSet ec2TagSet); /** *

* Information about the groups of EC2 instance tags that an instance must be identified by in order for it to * be included in the replacement environment for a blue/green deployment. Cannot be used in the same call as * tagFilters. *

* This is a convenience that creates an instance of the {@link EC2TagSet.Builder} avoiding the need to create * one manually via {@link EC2TagSet#builder()}. * * When the {@link Consumer} completes, {@link EC2TagSet.Builder#build()} is called immediately and its result * is passed to {@link #ec2TagSet(EC2TagSet)}. * * @param ec2TagSet * a consumer that will call methods on {@link EC2TagSet.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #ec2TagSet(EC2TagSet) */ default Builder ec2TagSet(Consumer ec2TagSet) { return ec2TagSet(EC2TagSet.builder().applyMutation(ec2TagSet).build()); } } static final class BuilderImpl implements Builder { private List tagFilters = DefaultSdkAutoConstructList.getInstance(); private List autoScalingGroups = DefaultSdkAutoConstructList.getInstance(); private EC2TagSet ec2TagSet; private BuilderImpl() { } private BuilderImpl(TargetInstances model) { tagFilters(model.tagFilters); autoScalingGroups(model.autoScalingGroups); ec2TagSet(model.ec2TagSet); } public final Collection getTagFilters() { return tagFilters != null ? tagFilters.stream().map(EC2TagFilter::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder tagFilters(Collection tagFilters) { this.tagFilters = EC2TagFilterListCopier.copy(tagFilters); return this; } @Override @SafeVarargs public final Builder tagFilters(EC2TagFilter... tagFilters) { tagFilters(Arrays.asList(tagFilters)); return this; } @Override @SafeVarargs public final Builder tagFilters(Consumer... tagFilters) { tagFilters(Stream.of(tagFilters).map(c -> EC2TagFilter.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setTagFilters(Collection tagFilters) { this.tagFilters = EC2TagFilterListCopier.copyFromBuilder(tagFilters); } public final Collection getAutoScalingGroups() { return autoScalingGroups; } @Override public final Builder autoScalingGroups(Collection autoScalingGroups) { this.autoScalingGroups = AutoScalingGroupNameListCopier.copy(autoScalingGroups); return this; } @Override @SafeVarargs public final Builder autoScalingGroups(String... autoScalingGroups) { autoScalingGroups(Arrays.asList(autoScalingGroups)); return this; } public final void setAutoScalingGroups(Collection autoScalingGroups) { this.autoScalingGroups = AutoScalingGroupNameListCopier.copy(autoScalingGroups); } public final EC2TagSet.Builder getEc2TagSet() { return ec2TagSet != null ? ec2TagSet.toBuilder() : null; } @Override public final Builder ec2TagSet(EC2TagSet ec2TagSet) { this.ec2TagSet = ec2TagSet; return this; } public final void setEc2TagSet(EC2TagSet.BuilderImpl ec2TagSet) { this.ec2TagSet = ec2TagSet != null ? ec2TagSet.build() : null; } @Override public TargetInstances build() { return new TargetInstances(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy