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

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

Go to download

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

There is a newer version: 2.28.5
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.scheduler.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 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 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> 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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ASSIGN_PUBLIC_IP_FIELD, SECURITY_GROUPS_FIELD, SUBNETS_FIELD)); private static final long serialVersionUID = 1L; private final String assignPublicIp; private final List securityGroups; private final List subnets; private AwsVpcConfiguration(BuilderImpl builder) { this.assignPublicIp = builder.assignPublicIp; this.securityGroups = builder.securityGroups; this.subnets = builder.subnets; } /** *

* 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; } /** * For responses, this returns true if the service returned a value for the SecurityGroups 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 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. *

*

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

* * @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; } /** * For responses, this returns true if the service returned a value for the Subnets 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 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. *

*

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

* * @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; } @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(assignPublicIpAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasSecurityGroups() ? securityGroups() : null); hashCode = 31 * hashCode + Objects.hashCode(hasSubnets() ? subnets() : null); 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 Objects.equals(assignPublicIpAsString(), other.assignPublicIpAsString()) && hasSecurityGroups() == other.hasSecurityGroups() && Objects.equals(securityGroups(), other.securityGroups()) && hasSubnets() == other.hasSubnets() && Objects.equals(subnets(), other.subnets()); } /** * 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("AssignPublicIp", assignPublicIpAsString()) .add("SecurityGroups", hasSecurityGroups() ? securityGroups() : null) .add("Subnets", hasSubnets() ? subnets() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "AssignPublicIp": return Optional.ofNullable(clazz.cast(assignPublicIpAsString())); case "SecurityGroups": return Optional.ofNullable(clazz.cast(securityGroups())); case "Subnets": return Optional.ofNullable(clazz.cast(subnets())); 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 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); /** *

* 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 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); } static final class BuilderImpl implements Builder { private String assignPublicIp; private List securityGroups = DefaultSdkAutoConstructList.getInstance(); private List subnets = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(AwsVpcConfiguration model) { assignPublicIp(model.assignPublicIp); securityGroups(model.securityGroups); subnets(model.subnets); } public final String getAssignPublicIp() { return assignPublicIp; } public final void setAssignPublicIp(String assignPublicIp) { this.assignPublicIp = 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 Collection getSecurityGroups() { if (securityGroups instanceof SdkAutoConstructList) { return null; } return securityGroups; } public final void setSecurityGroups(Collection securityGroups) { this.securityGroups = SecurityGroupsCopier.copy(securityGroups); } @Override public final Builder securityGroups(Collection securityGroups) { this.securityGroups = SecurityGroupsCopier.copy(securityGroups); return this; } @Override @SafeVarargs public final Builder securityGroups(String... securityGroups) { securityGroups(Arrays.asList(securityGroups)); return this; } public final Collection getSubnets() { if (subnets instanceof SdkAutoConstructList) { return null; } return subnets; } public final void setSubnets(Collection subnets) { this.subnets = SubnetsCopier.copy(subnets); } @Override public final Builder subnets(Collection subnets) { this.subnets = SubnetsCopier.copy(subnets); return this; } @Override @SafeVarargs public final Builder subnets(String... subnets) { subnets(Arrays.asList(subnets)); return this; } @Override public AwsVpcConfiguration build() { return new AwsVpcConfiguration(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy