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

software.amazon.awssdk.services.emr.model.BlockPublicAccessConfiguration Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon EMR module holds the client classes that are used for communicating with Amazon Elastic MapReduce Service

There is a newer version: 2.28.3
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.emr.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;

/**
 * 

* A configuration for Amazon EMR block public access. When BlockPublicSecurityGroupRules is set to * true, Amazon EMR prevents cluster creation if one of the cluster's security groups has a rule that * allows inbound traffic from 0.0.0.0/0 or ::/0 on a port, unless the port is specified as an exception using * PermittedPublicSecurityGroupRuleRanges. *

*/ @Generated("software.amazon.awssdk:codegen") public final class BlockPublicAccessConfiguration implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField BLOCK_PUBLIC_SECURITY_GROUP_RULES_FIELD = SdkField . builder(MarshallingType.BOOLEAN) .memberName("BlockPublicSecurityGroupRules") .getter(getter(BlockPublicAccessConfiguration::blockPublicSecurityGroupRules)) .setter(setter(Builder::blockPublicSecurityGroupRules)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BlockPublicSecurityGroupRules") .build()).build(); private static final SdkField> PERMITTED_PUBLIC_SECURITY_GROUP_RULE_RANGES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("PermittedPublicSecurityGroupRuleRanges") .getter(getter(BlockPublicAccessConfiguration::permittedPublicSecurityGroupRuleRanges)) .setter(setter(Builder::permittedPublicSecurityGroupRuleRanges)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("PermittedPublicSecurityGroupRuleRanges").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(PortRange::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList( BLOCK_PUBLIC_SECURITY_GROUP_RULES_FIELD, PERMITTED_PUBLIC_SECURITY_GROUP_RULE_RANGES_FIELD)); private static final long serialVersionUID = 1L; private final Boolean blockPublicSecurityGroupRules; private final List permittedPublicSecurityGroupRuleRanges; private BlockPublicAccessConfiguration(BuilderImpl builder) { this.blockPublicSecurityGroupRules = builder.blockPublicSecurityGroupRules; this.permittedPublicSecurityGroupRuleRanges = builder.permittedPublicSecurityGroupRuleRanges; } /** *

* Indicates whether Amazon EMR block public access is enabled (true) or disabled (false). * By default, the value is false for accounts that have created Amazon EMR clusters before July 2019. * For accounts created after this, the default is true. *

* * @return Indicates whether Amazon EMR block public access is enabled (true) or disabled ( * false). By default, the value is false for accounts that have created Amazon * EMR clusters before July 2019. For accounts created after this, the default is true. */ public final Boolean blockPublicSecurityGroupRules() { return blockPublicSecurityGroupRules; } /** * For responses, this returns true if the service returned a value for the PermittedPublicSecurityGroupRuleRanges * 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 hasPermittedPublicSecurityGroupRuleRanges() { return permittedPublicSecurityGroupRuleRanges != null && !(permittedPublicSecurityGroupRuleRanges instanceof SdkAutoConstructList); } /** *

* Specifies ports and port ranges that are permitted to have security group rules that allow inbound traffic from * all public sources. For example, if Port 23 (Telnet) is specified for * PermittedPublicSecurityGroupRuleRanges, Amazon EMR allows cluster creation if a security group * associated with the cluster has a rule that allows inbound traffic on Port 23 from IPv4 0.0.0.0/0 or IPv6 port * ::/0 as the source. *

*

* By default, Port 22, which is used for SSH access to the cluster Amazon EC2 instances, is in the list of * PermittedPublicSecurityGroupRuleRanges. *

*

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

* * @return Specifies ports and port ranges that are permitted to have security group rules that allow inbound * traffic from all public sources. For example, if Port 23 (Telnet) is specified for * PermittedPublicSecurityGroupRuleRanges, Amazon EMR allows cluster creation if a security * group associated with the cluster has a rule that allows inbound traffic on Port 23 from IPv4 0.0.0.0/0 * or IPv6 port ::/0 as the source.

*

* By default, Port 22, which is used for SSH access to the cluster Amazon EC2 instances, is in the list of * PermittedPublicSecurityGroupRuleRanges. */ public final List permittedPublicSecurityGroupRuleRanges() { return permittedPublicSecurityGroupRuleRanges; } @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(blockPublicSecurityGroupRules()); hashCode = 31 * hashCode + Objects.hashCode(hasPermittedPublicSecurityGroupRuleRanges() ? permittedPublicSecurityGroupRuleRanges() : 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 BlockPublicAccessConfiguration)) { return false; } BlockPublicAccessConfiguration other = (BlockPublicAccessConfiguration) obj; return Objects.equals(blockPublicSecurityGroupRules(), other.blockPublicSecurityGroupRules()) && hasPermittedPublicSecurityGroupRuleRanges() == other.hasPermittedPublicSecurityGroupRuleRanges() && Objects.equals(permittedPublicSecurityGroupRuleRanges(), other.permittedPublicSecurityGroupRuleRanges()); } /** * 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("BlockPublicAccessConfiguration") .add("BlockPublicSecurityGroupRules", blockPublicSecurityGroupRules()) .add("PermittedPublicSecurityGroupRuleRanges", hasPermittedPublicSecurityGroupRuleRanges() ? permittedPublicSecurityGroupRuleRanges() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "BlockPublicSecurityGroupRules": return Optional.ofNullable(clazz.cast(blockPublicSecurityGroupRules())); case "PermittedPublicSecurityGroupRuleRanges": return Optional.ofNullable(clazz.cast(permittedPublicSecurityGroupRuleRanges())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((BlockPublicAccessConfiguration) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Indicates whether Amazon EMR block public access is enabled (true) or disabled ( * false). By default, the value is false for accounts that have created Amazon EMR * clusters before July 2019. For accounts created after this, the default is true. *

* * @param blockPublicSecurityGroupRules * Indicates whether Amazon EMR block public access is enabled (true) or disabled ( * false). By default, the value is false for accounts that have created Amazon * EMR clusters before July 2019. For accounts created after this, the default is true. * @return Returns a reference to this object so that method calls can be chained together. */ Builder blockPublicSecurityGroupRules(Boolean blockPublicSecurityGroupRules); /** *

* Specifies ports and port ranges that are permitted to have security group rules that allow inbound traffic * from all public sources. For example, if Port 23 (Telnet) is specified for * PermittedPublicSecurityGroupRuleRanges, Amazon EMR allows cluster creation if a security group * associated with the cluster has a rule that allows inbound traffic on Port 23 from IPv4 0.0.0.0/0 or IPv6 * port ::/0 as the source. *

*

* By default, Port 22, which is used for SSH access to the cluster Amazon EC2 instances, is in the list of * PermittedPublicSecurityGroupRuleRanges. *

* * @param permittedPublicSecurityGroupRuleRanges * Specifies ports and port ranges that are permitted to have security group rules that allow inbound * traffic from all public sources. For example, if Port 23 (Telnet) is specified for * PermittedPublicSecurityGroupRuleRanges, Amazon EMR allows cluster creation if a security * group associated with the cluster has a rule that allows inbound traffic on Port 23 from IPv4 * 0.0.0.0/0 or IPv6 port ::/0 as the source.

*

* By default, Port 22, which is used for SSH access to the cluster Amazon EC2 instances, is in the list * of PermittedPublicSecurityGroupRuleRanges. * @return Returns a reference to this object so that method calls can be chained together. */ Builder permittedPublicSecurityGroupRuleRanges(Collection permittedPublicSecurityGroupRuleRanges); /** *

* Specifies ports and port ranges that are permitted to have security group rules that allow inbound traffic * from all public sources. For example, if Port 23 (Telnet) is specified for * PermittedPublicSecurityGroupRuleRanges, Amazon EMR allows cluster creation if a security group * associated with the cluster has a rule that allows inbound traffic on Port 23 from IPv4 0.0.0.0/0 or IPv6 * port ::/0 as the source. *

*

* By default, Port 22, which is used for SSH access to the cluster Amazon EC2 instances, is in the list of * PermittedPublicSecurityGroupRuleRanges. *

* * @param permittedPublicSecurityGroupRuleRanges * Specifies ports and port ranges that are permitted to have security group rules that allow inbound * traffic from all public sources. For example, if Port 23 (Telnet) is specified for * PermittedPublicSecurityGroupRuleRanges, Amazon EMR allows cluster creation if a security * group associated with the cluster has a rule that allows inbound traffic on Port 23 from IPv4 * 0.0.0.0/0 or IPv6 port ::/0 as the source.

*

* By default, Port 22, which is used for SSH access to the cluster Amazon EC2 instances, is in the list * of PermittedPublicSecurityGroupRuleRanges. * @return Returns a reference to this object so that method calls can be chained together. */ Builder permittedPublicSecurityGroupRuleRanges(PortRange... permittedPublicSecurityGroupRuleRanges); /** *

* Specifies ports and port ranges that are permitted to have security group rules that allow inbound traffic * from all public sources. For example, if Port 23 (Telnet) is specified for * PermittedPublicSecurityGroupRuleRanges, Amazon EMR allows cluster creation if a security group * associated with the cluster has a rule that allows inbound traffic on Port 23 from IPv4 0.0.0.0/0 or IPv6 * port ::/0 as the source. *

*

* By default, Port 22, which is used for SSH access to the cluster Amazon EC2 instances, is in the list of * PermittedPublicSecurityGroupRuleRanges. *

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

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.emr.model.PortRange.Builder#build()} is called immediately and its * result is passed to {@link #permittedPublicSecurityGroupRuleRanges(List)}. * * @param permittedPublicSecurityGroupRuleRanges * a consumer that will call methods on * {@link software.amazon.awssdk.services.emr.model.PortRange.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #permittedPublicSecurityGroupRuleRanges(java.util.Collection) */ Builder permittedPublicSecurityGroupRuleRanges(Consumer... permittedPublicSecurityGroupRuleRanges); } static final class BuilderImpl implements Builder { private Boolean blockPublicSecurityGroupRules; private List permittedPublicSecurityGroupRuleRanges = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(BlockPublicAccessConfiguration model) { blockPublicSecurityGroupRules(model.blockPublicSecurityGroupRules); permittedPublicSecurityGroupRuleRanges(model.permittedPublicSecurityGroupRuleRanges); } public final Boolean getBlockPublicSecurityGroupRules() { return blockPublicSecurityGroupRules; } public final void setBlockPublicSecurityGroupRules(Boolean blockPublicSecurityGroupRules) { this.blockPublicSecurityGroupRules = blockPublicSecurityGroupRules; } @Override public final Builder blockPublicSecurityGroupRules(Boolean blockPublicSecurityGroupRules) { this.blockPublicSecurityGroupRules = blockPublicSecurityGroupRules; return this; } public final List getPermittedPublicSecurityGroupRuleRanges() { List result = PortRangesCopier.copyToBuilder(this.permittedPublicSecurityGroupRuleRanges); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setPermittedPublicSecurityGroupRuleRanges( Collection permittedPublicSecurityGroupRuleRanges) { this.permittedPublicSecurityGroupRuleRanges = PortRangesCopier .copyFromBuilder(permittedPublicSecurityGroupRuleRanges); } @Override public final Builder permittedPublicSecurityGroupRuleRanges(Collection permittedPublicSecurityGroupRuleRanges) { this.permittedPublicSecurityGroupRuleRanges = PortRangesCopier.copy(permittedPublicSecurityGroupRuleRanges); return this; } @Override @SafeVarargs public final Builder permittedPublicSecurityGroupRuleRanges(PortRange... permittedPublicSecurityGroupRuleRanges) { permittedPublicSecurityGroupRuleRanges(Arrays.asList(permittedPublicSecurityGroupRuleRanges)); return this; } @Override @SafeVarargs public final Builder permittedPublicSecurityGroupRuleRanges( Consumer... permittedPublicSecurityGroupRuleRanges) { permittedPublicSecurityGroupRuleRanges(Stream.of(permittedPublicSecurityGroupRuleRanges) .map(c -> PortRange.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } @Override public BlockPublicAccessConfiguration build() { return new BlockPublicAccessConfiguration(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy