{-# 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.DeletePublicAccessBlock
-- 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 the @PublicAccessBlock@ configuration for an Amazon S3 bucket.
-- To use this operation, you must have the @s3:PutBucketPublicAccessBlock@
-- permission. For more information about permissions, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources Permissions Related to Bucket Subresource Operations>
-- and
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html Managing Access Permissions to Your Amazon S3 Resources>.
--
-- The following operations are related to @DeletePublicAccessBlock@:
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html Using Amazon S3 Block Public Access>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetPublicAccessBlock.html GetPublicAccessBlock>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutPublicAccessBlock.html PutPublicAccessBlock>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketPolicyStatus.html GetBucketPolicyStatus>
module Amazonka.S3.DeletePublicAccessBlock
  ( -- * Creating a Request
    DeletePublicAccessBlock (..),
    newDeletePublicAccessBlock,

    -- * Request Lenses
    deletePublicAccessBlock_expectedBucketOwner,
    deletePublicAccessBlock_bucket,

    -- * Destructuring the Response
    DeletePublicAccessBlockResponse (..),
    newDeletePublicAccessBlockResponse,
  )
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:/ 'newDeletePublicAccessBlock' smart constructor.
data DeletePublicAccessBlock = DeletePublicAccessBlock'
  { -- | 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.
    DeletePublicAccessBlock -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 bucket whose @PublicAccessBlock@ configuration you want to
    -- delete.
    DeletePublicAccessBlock -> BucketName
bucket :: BucketName
  }
  deriving (DeletePublicAccessBlock -> DeletePublicAccessBlock -> Bool
(DeletePublicAccessBlock -> DeletePublicAccessBlock -> Bool)
-> (DeletePublicAccessBlock -> DeletePublicAccessBlock -> Bool)
-> Eq DeletePublicAccessBlock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePublicAccessBlock -> DeletePublicAccessBlock -> Bool
$c/= :: DeletePublicAccessBlock -> DeletePublicAccessBlock -> Bool
== :: DeletePublicAccessBlock -> DeletePublicAccessBlock -> Bool
$c== :: DeletePublicAccessBlock -> DeletePublicAccessBlock -> Bool
Prelude.Eq, ReadPrec [DeletePublicAccessBlock]
ReadPrec DeletePublicAccessBlock
Int -> ReadS DeletePublicAccessBlock
ReadS [DeletePublicAccessBlock]
(Int -> ReadS DeletePublicAccessBlock)
-> ReadS [DeletePublicAccessBlock]
-> ReadPrec DeletePublicAccessBlock
-> ReadPrec [DeletePublicAccessBlock]
-> Read DeletePublicAccessBlock
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePublicAccessBlock]
$creadListPrec :: ReadPrec [DeletePublicAccessBlock]
readPrec :: ReadPrec DeletePublicAccessBlock
$creadPrec :: ReadPrec DeletePublicAccessBlock
readList :: ReadS [DeletePublicAccessBlock]
$creadList :: ReadS [DeletePublicAccessBlock]
readsPrec :: Int -> ReadS DeletePublicAccessBlock
$creadsPrec :: Int -> ReadS DeletePublicAccessBlock
Prelude.Read, Int -> DeletePublicAccessBlock -> ShowS
[DeletePublicAccessBlock] -> ShowS
DeletePublicAccessBlock -> String
(Int -> DeletePublicAccessBlock -> ShowS)
-> (DeletePublicAccessBlock -> String)
-> ([DeletePublicAccessBlock] -> ShowS)
-> Show DeletePublicAccessBlock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePublicAccessBlock] -> ShowS
$cshowList :: [DeletePublicAccessBlock] -> ShowS
show :: DeletePublicAccessBlock -> String
$cshow :: DeletePublicAccessBlock -> String
showsPrec :: Int -> DeletePublicAccessBlock -> ShowS
$cshowsPrec :: Int -> DeletePublicAccessBlock -> ShowS
Prelude.Show, (forall x.
 DeletePublicAccessBlock -> Rep DeletePublicAccessBlock x)
-> (forall x.
    Rep DeletePublicAccessBlock x -> DeletePublicAccessBlock)
-> Generic DeletePublicAccessBlock
forall x. Rep DeletePublicAccessBlock x -> DeletePublicAccessBlock
forall x. DeletePublicAccessBlock -> Rep DeletePublicAccessBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePublicAccessBlock x -> DeletePublicAccessBlock
$cfrom :: forall x. DeletePublicAccessBlock -> Rep DeletePublicAccessBlock x
Prelude.Generic)

-- |
-- Create a value of 'DeletePublicAccessBlock' 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', 'deletePublicAccessBlock_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', 'deletePublicAccessBlock_bucket' - The Amazon S3 bucket whose @PublicAccessBlock@ configuration you want to
-- delete.
newDeletePublicAccessBlock ::
  -- | 'bucket'
  BucketName ->
  DeletePublicAccessBlock
newDeletePublicAccessBlock :: BucketName -> DeletePublicAccessBlock
newDeletePublicAccessBlock BucketName
pBucket_ =
  DeletePublicAccessBlock' :: Maybe Text -> BucketName -> DeletePublicAccessBlock
DeletePublicAccessBlock'
    { $sel:expectedBucketOwner:DeletePublicAccessBlock' :: Maybe Text
expectedBucketOwner =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:DeletePublicAccessBlock' :: 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.
deletePublicAccessBlock_expectedBucketOwner :: Lens.Lens' DeletePublicAccessBlock (Prelude.Maybe Prelude.Text)
deletePublicAccessBlock_expectedBucketOwner :: (Maybe Text -> f (Maybe Text))
-> DeletePublicAccessBlock -> f DeletePublicAccessBlock
deletePublicAccessBlock_expectedBucketOwner = (DeletePublicAccessBlock -> Maybe Text)
-> (DeletePublicAccessBlock
    -> Maybe Text -> DeletePublicAccessBlock)
-> Lens
     DeletePublicAccessBlock
     DeletePublicAccessBlock
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePublicAccessBlock' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:DeletePublicAccessBlock' :: DeletePublicAccessBlock -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: DeletePublicAccessBlock
s@DeletePublicAccessBlock' {} Maybe Text
a -> DeletePublicAccessBlock
s {$sel:expectedBucketOwner:DeletePublicAccessBlock' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: DeletePublicAccessBlock)

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

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

instance Prelude.Hashable DeletePublicAccessBlock

instance Prelude.NFData DeletePublicAccessBlock

instance Core.ToHeaders DeletePublicAccessBlock where
  toHeaders :: DeletePublicAccessBlock -> [Header]
toHeaders DeletePublicAccessBlock' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:DeletePublicAccessBlock' :: DeletePublicAccessBlock -> BucketName
$sel:expectedBucketOwner:DeletePublicAccessBlock' :: DeletePublicAccessBlock -> 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 DeletePublicAccessBlock where
  toPath :: DeletePublicAccessBlock -> ByteString
toPath DeletePublicAccessBlock' {Maybe Text
BucketName
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:bucket:DeletePublicAccessBlock' :: DeletePublicAccessBlock -> BucketName
$sel:expectedBucketOwner:DeletePublicAccessBlock' :: DeletePublicAccessBlock -> 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 DeletePublicAccessBlock where
  toQuery :: DeletePublicAccessBlock -> QueryString
toQuery =
    QueryString -> DeletePublicAccessBlock -> QueryString
forall a b. a -> b -> a
Prelude.const
      ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"publicAccessBlock"])

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

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

instance
  Prelude.NFData
    DeletePublicAccessBlockResponse