software.amazon.awssdk.services.fms.model.SecurityGroupRuleDescription 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.fms.model;
import java.io.Serializable;
import java.util.Arrays;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes a set of permissions for a security group rule.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SecurityGroupRuleDescription implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField IPV4_RANGE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("IPV4Range").getter(getter(SecurityGroupRuleDescription::ipv4Range)).setter(setter(Builder::ipv4Range))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IPV4Range").build()).build();
private static final SdkField IPV6_RANGE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("IPV6Range").getter(getter(SecurityGroupRuleDescription::ipv6Range)).setter(setter(Builder::ipv6Range))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IPV6Range").build()).build();
private static final SdkField PREFIX_LIST_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrefixListId").getter(getter(SecurityGroupRuleDescription::prefixListId))
.setter(setter(Builder::prefixListId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrefixListId").build()).build();
private static final SdkField PROTOCOL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Protocol").getter(getter(SecurityGroupRuleDescription::protocol)).setter(setter(Builder::protocol))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Protocol").build()).build();
private static final SdkField FROM_PORT_FIELD = SdkField. builder(MarshallingType.LONG).memberName("FromPort")
.getter(getter(SecurityGroupRuleDescription::fromPort)).setter(setter(Builder::fromPort))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FromPort").build()).build();
private static final SdkField TO_PORT_FIELD = SdkField. builder(MarshallingType.LONG).memberName("ToPort")
.getter(getter(SecurityGroupRuleDescription::toPort)).setter(setter(Builder::toPort))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ToPort").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(IPV4_RANGE_FIELD,
IPV6_RANGE_FIELD, PREFIX_LIST_ID_FIELD, PROTOCOL_FIELD, FROM_PORT_FIELD, TO_PORT_FIELD));
private static final long serialVersionUID = 1L;
private final String ipv4Range;
private final String ipv6Range;
private final String prefixListId;
private final String protocol;
private final Long fromPort;
private final Long toPort;
private SecurityGroupRuleDescription(BuilderImpl builder) {
this.ipv4Range = builder.ipv4Range;
this.ipv6Range = builder.ipv6Range;
this.prefixListId = builder.prefixListId;
this.protocol = builder.protocol;
this.fromPort = builder.fromPort;
this.toPort = builder.toPort;
}
/**
*
* The IPv4 ranges for the security group rule.
*
*
* @return The IPv4 ranges for the security group rule.
*/
public final String ipv4Range() {
return ipv4Range;
}
/**
*
* The IPv6 ranges for the security group rule.
*
*
* @return The IPv6 ranges for the security group rule.
*/
public final String ipv6Range() {
return ipv6Range;
}
/**
*
* The ID of the prefix list for the security group rule.
*
*
* @return The ID of the prefix list for the security group rule.
*/
public final String prefixListId() {
return prefixListId;
}
/**
*
* The IP protocol name (tcp
, udp
, icmp
, icmpv6
) or number.
*
*
* @return The IP protocol name (tcp
, udp
, icmp
, icmpv6
) or
* number.
*/
public final String protocol() {
return protocol;
}
/**
*
* The start of the port range for the TCP and UDP protocols, or an ICMP/ICMPv6 type number. A value of
* -1
indicates all ICMP/ICMPv6 types.
*
*
* @return The start of the port range for the TCP and UDP protocols, or an ICMP/ICMPv6 type number. A value of
* -1
indicates all ICMP/ICMPv6 types.
*/
public final Long fromPort() {
return fromPort;
}
/**
*
* The end of the port range for the TCP and UDP protocols, or an ICMP/ICMPv6 code. A value of -1
* indicates all ICMP/ICMPv6 codes.
*
*
* @return The end of the port range for the TCP and UDP protocols, or an ICMP/ICMPv6 code. A value of
* -1
indicates all ICMP/ICMPv6 codes.
*/
public final Long toPort() {
return toPort;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(ipv4Range());
hashCode = 31 * hashCode + Objects.hashCode(ipv6Range());
hashCode = 31 * hashCode + Objects.hashCode(prefixListId());
hashCode = 31 * hashCode + Objects.hashCode(protocol());
hashCode = 31 * hashCode + Objects.hashCode(fromPort());
hashCode = 31 * hashCode + Objects.hashCode(toPort());
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 SecurityGroupRuleDescription)) {
return false;
}
SecurityGroupRuleDescription other = (SecurityGroupRuleDescription) obj;
return Objects.equals(ipv4Range(), other.ipv4Range()) && Objects.equals(ipv6Range(), other.ipv6Range())
&& Objects.equals(prefixListId(), other.prefixListId()) && Objects.equals(protocol(), other.protocol())
&& Objects.equals(fromPort(), other.fromPort()) && Objects.equals(toPort(), other.toPort());
}
/**
* 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("SecurityGroupRuleDescription").add("IPV4Range", ipv4Range()).add("IPV6Range", ipv6Range())
.add("PrefixListId", prefixListId()).add("Protocol", protocol()).add("FromPort", fromPort())
.add("ToPort", toPort()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "IPV4Range":
return Optional.ofNullable(clazz.cast(ipv4Range()));
case "IPV6Range":
return Optional.ofNullable(clazz.cast(ipv6Range()));
case "PrefixListId":
return Optional.ofNullable(clazz.cast(prefixListId()));
case "Protocol":
return Optional.ofNullable(clazz.cast(protocol()));
case "FromPort":
return Optional.ofNullable(clazz.cast(fromPort()));
case "ToPort":
return Optional.ofNullable(clazz.cast(toPort()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy