{-# 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.CreateBucket
-- 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)
--
-- Creates a new S3 bucket. To create a bucket, you must register with
-- Amazon S3 and have a valid Amazon Web Services Access Key ID to
-- authenticate requests. Anonymous requests are never allowed to create
-- buckets. By creating the bucket, you become the bucket owner.
--
-- Not every string is an acceptable bucket name. For information about
-- bucket naming restrictions, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html Bucket naming rules>.
--
-- If you want to create an Amazon S3 on Outposts bucket, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_CreateBucket.html Create Bucket>.
--
-- By default, the bucket is created in the US East (N. Virginia) Region.
-- You can optionally specify a Region in the request body. You might
-- choose a Region to optimize latency, minimize costs, or address
-- regulatory requirements. For example, if you reside in Europe, you will
-- probably find it advantageous to create buckets in the Europe (Ireland)
-- Region. For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro Accessing a bucket>.
--
-- If you send your create bucket request to the @s3.amazonaws.com@
-- endpoint, the request goes to the us-east-1 Region. Accordingly, the
-- signature calculations in Signature Version 4 must use us-east-1 as the
-- Region, even if the location constraint in the request specifies another
-- Region where the bucket is to be created. If you create a bucket in a
-- Region other than US East (N. Virginia), your application must be able
-- to handle 307 redirect. For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html Virtual hosting of buckets>.
--
-- When creating a bucket using this operation, you can optionally specify
-- the accounts or groups that should be granted specific permissions on
-- the bucket. There are two ways to grant the appropriate permissions
-- using the request headers.
--
-- -   Specify a canned ACL using 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. For
--     more information, see
--     <https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL Canned ACL>.
--
-- -   Specify access permissions explicitly using the @x-amz-grant-read@,
--     @x-amz-grant-write@, @x-amz-grant-read-acp@,
--     @x-amz-grant-write-acp@, and @x-amz-grant-full-control@ headers.
--     These headers map to the set of permissions 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-read@ header grants the
--     Amazon Web Services accounts identified by account IDs permissions
--     to read object data and its metadata:
--
--     @x-amz-grant-read: id=\"11112222333\", id=\"444455556666\" @
--
-- You can use either a canned ACL or specify access permissions
-- explicitly. You cannot do both.
--
-- __Permissions__
--
-- If your @CreateBucket@ request specifies ACL permissions and the ACL is
-- public-read, public-read-write, authenticated-read, or if you specify
-- access permissions explicitly through any other ACL, both
-- @s3:CreateBucket@ and @s3:PutBucketAcl@ permissions are needed. If the
-- ACL the @CreateBucket@ request is private, only @s3:CreateBucket@
-- permission is needed.
--
-- If @ObjectLockEnabledForBucket@ is set to true in your @CreateBucket@
-- request, @s3:PutBucketObjectLockConfiguration@ and
-- @s3:PutBucketVersioning@ permissions are required.
--
-- The following operations are related to @CreateBucket@:
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html PutObject>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html DeleteBucket>
module Amazonka.S3.CreateBucket
  ( -- * Creating a Request
    CreateBucket (..),
    newCreateBucket,

    -- * Request Lenses
    createBucket_grantReadACP,
    createBucket_objectLockEnabledForBucket,
    createBucket_grantWriteACP,
    createBucket_grantRead,
    createBucket_grantFullControl,
    createBucket_createBucketConfiguration,
    createBucket_grantWrite,
    createBucket_acl,
    createBucket_bucket,

    -- * Destructuring the Response
    CreateBucketResponse (..),
    newCreateBucketResponse,

    -- * Response Lenses
    createBucketResponse_location,
    createBucketResponse_httpStatus,
  )
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:/ 'newCreateBucket' smart constructor.
data CreateBucket = CreateBucket'
  { -- | Allows grantee to read the bucket ACL.
    CreateBucket -> Maybe Text
grantReadACP :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether you want S3 Object Lock to be enabled for the new
    -- bucket.
    CreateBucket -> Maybe Bool
objectLockEnabledForBucket :: Prelude.Maybe Prelude.Bool,
    -- | Allows grantee to write the ACL for the applicable bucket.
    CreateBucket -> Maybe Text
grantWriteACP :: Prelude.Maybe Prelude.Text,
    -- | Allows grantee to list the objects in the bucket.
    CreateBucket -> Maybe Text
grantRead :: Prelude.Maybe Prelude.Text,
    -- | Allows grantee the read, write, read ACP, and write ACP permissions on
    -- the bucket.
    CreateBucket -> Maybe Text
grantFullControl :: Prelude.Maybe Prelude.Text,
    -- | The configuration information for the bucket.
    CreateBucket -> Maybe CreateBucketConfiguration
createBucketConfiguration :: Prelude.Maybe CreateBucketConfiguration,
    -- | 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.
    CreateBucket -> Maybe Text
grantWrite :: Prelude.Maybe Prelude.Text,
    -- | The canned ACL to apply to the bucket.
    CreateBucket -> Maybe BucketCannedACL
acl :: Prelude.Maybe BucketCannedACL,
    -- | The name of the bucket to create.
    CreateBucket -> BucketName
bucket :: BucketName
  }
  deriving (CreateBucket -> CreateBucket -> Bool
(CreateBucket -> CreateBucket -> Bool)
-> (CreateBucket -> CreateBucket -> Bool) -> Eq CreateBucket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBucket -> CreateBucket -> Bool
$c/= :: CreateBucket -> CreateBucket -> Bool
== :: CreateBucket -> CreateBucket -> Bool
$c== :: CreateBucket -> CreateBucket -> Bool
Prelude.Eq, ReadPrec [CreateBucket]
ReadPrec CreateBucket
Int -> ReadS CreateBucket
ReadS [CreateBucket]
(Int -> ReadS CreateBucket)
-> ReadS [CreateBucket]
-> ReadPrec CreateBucket
-> ReadPrec [CreateBucket]
-> Read CreateBucket
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBucket]
$creadListPrec :: ReadPrec [CreateBucket]
readPrec :: ReadPrec CreateBucket
$creadPrec :: ReadPrec CreateBucket
readList :: ReadS [CreateBucket]
$creadList :: ReadS [CreateBucket]
readsPrec :: Int -> ReadS CreateBucket
$creadsPrec :: Int -> ReadS CreateBucket
Prelude.Read, Int -> CreateBucket -> ShowS
[CreateBucket] -> ShowS
CreateBucket -> String
(Int -> CreateBucket -> ShowS)
-> (CreateBucket -> String)
-> ([CreateBucket] -> ShowS)
-> Show CreateBucket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBucket] -> ShowS
$cshowList :: [CreateBucket] -> ShowS
show :: CreateBucket -> String
$cshow :: CreateBucket -> String
showsPrec :: Int -> CreateBucket -> ShowS
$cshowsPrec :: Int -> CreateBucket -> ShowS
Prelude.Show, (forall x. CreateBucket -> Rep CreateBucket x)
-> (forall x. Rep CreateBucket x -> CreateBucket)
-> Generic CreateBucket
forall x. Rep CreateBucket x -> CreateBucket
forall x. CreateBucket -> Rep CreateBucket x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBucket x -> CreateBucket
$cfrom :: forall x. CreateBucket -> Rep CreateBucket x
Prelude.Generic)

