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

software.amazon.awssdk.services.ec2.model.CreateTransitGatewayVpcAttachmentRequest 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.ec2.model;

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.awscore.AwsRequestOverrideConfiguration;
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;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class CreateTransitGatewayVpcAttachmentRequest extends Ec2Request implements
        ToCopyableBuilder {
    private static final SdkField TRANSIT_GATEWAY_ID_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("TransitGatewayId")
            .getter(getter(CreateTransitGatewayVpcAttachmentRequest::transitGatewayId))
            .setter(setter(Builder::transitGatewayId))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TransitGatewayId")
                    .unmarshallLocationName("TransitGatewayId").build()).build();

    private static final SdkField VPC_ID_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("VpcId")
            .getter(getter(CreateTransitGatewayVpcAttachmentRequest::vpcId))
            .setter(setter(Builder::vpcId))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VpcId")
                    .unmarshallLocationName("VpcId").build()).build();

    private static final SdkField> SUBNET_IDS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("SubnetIds")
            .getter(getter(CreateTransitGatewayVpcAttachmentRequest::subnetIds))
            .setter(setter(Builder::subnetIds))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubnetIds")
                    .unmarshallLocationName("SubnetIds").build(),
                    ListTrait
                            .builder()
                            .memberLocationName("item")
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("Item").unmarshallLocationName("item").build()).build())
                            .build()).build();

    private static final SdkField OPTIONS_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO)
            .memberName("Options")
            .getter(getter(CreateTransitGatewayVpcAttachmentRequest::options))
            .setter(setter(Builder::options))
            .constructor(CreateTransitGatewayVpcAttachmentRequestOptions::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Options")
                    .unmarshallLocationName("Options").build()).build();

    private static final SdkField> TAG_SPECIFICATIONS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("TagSpecifications")
            .getter(getter(CreateTransitGatewayVpcAttachmentRequest::tagSpecifications))
            .setter(setter(Builder::tagSpecifications))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TagSpecifications")
                    .unmarshallLocationName("TagSpecifications").build(),
                    ListTrait
                            .builder()
                            .memberLocationName("item")
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(TagSpecification::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("Item").unmarshallLocationName("item").build()).build())
                            .build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TRANSIT_GATEWAY_ID_FIELD,
            VPC_ID_FIELD, SUBNET_IDS_FIELD, OPTIONS_FIELD, TAG_SPECIFICATIONS_FIELD));

    private final String transitGatewayId;

    private final String vpcId;

    private final List subnetIds;

    private final CreateTransitGatewayVpcAttachmentRequestOptions options;

    private final List tagSpecifications;

    private CreateTransitGatewayVpcAttachmentRequest(BuilderImpl builder) {
        super(builder);
        this.transitGatewayId = builder.transitGatewayId;
        this.vpcId = builder.vpcId;
        this.subnetIds = builder.subnetIds;
        this.options = builder.options;
        this.tagSpecifications = builder.tagSpecifications;
    }

    /**
     * 

* The ID of the transit gateway. *

* * @return The ID of the transit gateway. */ public String transitGatewayId() { return transitGatewayId; } /** *

* The ID of the VPC. *

* * @return The ID of the VPC. */ public String vpcId() { return vpcId; } /** * Returns true if the SubnetIds 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 hasSubnetIds() { return subnetIds != null && !(subnetIds instanceof SdkAutoConstructList); } /** *

* The IDs of one or more subnets. You can specify only one subnet per Availability Zone. You must specify at least * one subnet, but we recommend that you specify two subnets for better availability. The transit gateway uses one * IP address from each specified subnet. *

*

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

*

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

* * @return The IDs of one or more subnets. You can specify only one subnet per Availability Zone. You must specify * at least one subnet, but we recommend that you specify two subnets for better availability. The transit * gateway uses one IP address from each specified subnet. */ public List subnetIds() { return subnetIds; } /** *

* The VPC attachment options. *

* * @return The VPC attachment options. */ public CreateTransitGatewayVpcAttachmentRequestOptions options() { return options; } /** * Returns true if the TagSpecifications 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 hasTagSpecifications() { return tagSpecifications != null && !(tagSpecifications instanceof SdkAutoConstructList); } /** *

* The tags to apply to the VPC attachment. *

*

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

*

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

* * @return The tags to apply to the VPC attachment. */ public List tagSpecifications() { return tagSpecifications; } @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 + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(transitGatewayId()); hashCode = 31 * hashCode + Objects.hashCode(vpcId()); hashCode = 31 * hashCode + Objects.hashCode(subnetIds()); hashCode = 31 * hashCode + Objects.hashCode(options()); hashCode = 31 * hashCode + Objects.hashCode(tagSpecifications()); return hashCode; } @Override public boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CreateTransitGatewayVpcAttachmentRequest)) { return false; } CreateTransitGatewayVpcAttachmentRequest other = (CreateTransitGatewayVpcAttachmentRequest) obj; return Objects.equals(transitGatewayId(), other.transitGatewayId()) && Objects.equals(vpcId(), other.vpcId()) && Objects.equals(subnetIds(), other.subnetIds()) && Objects.equals(options(), other.options()) && Objects.equals(tagSpecifications(), other.tagSpecifications()); } /** * 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("CreateTransitGatewayVpcAttachmentRequest").add("TransitGatewayId", transitGatewayId()) .add("VpcId", vpcId()).add("SubnetIds", subnetIds()).add("Options", options()) .add("TagSpecifications", tagSpecifications()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "TransitGatewayId": return Optional.ofNullable(clazz.cast(transitGatewayId())); case "VpcId": return Optional.ofNullable(clazz.cast(vpcId())); case "SubnetIds": return Optional.ofNullable(clazz.cast(subnetIds())); case "Options": return Optional.ofNullable(clazz.cast(options())); case "TagSpecifications": return Optional.ofNullable(clazz.cast(tagSpecifications())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateTransitGatewayVpcAttachmentRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends Ec2Request.Builder, SdkPojo, CopyableBuilder { /** *

* The ID of the transit gateway. *

* * @param transitGatewayId * The ID of the transit gateway. * @return Returns a reference to this object so that method calls can be chained together. */ Builder transitGatewayId(String transitGatewayId); /** *

* The ID of the VPC. *

* * @param vpcId * The ID of the VPC. * @return Returns a reference to this object so that method calls can be chained together. */ Builder vpcId(String vpcId); /** *

* The IDs of one or more subnets. You can specify only one subnet per Availability Zone. You must specify at * least one subnet, but we recommend that you specify two subnets for better availability. The transit gateway * uses one IP address from each specified subnet. *

* * @param subnetIds * The IDs of one or more subnets. You can specify only one subnet per Availability Zone. You must * specify at least one subnet, but we recommend that you specify two subnets for better availability. * The transit gateway uses one IP address from each specified subnet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder subnetIds(Collection subnetIds); /** *

* The IDs of one or more subnets. You can specify only one subnet per Availability Zone. You must specify at * least one subnet, but we recommend that you specify two subnets for better availability. The transit gateway * uses one IP address from each specified subnet. *

* * @param subnetIds * The IDs of one or more subnets. You can specify only one subnet per Availability Zone. You must * specify at least one subnet, but we recommend that you specify two subnets for better availability. * The transit gateway uses one IP address from each specified subnet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder subnetIds(String... subnetIds); /** *

* The VPC attachment options. *

* * @param options * The VPC attachment options. * @return Returns a reference to this object so that method calls can be chained together. */ Builder options(CreateTransitGatewayVpcAttachmentRequestOptions options); /** *

* The VPC attachment options. *

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

* The tags to apply to the VPC attachment. *

* * @param tagSpecifications * The tags to apply to the VPC attachment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tagSpecifications(Collection tagSpecifications); /** *

* The tags to apply to the VPC attachment. *

* * @param tagSpecifications * The tags to apply to the VPC attachment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tagSpecifications(TagSpecification... tagSpecifications); /** *

* The tags to apply to the VPC attachment. *

* 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 #tagSpecifications(List)}. * * @param tagSpecifications * 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 #tagSpecifications(List) */ Builder tagSpecifications(Consumer... tagSpecifications); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends Ec2Request.BuilderImpl implements Builder { private String transitGatewayId; private String vpcId; private List subnetIds = DefaultSdkAutoConstructList.getInstance(); private CreateTransitGatewayVpcAttachmentRequestOptions options; private List tagSpecifications = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(CreateTransitGatewayVpcAttachmentRequest model) { super(model); transitGatewayId(model.transitGatewayId); vpcId(model.vpcId); subnetIds(model.subnetIds); options(model.options); tagSpecifications(model.tagSpecifications); } public final String getTransitGatewayId() { return transitGatewayId; } @Override public final Builder transitGatewayId(String transitGatewayId) { this.transitGatewayId = transitGatewayId; return this; } public final void setTransitGatewayId(String transitGatewayId) { this.transitGatewayId = transitGatewayId; } public final String getVpcId() { return vpcId; } @Override public final Builder vpcId(String vpcId) { this.vpcId = vpcId; return this; } public final void setVpcId(String vpcId) { this.vpcId = vpcId; } public final Collection getSubnetIds() { return subnetIds; } @Override public final Builder subnetIds(Collection subnetIds) { this.subnetIds = TransitGatewaySubnetIdListCopier.copy(subnetIds); return this; } @Override @SafeVarargs public final Builder subnetIds(String... subnetIds) { subnetIds(Arrays.asList(subnetIds)); return this; } public final void setSubnetIds(Collection subnetIds) { this.subnetIds = TransitGatewaySubnetIdListCopier.copy(subnetIds); } public final CreateTransitGatewayVpcAttachmentRequestOptions.Builder getOptions() { return options != null ? options.toBuilder() : null; } @Override public final Builder options(CreateTransitGatewayVpcAttachmentRequestOptions options) { this.options = options; return this; } public final void setOptions(CreateTransitGatewayVpcAttachmentRequestOptions.BuilderImpl options) { this.options = options != null ? options.build() : null; } public final Collection getTagSpecifications() { return tagSpecifications != null ? tagSpecifications.stream().map(TagSpecification::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder tagSpecifications(Collection tagSpecifications) { this.tagSpecifications = TagSpecificationListCopier.copy(tagSpecifications); return this; } @Override @SafeVarargs public final Builder tagSpecifications(TagSpecification... tagSpecifications) { tagSpecifications(Arrays.asList(tagSpecifications)); return this; } @Override @SafeVarargs public final Builder tagSpecifications(Consumer... tagSpecifications) { tagSpecifications(Stream.of(tagSpecifications).map(c -> TagSpecification.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setTagSpecifications(Collection tagSpecifications) { this.tagSpecifications = TagSpecificationListCopier.copyFromBuilder(tagSpecifications); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateTransitGatewayVpcAttachmentRequest build() { return new CreateTransitGatewayVpcAttachmentRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy