
software.amazon.awssdk.services.directconnect.model.DirectConnectGatewayAssociation 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.directconnect.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;
/**
*
* Information about an association between a Direct Connect gateway and a virtual private gateway or transit gateway.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DirectConnectGatewayAssociation implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField DIRECT_CONNECT_GATEWAY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("directConnectGatewayId").getter(getter(DirectConnectGatewayAssociation::directConnectGatewayId))
.setter(setter(Builder::directConnectGatewayId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("directConnectGatewayId").build())
.build();
private static final SdkField DIRECT_CONNECT_GATEWAY_OWNER_ACCOUNT_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("directConnectGatewayOwnerAccount")
.getter(getter(DirectConnectGatewayAssociation::directConnectGatewayOwnerAccount))
.setter(setter(Builder::directConnectGatewayOwnerAccount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("directConnectGatewayOwnerAccount")
.build()).build();
private static final SdkField ASSOCIATION_STATE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("associationState").getter(getter(DirectConnectGatewayAssociation::associationStateAsString))
.setter(setter(Builder::associationState))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("associationState").build()).build();
private static final SdkField STATE_CHANGE_ERROR_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("stateChangeError").getter(getter(DirectConnectGatewayAssociation::stateChangeError))
.setter(setter(Builder::stateChangeError))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stateChangeError").build()).build();
private static final SdkField ASSOCIATED_GATEWAY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("associatedGateway")
.getter(getter(DirectConnectGatewayAssociation::associatedGateway)).setter(setter(Builder::associatedGateway))
.constructor(AssociatedGateway::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("associatedGateway").build()).build();
private static final SdkField ASSOCIATION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("associationId").getter(getter(DirectConnectGatewayAssociation::associationId))
.setter(setter(Builder::associationId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("associationId").build()).build();
private static final SdkField> ALLOWED_PREFIXES_TO_DIRECT_CONNECT_GATEWAY_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("allowedPrefixesToDirectConnectGateway")
.getter(getter(DirectConnectGatewayAssociation::allowedPrefixesToDirectConnectGateway))
.setter(setter(Builder::allowedPrefixesToDirectConnectGateway))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("allowedPrefixesToDirectConnectGateway").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(RouteFilterPrefix::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField VIRTUAL_GATEWAY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("virtualGatewayId").getter(getter(DirectConnectGatewayAssociation::virtualGatewayId))
.setter(setter(Builder::virtualGatewayId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("virtualGatewayId").build()).build();
private static final SdkField VIRTUAL_GATEWAY_REGION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("virtualGatewayRegion").getter(getter(DirectConnectGatewayAssociation::virtualGatewayRegion))
.setter(setter(Builder::virtualGatewayRegion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("virtualGatewayRegion").build())
.build();
private static final SdkField VIRTUAL_GATEWAY_OWNER_ACCOUNT_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("virtualGatewayOwnerAccount")
.getter(getter(DirectConnectGatewayAssociation::virtualGatewayOwnerAccount))
.setter(setter(Builder::virtualGatewayOwnerAccount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("virtualGatewayOwnerAccount").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
DIRECT_CONNECT_GATEWAY_ID_FIELD, DIRECT_CONNECT_GATEWAY_OWNER_ACCOUNT_FIELD, ASSOCIATION_STATE_FIELD,
STATE_CHANGE_ERROR_FIELD, ASSOCIATED_GATEWAY_FIELD, ASSOCIATION_ID_FIELD,
ALLOWED_PREFIXES_TO_DIRECT_CONNECT_GATEWAY_FIELD, VIRTUAL_GATEWAY_ID_FIELD, VIRTUAL_GATEWAY_REGION_FIELD,
VIRTUAL_GATEWAY_OWNER_ACCOUNT_FIELD));
private static final long serialVersionUID = 1L;
private final String directConnectGatewayId;
private final String directConnectGatewayOwnerAccount;
private final String associationState;
private final String stateChangeError;
private final AssociatedGateway associatedGateway;
private final String associationId;
private final List allowedPrefixesToDirectConnectGateway;
private final String virtualGatewayId;
private final String virtualGatewayRegion;
private final String virtualGatewayOwnerAccount;
private DirectConnectGatewayAssociation(BuilderImpl builder) {
this.directConnectGatewayId = builder.directConnectGatewayId;
this.directConnectGatewayOwnerAccount = builder.directConnectGatewayOwnerAccount;
this.associationState = builder.associationState;
this.stateChangeError = builder.stateChangeError;
this.associatedGateway = builder.associatedGateway;
this.associationId = builder.associationId;
this.allowedPrefixesToDirectConnectGateway = builder.allowedPrefixesToDirectConnectGateway;
this.virtualGatewayId = builder.virtualGatewayId;
this.virtualGatewayRegion = builder.virtualGatewayRegion;
this.virtualGatewayOwnerAccount = builder.virtualGatewayOwnerAccount;
}
/**
*
* The ID of the Direct Connect gateway.
*
*
* @return The ID of the Direct Connect gateway.
*/
public final String directConnectGatewayId() {
return directConnectGatewayId;
}
/**
*
* The ID of the Amazon Web Services account that owns the associated gateway.
*
*
* @return The ID of the Amazon Web Services account that owns the associated gateway.
*/
public final String directConnectGatewayOwnerAccount() {
return directConnectGatewayOwnerAccount;
}
/**
*
* The state of the association. The following are the possible values:
*
*
* -
*
* associating
: The initial state after calling CreateDirectConnectGatewayAssociation.
*
*
* -
*
* associated
: The Direct Connect gateway and virtual private gateway or transit gateway are
* successfully associated and ready to pass traffic.
*
*
* -
*
* disassociating
: The initial state after calling DeleteDirectConnectGatewayAssociation.
*
*
* -
*
* disassociated
: The virtual private gateway or transit gateway is disassociated from the Direct
* Connect gateway. Traffic flow between the Direct Connect gateway and virtual private gateway or transit gateway
* is stopped.
*
*
* -
*
* updating
: The CIDR blocks for the virtual private gateway or transit gateway are currently being
* updated. This could be new CIDR blocks added or current CIDR blocks removed.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #associationState}
* will return {@link DirectConnectGatewayAssociationState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the
* service is available from {@link #associationStateAsString}.
*
*
* @return The state of the association. The following are the possible values:
*
* -
*
* associating
: The initial state after calling CreateDirectConnectGatewayAssociation.
*
*
* -
*
* associated
: The Direct Connect gateway and virtual private gateway or transit gateway are
* successfully associated and ready to pass traffic.
*
*
* -
*
* disassociating
: The initial state after calling
* DeleteDirectConnectGatewayAssociation.
*
*
* -
*
* disassociated
: The virtual private gateway or transit gateway is disassociated from the
* Direct Connect gateway. Traffic flow between the Direct Connect gateway and virtual private gateway or
* transit gateway is stopped.
*
*
* -
*
* updating
: The CIDR blocks for the virtual private gateway or transit gateway are currently
* being updated. This could be new CIDR blocks added or current CIDR blocks removed.
*
*
* @see DirectConnectGatewayAssociationState
*/
public final DirectConnectGatewayAssociationState associationState() {
return DirectConnectGatewayAssociationState.fromValue(associationState);
}
/**
*
* The state of the association. The following are the possible values:
*
*
* -
*
* associating
: The initial state after calling CreateDirectConnectGatewayAssociation.
*
*
* -
*
* associated
: The Direct Connect gateway and virtual private gateway or transit gateway are
* successfully associated and ready to pass traffic.
*
*
* -
*
* disassociating
: The initial state after calling DeleteDirectConnectGatewayAssociation.
*
*
* -
*
* disassociated
: The virtual private gateway or transit gateway is disassociated from the Direct
* Connect gateway. Traffic flow between the Direct Connect gateway and virtual private gateway or transit gateway
* is stopped.
*
*
* -
*
* updating
: The CIDR blocks for the virtual private gateway or transit gateway are currently being
* updated. This could be new CIDR blocks added or current CIDR blocks removed.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #associationState}
* will return {@link DirectConnectGatewayAssociationState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the
* service is available from {@link #associationStateAsString}.
*
*
* @return The state of the association. The following are the possible values:
*
* -
*
* associating
: The initial state after calling CreateDirectConnectGatewayAssociation.
*
*
* -
*
* associated
: The Direct Connect gateway and virtual private gateway or transit gateway are
* successfully associated and ready to pass traffic.
*
*
* -
*
* disassociating
: The initial state after calling
* DeleteDirectConnectGatewayAssociation.
*
*
* -
*
* disassociated
: The virtual private gateway or transit gateway is disassociated from the
* Direct Connect gateway. Traffic flow between the Direct Connect gateway and virtual private gateway or
* transit gateway is stopped.
*
*
* -
*
* updating
: The CIDR blocks for the virtual private gateway or transit gateway are currently
* being updated. This could be new CIDR blocks added or current CIDR blocks removed.
*
*
* @see DirectConnectGatewayAssociationState
*/
public final String associationStateAsString() {
return associationState;
}
/**
*
* The error message if the state of an object failed to advance.
*
*
* @return The error message if the state of an object failed to advance.
*/
public final String stateChangeError() {
return stateChangeError;
}
/**
*
* Information about the associated gateway.
*
*
* @return Information about the associated gateway.
*/
public final AssociatedGateway associatedGateway() {
return associatedGateway;
}
/**
*
* The ID of the Direct Connect gateway association.
*
*
* @return The ID of the Direct Connect gateway association.
*/
public final String associationId() {
return associationId;
}
/**
* For responses, this returns true if the service returned a value for the AllowedPrefixesToDirectConnectGateway
* 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 hasAllowedPrefixesToDirectConnectGateway() {
return allowedPrefixesToDirectConnectGateway != null
&& !(allowedPrefixesToDirectConnectGateway instanceof SdkAutoConstructList);
}
/**
*
* The Amazon VPC prefixes to advertise to the Direct Connect gateway.
*
*
* 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 #hasAllowedPrefixesToDirectConnectGateway}
* method.
*
*
* @return The Amazon VPC prefixes to advertise to the Direct Connect gateway.
*/
public final List allowedPrefixesToDirectConnectGateway() {
return allowedPrefixesToDirectConnectGateway;
}
/**
*
* The ID of the virtual private gateway. Applies only to private virtual interfaces.
*
*
* @return The ID of the virtual private gateway. Applies only to private virtual interfaces.
*/
public final String virtualGatewayId() {
return virtualGatewayId;
}
/**
*
* The Amazon Web Services Region where the virtual private gateway is located.
*
*
* @return The Amazon Web Services Region where the virtual private gateway is located.
*/
public final String virtualGatewayRegion() {
return virtualGatewayRegion;
}
/**
*
* The ID of the Amazon Web Services account that owns the virtual private gateway.
*
*
* @return The ID of the Amazon Web Services account that owns the virtual private gateway.
*/
public final String virtualGatewayOwnerAccount() {
return virtualGatewayOwnerAccount;
}
@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(directConnectGatewayId());
hashCode = 31 * hashCode + Objects.hashCode(directConnectGatewayOwnerAccount());
hashCode = 31 * hashCode + Objects.hashCode(associationStateAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateChangeError());
hashCode = 31 * hashCode + Objects.hashCode(associatedGateway());
hashCode = 31 * hashCode + Objects.hashCode(associationId());
hashCode = 31 * hashCode
+ Objects.hashCode(hasAllowedPrefixesToDirectConnectGateway() ? allowedPrefixesToDirectConnectGateway() : null);
hashCode = 31 * hashCode + Objects.hashCode(virtualGatewayId());
hashCode = 31 * hashCode + Objects.hashCode(virtualGatewayRegion());
hashCode = 31 * hashCode + Objects.hashCode(virtualGatewayOwnerAccount());
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 DirectConnectGatewayAssociation)) {
return false;
}
DirectConnectGatewayAssociation other = (DirectConnectGatewayAssociation) obj;
return Objects.equals(directConnectGatewayId(), other.directConnectGatewayId())
&& Objects.equals(directConnectGatewayOwnerAccount(), other.directConnectGatewayOwnerAccount())
&& Objects.equals(associationStateAsString(), other.associationStateAsString())
&& Objects.equals(stateChangeError(), other.stateChangeError())
&& Objects.equals(associatedGateway(), other.associatedGateway())
&& Objects.equals(associationId(), other.associationId())
&& hasAllowedPrefixesToDirectConnectGateway() == other.hasAllowedPrefixesToDirectConnectGateway()
&& Objects.equals(allowedPrefixesToDirectConnectGateway(), other.allowedPrefixesToDirectConnectGateway())
&& Objects.equals(virtualGatewayId(), other.virtualGatewayId())
&& Objects.equals(virtualGatewayRegion(), other.virtualGatewayRegion())
&& Objects.equals(virtualGatewayOwnerAccount(), other.virtualGatewayOwnerAccount());
}
/**
* 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("DirectConnectGatewayAssociation")
.add("DirectConnectGatewayId", directConnectGatewayId())
.add("DirectConnectGatewayOwnerAccount", directConnectGatewayOwnerAccount())
.add("AssociationState", associationStateAsString())
.add("StateChangeError", stateChangeError())
.add("AssociatedGateway", associatedGateway())
.add("AssociationId", associationId())
.add("AllowedPrefixesToDirectConnectGateway",
hasAllowedPrefixesToDirectConnectGateway() ? allowedPrefixesToDirectConnectGateway() : null)
.add("VirtualGatewayId", virtualGatewayId()).add("VirtualGatewayRegion", virtualGatewayRegion())
.add("VirtualGatewayOwnerAccount", virtualGatewayOwnerAccount()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "directConnectGatewayId":
return Optional.ofNullable(clazz.cast(directConnectGatewayId()));
case "directConnectGatewayOwnerAccount":
return Optional.ofNullable(clazz.cast(directConnectGatewayOwnerAccount()));
case "associationState":
return Optional.ofNullable(clazz.cast(associationStateAsString()));
case "stateChangeError":
return Optional.ofNullable(clazz.cast(stateChangeError()));
case "associatedGateway":
return Optional.ofNullable(clazz.cast(associatedGateway()));
case "associationId":
return Optional.ofNullable(clazz.cast(associationId()));
case "allowedPrefixesToDirectConnectGateway":
return Optional.ofNullable(clazz.cast(allowedPrefixesToDirectConnectGateway()));
case "virtualGatewayId":
return Optional.ofNullable(clazz.cast(virtualGatewayId()));
case "virtualGatewayRegion":
return Optional.ofNullable(clazz.cast(virtualGatewayRegion()));
case "virtualGatewayOwnerAccount":
return Optional.ofNullable(clazz.cast(virtualGatewayOwnerAccount()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function