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

software.amazon.awssdk.services.s3.model.PutBucketAclRequest 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 2014-2019 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 PutBucketAclRequest extends S3Request implements
        ToCopyableBuilder {
    private static final SdkField ACL_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .getter(getter(PutBucketAclRequest::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)
            .getter(getter(PutBucketAclRequest::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)
            .getter(getter(PutBucketAclRequest::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)
            .getter(getter(PutBucketAclRequest::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)
            .getter(getter(PutBucketAclRequest::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)
            .getter(getter(PutBucketAclRequest::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)
            .getter(getter(PutBucketAclRequest::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)
            .getter(getter(PutBucketAclRequest::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)
            .getter(getter(PutBucketAclRequest::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 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));

    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 PutBucketAclRequest(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;
    }

    /**
     * 

* The canned ACL to apply to the bucket. *

*

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

* * @return The canned ACL to apply to the bucket. * @see BucketCannedACL */ public BucketCannedACL acl() { return BucketCannedACL.fromValue(acl); } /** *

* The canned ACL to apply to the bucket. *

*

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

* * @return The canned ACL to apply to the bucket. * @see BucketCannedACL */ public String aclAsString() { return acl; } /** *

* * @return */ public AccessControlPolicy accessControlPolicy() { return accessControlPolicy; } /** *

* * @return */ public String bucket() { return bucket; } /** *

* * @return */ public String contentMD5() { return contentMD5; } /** *

* Allows grantee the read, write, read ACP, and write ACP permissions on the bucket. *

* * @return Allows grantee the read, write, read ACP, and write ACP permissions on the bucket. */ public String grantFullControl() { return grantFullControl; } /** *

* Allows grantee to list the objects in the bucket. *

* * @return Allows grantee to list the objects in the bucket. */ public String grantRead() { return grantRead; } /** *

* Allows grantee to read the bucket ACL. *

* * @return Allows grantee to read the bucket ACL. */ public 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 String grantWrite() { return grantWrite; } /** *

* Allows grantee to write the ACL for the applicable bucket. *

* * @return Allows grantee to write the ACL for the applicable bucket. */ public String grantWriteACP() { return grantWriteACP; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; 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()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof PutBucketAclRequest)) { return false; } PutBucketAclRequest other = (PutBucketAclRequest) 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()); } /** * 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 String toString() { return ToString.builder("PutBucketAclRequest").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()).build(); } public 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())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((PutBucketAclRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends S3Request.Builder, SdkPojo, CopyableBuilder { /** *

* The canned ACL to apply to the bucket. *

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

* The canned ACL to apply to the bucket. *

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

* * @param accessControlPolicy * @return Returns a reference to this object so that method calls can be chained together. */ Builder accessControlPolicy(AccessControlPolicy accessControlPolicy); /** *

* This is a convenience that creates an instance of the {@link AccessControlPolicy.Builder} avoiding the need * to create one manually via {@link AccessControlPolicy#builder()}. * * When the {@link Consumer} completes, {@link AccessControlPolicy.Builder#build()} is called immediately and * its result is passed to {@link #accessControlPolicy(AccessControlPolicy)}. * * @param accessControlPolicy * a consumer that will call methods on {@link AccessControlPolicy.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #accessControlPolicy(AccessControlPolicy) */ default Builder accessControlPolicy(Consumer accessControlPolicy) { return accessControlPolicy(AccessControlPolicy.builder().applyMutation(accessControlPolicy).build()); } /** *

* * @param bucket * @return Returns a reference to this object so that method calls can be chained together. */ Builder bucket(String bucket); /** *

* * @param contentMD5 * @return Returns a reference to this object so that method calls can be chained together. */ Builder contentMD5(String contentMD5); /** *

* Allows grantee the read, write, read ACP, and write ACP permissions on the bucket. *

* * @param grantFullControl * Allows grantee the read, write, read ACP, and write ACP permissions on the bucket. * @return Returns a reference to this object so that method calls can be chained together. */ Builder grantFullControl(String grantFullControl); /** *

* Allows grantee to list the objects in the bucket. *

* * @param grantRead * Allows grantee to list the objects in the bucket. * @return Returns a reference to this object so that method calls can be chained together. */ Builder grantRead(String grantRead); /** *

* Allows grantee to read the bucket ACL. *

* * @param grantReadACP * Allows grantee to read the bucket ACL. * @return Returns a reference to this object so that method calls can be chained together. */ Builder grantReadACP(String grantReadACP); /** *

* Allows grantee to create, overwrite, and delete any object in the bucket. *

* * @param grantWrite * Allows grantee to create, overwrite, and delete any object in the bucket. * @return Returns a reference to this object so that method calls can be chained together. */ Builder grantWrite(String grantWrite); /** *

* Allows grantee to write the ACL for the applicable bucket. *

* * @param grantWriteACP * Allows grantee to write the ACL for the applicable bucket. * @return Returns a reference to this object so that method calls can be chained together. */ Builder grantWriteACP(String grantWriteACP); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends S3Request.BuilderImpl implements Builder { private String acl; private AccessControlPolicy accessControlPolicy; private String bucket; private String contentMD5; private String grantFullControl; private String grantRead; private String grantReadACP; private String grantWrite; private String grantWriteACP; private BuilderImpl() { } private BuilderImpl(PutBucketAclRequest model) { super(model); acl(model.acl); accessControlPolicy(model.accessControlPolicy); bucket(model.bucket); contentMD5(model.contentMD5); grantFullControl(model.grantFullControl); grantRead(model.grantRead); grantReadACP(model.grantReadACP); grantWrite(model.grantWrite); grantWriteACP(model.grantWriteACP); } public final String getAclAsString() { return acl; } @Override public final Builder acl(String acl) { this.acl = acl; return this; } @Override public final Builder acl(BucketCannedACL acl) { this.acl(acl.toString()); return this; } public final void setAcl(String acl) { this.acl = acl; } public final AccessControlPolicy.Builder getAccessControlPolicy() { return accessControlPolicy != null ? accessControlPolicy.toBuilder() : null; } @Override public final Builder accessControlPolicy(AccessControlPolicy accessControlPolicy) { this.accessControlPolicy = accessControlPolicy; return this; } public final void setAccessControlPolicy(AccessControlPolicy.BuilderImpl accessControlPolicy) { this.accessControlPolicy = accessControlPolicy != null ? accessControlPolicy.build() : null; } public final String getBucket() { return bucket; } @Override public final Builder bucket(String bucket) { this.bucket = bucket; return this; } public final void setBucket(String bucket) { this.bucket = bucket; } public final String getContentMD5() { return contentMD5; } @Override public final Builder contentMD5(String contentMD5) { this.contentMD5 = contentMD5; return this; } public final void setContentMD5(String contentMD5) { this.contentMD5 = contentMD5; } public final String getGrantFullControl() { return grantFullControl; } @Override public final Builder grantFullControl(String grantFullControl) { this.grantFullControl = grantFullControl; return this; } public final void setGrantFullControl(String grantFullControl) { this.grantFullControl = grantFullControl; } public final String getGrantRead() { return grantRead; } @Override public final Builder grantRead(String grantRead) { this.grantRead = grantRead; return this; } public final void setGrantRead(String grantRead) { this.grantRead = grantRead; } public final String getGrantReadACP() { return grantReadACP; } @Override public final Builder grantReadACP(String grantReadACP) { this.grantReadACP = grantReadACP; return this; } public final void setGrantReadACP(String grantReadACP) { this.grantReadACP = grantReadACP; } public final String getGrantWrite() { return grantWrite; } @Override public final Builder grantWrite(String grantWrite) { this.grantWrite = grantWrite; return this; } public final void setGrantWrite(String grantWrite) { this.grantWrite = grantWrite; } public final String getGrantWriteACP() { return grantWriteACP; } @Override public final Builder grantWriteACP(String grantWriteACP) { this.grantWriteACP = grantWriteACP; return this; } public final void setGrantWriteACP(String grantWriteACP) { this.grantWriteACP = grantWriteACP; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public PutBucketAclRequest build() { return new PutBucketAclRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy