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

software.amazon.awssdk.services.s3.model.S3Location Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon S3 module holds the client classes that are used for communicating with Amazon Simple Storage Service

There is a newer version: 2.29.39
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.s3.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.traits.RequiredTrait;
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 Amazon S3 location that will receive the results of the restore request. *

*/ @Generated("software.amazon.awssdk:codegen") public final class S3Location implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField BUCKET_NAME_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("BucketName") .getter(getter(S3Location::bucketName)) .setter(setter(Builder::bucketName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BucketName") .unmarshallLocationName("BucketName").build(), RequiredTrait.create()).build(); private static final SdkField PREFIX_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("Prefix") .getter(getter(S3Location::prefix)) .setter(setter(Builder::prefix)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Prefix") .unmarshallLocationName("Prefix").build(), RequiredTrait.create()).build(); private static final SdkField ENCRYPTION_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("Encryption") .getter(getter(S3Location::encryption)) .setter(setter(Builder::encryption)) .constructor(Encryption::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Encryption") .unmarshallLocationName("Encryption").build()).build(); private static final SdkField CANNED_ACL_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("CannedACL") .getter(getter(S3Location::cannedACLAsString)) .setter(setter(Builder::cannedACL)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CannedACL") .unmarshallLocationName("CannedACL").build()).build(); private static final SdkField> ACCESS_CONTROL_LIST_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("AccessControlList") .getter(getter(S3Location::accessControlList)) .setter(setter(Builder::accessControlList)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccessControlList") .unmarshallLocationName("AccessControlList").build(), ListTrait .builder() .memberLocationName("Grant") .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(Grant::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("Grant").unmarshallLocationName("Grant").build()).build()) .build()).build(); private static final SdkField TAGGING_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("Tagging") .getter(getter(S3Location::tagging)) .setter(setter(Builder::tagging)) .constructor(Tagging::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tagging") .unmarshallLocationName("Tagging").build()).build(); private static final SdkField> USER_METADATA_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("UserMetadata") .getter(getter(S3Location::userMetadata)) .setter(setter(Builder::userMetadata)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UserMetadata") .unmarshallLocationName("UserMetadata").build(), ListTrait .builder() .memberLocationName("MetadataEntry") .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(MetadataEntry::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("MetadataEntry").unmarshallLocationName("MetadataEntry") .build()).build()).build()).build(); private static final SdkField STORAGE_CLASS_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("StorageClass") .getter(getter(S3Location::storageClassAsString)) .setter(setter(Builder::storageClass)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StorageClass") .unmarshallLocationName("StorageClass").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BUCKET_NAME_FIELD, PREFIX_FIELD, ENCRYPTION_FIELD, CANNED_ACL_FIELD, ACCESS_CONTROL_LIST_FIELD, TAGGING_FIELD, USER_METADATA_FIELD, STORAGE_CLASS_FIELD)); private static final long serialVersionUID = 1L; private final String bucketName; private final String prefix; private final Encryption encryption; private final String cannedACL; private final List accessControlList; private final Tagging tagging; private final List userMetadata; private final String storageClass; private S3Location(BuilderImpl builder) { this.bucketName = builder.bucketName; this.prefix = builder.prefix; this.encryption = builder.encryption; this.cannedACL = builder.cannedACL; this.accessControlList = builder.accessControlList; this.tagging = builder.tagging; this.userMetadata = builder.userMetadata; this.storageClass = builder.storageClass; } /** *

* The name of the bucket where the restore results will be placed. *

* * @return The name of the bucket where the restore results will be placed. */ public final String bucketName() { return bucketName; } /** *

* The prefix that is prepended to the restore results for this request. *

* * @return The prefix that is prepended to the restore results for this request. */ public final String prefix() { return prefix; } /** * Returns the value of the Encryption property for this object. * * @return The value of the Encryption property for this object. */ public final Encryption encryption() { return encryption; } /** *

* The canned ACL to apply to the restore results. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #cannedACL} will * return {@link ObjectCannedACL#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #cannedACLAsString}. *

* * @return The canned ACL to apply to the restore results. * @see ObjectCannedACL */ public final ObjectCannedACL cannedACL() { return ObjectCannedACL.fromValue(cannedACL); } /** *

* The canned ACL to apply to the restore results. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #cannedACL} will * return {@link ObjectCannedACL#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #cannedACLAsString}. *

* * @return The canned ACL to apply to the restore results. * @see ObjectCannedACL */ public final String cannedACLAsString() { return cannedACL; } /** * For responses, this returns true if the service returned a value for the AccessControlList 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 hasAccessControlList() { return accessControlList != null && !(accessControlList instanceof SdkAutoConstructList); } /** *

* A list of grants that control access to the staged results. *

*

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

* * @return A list of grants that control access to the staged results. */ public final List accessControlList() { return accessControlList; } /** *

* The tag-set that is applied to the restore results. *

* * @return The tag-set that is applied to the restore results. */ public final Tagging tagging() { return tagging; } /** * For responses, this returns true if the service returned a value for the UserMetadata 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 hasUserMetadata() { return userMetadata != null && !(userMetadata instanceof SdkAutoConstructList); } /** *

* A list of metadata to store with the restore results in S3. *

*

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

* * @return A list of metadata to store with the restore results in S3. */ public final List userMetadata() { return userMetadata; } /** *

* The class of storage used to store the restore results. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #storageClass} will * return {@link StorageClass#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #storageClassAsString}. *

* * @return The class of storage used to store the restore results. * @see StorageClass */ public final StorageClass storageClass() { return StorageClass.fromValue(storageClass); } /** *

* The class of storage used to store the restore results. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #storageClass} will * return {@link StorageClass#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #storageClassAsString}. *

* * @return The class of storage used to store the restore results. * @see StorageClass */ public final String storageClassAsString() { return storageClass; } @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(bucketName()); hashCode = 31 * hashCode + Objects.hashCode(prefix()); hashCode = 31 * hashCode + Objects.hashCode(encryption()); hashCode = 31 * hashCode + Objects.hashCode(cannedACLAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasAccessControlList() ? accessControlList() : null); hashCode = 31 * hashCode + Objects.hashCode(tagging()); hashCode = 31 * hashCode + Objects.hashCode(hasUserMetadata() ? userMetadata() : null); hashCode = 31 * hashCode + Objects.hashCode(storageClassAsString()); 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 S3Location)) { return false; } S3Location other = (S3Location) obj; return Objects.equals(bucketName(), other.bucketName()) && Objects.equals(prefix(), other.prefix()) && Objects.equals(encryption(), other.encryption()) && Objects.equals(cannedACLAsString(), other.cannedACLAsString()) && hasAccessControlList() == other.hasAccessControlList() && Objects.equals(accessControlList(), other.accessControlList()) && Objects.equals(tagging(), other.tagging()) && hasUserMetadata() == other.hasUserMetadata() && Objects.equals(userMetadata(), other.userMetadata()) && Objects.equals(storageClassAsString(), other.storageClassAsString()); } /** * 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("S3Location").add("BucketName", bucketName()).add("Prefix", prefix()) .add("Encryption", encryption()).add("CannedACL", cannedACLAsString()) .add("AccessControlList", hasAccessControlList() ? accessControlList() : null).add("Tagging", tagging()) .add("UserMetadata", hasUserMetadata() ? userMetadata() : null).add("StorageClass", storageClassAsString()) .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "BucketName": return Optional.ofNullable(clazz.cast(bucketName())); case "Prefix": return Optional.ofNullable(clazz.cast(prefix())); case "Encryption": return Optional.ofNullable(clazz.cast(encryption())); case "CannedACL": return Optional.ofNullable(clazz.cast(cannedACLAsString())); case "AccessControlList": return Optional.ofNullable(clazz.cast(accessControlList())); case "Tagging": return Optional.ofNullable(clazz.cast(tagging())); case "UserMetadata": return Optional.ofNullable(clazz.cast(userMetadata())); case "StorageClass": return Optional.ofNullable(clazz.cast(storageClassAsString())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((S3Location) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The name of the bucket where the restore results will be placed. *

* * @param bucketName * The name of the bucket where the restore results will be placed. * @return Returns a reference to this object so that method calls can be chained together. */ Builder bucketName(String bucketName); /** *

* The prefix that is prepended to the restore results for this request. *

* * @param prefix * The prefix that is prepended to the restore results for this request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder prefix(String prefix); /** * Sets the value of the Encryption property for this object. * * @param encryption * The new value for the Encryption property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder encryption(Encryption encryption); /** * Sets the value of the Encryption property for this object. * * This is a convenience method that creates an instance of the {@link Encryption.Builder} avoiding the need to * create one manually via {@link Encryption#builder()}. * *

* When the {@link Consumer} completes, {@link Encryption.Builder#build()} is called immediately and its result * is passed to {@link #encryption(Encryption)}. * * @param encryption * a consumer that will call methods on {@link Encryption.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #encryption(Encryption) */ default Builder encryption(Consumer encryption) { return encryption(Encryption.builder().applyMutation(encryption).build()); } /** *

* The canned ACL to apply to the restore results. *

* * @param cannedACL * The canned ACL to apply to the restore results. * @see ObjectCannedACL * @return Returns a reference to this object so that method calls can be chained together. * @see ObjectCannedACL */ Builder cannedACL(String cannedACL); /** *

* The canned ACL to apply to the restore results. *

* * @param cannedACL * The canned ACL to apply to the restore results. * @see ObjectCannedACL * @return Returns a reference to this object so that method calls can be chained together. * @see ObjectCannedACL */ Builder cannedACL(ObjectCannedACL cannedACL); /** *

* A list of grants that control access to the staged results. *

* * @param accessControlList * A list of grants that control access to the staged results. * @return Returns a reference to this object so that method calls can be chained together. */ Builder accessControlList(Collection accessControlList); /** *

* A list of grants that control access to the staged results. *

* * @param accessControlList * A list of grants that control access to the staged results. * @return Returns a reference to this object so that method calls can be chained together. */ Builder accessControlList(Grant... accessControlList); /** *

* A list of grants that control access to the staged results. *

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

* When the {@link Consumer} completes, {@link software.amazon.awssdk.services.s3.model.Grant.Builder#build()} * is called immediately and its result is passed to {@link #accessControlList(List)}. * * @param accessControlList * a consumer that will call methods on {@link software.amazon.awssdk.services.s3.model.Grant.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #accessControlList(java.util.Collection) */ Builder accessControlList(Consumer... accessControlList); /** *

* The tag-set that is applied to the restore results. *

* * @param tagging * The tag-set that is applied to the restore results. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tagging(Tagging tagging); /** *

* The tag-set that is applied to the restore results. *

* This is a convenience method that creates an instance of the {@link Tagging.Builder} avoiding the need to * create one manually via {@link Tagging#builder()}. * *

* When the {@link Consumer} completes, {@link Tagging.Builder#build()} is called immediately and its result is * passed to {@link #tagging(Tagging)}. * * @param tagging * a consumer that will call methods on {@link Tagging.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #tagging(Tagging) */ default Builder tagging(Consumer tagging) { return tagging(Tagging.builder().applyMutation(tagging).build()); } /** *

* A list of metadata to store with the restore results in S3. *

* * @param userMetadata * A list of metadata to store with the restore results in S3. * @return Returns a reference to this object so that method calls can be chained together. */ Builder userMetadata(Collection userMetadata); /** *

* A list of metadata to store with the restore results in S3. *

* * @param userMetadata * A list of metadata to store with the restore results in S3. * @return Returns a reference to this object so that method calls can be chained together. */ Builder userMetadata(MetadataEntry... userMetadata); /** *

* A list of metadata to store with the restore results in S3. *

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

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.s3.model.MetadataEntry.Builder#build()} is called immediately and its * result is passed to {@link #userMetadata(List)}. * * @param userMetadata * a consumer that will call methods on * {@link software.amazon.awssdk.services.s3.model.MetadataEntry.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #userMetadata(java.util.Collection) */ Builder userMetadata(Consumer... userMetadata); /** *

* The class of storage used to store the restore results. *

* * @param storageClass * The class of storage used to store the restore results. * @see StorageClass * @return Returns a reference to this object so that method calls can be chained together. * @see StorageClass */ Builder storageClass(String storageClass); /** *

* The class of storage used to store the restore results. *

* * @param storageClass * The class of storage used to store the restore results. * @see StorageClass * @return Returns a reference to this object so that method calls can be chained together. * @see StorageClass */ Builder storageClass(StorageClass storageClass); } static final class BuilderImpl implements Builder { private String bucketName; private String prefix; private Encryption encryption; private String cannedACL; private List accessControlList = DefaultSdkAutoConstructList.getInstance(); private Tagging tagging; private List userMetadata = DefaultSdkAutoConstructList.getInstance(); private String storageClass; private BuilderImpl() { } private BuilderImpl(S3Location model) { bucketName(model.bucketName); prefix(model.prefix); encryption(model.encryption); cannedACL(model.cannedACL); accessControlList(model.accessControlList); tagging(model.tagging); userMetadata(model.userMetadata); storageClass(model.storageClass); } public final String getBucketName() { return bucketName; } public final void setBucketName(String bucketName) { this.bucketName = bucketName; } @Override public final Builder bucketName(String bucketName) { this.bucketName = bucketName; return this; } public final String getPrefix() { return prefix; } public final void setPrefix(String prefix) { this.prefix = prefix; } @Override public final Builder prefix(String prefix) { this.prefix = prefix; return this; } public final Encryption.Builder getEncryption() { return encryption != null ? encryption.toBuilder() : null; } public final void setEncryption(Encryption.BuilderImpl encryption) { this.encryption = encryption != null ? encryption.build() : null; } @Override public final Builder encryption(Encryption encryption) { this.encryption = encryption; return this; } public final String getCannedACL() { return cannedACL; } public final void setCannedACL(String cannedACL) { this.cannedACL = cannedACL; } @Override public final Builder cannedACL(String cannedACL) { this.cannedACL = cannedACL; return this; } @Override public final Builder cannedACL(ObjectCannedACL cannedACL) { this.cannedACL(cannedACL == null ? null : cannedACL.toString()); return this; } public final List getAccessControlList() { List result = GrantsCopier.copyToBuilder(this.accessControlList); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setAccessControlList(Collection accessControlList) { this.accessControlList = GrantsCopier.copyFromBuilder(accessControlList); } @Override public final Builder accessControlList(Collection accessControlList) { this.accessControlList = GrantsCopier.copy(accessControlList); return this; } @Override @SafeVarargs public final Builder accessControlList(Grant... accessControlList) { accessControlList(Arrays.asList(accessControlList)); return this; } @Override @SafeVarargs public final Builder accessControlList(Consumer... accessControlList) { accessControlList(Stream.of(accessControlList).map(c -> Grant.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final Tagging.Builder getTagging() { return tagging != null ? tagging.toBuilder() : null; } public final void setTagging(Tagging.BuilderImpl tagging) { this.tagging = tagging != null ? tagging.build() : null; } @Override public final Builder tagging(Tagging tagging) { this.tagging = tagging; return this; } public final List getUserMetadata() { List result = UserMetadataCopier.copyToBuilder(this.userMetadata); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setUserMetadata(Collection userMetadata) { this.userMetadata = UserMetadataCopier.copyFromBuilder(userMetadata); } @Override public final Builder userMetadata(Collection userMetadata) { this.userMetadata = UserMetadataCopier.copy(userMetadata); return this; } @Override @SafeVarargs public final Builder userMetadata(MetadataEntry... userMetadata) { userMetadata(Arrays.asList(userMetadata)); return this; } @Override @SafeVarargs public final Builder userMetadata(Consumer... userMetadata) { userMetadata(Stream.of(userMetadata).map(c -> MetadataEntry.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final String getStorageClass() { return storageClass; } public final void setStorageClass(String storageClass) { this.storageClass = storageClass; } @Override public final Builder storageClass(String storageClass) { this.storageClass = storageClass; return this; } @Override public final Builder storageClass(StorageClass storageClass) { this.storageClass(storageClass == null ? null : storageClass.toString()); return this; } @Override public S3Location build() { return new S3Location(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy