software.amazon.awssdk.services.dataexchange.model.S3DataAccessAsset Maven / Gradle / Ivy
Show all versions of dataexchange 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.dataexchange.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;
/**
*
* The Amazon S3 data access that is the asset.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class S3DataAccessAsset implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField BUCKET_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Bucket")
.getter(getter(S3DataAccessAsset::bucket)).setter(setter(Builder::bucket))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Bucket").build()).build();
private static final SdkField> KEY_PREFIXES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("KeyPrefixes")
.getter(getter(S3DataAccessAsset::keyPrefixes))
.setter(setter(Builder::keyPrefixes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyPrefixes").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> KEYS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Keys")
.getter(getter(S3DataAccessAsset::keys))
.setter(setter(Builder::keys))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Keys").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 S3_ACCESS_POINT_ALIAS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("S3AccessPointAlias").getter(getter(S3DataAccessAsset::s3AccessPointAlias))
.setter(setter(Builder::s3AccessPointAlias))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("S3AccessPointAlias").build())
.build();
private static final SdkField S3_ACCESS_POINT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("S3AccessPointArn").getter(getter(S3DataAccessAsset::s3AccessPointArn))
.setter(setter(Builder::s3AccessPointArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("S3AccessPointArn").build()).build();
private static final SdkField> KMS_KEYS_TO_GRANT_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("KmsKeysToGrant")
.getter(getter(S3DataAccessAsset::kmsKeysToGrant))
.setter(setter(Builder::kmsKeysToGrant))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KmsKeysToGrant").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(KmsKeyToGrant::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BUCKET_FIELD,
KEY_PREFIXES_FIELD, KEYS_FIELD, S3_ACCESS_POINT_ALIAS_FIELD, S3_ACCESS_POINT_ARN_FIELD, KMS_KEYS_TO_GRANT_FIELD));
private static final long serialVersionUID = 1L;
private final String bucket;
private final List keyPrefixes;
private final List keys;
private final String s3AccessPointAlias;
private final String s3AccessPointArn;
private final List kmsKeysToGrant;
private S3DataAccessAsset(BuilderImpl builder) {
this.bucket = builder.bucket;
this.keyPrefixes = builder.keyPrefixes;
this.keys = builder.keys;
this.s3AccessPointAlias = builder.s3AccessPointAlias;
this.s3AccessPointArn = builder.s3AccessPointArn;
this.kmsKeysToGrant = builder.kmsKeysToGrant;
}
/**
*
* The Amazon S3 bucket hosting data to be shared in the S3 data access.
*
*
* @return The Amazon S3 bucket hosting data to be shared in the S3 data access.
*/
public final String bucket() {
return bucket;
}
/**
* For responses, this returns true if the service returned a value for the KeyPrefixes 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 hasKeyPrefixes() {
return keyPrefixes != null && !(keyPrefixes instanceof SdkAutoConstructList);
}
/**
*
* The Amazon S3 bucket used for hosting shared data in the Amazon S3 data access.
*
*
* 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 #hasKeyPrefixes} method.
*
*
* @return The Amazon S3 bucket used for hosting shared data in the Amazon S3 data access.
*/
public final List keyPrefixes() {
return keyPrefixes;
}
/**
* For responses, this returns true if the service returned a value for the Keys 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 hasKeys() {
return keys != null && !(keys instanceof SdkAutoConstructList);
}
/**
*
* S3 keys made available using this asset.
*
*
* 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 #hasKeys} method.
*
*
* @return S3 keys made available using this asset.
*/
public final List keys() {
return keys;
}
/**
*
* The automatically-generated bucket-style alias for your Amazon S3 Access Point. Customers can access their
* entitled data using the S3 Access Point alias.
*
*
* @return The automatically-generated bucket-style alias for your Amazon S3 Access Point. Customers can access
* their entitled data using the S3 Access Point alias.
*/
public final String s3AccessPointAlias() {
return s3AccessPointAlias;
}
/**
*
* The ARN for your Amazon S3 Access Point. Customers can also access their entitled data using the S3 Access Point
* ARN.
*
*
* @return The ARN for your Amazon S3 Access Point. Customers can also access their entitled data using the S3
* Access Point ARN.
*/
public final String s3AccessPointArn() {
return s3AccessPointArn;
}
/**
* For responses, this returns true if the service returned a value for the KmsKeysToGrant 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 hasKmsKeysToGrant() {
return kmsKeysToGrant != null && !(kmsKeysToGrant instanceof SdkAutoConstructList);
}
/**
*
* List of AWS KMS CMKs (Key Management System Customer Managed Keys) and ARNs used to encrypt S3 objects being
* shared in this S3 Data Access asset. Providers must include all AWS KMS keys used to encrypt these shared S3
* objects.
*
*
* 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 #hasKmsKeysToGrant} method.
*
*
* @return List of AWS KMS CMKs (Key Management System Customer Managed Keys) and ARNs used to encrypt S3 objects
* being shared in this S3 Data Access asset. Providers must include all AWS KMS keys used to encrypt these
* shared S3 objects.
*/
public final List kmsKeysToGrant() {
return kmsKeysToGrant;
}
@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(bucket());
hashCode = 31 * hashCode + Objects.hashCode(hasKeyPrefixes() ? keyPrefixes() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasKeys() ? keys() : null);
hashCode = 31 * hashCode + Objects.hashCode(s3AccessPointAlias());
hashCode = 31 * hashCode + Objects.hashCode(s3AccessPointArn());
hashCode = 31 * hashCode + Objects.hashCode(hasKmsKeysToGrant() ? kmsKeysToGrant() : 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 S3DataAccessAsset)) {
return false;
}
S3DataAccessAsset other = (S3DataAccessAsset) obj;
return Objects.equals(bucket(), other.bucket()) && hasKeyPrefixes() == other.hasKeyPrefixes()
&& Objects.equals(keyPrefixes(), other.keyPrefixes()) && hasKeys() == other.hasKeys()
&& Objects.equals(keys(), other.keys()) && Objects.equals(s3AccessPointAlias(), other.s3AccessPointAlias())
&& Objects.equals(s3AccessPointArn(), other.s3AccessPointArn())
&& hasKmsKeysToGrant() == other.hasKmsKeysToGrant() && Objects.equals(kmsKeysToGrant(), other.kmsKeysToGrant());
}
/**
* 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("S3DataAccessAsset").add("Bucket", bucket())
.add("KeyPrefixes", hasKeyPrefixes() ? keyPrefixes() : null).add("Keys", hasKeys() ? keys() : null)
.add("S3AccessPointAlias", s3AccessPointAlias()).add("S3AccessPointArn", s3AccessPointArn())
.add("KmsKeysToGrant", hasKmsKeysToGrant() ? kmsKeysToGrant() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Bucket":
return Optional.ofNullable(clazz.cast(bucket()));
case "KeyPrefixes":
return Optional.ofNullable(clazz.cast(keyPrefixes()));
case "Keys":
return Optional.ofNullable(clazz.cast(keys()));
case "S3AccessPointAlias":
return Optional.ofNullable(clazz.cast(s3AccessPointAlias()));
case "S3AccessPointArn":
return Optional.ofNullable(clazz.cast(s3AccessPointArn()));
case "KmsKeysToGrant":
return Optional.ofNullable(clazz.cast(kmsKeysToGrant()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function