{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.S3.PutBucketAcl
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sets the permissions on an existing bucket using access control lists
-- (ACL). For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/S3_ACLs_UsingACLs.html Using ACLs>.
-- To set the ACL of a bucket, you must have @WRITE_ACP@ permission.
--
-- You can use one of the following two ways to set a bucket\'s
-- permissions:
--
-- -   Specify the ACL in the request body
--
-- -   Specify permissions using request headers
--
-- You cannot specify access permission using both the body and the request
-- headers.
--
-- Depending on your application needs, you may choose to set the ACL on a
-- bucket using either the request body or the headers. For example, if you
-- have an existing application that updates a bucket ACL using the request
-- body, then you can continue to use that approach.
--
-- __Access Permissions__
--
-- You can set access permissions using one of the following methods:
--
-- -   Specify a canned ACL with the @x-amz-acl@ request header. Amazon S3
--     supports a set of predefined ACLs, known as /canned ACLs/. Each
--     canned ACL has a predefined set of grantees and permissions. Specify
--     the canned ACL name as the value of @x-amz-acl@. If you use this
--     header, you cannot use other access control-specific headers in your
--     request. For more information, see
--     <https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL Canned ACL>.
--
-- -   Specify access permissions explicitly with the @x-amz-grant-read@,
--     @x-amz-grant-read-acp@, @x-amz-grant-write-acp@, and
--     @x-amz-grant-full-control@ headers. When using these headers, you
--     specify explicit access permissions and grantees (Amazon Web
--     Services accounts or Amazon S3 groups) who will receive the
--     permission. If you use these ACL-specific headers, you cannot use
--     the @x-amz-acl@ header to set a canned ACL. These parameters map to
--     the set of permissions that Amazon S3 supports in an ACL. For more
--     information, see
--     <https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html Access Control List (ACL) Overview>.
--
--     You specify each grantee as a type=value pair, where the type is one
--     of the following:
--
--     -   @id@ – if the value specified is the canonical user ID of an
--         Amazon Web Services account
--
--     -   @uri@ – if you are granting permissions to a predefined group
--
--     -   @emailAddress@ – if the value specified is the email address of
--         an Amazon Web Services account
--
--         Using email addresses to specify a grantee is only supported in
--         the following Amazon Web Services Regions:
--
--         -   US East (N. Virginia)
--
--         -   US West (N. California)
--
--         -   US West (Oregon)
--
--         -   Asia Pacific (Singapore)
--
--         -   Asia Pacific (Sydney)
--
--         -   Asia Pacific (Tokyo)
--
--         -   Europe (Ireland)
--
--         -   South America (São Paulo)
--
--         For a list of all the Amazon S3 supported Regions and endpoints,
--         see
--         <https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region Regions and Endpoints>
--         in the Amazon Web Services General Reference.
--
--     For example, the following @x-amz-grant-write@ header grants create,
--     overwrite, and delete objects permission to LogDelivery group
--     predefined by Amazon S3 and two Amazon Web Services accounts
--     identified by their email addresses.
--
--     @x-amz-grant-write: uri=\"http:\/\/acs.amazonaws.com\/groups\/s3\/LogDelivery\", id=\"111122223333\", id=\"555566667777\" @
--
-- You can use either a canned ACL or specify access permissions
-- explicitly. You cannot do both.
--
-- __Grantee Values__
--
-- You can specify the person (grantee) to whom you\'re assigning access
-- rights (using request elements) in the following ways:
--
-- -   By the person\'s ID:
--
--     @\<Grantee xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:type=\"CanonicalUser\">\<ID>\<>ID\<>\<\/ID>\<DisplayName>\<>GranteesEmail\<>\<\/DisplayName> \<\/Grantee>@
--
--     DisplayName is optional and ignored in the request
--
-- -   By URI:
--
--     @\<Grantee xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:type=\"Group\">\<URI>\<>http:\/\/acs.amazonaws.com\/groups\/global\/AuthenticatedUsers\<>\<\/URI>\<\/Grantee>@
--
-- -   By Email address:
--
--     @\<Grantee xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:type=\"AmazonCustomerByEmail\">\<EmailAddress>\<>Grantees\@email.com\<>\<\/EmailAddress>lt;\/Grantee>@
--
--     The grantee is resolved to the CanonicalUser and, in a response to a
--     GET Object acl request, appears as the CanonicalUser.
--
--     Using email addresses to specify a grantee is only supported in the
--     following Amazon Web Services Regions:
--
--     -   US East (N. Virginia)
--
--     -   US West (N. California)
--
--     -   US West (Oregon)
--
--     -   Asia Pacific (Singapore)
--
--     -   Asia Pacific (Sydney)
--
--     -   Asia Pacific (Tokyo)
--
--     -   Europe (Ireland)
--
--     -   South America (São Paulo)
--
--     For a list of all the Amazon S3 supported Regions and endpoints, see
--     <https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region Regions and Endpoints>
--     in the Amazon Web Services General Reference.
--
-- __Related Resources__
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html CreateBucket>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html DeleteBucket>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAcl.html GetObjectAcl>
module Amazonka.S3.PutBucketAcl
  ( -- * Creating a Request
    PutBucketAcl (..),
    newPutBucketAcl,

    -- * Request Lenses
    putBucketAcl_grantReadACP,
    putBucketAcl_grantWriteACP,
    putBucketAcl_grantRead,
    putBucketAcl_grantFullControl,
    putBucketAcl_contentMD5,
    putBucketAcl_accessControlPolicy,
    putBucketAcl_grantWrite,
    putBucketAcl_acl,
    putBucketAcl_expectedBucketOwner,
    putBucketAcl_bucket,

    -- * Destructuring the Response
    PutBucketAclResponse (..),
    newPutBucketAclResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.S3.Types

-- | /See:/ 'newPutBucketAcl' smart constructor.
data PutBucketAcl = PutBucketAcl'
  { -- | Allows grantee to read the bucket ACL.
    PutBucketAcl -> Maybe Text
grantReadACP :: Prelude.Maybe Prelude.Text,
    -- | Allows grantee to write the ACL for the applicable bucket.
    PutBucketAcl -> Maybe Text
grantWriteACP :: Prelude.Maybe Prelude.Text,
    -- | Allows grantee to list the objects in the bucket.
    PutBucketAcl -> Maybe Text
grantRead :: Prelude.Maybe Prelude.Text,
    -- | Allows grantee the read, write, read ACP, and write ACP permissions on
    -- the bucket.
    PutBucketAcl -> Maybe Text
grantFullControl :: Prelude.Maybe Prelude.Text,
    -- | 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
    -- <http://www.ietf.org/rfc/rfc1864.txt RFC 1864.>
    --
    -- For requests made using the Amazon Web Services Command Line Interface
    -- (CLI) or Amazon Web Services SDKs, this field is calculated
    -- automatically.
    PutBucketAcl -> Maybe Text
contentMD5 :: Prelude.Maybe Prelude.Text,
    -- | Contains the elements that set the ACL permissions for an object per
    -- grantee.
    PutBucketAcl -> Maybe AccessControlPolicy
accessControlPolicy :: Prelude.Maybe AccessControlPolicy,
    -- | Allows grantee to create new objects in the bucket.
    --
    -- For the bucket and object owners of existing objects, also allows
    -- deletions and overwrites of those objects.
    PutBucketAcl -> Maybe Text
grantWrite :: Prelude.Maybe Prelude.Text,
    -- | The canned ACL to apply to the bucket.
    PutBucketAcl -> Maybe BucketCannedACL
acl :: Prelude.Maybe BucketCannedACL,
    -- | 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.
    PutBucketAcl -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The bucket to which to apply the ACL.
    PutBucketAcl -> BucketName
bucket :: BucketName
  }
  deriving (PutBucketAcl -> PutBucketAcl -> Bool
(PutBucketAcl -> PutBucketAcl -> Bool)
-> (PutBucketAcl -> PutBucketAcl -> Bool) -> Eq PutBucketAcl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutBucketAcl -> PutBucketAcl -> Bool
$c/= :: PutBucketAcl -> PutBucketAcl -> Bool
== :: PutBucketAcl -> PutBucketAcl -> Bool
$c== :: PutBucketAcl -> PutBucketAcl -> Bool
Prelude.Eq, ReadPrec [PutBucketAcl]
ReadPrec PutBucketAcl
Int -> ReadS PutBucketAcl
ReadS [PutBucketAcl]
(Int -> ReadS PutBucketAcl)
-> ReadS [PutBucketAcl]
-> ReadPrec PutBucketAcl
-> ReadPrec [PutBucketAcl]
-> Read PutBucketAcl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutBucketAcl]
$creadListPrec :: ReadPrec [PutBucketAcl]
readPrec :: ReadPrec PutBucketAcl
$creadPrec :: ReadPrec PutBucketAcl
readList :: ReadS [PutBucketAcl]
$creadList :: ReadS [PutBucketAcl]
readsPrec :: Int -> ReadS PutBucketAcl
$creadsPrec :: Int -> ReadS PutBucketAcl
Prelude.Read, Int -> PutBucketAcl -> ShowS
[PutBucketAcl] -> ShowS
PutBucketAcl -> String
(Int -> PutBucketAcl -> ShowS)
-> (PutBucketAcl -> String)
-> ([PutBucketAcl] -> ShowS)
-> Show PutBucketAcl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutBucketAcl] -> ShowS
$cshowList :: [PutBucketAcl] -> ShowS
show :: PutBucketAcl -> String
$cshow :: PutBucketAcl -> String
showsPrec :: Int -> PutBucketAcl -> ShowS
$cshowsPrec :: Int -> PutBucketAcl -> ShowS
Prelude.Show, (forall x. PutBucketAcl -> Rep PutBucketAcl x)
-> (forall x. Rep PutBucketAcl x -> PutBucketAcl)
-> Generic PutBucketAcl
forall x. Rep PutBucketAcl x -> PutBucketAcl
forall x. PutBucketAcl -> Rep PutBucketAcl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutBucketAcl x -> PutBucketAcl
$cfrom :: forall x. PutBucketAcl -> Rep PutBucketAcl x
Prelude.Generic)

-- |
-- Create a value of 'PutBucketAcl' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'grantReadACP', 'putBucketAcl_grantReadACP' - Allows grantee to read the bucket ACL.
--
-- 'grantWriteACP', 'putBucketAcl_grantWriteACP' - Allows grantee to write the ACL for the applicable bucket.
--
-- 'grantRead', 'putBucketAcl_grantRead' - Allows grantee to list the objects in the bucket.
--
-- 'grantFullControl', 'putBucketAcl_grantFullControl' - Allows grantee the read, write, read ACP, and write ACP permissions on
-- the bucket.
--
-- 'contentMD5', 'putBucketAcl_contentMD5' - 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
-- <http://www.ietf.org/rfc/rfc1864.txt RFC 1864.>
--
-- For requests made using the Amazon Web Services Command Line Interface
-- (CLI) or Amazon Web Services SDKs, this field is calculated
-- automatically.
--
-- 'accessControlPolicy', 'putBucketAcl_accessControlPolicy' - Contains the elements that set the ACL permissions for an object per
-- grantee.
--
-- 'grantWrite', 'putBucketAcl_grantWrite' - Allows grantee to create new objects in the bucket.
--
-- For the bucket and object owners of existing objects, also allows
-- deletions and overwrites of those objects.
--
-- 'acl', 'putBucketAcl_acl' - The canned ACL to apply to the bucket.
--
-- 'expectedBucketOwner', 'putBucketAcl_expectedBucketOwner' - 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.
--
-- 'bucket', 'putBucketAcl_bucket' - The bucket to which to apply the ACL.
newPutBucketAcl ::
  -- | 'bucket'
  BucketName ->
  PutBucketAcl
newPutBucketAcl :: BucketName -> PutBucketAcl
newPutBucketAcl BucketName
pBucket_ =
  PutBucketAcl' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe AccessControlPolicy
-> Maybe Text
-> Maybe BucketCannedACL
-> Maybe Text
-> BucketName
-> PutBucketAcl
PutBucketAcl'
    { $sel:grantReadACP:PutBucketAcl' :: Maybe Text
grantReadACP = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:grantWriteACP:PutBucketAcl' :: Maybe Text
grantWriteACP = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:grantRead:PutBucketAcl' :: Maybe Text
grantRead = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:grantFullControl:PutBucketAcl' :: Maybe Text
grantFullControl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contentMD5:PutBucketAcl' :: Maybe Text
contentMD5 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accessControlPolicy:PutBucketAcl' :: Maybe AccessControlPolicy
accessControlPolicy = Maybe AccessControlPolicy
forall a. Maybe a
Prelude.Nothing,
      $sel:grantWrite:PutBucketAcl' :: Maybe Text
grantWrite = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:acl:PutBucketAcl' :: Maybe BucketCannedACL
acl = Maybe BucketCannedACL
forall a. Maybe a
Prelude.Nothing,
      $sel:expectedBucketOwner:PutBucketAcl' :: Maybe Text
expectedBucketOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:PutBucketAcl' :: BucketName
bucket = BucketName
pBucket_
    }

-- | Allows grantee to read the bucket ACL.
putBucketAcl_grantReadACP :: Lens.Lens' PutBucketAcl (Prelude.Maybe Prelude.Text)
putBucketAcl_grantReadACP :: (Maybe Text -> f (Maybe Text)) -> PutBucketAcl -> f PutBucketAcl
putBucketAcl_grantReadACP = (PutBucketAcl -> Maybe Text)
-> (PutBucketAcl -> Maybe Text -> PutBucketAcl)
-> Lens PutBucketAcl PutBucketAcl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {Maybe Text
grantReadACP :: Maybe Text
$sel:grantReadACP:PutBucketAcl' :: PutBucketAcl -> Maybe Text
grantReadACP} -> Maybe Text
grantReadACP) (\s :: PutBucketAcl
s@PutBucketAcl' {} Maybe Text
a -> PutBucketAcl
s {$sel:grantReadACP:PutBucketAcl' :: Maybe Text
grantReadACP = Maybe Text
a} :: PutBucketAcl)

-- | Allows grantee to write the ACL for the applicable bucket.
putBucketAcl_grantWriteACP :: Lens.Lens' PutBucketAcl (Prelude.Maybe Prelude.Text)
putBucketAcl_grantWriteACP :: (Maybe Text -> f (Maybe Text)) -> PutBucketAcl -> f PutBucketAcl
putBucketAcl_grantWriteACP = (PutBucketAcl -> Maybe Text)
-> (PutBucketAcl -> Maybe Text -> PutBucketAcl)
-> Lens PutBucketAcl PutBucketAcl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {Maybe Text
grantWriteACP :: Maybe Text
$sel:grantWriteACP:PutBucketAcl' :: PutBucketAcl -> Maybe Text
grantWriteACP} -> Maybe Text
grantWriteACP) (\s :: PutBucketAcl
s@PutBucketAcl' {} Maybe Text
a -> PutBucketAcl
s {$sel:grantWriteACP:PutBucketAcl' :: Maybe Text
grantWriteACP = Maybe Text
a} :: PutBucketAcl)

-- | Allows grantee to list the objects in the bucket.
putBucketAcl_grantRead :: Lens.Lens' PutBucketAcl (Prelude.Maybe Prelude.Text)
putBucketAcl_grantRead :: (Maybe Text -> f (Maybe Text)) -> PutBucketAcl -> f PutBucketAcl
putBucketAcl_grantRead = (PutBucketAcl -> Maybe Text)
-> (PutBucketAcl -> Maybe Text -> PutBucketAcl)
-> Lens PutBucketAcl PutBucketAcl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {Maybe Text
grantRead :: Maybe Text
$sel:grantRead:PutBucketAcl' :: PutBucketAcl -> Maybe Text
grantRead} -> Maybe Text
grantRead) (\s :: PutBucketAcl
s@PutBucketAcl' {} Maybe Text
a -> PutBucketAcl
s {$sel:grantRead:PutBucketAcl' :: Maybe Text
grantRead = Maybe Text
a} :: PutBucketAcl)

-- | Allows grantee the read, write, read ACP, and write ACP permissions on
-- the bucket.
putBucketAcl_grantFullControl :: Lens.Lens' PutBucketAcl (Prelude.Maybe Prelude.Text)
putBucketAcl_grantFullControl :: (Maybe Text -> f (Maybe Text)) -> PutBucketAcl -> f PutBucketAcl
putBucketAcl_grantFullControl = (PutBucketAcl -> Maybe Text)
-> (PutBucketAcl -> Maybe Text -> PutBucketAcl)
-> Lens PutBucketAcl PutBucketAcl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {Maybe Text
grantFullControl :: Maybe Text
$sel:grantFullControl:PutBucketAcl' :: PutBucketAcl -> Maybe Text
grantFullControl} -> Maybe Text
grantFullControl) (\s :: PutBucketAcl
s@PutBucketAcl' {} Maybe Text
a -> PutBucketAcl
s {$sel:grantFullControl:PutBucketAcl' :: Maybe Text
grantFullControl = Maybe Text
a} :: PutBucketAcl)

-- | 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
-- <http://www.ietf.org/rfc/rfc1864.txt RFC 1864.>
--
-- For requests made using the Amazon Web Services Command Line Interface
-- (CLI) or Amazon Web Services SDKs, this field is calculated
-- automatically.
putBucketAcl_contentMD5 :: Lens.Lens' PutBucketAcl (Prelude.Maybe Prelude.Text)
putBucketAcl_contentMD5 :: (Maybe Text -> f (Maybe Text)) -> PutBucketAcl -> f PutBucketAcl
putBucketAcl_contentMD5 = (PutBucketAcl -> Maybe Text)
-> (PutBucketAcl -> Maybe Text -> PutBucketAcl)
-> Lens PutBucketAcl PutBucketAcl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {Maybe Text
contentMD5 :: Maybe Text
$sel:contentMD5:PutBucketAcl' :: PutBucketAcl -> Maybe Text
contentMD5} -> Maybe Text
contentMD5) (\s :: PutBucketAcl
s@PutBucketAcl' {} Maybe Text
a -> PutBucketAcl
s {$sel:contentMD5:PutBucketAcl' :: Maybe Text
contentMD5 = Maybe Text
a} :: PutBucketAcl)

-- | Contains the elements that set the ACL permissions for an object per
-- grantee.
putBucketAcl_accessControlPolicy :: Lens.Lens' PutBucketAcl (Prelude.Maybe AccessControlPolicy)
putBucketAcl_accessControlPolicy :: (Maybe AccessControlPolicy -> f (Maybe AccessControlPolicy))
-> PutBucketAcl -> f PutBucketAcl
putBucketAcl_accessControlPolicy = (PutBucketAcl -> Maybe AccessControlPolicy)
-> (PutBucketAcl -> Maybe AccessControlPolicy -> PutBucketAcl)
-> Lens
     PutBucketAcl
     PutBucketAcl
     (Maybe AccessControlPolicy)
     (Maybe AccessControlPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {Maybe AccessControlPolicy
accessControlPolicy :: Maybe AccessControlPolicy
$sel:accessControlPolicy:PutBucketAcl' :: PutBucketAcl -> Maybe AccessControlPolicy
accessControlPolicy} -> Maybe AccessControlPolicy
accessControlPolicy) (\s :: PutBucketAcl
s@PutBucketAcl' {} Maybe AccessControlPolicy
a -> PutBucketAcl
s {$sel:accessControlPolicy:PutBucketAcl' :: Maybe AccessControlPolicy
accessControlPolicy = Maybe AccessControlPolicy
a} :: PutBucketAcl)

-- | Allows grantee to create new objects in the bucket.
--
-- For the bucket and object owners of existing objects, also allows
-- deletions and overwrites of those objects.
putBucketAcl_grantWrite :: Lens.Lens' PutBucketAcl (Prelude.Maybe Prelude.Text)
putBucketAcl_grantWrite :: (Maybe Text -> f (Maybe Text)) -> PutBucketAcl -> f PutBucketAcl
putBucketAcl_grantWrite = (PutBucketAcl -> Maybe Text)
-> (PutBucketAcl -> Maybe Text -> PutBucketAcl)
-> Lens PutBucketAcl PutBucketAcl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {Maybe Text
grantWrite :: Maybe Text
$sel:grantWrite:PutBucketAcl' :: PutBucketAcl -> Maybe Text
grantWrite} -> Maybe Text
grantWrite) (\s :: PutBucketAcl
s@PutBucketAcl' {} Maybe Text
a -> PutBucketAcl
s {$sel:grantWrite:PutBucketAcl' :: Maybe Text
grantWrite = Maybe Text
a} :: PutBucketAcl)

-- | The canned ACL to apply to the bucket.
putBucketAcl_acl :: Lens.Lens' PutBucketAcl (Prelude.Maybe BucketCannedACL)
putBucketAcl_acl :: (Maybe BucketCannedACL -> f (Maybe BucketCannedACL))
-> PutBucketAcl -> f PutBucketAcl
putBucketAcl_acl = (PutBucketAcl -> Maybe BucketCannedACL)
-> (PutBucketAcl -> Maybe BucketCannedACL -> PutBucketAcl)
-> Lens
     PutBucketAcl
     PutBucketAcl
     (Maybe BucketCannedACL)
     (Maybe BucketCannedACL)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {Maybe BucketCannedACL
acl :: Maybe BucketCannedACL
$sel:acl:PutBucketAcl' :: PutBucketAcl -> Maybe BucketCannedACL
acl} -> Maybe BucketCannedACL
acl) (\s :: PutBucketAcl
s@PutBucketAcl' {} Maybe BucketCannedACL
a -> PutBucketAcl
s {$sel:acl:PutBucketAcl' :: Maybe BucketCannedACL
acl = Maybe BucketCannedACL
a} :: PutBucketAcl)

-- | 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.
putBucketAcl_expectedBucketOwner :: Lens.Lens' PutBucketAcl (Prelude.Maybe Prelude.Text)
putBucketAcl_expectedBucketOwner :: (Maybe Text -> f (Maybe Text)) -> PutBucketAcl -> f PutBucketAcl
putBucketAcl_expectedBucketOwner = (PutBucketAcl -> Maybe Text)
-> (PutBucketAcl -> Maybe Text -> PutBucketAcl)
-> Lens PutBucketAcl PutBucketAcl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:PutBucketAcl' :: PutBucketAcl -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: PutBucketAcl
s@PutBucketAcl' {} Maybe Text
a -> PutBucketAcl
s {$sel:expectedBucketOwner:PutBucketAcl' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: PutBucketAcl)

-- | The bucket to which to apply the ACL.
putBucketAcl_bucket :: Lens.Lens' PutBucketAcl BucketName
putBucketAcl_bucket :: (BucketName -> f BucketName) -> PutBucketAcl -> f PutBucketAcl
putBucketAcl_bucket = (PutBucketAcl -> BucketName)
-> (PutBucketAcl -> BucketName -> PutBucketAcl)
-> Lens PutBucketAcl PutBucketAcl BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBucketAcl' {BucketName
bucket :: BucketName
$sel:bucket:PutBucketAcl' :: PutBucketAcl -> BucketName
bucket} -> BucketName
bucket) (\s :: PutBucketAcl
s@PutBucketAcl' {} BucketName
a -> PutBucketAcl
s {$sel:bucket:PutBucketAcl' :: BucketName
bucket = BucketName
a} :: PutBucketAcl)

instance Core.AWSRequest PutBucketAcl where
  type AWSResponse PutBucketAcl = PutBucketAclResponse
  request :: PutBucketAcl -> Request PutBucketAcl
request =
    Request PutBucketAcl -> Request PutBucketAcl
forall a. Request a -> Request a
Request.s3vhost
      (Request PutBucketAcl -> Request PutBucketAcl)
-> (PutBucketAcl -> Request PutBucketAcl)
-> PutBucketAcl
-> Request PutBucketAcl
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> PutBucketAcl -> Request PutBucketAcl
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.putXML Service
defaultService
  response :: Logger
-> Service
-> Proxy PutBucketAcl
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutBucketAcl)))
response = AWSResponse PutBucketAcl
-> Logger
-> Service
-> Proxy PutBucketAcl
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutBucketAcl)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse PutBucketAcl
PutBucketAclResponse
PutBucketAclResponse'

instance Prelude.Hashable PutBucketAcl

instance Prelude.NFData PutBucketAcl

instance Core.ToElement PutBucketAcl where
  toElement :: PutBucketAcl -> Element
toElement PutBucketAcl' {Maybe Text
Maybe BucketCannedACL
Maybe AccessControlPolicy
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
acl :: Maybe BucketCannedACL
grantWrite :: Maybe Text
accessControlPolicy :: Maybe AccessControlPolicy
contentMD5 :: Maybe Text
grantFullControl :: Maybe Text
grantRead :: Maybe Text
grantWriteACP :: Maybe Text
grantReadACP :: Maybe Text
$sel:bucket:PutBucketAcl' :: PutBucketAcl -> BucketName
$sel:expectedBucketOwner:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:acl:PutBucketAcl' :: PutBucketAcl -> Maybe BucketCannedACL
$sel:grantWrite:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:accessControlPolicy:PutBucketAcl' :: PutBucketAcl -> Maybe AccessControlPolicy
$sel:contentMD5:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantFullControl:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantRead:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantWriteACP:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantReadACP:PutBucketAcl' :: PutBucketAcl -> Maybe Text
..} =
    Name -> Maybe AccessControlPolicy -> Element
forall a. ToXML a => Name -> a -> Element
Core.mkElement
      Name
"{http://s3.amazonaws.com/doc/2006-03-01/}AccessControlPolicy"
      Maybe AccessControlPolicy
accessControlPolicy

instance Core.ToHeaders PutBucketAcl where
  toHeaders :: PutBucketAcl -> [Header]
toHeaders PutBucketAcl' {Maybe Text
Maybe BucketCannedACL
Maybe AccessControlPolicy
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
acl :: Maybe BucketCannedACL
grantWrite :: Maybe Text
accessControlPolicy :: Maybe AccessControlPolicy
contentMD5 :: Maybe Text
grantFullControl :: Maybe Text
grantRead :: Maybe Text
grantWriteACP :: Maybe Text
grantReadACP :: Maybe Text
$sel:bucket:PutBucketAcl' :: PutBucketAcl -> BucketName
$sel:expectedBucketOwner:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:acl:PutBucketAcl' :: PutBucketAcl -> Maybe BucketCannedACL
$sel:grantWrite:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:accessControlPolicy:PutBucketAcl' :: PutBucketAcl -> Maybe AccessControlPolicy
$sel:contentMD5:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantFullControl:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantRead:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantWriteACP:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantReadACP:PutBucketAcl' :: PutBucketAcl -> Maybe Text
..} =
    [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-grant-read-acp" HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
grantReadACP,
        HeaderName
"x-amz-grant-write-acp" HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
grantWriteACP,
        HeaderName
"x-amz-grant-read" HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
grantRead,
        HeaderName
"x-amz-grant-full-control" HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
grantFullControl,
        HeaderName
"Content-MD5" HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
contentMD5,
        HeaderName
"x-amz-grant-write" HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
grantWrite,
        HeaderName
"x-amz-acl" HeaderName -> Maybe BucketCannedACL -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe BucketCannedACL
acl,
        HeaderName
"x-amz-expected-bucket-owner"
          HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
expectedBucketOwner
      ]

instance Core.ToPath PutBucketAcl where
  toPath :: PutBucketAcl -> ByteString
