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

software.amazon.awssdk.services.eventbridge.model.AwsVpcConfiguration Maven / Gradle / Ivy

Go to download

The AWS Java SDK for EventBridge module holds the client classes that are used for communicating with EventBridge.

There is a newer version: 2.29.39
Show newest version
/*
 * 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.eventbridge.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.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.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;

/**
 * 

* This structure specifies the VPC subnets and security groups for the task, and whether a public IP address is to be * used. This structure is relevant only for ECS tasks that use the awsvpc network mode. *

*/ @Generated("software.amazon.awssdk:codegen") public final class AwsVpcConfiguration implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> SUBNETS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Subnets") .getter(getter(AwsVpcConfiguration::subnets)) .setter(setter(Builder::subnets)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Subnets").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> SECURITY_GROUPS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("SecurityGroups") .getter(getter(AwsVpcConfiguration::securityGroups)) .setter(setter(Builder::securityGroups)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecurityGroups").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 ASSIGN_PUBLIC_IP_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("AssignPublicIp").getter(getter(AwsVpcConfiguration::assignPublicIpAsString)) .setter(setter(Builder::assignPublicIp)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssignPublicIp").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SUBNETS_FIELD, SECURITY_GROUPS_FIELD, ASSIGN_PUBLIC_IP_FIELD)); private static final long serialVersionUID = 1L; private final List subnets; private final List securityGroups; private final String assignPublicIp; private AwsVpcConfiguration(BuilderImpl builder) { this.subnets = builder.subnets; this.securityGroups = builder.securityGroups; this.assignPublicIp = builder.assignPublicIp; } /** * Returns true if the Subnets 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 final boolean hasSubnets() { return subnets != null && !(subnets instanceof SdkAutoConstructList); } /** *

* Specifies the subnets associated with the task. These subnets must all be in the same VPC. You can specify as * many as 16 subnets. *

*

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

*

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

* * @return Specifies the subnets associated with the task. These subnets must all be in the same VPC. You can * specify as many as 16 subnets. */ public final List subnets() { return subnets; } /** * Returns true if the SecurityGroups 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 final boolean hasSecurityGroups() { return securityGroups != null && !(securityGroups instanceof SdkAutoConstructList); } /** *

* Specifies the security groups associated with the task. These security groups must all be in the same VPC. You * can specify as many as five security groups. If you do not specify a security group, the default security group * for the VPC is used. *

*

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

*

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

* * @return Specifies the security groups associated with the task. These security groups must all be in the same * VPC. You can specify as many as five security groups. If you do not specify a security group, the default * security group for the VPC is used. */ public final List securityGroups() { return securityGroups; } /** *

* Specifies whether the task's elastic network interface receives a public IP address. You can specify * ENABLED only when LaunchType in EcsParameters is set to * FARGATE. *

*

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

* * @return Specifies whether the task's elastic network interface receives a public IP address. You can specify * ENABLED only when LaunchType in EcsParameters is set to * FARGATE. * @see AssignPublicIp */ public final AssignPublicIp assignPublicIp() { return AssignPublicIp.fromValue(assignPublicIp); } /** *

* Specifies whether the task's elastic network interface receives a public IP address. You can specify * ENABLED only when LaunchType in EcsParameters is set to * FARGATE. *

*

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

* * @return Specifies whether the task's elastic network interface receives a public IP address. You can specify * ENABLED only when LaunchType in EcsParameters is set to * FARGATE. * @see AssignPublicIp */ public final String assignPublicIpAsString() { return assignPublicIp; } @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(hasSubnets() ? subnets() : null); hashCode = 31 * hashCode + Objects.hashCode(hasSecurityGroups() ? securityGroups() : null); hashCode = 31 * hashCode + Objects.hashCode(assignPublicIpAsString()); 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 AwsVpcConfiguration)) { return false; } AwsVpcConfiguration other = (AwsVpcConfiguration) obj; return hasSubnets() == other.hasSubnets() && Objects.equals(subnets(), other.subnets()) && hasSecurityGroups() == other.hasSecurityGroups() && Objects.equals(securityGroups(), other.securityGroups()) && Objects.equals(assignPublicIpAsString(), other.assignPublicIpAsString()); } /** * 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("AwsVpcConfiguration").add("Subnets", hasSubnets() ? subnets() : null) .add("SecurityGroups", hasSecurityGroups() ? securityGroups() : null) .add("AssignPublicIp", assignPublicIpAsString()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Subnets": return Optional.ofNullable(clazz.cast(subnets())); case "SecurityGroups": return Optional.ofNullable(clazz.cast(securityGroups())); case "AssignPublicIp": return Optional.ofNullable(clazz.cast(assignPublicIpAsString())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((AwsVpcConfiguration) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Specifies the subnets associated with the task. These subnets must all be in the same VPC. You can specify as * many as 16 subnets. *

* * @param subnets * Specifies the subnets associated with the task. These subnets must all be in the same VPC. You can * specify as many as 16 subnets. * @return Returns a reference to this object so that method calls can be chained together. */ Builder subnets(Collection subnets); /** *

* Specifies the subnets associated with the task. These subnets must all be in the same VPC. You can specify as * many as 16 subnets. *

* * @param subnets * Specifies the subnets associated with the task. These subnets must all be in the same VPC. You can * specify as many as 16 subnets. * @return Returns a reference to this object so that method calls can be chained together. */ Builder subnets(String... subnets); /** *

* Specifies the security groups associated with the task. These security groups must all be in the same VPC. * You can specify as many as five security groups. If you do not specify a security group, the default security * group for the VPC is used. *

* * @param securityGroups * Specifies the security groups associated with the task. These security groups must all be in the same * VPC. You can specify as many as five security groups. If you do not specify a security group, the * default security group for the VPC is used. * @return Returns a reference to this object so that method calls can be chained together. */ Builder securityGroups(Collection securityGroups); /** *

* Specifies the security groups associated with the task. These security groups must all be in the same VPC. * You can specify as many as five security groups. If you do not specify a security group, the default security * group for the VPC is used. *

* * @param securityGroups * Specifies the security groups associated with the task. These security groups must all be in the same * VPC. You can specify as many as five security groups. If you do not specify a security group, the * default security group for the VPC is used. * @return Returns a reference to this object so that method calls can be chained together. */ Builder securityGroups(String... securityGroups); /** *

* Specifies whether the task's elastic network interface receives a public IP address. You can specify * ENABLED only when LaunchType in EcsParameters is set to * FARGATE. *

* * @param assignPublicIp * Specifies whether the task's elastic network interface receives a public IP address. You can specify * ENABLED only when LaunchType in EcsParameters is set to * FARGATE. * @see AssignPublicIp * @return Returns a reference to this object so that method calls can be chained together. * @see AssignPublicIp */ Builder assignPublicIp(String assignPublicIp); /** *

* Specifies whether the task's elastic network interface receives a public IP address. You can specify * ENABLED only when LaunchType in EcsParameters is set to * FARGATE. *

* * @param assignPublicIp * Specifies whether the task's elastic network interface receives a public IP address. You can specify * ENABLED only when LaunchType in EcsParameters is set to * FARGATE. * @see AssignPublicIp * @return Returns a reference to this object so that method calls can be chained together. * @see AssignPublicIp */ Builder assignPublicIp(AssignPublicIp assignPublicIp); } static final class BuilderImpl implements Builder { private List subnets = DefaultSdkAutoConstructList.getInstance(); private List securityGroups = DefaultSdkAutoConstructList.getInstance(); private String assignPublicIp; private BuilderImpl() { } private BuilderImpl(AwsVpcConfiguration model) { subnets(model.subnets); securityGroups(model.securityGroups); assignPublicIp(model.assignPublicIp); } public final Collection getSubnets() { if (subnets instanceof SdkAutoConstructList) { return null; } return subnets; } @Override public final Builder subnets(Collection subnets) { this.subnets = StringListCopier.copy(subnets); return this; } @Override @SafeVarargs public final Builder subnets(String... subnets) { subnets(Arrays.asList(subnets)); return this; } public final void setSubnets(Collection subnets) { this.subnets = StringListCopier.copy(subnets); } public final Collection getSecurityGroups() { if (securityGroups instanceof SdkAutoConstructList) { return null; } return securityGroups; } @Override public final Builder securityGroups(Collection securityGroups) { this.securityGroups = StringListCopier.copy(securityGroups); return this; } @Override @SafeVarargs public final Builder securityGroups(String... securityGroups) { securityGroups(Arrays.asList(securityGroups)); return this; } public final void setSecurityGroups(Collection securityGroups) { this.securityGroups = StringListCopier.copy(securityGroups); } public final String getAssignPublicIp() { return assignPublicIp; } @Override public final Builder assignPublicIp(String assignPublicIp) { this.assignPublicIp = assignPublicIp; return this; } @Override public final Builder assignPublicIp(AssignPublicIp assignPublicIp) { this.assignPublicIp(assignPublicIp == null ? null : assignPublicIp.toString()); return this; } public final void setAssignPublicIp(String assignPublicIp) { this.assignPublicIp = assignPublicIp; } @Override public AwsVpcConfiguration build() { return new AwsVpcConfiguration(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy