software.amazon.awssdk.services.redshift.model.AuthorizeEndpointAccessResponse Maven / Gradle / Ivy
Show all versions of redshift Show documentation
/*
* 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.redshift.model;
import java.time.Instant;
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;
/**
*
* Describes an endpoint authorization for authorizing Redshift-managed VPC endpoint access to a cluster across Amazon
* Web Services accounts.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AuthorizeEndpointAccessResponse extends RedshiftResponse implements
ToCopyableBuilder {
private static final SdkField GRANTOR_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Grantor")
.getter(getter(AuthorizeEndpointAccessResponse::grantor)).setter(setter(Builder::grantor))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Grantor").build()).build();
private static final SdkField GRANTEE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Grantee")
.getter(getter(AuthorizeEndpointAccessResponse::grantee)).setter(setter(Builder::grantee))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Grantee").build()).build();
private static final SdkField CLUSTER_IDENTIFIER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ClusterIdentifier").getter(getter(AuthorizeEndpointAccessResponse::clusterIdentifier))
.setter(setter(Builder::clusterIdentifier))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClusterIdentifier").build()).build();
private static final SdkField AUTHORIZE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("AuthorizeTime").getter(getter(AuthorizeEndpointAccessResponse::authorizeTime))
.setter(setter(Builder::authorizeTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AuthorizeTime").build()).build();
private static final SdkField CLUSTER_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ClusterStatus").getter(getter(AuthorizeEndpointAccessResponse::clusterStatus))
.setter(setter(Builder::clusterStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClusterStatus").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(AuthorizeEndpointAccessResponse::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField ALLOWED_ALL_VP_CS_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("AllowedAllVPCs").getter(getter(AuthorizeEndpointAccessResponse::allowedAllVPCs))
.setter(setter(Builder::allowedAllVPCs))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AllowedAllVPCs").build()).build();
private static final SdkField> ALLOWED_VP_CS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("AllowedVPCs")
.getter(getter(AuthorizeEndpointAccessResponse::allowedVPCs))
.setter(setter(Builder::allowedVPCs))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AllowedVPCs").build(),
ListTrait
.builder()
.memberLocationName("VpcIdentifier")
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("VpcIdentifier").build()).build()).build()).build();
private static final SdkField ENDPOINT_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("EndpointCount").getter(getter(AuthorizeEndpointAccessResponse::endpointCount))
.setter(setter(Builder::endpointCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndpointCount").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(GRANTOR_FIELD, GRANTEE_FIELD,
CLUSTER_IDENTIFIER_FIELD, AUTHORIZE_TIME_FIELD, CLUSTER_STATUS_FIELD, STATUS_FIELD, ALLOWED_ALL_VP_CS_FIELD,
ALLOWED_VP_CS_FIELD, ENDPOINT_COUNT_FIELD));
private final String grantor;
private final String grantee;
private final String clusterIdentifier;
private final Instant authorizeTime;
private final String clusterStatus;
private final String status;
private final Boolean allowedAllVPCs;
private final List allowedVPCs;
private final Integer endpointCount;
private AuthorizeEndpointAccessResponse(BuilderImpl builder) {
super(builder);
this.grantor = builder.grantor;
this.grantee = builder.grantee;
this.clusterIdentifier = builder.clusterIdentifier;
this.authorizeTime = builder.authorizeTime;
this.clusterStatus = builder.clusterStatus;
this.status = builder.status;
this.allowedAllVPCs = builder.allowedAllVPCs;
this.allowedVPCs = builder.allowedVPCs;
this.endpointCount = builder.endpointCount;
}
/**
*
* The Amazon Web Services account ID of the cluster owner.
*
*
* @return The Amazon Web Services account ID of the cluster owner.
*/
public final String grantor() {
return grantor;
}
/**
*
* The Amazon Web Services account ID of the grantee of the cluster.
*
*
* @return The Amazon Web Services account ID of the grantee of the cluster.
*/
public final String grantee() {
return grantee;
}
/**
*
* The cluster identifier.
*
*
* @return The cluster identifier.
*/
public final String clusterIdentifier() {
return clusterIdentifier;
}
/**
*
* The time (UTC) when the authorization was created.
*
*
* @return The time (UTC) when the authorization was created.
*/
public final Instant authorizeTime() {
return authorizeTime;
}
/**
*
* The status of the cluster.
*
*
* @return The status of the cluster.
*/
public final String clusterStatus() {
return clusterStatus;
}
/**
*
* The status of the authorization action.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AuthorizationStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the authorization action.
* @see AuthorizationStatus
*/
public final AuthorizationStatus status() {
return AuthorizationStatus.fromValue(status);
}
/**
*
* The status of the authorization action.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AuthorizationStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the authorization action.
* @see AuthorizationStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* Indicates whether all VPCs in the grantee account are allowed access to the cluster.
*
*
* @return Indicates whether all VPCs in the grantee account are allowed access to the cluster.
*/
public final Boolean allowedAllVPCs() {
return allowedAllVPCs;
}
/**
* For responses, this returns true if the service returned a value for the AllowedVPCs 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 hasAllowedVPCs() {
return allowedVPCs != null && !(allowedVPCs instanceof SdkAutoConstructList);
}
/**
*
* The VPCs allowed access to the cluster.
*
*
* 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 #hasAllowedVPCs} method.
*
*
* @return The VPCs allowed access to the cluster.
*/
public final List allowedVPCs() {
return allowedVPCs;
}
/**
*
* The number of Redshift-managed VPC endpoints created for the authorization.
*
*
* @return The number of Redshift-managed VPC endpoints created for the authorization.
*/
public final Integer endpointCount() {
return endpointCount;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(grantor());
hashCode = 31 * hashCode + Objects.hashCode(grantee());
hashCode = 31 * hashCode + Objects.hashCode(clusterIdentifier());
hashCode = 31 * hashCode + Objects.hashCode(authorizeTime());
hashCode = 31 * hashCode + Objects.hashCode(clusterStatus());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(allowedAllVPCs());
hashCode = 31 * hashCode + Objects.hashCode(hasAllowedVPCs() ? allowedVPCs() : null);
hashCode = 31 * hashCode + Objects.hashCode(endpointCount());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AuthorizeEndpointAccessResponse)) {
return false;
}
AuthorizeEndpointAccessResponse other = (AuthorizeEndpointAccessResponse) obj;
return Objects.equals(grantor(), other.grantor()) && Objects.equals(grantee(), other.grantee())
&& Objects.equals(clusterIdentifier(), other.clusterIdentifier())
&& Objects.equals(authorizeTime(), other.authorizeTime())
&& Objects.equals(clusterStatus(), other.clusterStatus())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(allowedAllVPCs(), other.allowedAllVPCs()) && hasAllowedVPCs() == other.hasAllowedVPCs()
&& Objects.equals(allowedVPCs(), other.allowedVPCs()) && Objects.equals(endpointCount(), other.endpointCount());
}
/**
* 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("AuthorizeEndpointAccessResponse").add("Grantor", grantor()).add("Grantee", grantee())
.add("ClusterIdentifier", clusterIdentifier()).add("AuthorizeTime", authorizeTime())
.add("ClusterStatus", clusterStatus()).add("Status", statusAsString()).add("AllowedAllVPCs", allowedAllVPCs())
.add("AllowedVPCs", hasAllowedVPCs() ? allowedVPCs() : null).add("EndpointCount", endpointCount()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Grantor":
return Optional.ofNullable(clazz.cast(grantor()));
case "Grantee":
return Optional.ofNullable(clazz.cast(grantee()));
case "ClusterIdentifier":
return Optional.ofNullable(clazz.cast(clusterIdentifier()));
case "AuthorizeTime":
return Optional.ofNullable(clazz.cast(authorizeTime()));
case "ClusterStatus":
return Optional.ofNullable(clazz.cast(clusterStatus()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "AllowedAllVPCs":
return Optional.ofNullable(clazz.cast(allowedAllVPCs()));
case "AllowedVPCs":
return Optional.ofNullable(clazz.cast(allowedVPCs()));
case "EndpointCount":
return Optional.ofNullable(clazz.cast(endpointCount()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function