{-# 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-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)
--
-- 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.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:/ '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 will fail with an HTTP
    -- @403 (Access Denied)@ error.
    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
(DeleteBucketOwnershipControls
 -> DeleteBucketOwnershipControls -> Bool)
-> (DeleteBucketOwnershipControls
    -> DeleteBucketOwnershipControls -> Bool)
-> Eq DeleteBucketOwnershipControls
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]
(Int -> ReadS DeleteBucketOwnershipControls)
-> ReadS [DeleteBucketOwnershipControls]
-> ReadPrec DeleteBucketOwnershipControls
-> ReadPrec [DeleteBucketOwnershipControls]
-> Read 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
(Int -> DeleteBucketOwnershipControls -> ShowS)
-> (DeleteBucketOwnershipControls -> String)
-> ([DeleteBucketOwnershipControls] -> ShowS)
-> Show DeleteBucketOwnershipControls
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.
 DeleteBucketOwnershipControls
 -> Rep DeleteBucketOwnershipControls x)
-> (forall x.
    Rep DeleteBucketOwnershipControls x
    -> DeleteBucketOwnershipControls)
-> Generic DeleteBucketOwnershipControls
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 will fail with an HTTP
-- @403 (Access Denied)@ error.
--
-- 'bucket', 'deleteBucketOwnershipControls_bucket' - The Amazon S3 bucket whose @OwnershipControls@ you want to delete.
newDeleteBucketOwnershipControls ::
  -- | 'bucket'
  BucketName ->
  DeleteBucketOwnershipControls
newDeleteBucketOwnershipControls :: BucketName -> DeleteBucketOwnershipControls
newDeleteBucketOwnershipControls BucketName
pBucket_ =
  DeleteBucketOwnershipControls' :: Maybe Text -> BucketName -> DeleteBucketOwnershipControls
DeleteBucketOwnershipControls'
    { $sel:expectedBucketOwner:DeleteBucketOwnershipControls' :: Maybe Text
expectedBucketOwner =
        Maybe Text
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 will fail with an HTTP
-- @403 (Access Denied)@ error.
deleteBucketOwnershipControls_expectedBucketOwner :: Lens.Lens' DeleteBucketOwnershipControls (Prelude.Maybe Prelude.Text)
deleteBucketOwnershipControls_expectedBucketOwner :: (Maybe Text -> f (Maybe Text))
-> DeleteBucketOwnershipControls -> f DeleteBucketOwnershipControls
deleteBucketOwnershipControls_expectedBucketOwner = (DeleteBucketOwnershipControls -> Maybe Text)
-> (DeleteBucketOwnershipControls
    -> Maybe Text -> DeleteBucketOwnershipControls)
-> Lens
     DeleteBucketOwnershipControls
     DeleteBucketOwnershipControls
     (Maybe Text)
     (Maybe Text)
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 :: (BucketName -> f BucketName)
-> DeleteBucketOwnershipControls -> f DeleteBucketOwnershipControls
deleteBucketOwnershipControls_bucket = (DeleteBucketOwnershipControls -> BucketName)
-> (DeleteBucketOwnershipControls
    -> BucketName -> DeleteBucketOwnershipControls)
-> Lens
     DeleteBucketOwnershipControls
     DeleteBucketOwnershipControls
     BucketName
     BucketName
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 :: DeleteBucketOwnershipControls
-> Request DeleteBucketOwnershipControls
request =
    Request DeleteBucketOwnershipControls
-> Request DeleteBucketOwnershipControls
forall a. Request a -> Request a
Request.s3vhost
      (Request DeleteBucketOwnershipControls
 -> Request DeleteBucketOwnershipControls)
-> (DeleteBucketOwnershipControls
    -> Request DeleteBucketOwnershipControls)
-> DeleteBucketOwnershipControls
-> Request DeleteBucketOwnershipControls
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service
-> DeleteBucketOwnershipControls
-> Request DeleteBucketOwnershipControls
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteBucketOwnershipControls
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteBucketOwnershipControls)))
response =
    AWSResponse DeleteBucketOwnershipControls
-> Logger
-> Service
-> Proxy DeleteBucketOwnershipControls
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteBucketOwnershipControls)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse DeleteBucketOwnershipControls
DeleteBucketOwnershipControlsResponse
DeleteBucketOwnershipControlsResponse'

instance
  Prelude.Hashable
    DeleteBucketOwnershipControls

instance Prelude.NFData DeleteBucketOwnershipControls

instance Core.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
..} =
    [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-expected-bucket-owner"
          HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
expectedBucketOwner
      ]

instance Core.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
..} =
    [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 DeleteBucketOwnershipControls where
  toQuery :: DeleteBucketOwnershipControls -> QueryString
toQuery =
    QueryString -> DeleteBucketOwnershipControls -> QueryString
forall a b. a -> b -> a
Prelude.const
      ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"ownershipControls"])

-- | /See:/ 'newDeleteBucketOwnershipControlsResponse' smart constructor.
data DeleteBucketOwnershipControlsResponse = DeleteBucketOwnershipControlsResponse'
  {
  }
  deriving (DeleteBucketOwnershipControlsResponse
-> DeleteBucketOwnershipControlsResponse -> Bool
(DeleteBucketOwnershipControlsResponse
 -> DeleteBucketOwnershipControlsResponse -> Bool)
-> (DeleteBucketOwnershipControlsResponse
    -> DeleteBucketOwnershipControlsResponse -> Bool)
-> Eq DeleteBucketOwnershipControlsResponse
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]
(Int -> ReadS DeleteBucketOwnershipControlsResponse)
-> ReadS [DeleteBucketOwnershipControlsResponse]
-> ReadPrec DeleteBucketOwnershipControlsResponse
-> ReadPrec [DeleteBucketOwnershipControlsResponse]
-> Read 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
(Int -> DeleteBucketOwnershipControlsResponse -> ShowS)
-> (DeleteBucketOwnershipControlsResponse -> String)
-> ([DeleteBucketOwnershipControlsResponse] -> ShowS)
-> Show DeleteBucketOwnershipControlsResponse
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.
 DeleteBucketOwnershipControlsResponse
 -> Rep DeleteBucketOwnershipControlsResponse x)
-> (forall x.
    Rep DeleteBucketOwnershipControlsResponse x
    -> DeleteBucketOwnershipControlsResponse)
-> Generic DeleteBucketOwnershipControlsResponse
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