{-# 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.DeleteBucketOwnershipControls
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes @OwnershipControls@ for an Amazon S3 bucket. To use this
-- operation, you must have the @s3:PutBucketOwnershipControls@ permission.
-- For more information about Amazon S3 permissions, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html Specifying Permissions in a Policy>.
--
-- For information about Amazon S3 Object Ownership, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/about-object-ownership.html Using Object Ownership>.
--
-- The following operations are related to @DeleteBucketOwnershipControls@:
--
-- -   GetBucketOwnershipControls
--
-- -   PutBucketOwnershipControls
module Amazonka.S3.DeleteBucketOwnershipControls
  ( -- * Creating a Request
    DeleteBucketOwnershipControls (..),
    newDeleteBucketOwnershipControls,

    -- * Request Lenses
    deleteBucketOwnershipControls_expectedBucketOwner,
    deleteBucketOwnershipControls_bucket,

    -- * Destructuring the Response
    DeleteBucketOwnershipControlsResponse (..),
    newDeleteBucketOwnershipControlsResponse,
  )
where

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

-- | /See:/ 'newDeleteBucketOwnershipControls' smart constructor.
data DeleteBucketOwnershipControls = DeleteBucketOwnershipControls'
  { -- | The account ID of the expected bucket owner. If the bucket is owned by a
    -- different account, the request fails with the HTTP status code
    -- @403 Forbidden@ (access denied).
    DeleteBucketOwnershipControls -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 bucket whose @OwnershipControls@ you want to delete.
    DeleteBucketOwnershipControls -> BucketName
bucket :: BucketName
  }
  deriving (DeleteBucketOwnershipControls
-> DeleteBucketOwnershipControls -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBucketOwnershipControls
-> DeleteBucketOwnershipControls -> Bool
$c/= :: DeleteBucketOwnershipControls
-> DeleteBucketOwnershipControls -> Bool
== :: DeleteBucketOwnershipControls
-> DeleteBucketOwnershipControls -> Bool
$c== :: DeleteBucketOwnershipControls
-> DeleteBucketOwnershipControls -> Bool
Prelude.Eq, ReadPrec [DeleteBucketOwnershipControls]
ReadPrec DeleteBucketOwnershipControls
Int -> ReadS DeleteBucketOwnershipControls
ReadS [DeleteBucketOwnershipControls]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBucketOwnershipControls]
$creadListPrec :: ReadPrec [DeleteBucketOwnershipControls]
readPrec :: ReadPrec DeleteBucketOwnershipControls
$creadPrec :: ReadPrec DeleteBucketOwnershipControls
readList :: ReadS [DeleteBucketOwnershipControls]
$creadList :: ReadS [DeleteBucketOwnershipControls]
readsPrec :: Int -> ReadS DeleteBucketOwnershipControls
$creadsPrec :: Int -> ReadS DeleteBucketOwnershipControls
Prelude.Read, Int -> DeleteBucketOwnershipControls -> ShowS
[DeleteBucketOwnershipControls] -> ShowS
DeleteBucketOwnershipControls -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBucketOwnershipControls] -> ShowS
$cshowList :: [DeleteBucketOwnershipControls] -> ShowS
show :: DeleteBucketOwnershipControls -> String
$cshow :: DeleteBucketOwnershipControls -> String
showsPrec :: Int -> DeleteBucketOwnershipControls -> ShowS
$cshowsPrec :: Int -> DeleteBucketOwnershipControls -> ShowS
Prelude.Show, forall x.
Rep DeleteBucketOwnershipControls x
-> DeleteBucketOwnershipControls
forall x.
DeleteBucketOwnershipControls
-> Rep DeleteBucketOwnershipControls x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteBucketOwnershipControls x
-> DeleteBucketOwnershipControls
$cfrom :: forall x.
DeleteBucketOwnershipControls
-> Rep DeleteBucketOwnershipControls x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBucketOwnershipControls' 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:
--
-- 'expectedBucketOwner', 'deleteBucketOwnershipControls_expectedBucketOwner' - The account ID of the expected bucket owner. If the bucket is owned by a
-- different account, the request fails with the HTTP status code
-- @403 Forbidden@ (access denied).
--
-- 'bucket', 'deleteBucketOwnershipControls_bucket' - The Amazon S3 bucket whose @OwnershipControls@ you want to delete.
newDeleteBucketOwnershipControls ::
  -- | 'bucket'
  BucketName ->
  DeleteBucketOwnershipControls
newDeleteBucketOwnershipControls :: BucketName -> DeleteBucketOwnershipControls
newDeleteBucketOwnershipControls BucketName
pBucket_ =
  DeleteBucketOwnershipControls'
    { $sel:expectedBucketOwner:DeleteBucketOwnershipControls' :: Maybe Text
expectedBucketOwner =
        forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:DeleteBucketOwnershipControls' :: BucketName
bucket = BucketName
pBucket_
    }

-- | The account ID of the expected bucket owner. If the bucket is owned by a
-- different account, the request fails with the HTTP status code
-- @403 Forbidden@ (access denied).
deleteBucketOwnershipControls_expectedBucketOwner :: Lens.Lens' DeleteBucketOwnershipControls (Prelude.Maybe Prelude.Text)
deleteBucketOwnershipControls_expectedBucketOwner :: Lens' DeleteBucketOwnershipControls (Maybe Text)
deleteBucketOwnershipControls_expectedBucketOwner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketOwnershipControls' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: DeleteBucketOwnershipControls
s@DeleteBucketOwnershipControls' {} Maybe Text
a -> DeleteBucketOwnershipControls
s {$sel:expectedBucketOwner:DeleteBucketOwnershipControls' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: DeleteBucketOwnershipControls)

-- | The Amazon S3 bucket whose @OwnershipControls@ you want to delete.
deleteBucketOwnershipControls_bucket :: Lens.Lens' DeleteBucketOwnershipControls BucketName
deleteBucketOwnershipControls_bucket :: Lens' DeleteBucketOwnershipControls BucketName
deleteBucketOwnershipControls_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketOwnershipControls' {BucketName
bucket :: BucketName
$sel:bucket:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> BucketName
bucket} -> BucketName
bucket) (\s :: DeleteBucketOwnershipControls
s@DeleteBucketOwnershipControls' {} BucketName
a -> DeleteBucketOwnershipControls
s {$sel:bucket:DeleteBucketOwnershipControls' :: BucketName
bucket = BucketName
a} :: DeleteBucketOwnershipControls)

instance
  Core.AWSRequest
    DeleteBucketOwnershipControls
  where
  type
    AWSResponse DeleteBucketOwnershipControls =
      DeleteBucketOwnershipControlsResponse
  request :: (Service -> Service)
-> DeleteBucketOwnershipControls
-> Request DeleteBucketOwnershipControls
request Service -> Service
overrides =
    forall a. Request a -> Request a
Request.s3vhost
      forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteBucketOwnershipControls
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteBucketOwnershipControls)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      DeleteBucketOwnershipControlsResponse
DeleteBucketOwnershipControlsResponse'

instance
  Prelude.Hashable
    DeleteBucketOwnershipControls
  where
  hashWithSalt :: Int -> DeleteBucketOwnershipControls -> Int
hashWithSalt Int
_salt DeleteBucketOwnershipControls' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> BucketName
$sel:expectedBucketOwner:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
expectedBucketOwner
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` BucketName
bucket

instance Prelude.NFData DeleteBucketOwnershipControls where
  rnf :: DeleteBucketOwnershipControls -> ()
rnf DeleteBucketOwnershipControls' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> BucketName
$sel:expectedBucketOwner:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
expectedBucketOwner
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf BucketName
bucket

instance Data.ToHeaders DeleteBucketOwnershipControls where
  toHeaders :: DeleteBucketOwnershipControls -> [Header]
toHeaders DeleteBucketOwnershipControls' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> BucketName
$sel:expectedBucketOwner:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-expected-bucket-owner"
          forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# Maybe Text
expectedBucketOwner
      ]

instance Data.ToPath DeleteBucketOwnershipControls where
  toPath :: DeleteBucketOwnershipControls -> ByteString
toPath DeleteBucketOwnershipControls' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> BucketName
$sel:expectedBucketOwner:DeleteBucketOwnershipControls' :: DeleteBucketOwnershipControls -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/", forall a. ToByteString a => a -> ByteString
Data.toBS BucketName
bucket]

instance Data.ToQuery DeleteBucketOwnershipControls where
  toQuery :: DeleteBucketOwnershipControls -> QueryString
toQuery =
    forall a b. a -> b -> a
Prelude.const
      (forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"ownershipControls"])

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

-- |
-- Create a value of 'DeleteBucketOwnershipControlsResponse' 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.
newDeleteBucketOwnershipControlsResponse ::
  DeleteBucketOwnershipControlsResponse
newDeleteBucketOwnershipControlsResponse :: DeleteBucketOwnershipControlsResponse
newDeleteBucketOwnershipControlsResponse =
  DeleteBucketOwnershipControlsResponse
DeleteBucketOwnershipControlsResponse'

instance
  Prelude.NFData
    DeleteBucketOwnershipControlsResponse
  where
  rnf :: DeleteBucketOwnershipControlsResponse -> ()
rnf DeleteBucketOwnershipControlsResponse
_ = ()