toPath PutBucketAcl' {Maybe Text
Maybe BucketCannedACL
Maybe AccessControlPolicy
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
acl :: Maybe BucketCannedACL
grantWrite :: Maybe Text
accessControlPolicy :: Maybe AccessControlPolicy
contentMD5 :: Maybe Text
grantFullControl :: Maybe Text
grantRead :: Maybe Text
grantWriteACP :: Maybe Text
grantReadACP :: Maybe Text
$sel:bucket:PutBucketAcl' :: PutBucketAcl -> BucketName
$sel:expectedBucketOwner:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:acl:PutBucketAcl' :: PutBucketAcl -> Maybe BucketCannedACL
$sel:grantWrite:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:accessControlPolicy:PutBucketAcl' :: PutBucketAcl -> Maybe AccessControlPolicy
$sel:contentMD5:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantFullControl:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantRead:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantWriteACP:PutBucketAcl' :: PutBucketAcl -> Maybe Text
$sel:grantReadACP:PutBucketAcl' :: PutBucketAcl -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/", BucketName -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS BucketName
bucket]

instance Core.ToQuery PutBucketAcl where
  toQuery :: PutBucketAcl -> QueryString
toQuery = QueryString -> PutBucketAcl -> QueryString
forall a b. a -> b -> a
Prelude.const ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"acl"])

-- | /See:/ 'newPutBucketAclResponse' smart constructor.
data PutBucketAclResponse = PutBucketAclResponse'
  {
  }
  deriving (PutBucketAclResponse -> PutBucketAclResponse -> Bool
(PutBucketAclResponse -> PutBucketAclResponse -> Bool)
-> (PutBucketAclResponse -> PutBucketAclResponse -> Bool)
-> Eq PutBucketAclResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutBucketAclResponse -> PutBucketAclResponse -> Bool
$c/= :: PutBucketAclResponse -> PutBucketAclResponse -> Bool
== :: PutBucketAclResponse -> PutBucketAclResponse -> Bool
$c== :: PutBucketAclResponse -> PutBucketAclResponse -> Bool
Prelude.Eq, ReadPrec [PutBucketAclResponse]
ReadPrec PutBucketAclResponse
Int -> ReadS PutBucketAclResponse
ReadS [PutBucketAclResponse]
(Int -> ReadS PutBucketAclResponse)
-> ReadS [PutBucketAclResponse]
-> ReadPrec PutBucketAclResponse
-> ReadPrec [PutBucketAclResponse]
-> Read PutBucketAclResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutBucketAclResponse]
$creadListPrec :: ReadPrec [PutBucketAclResponse]
readPrec :: ReadPrec PutBucketAclResponse
$creadPrec :: ReadPrec PutBucketAclResponse
readList :: ReadS [PutBucketAclResponse]
$creadList :: ReadS [PutBucketAclResponse]
readsPrec :: Int -> ReadS PutBucketAclResponse
$creadsPrec :: Int -> ReadS PutBucketAclResponse
Prelude.Read, Int -> PutBucketAclResponse -> ShowS
[PutBucketAclResponse] -> ShowS
PutBucketAclResponse -> String
(Int -> PutBucketAclResponse -> ShowS)
-> (PutBucketAclResponse -> String)
-> ([PutBucketAclResponse] -> ShowS)
-> Show PutBucketAclResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutBucketAclResponse] -> ShowS
$cshowList :: [PutBucketAclResponse] -> ShowS
show :: PutBucketAclResponse -> String
$cshow :: PutBucketAclResponse -> String
showsPrec :: Int -> PutBucketAclResponse -> ShowS
$cshowsPrec :: Int -> PutBucketAclResponse -> ShowS
Prelude.Show, (forall x. PutBucketAclResponse -> Rep PutBucketAclResponse x)
-> (forall x. Rep PutBucketAclResponse x -> PutBucketAclResponse)
-> Generic PutBucketAclResponse
forall x. Rep PutBucketAclResponse x -> PutBucketAclResponse
forall x. PutBucketAclResponse -> Rep PutBucketAclResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutBucketAclResponse x -> PutBucketAclResponse
$cfrom :: forall x. PutBucketAclResponse -> Rep PutBucketAclResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutBucketAclResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
newPutBucketAclResponse ::
  PutBucketAclResponse
newPutBucketAclResponse :: PutBucketAclResponse
newPutBucketAclResponse = PutBucketAclResponse
PutBucketAclResponse'

instance Prelude.NFData PutBucketAclResponse