-- |
-- Create a value of 'CreateBucket' 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', 'createBucket_grantReadACP' - Allows grantee to read the bucket ACL.
--
-- 'objectLockEnabledForBucket', 'createBucket_objectLockEnabledForBucket' - Specifies whether you want S3 Object Lock to be enabled for the new
-- bucket.
--
-- 'grantWriteACP', 'createBucket_grantWriteACP' - Allows grantee to write the ACL for the applicable bucket.
--
-- 'grantRead', 'createBucket_grantRead' - Allows grantee to list the objects in the bucket.
--
-- 'grantFullControl', 'createBucket_grantFullControl' - Allows grantee the read, write, read ACP, and write ACP permissions on
-- the bucket.
--
-- 'createBucketConfiguration', 'createBucket_createBucketConfiguration' - The configuration information for the bucket.
--
-- 'grantWrite', 'createBucket_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', 'createBucket_acl' - The canned ACL to apply to the bucket.
--
-- 'bucket', 'createBucket_bucket' - The name of the bucket to create.
newCreateBucket ::
  -- | 'bucket'
  BucketName ->
  CreateBucket
newCreateBucket :: BucketName -> CreateBucket
newCreateBucket BucketName
pBucket_ =
  CreateBucket' :: Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CreateBucketConfiguration
-> Maybe Text
-> Maybe BucketCannedACL
-> BucketName
-> CreateBucket
CreateBucket'
    { $sel:grantReadACP:CreateBucket' :: Maybe Text
grantReadACP = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:objectLockEnabledForBucket:CreateBucket' :: Maybe Bool
objectLockEnabledForBucket = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:grantWriteACP:CreateBucket' :: Maybe Text
grantWriteACP = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:grantRead:CreateBucket' :: Maybe Text
grantRead = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:grantFullControl:CreateBucket' :: Maybe Text
grantFullControl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createBucketConfiguration:CreateBucket' :: Maybe CreateBucketConfiguration
createBucketConfiguration = Maybe CreateBucketConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:grantWrite:CreateBucket' :: Maybe Text
grantWrite = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:acl:CreateBucket' :: Maybe BucketCannedACL
acl = Maybe BucketCannedACL
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:CreateBucket' :: BucketName
bucket = BucketName
pBucket_
    }

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

-- | Specifies whether you want S3 Object Lock to be enabled for the new
-- bucket.
createBucket_objectLockEnabledForBucket :: Lens.Lens' CreateBucket (Prelude.Maybe Prelude.Bool)
createBucket_objectLockEnabledForBucket :: (Maybe Bool -> f (Maybe Bool)) -> CreateBucket -> f CreateBucket
createBucket_objectLockEnabledForBucket = (CreateBucket -> Maybe Bool)
-> (CreateBucket -> Maybe Bool -> CreateBucket)
-> Lens CreateBucket CreateBucket (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucket' {Maybe Bool
objectLockEnabledForBucket :: Maybe Bool
$sel:objectLockEnabledForBucket:CreateBucket' :: CreateBucket -> Maybe Bool
objectLockEnabledForBucket} -> Maybe Bool
objectLockEnabledForBucket) (\s :: CreateBucket
s@CreateBucket' {} Maybe Bool
a -> CreateBucket
s {$sel:objectLockEnabledForBucket:CreateBucket' :: Maybe Bool
objectLockEnabledForBucket = Maybe Bool
a} :: CreateBucket)

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

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

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

-- | The configuration information for the bucket.
createBucket_createBucketConfiguration :: Lens.Lens' CreateBucket (Prelude.Maybe CreateBucketConfiguration)
createBucket_createBucketConfiguration :: (Maybe CreateBucketConfiguration
 -> f (Maybe CreateBucketConfiguration))
-> CreateBucket -> f CreateBucket
createBucket_createBucketConfiguration = (CreateBucket -> Maybe CreateBucketConfiguration)
-> (CreateBucket
    -> Maybe CreateBucketConfiguration -> CreateBucket)
-> Lens
     CreateBucket
     CreateBucket
     (Maybe CreateBucketConfiguration)
     (Maybe CreateBucketConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucket' {Maybe CreateBucketConfiguration
createBucketConfiguration :: Maybe CreateBucketConfiguration
$sel:createBucketConfiguration:CreateBucket' :: CreateBucket -> Maybe CreateBucketConfiguration
createBucketConfiguration} -> Maybe CreateBucketConfiguration
createBucketConfiguration) (\s :: CreateBucket
s@CreateBucket' {} Maybe CreateBucketConfiguration
a -> CreateBucket
s {$sel:createBucketConfiguration:CreateBucket' :: Maybe CreateBucketConfiguration
createBucketConfiguration = Maybe CreateBucketConfiguration
a} :: CreateBucket)

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

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

-- | The name of the bucket to create.
createBucket_bucket :: Lens.Lens' CreateBucket BucketName
createBucket_bucket :: (BucketName -> f BucketName) -> CreateBucket -> f CreateBucket
createBucket_bucket = (CreateBucket -> BucketName)
-> (CreateBucket -> BucketName -> CreateBucket)
-> Lens CreateBucket CreateBucket BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucket' {BucketName
bucket :: BucketName
$sel:bucket:CreateBucket' :: CreateBucket -> BucketName
bucket} -> BucketName
bucket) (\s :: CreateBucket
s@CreateBucket' {} BucketName
a -> CreateBucket
s {$sel:bucket:CreateBucket' :: BucketName
bucket = BucketName
a} :: CreateBucket)

instance Core.AWSRequest CreateBucket where
  type AWSResponse CreateBucket = CreateBucketResponse
  request :: CreateBucket -> Request CreateBucket
request =
    Request CreateBucket -> Request CreateBucket
forall a. Request a -> Request a
Request.s3vhost
      (Request CreateBucket -> Request CreateBucket)
-> (CreateBucket -> Request CreateBucket)
-> CreateBucket
-> Request CreateBucket
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> CreateBucket -> Request CreateBucket
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.putXML Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateBucket
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBucket)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CreateBucket))
-> Logger
-> Service
-> Proxy CreateBucket
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBucket)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Maybe Text -> Int -> CreateBucketResponse
CreateBucketResponse'
            (Maybe Text -> Int -> CreateBucketResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateBucketResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Location")
            Either String (Int -> CreateBucketResponse)
-> Either String Int -> Either String CreateBucketResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateBucket

instance Prelude.NFData CreateBucket

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

instance Core.ToHeaders CreateBucket where
  toHeaders :: CreateBucket -> ResponseHeaders
toHeaders CreateBucket' {Maybe Bool
Maybe Text
Maybe BucketCannedACL
Maybe CreateBucketConfiguration
BucketName
bucket :: BucketName
acl :: Maybe BucketCannedACL
grantWrite :: Maybe Text
createBucketConfiguration :: Maybe CreateBucketConfiguration
grantFullControl :: Maybe Text
grantRead :: Maybe Text
grantWriteACP :: Maybe Text
objectLockEnabledForBucket :: Maybe Bool
grantReadACP :: Maybe Text
$sel:bucket:CreateBucket' :: CreateBucket -> BucketName
$sel:acl:CreateBucket' :: CreateBucket -> Maybe BucketCannedACL
$sel:grantWrite:CreateBucket' :: CreateBucket -> Maybe Text
$sel:createBucketConfiguration:CreateBucket' :: CreateBucket -> Maybe CreateBucketConfiguration
$sel:grantFullControl:CreateBucket' :: CreateBucket -> Maybe Text
$sel:grantRead:CreateBucket' :: CreateBucket -> Maybe Text
$sel:grantWriteACP:CreateBucket' :: CreateBucket -> Maybe Text
$sel:objectLockEnabledForBucket:CreateBucket' :: CreateBucket -> Maybe Bool
$sel:grantReadACP:CreateBucket' :: CreateBucket -> Maybe Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-grant-read-acp" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
grantReadACP,
        HeaderName
"x-amz-bucket-object-lock-enabled"
          HeaderName -> Maybe Bool -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Bool
objectLockEnabledForBucket,
        HeaderName
"x-amz-grant-write-acp" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
grantWriteACP,
        HeaderName
"x-amz-grant-read" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
grantRead,
        HeaderName
"x-amz-grant-full-control" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
grantFullControl,
        HeaderName
"x-amz-grant-write" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
grantWrite,
        HeaderName
"x-amz-acl" HeaderName -> Maybe BucketCannedACL -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe BucketCannedACL
acl
      ]

instance Core.ToPath CreateBucket where
  toPath :: CreateBucket -> ByteString
toPath CreateBucket' {Maybe Bool
Maybe Text
Maybe BucketCannedACL
Maybe CreateBucketConfiguration
BucketName
bucket :: BucketName
acl :: Maybe BucketCannedACL
grantWrite :: Maybe Text
createBucketConfiguration :: Maybe CreateBucketConfiguration
grantFullControl :: Maybe Text
grantRead :: Maybe Text
grantWriteACP :: Maybe Text
objectLockEnabledForBucket :: Maybe Bool
grantReadACP :: Maybe Text
$sel:bucket:CreateBucket' :: CreateBucket -> BucketName
$sel:acl:CreateBucket' :: CreateBucket -> Maybe BucketCannedACL
$sel:grantWrite:CreateBucket' :: CreateBucket -> Maybe Text
$sel:createBucketConfiguration:CreateBucket' :: CreateBucket -> Maybe CreateBucketConfiguration
$sel:grantFullControl:CreateBucket' :: CreateBucket -> Maybe Text
$sel:grantRead:CreateBucket' :: CreateBucket -> Maybe Text
$sel:grantWriteACP:CreateBucket' :: CreateBucket -> Maybe Text
$sel:objectLockEnabledForBucket:CreateBucket' :: CreateBucket -> Maybe Bool
$sel:grantReadACP:CreateBucket' :: CreateBucket -> 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 CreateBucket where
  toQuery :: CreateBucket -> QueryString
toQuery = QueryString -> CreateBucket -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateBucketResponse' smart constructor.
data CreateBucketResponse = CreateBucketResponse'
  { -- | Specifies the Region where the bucket will be created. If you are
    -- creating a bucket on the US East (N. Virginia) Region (us-east-1), you
    -- do not need to specify the location.
    CreateBucketResponse -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateBucketResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateBucketResponse -> CreateBucketResponse -> Bool
(CreateBucketResponse -> CreateBucketResponse -> Bool)
-> (CreateBucketResponse -> CreateBucketResponse -> Bool)
-> Eq CreateBucketResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBucketResponse -> CreateBucketResponse -> Bool
$c/= :: CreateBucketResponse -> CreateBucketResponse -> Bool
== :: CreateBucketResponse -> CreateBucketResponse -> Bool
$c== :: CreateBucketResponse -> CreateBucketResponse -> Bool
Prelude.Eq, ReadPrec [CreateBucketResponse]
ReadPrec CreateBucketResponse
Int -> ReadS CreateBucketResponse
ReadS [CreateBucketResponse]
(Int -> ReadS CreateBucketResponse)
-> ReadS [CreateBucketResponse]
-> ReadPrec CreateBucketResponse
-> ReadPrec [CreateBucketResponse]
-> Read CreateBucketResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBucketResponse]
$creadListPrec :: ReadPrec [CreateBucketResponse]
readPrec :: ReadPrec CreateBucketResponse
$creadPrec :: ReadPrec CreateBucketResponse
readList :: ReadS [CreateBucketResponse]
$creadList :: ReadS [CreateBucketResponse]
readsPrec :: Int -> ReadS CreateBucketResponse
$creadsPrec :: Int -> ReadS CreateBucketResponse
Prelude.Read, Int -> CreateBucketResponse -> ShowS
[CreateBucketResponse] -> ShowS
CreateBucketResponse -> String
(Int -> CreateBucketResponse -> ShowS)
-> (CreateBucketResponse -> String)
-> ([CreateBucketResponse] -> ShowS)
-> Show CreateBucketResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBucketResponse] -> ShowS
$cshowList :: [CreateBucketResponse] -> ShowS
show :: CreateBucketResponse -> String
$cshow :: CreateBucketResponse -> String
showsPrec :: Int -> CreateBucketResponse -> ShowS
$cshowsPrec :: Int -> CreateBucketResponse -> ShowS
Prelude.Show, (forall x. CreateBucketResponse -> Rep CreateBucketResponse x)
-> (forall x. Rep CreateBucketResponse x -> CreateBucketResponse)
-> Generic CreateBucketResponse
forall x. Rep CreateBucketResponse x -> CreateBucketResponse
forall x. CreateBucketResponse -> Rep CreateBucketResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBucketResponse x -> CreateBucketResponse
$cfrom :: forall x. CreateBucketResponse -> Rep CreateBucketResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateBucketResponse' 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:
--
-- 'location', 'createBucketResponse_location' - Specifies the Region where the bucket will be created. If you are
-- creating a bucket on the US East (N. Virginia) Region (us-east-1), you
-- do not need to specify the location.
--
-- 'httpStatus', 'createBucketResponse_httpStatus' - The response's http status code.
newCreateBucketResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateBucketResponse
newCreateBucketResponse :: Int -> CreateBucketResponse
newCreateBucketResponse Int
pHttpStatus_ =
  CreateBucketResponse' :: Maybe Text -> Int -> CreateBucketResponse
CreateBucketResponse'
    { $sel:location:CreateBucketResponse' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateBucketResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Specifies the Region where the bucket will be created. If you are
-- creating a bucket on the US East (N. Virginia) Region (us-east-1), you
-- do not need to specify the location.
createBucketResponse_location :: Lens.Lens' CreateBucketResponse (Prelude.Maybe Prelude.Text)
createBucketResponse_location :: (Maybe Text -> f (Maybe Text))
-> CreateBucketResponse -> f CreateBucketResponse
createBucketResponse_location = (CreateBucketResponse -> Maybe Text)
-> (CreateBucketResponse -> Maybe Text -> CreateBucketResponse)
-> Lens
     CreateBucketResponse CreateBucketResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucketResponse' {Maybe Text
location :: Maybe Text
$sel:location:CreateBucketResponse' :: CreateBucketResponse -> Maybe Text
location} -> Maybe Text
location) (\s :: CreateBucketResponse
s@CreateBucketResponse' {} Maybe Text
a -> CreateBucketResponse
s {$sel:location:CreateBucketResponse' :: Maybe Text
location = Maybe Text
a} :: CreateBucketResponse)

-- | The response's http status code.
createBucketResponse_httpStatus :: Lens.Lens' CreateBucketResponse Prelude.Int
createBucketResponse_httpStatus :: (Int -> f Int) -> CreateBucketResponse -> f CreateBucketResponse
createBucketResponse_httpStatus = (CreateBucketResponse -> Int)
-> (CreateBucketResponse -> Int -> CreateBucketResponse)
-> Lens CreateBucketResponse CreateBucketResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucketResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateBucketResponse' :: CreateBucketResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateBucketResponse
s@CreateBucketResponse' {} Int
a -> CreateBucketResponse
s {$sel:httpStatus:CreateBucketResponse' :: Int
httpStatus = Int
a} :: CreateBucketResponse)

instance Prelude.NFData CreateBucketResponse