software.amazon.awssdk.services.s3.model.PutObjectAclRequest Maven / Gradle / Ivy
Show all versions of s3 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.s3.model;
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.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
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.core.traits.PayloadTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class PutObjectAclRequest extends S3Request implements
ToCopyableBuilder {
private static final SdkField ACL_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ACL")
.getter(getter(PutObjectAclRequest::aclAsString))
.setter(setter(Builder::acl))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-acl")
.unmarshallLocationName("x-amz-acl").build()).build();
private static final SdkField ACCESS_CONTROL_POLICY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("AccessControlPolicy")
.getter(getter(PutObjectAclRequest::accessControlPolicy))
.setter(setter(Builder::accessControlPolicy))
.constructor(AccessControlPolicy::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccessControlPolicy")
.unmarshallLocationName("AccessControlPolicy").build(), PayloadTrait.create()).build();
private static final SdkField BUCKET_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Bucket")
.getter(getter(PutObjectAclRequest::bucket))
.setter(setter(Builder::bucket))
.traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("Bucket")
.unmarshallLocationName("Bucket").build()).build();
private static final SdkField CONTENT_MD5_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ContentMD5")
.getter(getter(PutObjectAclRequest::contentMD5))
.setter(setter(Builder::contentMD5))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("Content-MD5")
.unmarshallLocationName("Content-MD5").build()).build();
private static final SdkField GRANT_FULL_CONTROL_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("GrantFullControl")
.getter(getter(PutObjectAclRequest::grantFullControl))
.setter(setter(Builder::grantFullControl))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-grant-full-control")
.unmarshallLocationName("x-amz-grant-full-control").build()).build();
private static final SdkField GRANT_READ_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("GrantRead")
.getter(getter(PutObjectAclRequest::grantRead))
.setter(setter(Builder::grantRead))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-grant-read")
.unmarshallLocationName("x-amz-grant-read").build()).build();
private static final SdkField GRANT_READ_ACP_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("GrantReadACP")
.getter(getter(PutObjectAclRequest::grantReadACP))
.setter(setter(Builder::grantReadACP))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-grant-read-acp")
.unmarshallLocationName("x-amz-grant-read-acp").build()).build();
private static final SdkField GRANT_WRITE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("GrantWrite")
.getter(getter(PutObjectAclRequest::grantWrite))
.setter(setter(Builder::grantWrite))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-grant-write")
.unmarshallLocationName("x-amz-grant-write").build()).build();
private static final SdkField GRANT_WRITE_ACP_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("GrantWriteACP")
.getter(getter(PutObjectAclRequest::grantWriteACP))
.setter(setter(Builder::grantWriteACP))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-grant-write-acp")
.unmarshallLocationName("x-amz-grant-write-acp").build()).build();
private static final SdkField KEY_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Key")
.getter(getter(PutObjectAclRequest::key))
.setter(setter(Builder::key))
.traits(LocationTrait.builder().location(MarshallLocation.GREEDY_PATH).locationName("Key")
.unmarshallLocationName("Key").build()).build();
private static final SdkField REQUEST_PAYER_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("RequestPayer")
.getter(getter(PutObjectAclRequest::requestPayerAsString))
.setter(setter(Builder::requestPayer))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-request-payer")
.unmarshallLocationName("x-amz-request-payer").build()).build();
private static final SdkField VERSION_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("VersionId")
.getter(getter(PutObjectAclRequest::versionId))
.setter(setter(Builder::versionId))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("versionId")
.unmarshallLocationName("versionId").build()).build();
private static final SdkField EXPECTED_BUCKET_OWNER_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ExpectedBucketOwner")
.getter(getter(PutObjectAclRequest::expectedBucketOwner))
.setter(setter(Builder::expectedBucketOwner))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-expected-bucket-owner")
.unmarshallLocationName("x-amz-expected-bucket-owner").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACL_FIELD,
ACCESS_CONTROL_POLICY_FIELD, BUCKET_FIELD, CONTENT_MD5_FIELD, GRANT_FULL_CONTROL_FIELD, GRANT_READ_FIELD,
GRANT_READ_ACP_FIELD, GRANT_WRITE_FIELD, GRANT_WRITE_ACP_FIELD, KEY_FIELD, REQUEST_PAYER_FIELD, VERSION_ID_FIELD,
EXPECTED_BUCKET_OWNER_FIELD));
private final String acl;
private final AccessControlPolicy accessControlPolicy;
private final String bucket;
private final String contentMD5;
private final String grantFullControl;
private final String grantRead;
private final String grantReadACP;
private final String grantWrite;
private final String grantWriteACP;
private final String key;
private final String requestPayer;
private final String versionId;
private final String expectedBucketOwner;
private PutObjectAclRequest(BuilderImpl builder) {
super(builder);
this.acl = builder.acl;
this.accessControlPolicy = builder.accessControlPolicy;
this.bucket = builder.bucket;
this.contentMD5 = builder.contentMD5;
this.grantFullControl = builder.grantFullControl;
this.grantRead = builder.grantRead;
this.grantReadACP = builder.grantReadACP;
this.grantWrite = builder.grantWrite;
this.grantWriteACP = builder.grantWriteACP;
this.key = builder.key;
this.requestPayer = builder.requestPayer;
this.versionId = builder.versionId;
this.expectedBucketOwner = builder.expectedBucketOwner;
}
/**
*
* The canned ACL to apply to the object. For more information, see Canned ACL.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #acl} will return
* {@link ObjectCannedACL#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #aclAsString}.
*
*
* @return The canned ACL to apply to the object. For more information, see Canned ACL.
* @see ObjectCannedACL
*/
public final ObjectCannedACL acl() {
return ObjectCannedACL.fromValue(acl);
}
/**
*
* The canned ACL to apply to the object. For more information, see Canned ACL.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #acl} will return
* {@link ObjectCannedACL#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #aclAsString}.
*
*
* @return The canned ACL to apply to the object. For more information, see Canned ACL.
* @see ObjectCannedACL
*/
public final String aclAsString() {
return acl;
}
/**
*
* Contains the elements that set the ACL permissions for an object per grantee.
*
*
* @return Contains the elements that set the ACL permissions for an object per grantee.
*/
public final AccessControlPolicy accessControlPolicy() {
return accessControlPolicy;
}
/**
*
* The bucket name that contains the object to which you want to attach the ACL.
*
*
* When using this action with an access point, you must direct requests to the access point hostname. The access
* point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com.
* When using this action with an access point through the AWS SDKs, you provide the access point ARN in place of
* the bucket name. For more information about access point ARNs, see Using Access Points in
* the Amazon S3 User Guide.
*
*
* @return The bucket name that contains the object to which you want to attach the ACL.
*
* When using this action with an access point, you must direct requests to the access point hostname. The
* access point hostname takes the form
* AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this
* action with an access point through the AWS SDKs, you provide the access point ARN in place of the bucket
* name. For more information about access point ARNs, see Using Access
* Points in the Amazon S3 User Guide.
*/
public final String bucket() {
return bucket;
}
/**
*
* The base64-encoded 128-bit MD5 digest of the data. This header must be used as a message integrity check to
* verify that the request body was not corrupted in transit. For more information, go to RFC 1864.>
*
*
* For requests made using the AWS Command Line Interface (CLI) or AWS SDKs, this field is calculated automatically.
*
*
* @return The base64-encoded 128-bit MD5 digest of the data. This header must be used as a message integrity check
* to verify that the request body was not corrupted in transit. For more information, go to RFC 1864.>
*
* For requests made using the AWS Command Line Interface (CLI) or AWS SDKs, this field is calculated
* automatically.
*/
public final String contentMD5() {
return contentMD5;
}
/**
*
* Allows grantee the read, write, read ACP, and write ACP permissions on the bucket.
*
*
* This action is not supported by Amazon S3 on Outposts.
*
*
* @return Allows grantee the read, write, read ACP, and write ACP permissions on the bucket.
*
* This action is not supported by Amazon S3 on Outposts.
*/
public final String grantFullControl() {
return grantFullControl;
}
/**
*
* Allows grantee to list the objects in the bucket.
*
*
* This action is not supported by Amazon S3 on Outposts.
*
*
* @return Allows grantee to list the objects in the bucket.
*
* This action is not supported by Amazon S3 on Outposts.
*/
public final String grantRead() {
return grantRead;
}
/**
*
* Allows grantee to read the bucket ACL.
*
*
* This action is not supported by Amazon S3 on Outposts.
*
*
* @return Allows grantee to read the bucket ACL.
*
* This action is not supported by Amazon S3 on Outposts.
*/
public final String grantReadACP() {
return grantReadACP;
}
/**
*
* Allows grantee to create, overwrite, and delete any object in the bucket.
*
*
* @return Allows grantee to create, overwrite, and delete any object in the bucket.
*/
public final String grantWrite() {
return grantWrite;
}
/**
*
* Allows grantee to write the ACL for the applicable bucket.
*
*
* This action is not supported by Amazon S3 on Outposts.
*
*
* @return Allows grantee to write the ACL for the applicable bucket.
*
* This action is not supported by Amazon S3 on Outposts.
*/
public final String grantWriteACP() {
return grantWriteACP;
}
/**
*
* Key for which the PUT action was initiated.
*
*
* When using this action with an access point, you must direct requests to the access point hostname. The access
* point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com.
* When using this action with an access point through the AWS SDKs, you provide the access point ARN in place of
* the bucket name. For more information about access point ARNs, see Using Access Points in
* the Amazon S3 User Guide.
*
*
* When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The
* S3 on Outposts hostname takes the form
* AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this
* action using S3 on Outposts through the AWS SDKs, you provide the Outposts bucket ARN in place of the bucket
* name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the
* Amazon S3 User Guide.
*
*
* @return Key for which the PUT action was initiated.
*
* When using this action with an access point, you must direct requests to the access point hostname. The
* access point hostname takes the form
* AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this
* action with an access point through the AWS SDKs, you provide the access point ARN in place of the bucket
* name. For more information about access point ARNs, see Using Access
* Points in the Amazon S3 User Guide.
*
*
* When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts
* hostname. The S3 on Outposts hostname takes the form
* AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When
* using this action using S3 on Outposts through the AWS SDKs, you provide the Outposts bucket ARN in place
* of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts
* in the Amazon S3 User Guide.
*/
public final String key() {
return key;
}
/**
* Returns the value of the RequestPayer property for this object.
*
* If the service returns an enum value that is not available in the current SDK version, {@link #requestPayer} will
* return {@link RequestPayer#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #requestPayerAsString}.
*
*
* @return The value of the RequestPayer property for this object.
* @see RequestPayer
*/
public final RequestPayer requestPayer() {
return RequestPayer.fromValue(requestPayer);
}
/**
* Returns the value of the RequestPayer property for this object.
*
* If the service returns an enum value that is not available in the current SDK version, {@link #requestPayer} will
* return {@link RequestPayer#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #requestPayerAsString}.
*
*
* @return The value of the RequestPayer property for this object.
* @see RequestPayer
*/
public final String requestPayerAsString() {
return requestPayer;
}
/**
*
* VersionId used to reference a specific version of the object.
*
*
* @return VersionId used to reference a specific version of the object.
*/
public final String versionId() {
return versionId;
}
/**
*
* The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail
* with an HTTP 403 (Access Denied)
error.
*
*
* @return The account ID of the expected bucket owner. If the bucket is owned by a different account, the request
* will fail with an HTTP 403 (Access Denied)
error.
*/
public final String expectedBucketOwner() {
return expectedBucketOwner;
}
@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(aclAsString());
hashCode = 31 * hashCode + Objects.hashCode(accessControlPolicy());
hashCode = 31 * hashCode + Objects.hashCode(bucket());
hashCode = 31 * hashCode + Objects.hashCode(contentMD5());
hashCode = 31 * hashCode + Objects.hashCode(grantFullControl());
hashCode = 31 * hashCode + Objects.hashCode(grantRead());
hashCode = 31 * hashCode + Objects.hashCode(grantReadACP());
hashCode = 31 * hashCode + Objects.hashCode(grantWrite());
hashCode = 31 * hashCode + Objects.hashCode(grantWriteACP());
hashCode = 31 * hashCode + Objects.hashCode(key());
hashCode = 31 * hashCode + Objects.hashCode(requestPayerAsString());
hashCode = 31 * hashCode + Objects.hashCode(versionId());
hashCode = 31 * hashCode + Objects.hashCode(expectedBucketOwner());
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 PutObjectAclRequest)) {
return false;
}
PutObjectAclRequest other = (PutObjectAclRequest) obj;
return Objects.equals(aclAsString(), other.aclAsString())
&& Objects.equals(accessControlPolicy(), other.accessControlPolicy()) && Objects.equals(bucket(), other.bucket())
&& Objects.equals(contentMD5(), other.contentMD5())
&& Objects.equals(grantFullControl(), other.grantFullControl()) && Objects.equals(grantRead(), other.grantRead())
&& Objects.equals(grantReadACP(), other.grantReadACP()) && Objects.equals(grantWrite(), other.grantWrite())
&& Objects.equals(grantWriteACP(), other.grantWriteACP()) && Objects.equals(key(), other.key())
&& Objects.equals(requestPayerAsString(), other.requestPayerAsString())
&& Objects.equals(versionId(), other.versionId())
&& Objects.equals(expectedBucketOwner(), other.expectedBucketOwner());
}
/**
* 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("PutObjectAclRequest").add("ACL", aclAsString())
.add("AccessControlPolicy", accessControlPolicy()).add("Bucket", bucket()).add("ContentMD5", contentMD5())
.add("GrantFullControl", grantFullControl()).add("GrantRead", grantRead()).add("GrantReadACP", grantReadACP())
.add("GrantWrite", grantWrite()).add("GrantWriteACP", grantWriteACP()).add("Key", key())
.add("RequestPayer", requestPayerAsString()).add("VersionId", versionId())
.add("ExpectedBucketOwner", expectedBucketOwner()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ACL":
return Optional.ofNullable(clazz.cast(aclAsString()));
case "AccessControlPolicy":
return Optional.ofNullable(clazz.cast(accessControlPolicy()));
case "Bucket":
return Optional.ofNullable(clazz.cast(bucket()));
case "ContentMD5":
return Optional.ofNullable(clazz.cast(contentMD5()));
case "GrantFullControl":
return Optional.ofNullable(clazz.cast(grantFullControl()));
case "GrantRead":
return Optional.ofNullable(clazz.cast(grantRead()));
case "GrantReadACP":
return Optional.ofNullable(clazz.cast(grantReadACP()));
case "GrantWrite":
return Optional.ofNullable(clazz.cast(grantWrite()));
case "GrantWriteACP":
return Optional.ofNullable(clazz.cast(grantWriteACP()));
case "Key":
return Optional.ofNullable(clazz.cast(key()));
case "RequestPayer":
return Optional.ofNullable(clazz.cast(requestPayerAsString()));
case "VersionId":
return Optional.ofNullable(clazz.cast(versionId()));
case "ExpectedBucketOwner":
return Optional.ofNullable(clazz.cast(expectedBucketOwner()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function