{-# 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.DeleteBucketEncryption
-- 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)
--
-- This implementation of the DELETE action removes default encryption from
-- the bucket. For information about the Amazon S3 default encryption
-- feature, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html Amazon S3 Default Bucket Encryption>
-- in the /Amazon S3 User Guide/.
--
-- To use this operation, you must have permissions to perform the
-- @s3:PutEncryptionConfiguration@ action. The bucket owner has this
-- permission by default. The bucket owner can grant this permission to
-- others. 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>
-- in the /Amazon S3 User Guide/.
--
-- __Related Resources__
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketEncryption.html PutBucketEncryption>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketEncryption.html GetBucketEncryption>
module Amazonka.S3.DeleteBucketEncryption
  ( -- * Creating a Request
    DeleteBucketEncryption (..),
    newDeleteBucketEncryption,

    -- * Request Lenses
    deleteBucketEncryption_expectedBucketOwner,
    deleteBucketEncryption_bucket,

    -- * Destructuring the Response
    DeleteBucketEncryptionResponse (..),
    newDeleteBucketEncryptionResponse,
  )
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:/ 'newDeleteBucketEncryption' smart constructor.
data DeleteBucketEncryption = DeleteBucketEncryption'
  { -- | 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.
    DeleteBucketEncryption -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the bucket containing the server-side encryption
    -- configuration to delete.
    DeleteBucketEncryption -> BucketName
bucket :: BucketName
  }
  deriving (DeleteBucketEncryption -> DeleteBucketEncryption -> Bool
(DeleteBucketEncryption -> DeleteBucketEncryption -> Bool)
-> (DeleteBucketEncryption -> DeleteBucketEncryption -> Bool)
-> Eq DeleteBucketEncryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBucketEncryption -> DeleteBucketEncryption -> Bool
$c/= :: DeleteBucketEncryption -> DeleteBucketEncryption -> Bool
== :: DeleteBucketEncryption -> DeleteBucketEncryption -> Bool
$c== :: DeleteBucketEncryption -> DeleteBucketEncryption -> Bool
Prelude.Eq, ReadPrec [DeleteBucketEncryption]
ReadPrec DeleteBucketEncryption
Int -> ReadS DeleteBucketEncryption
ReadS [DeleteBucketEncryption]
(Int -> ReadS DeleteBucketEncryption)
-> ReadS [DeleteBucketEncryption]
-> ReadPrec DeleteBucketEncryption
-> ReadPrec [DeleteBucketEncryption]
-> Read DeleteBucketEncryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBucketEncryption]
$creadListPrec :: ReadPrec [DeleteBucketEncryption]
readPrec :: ReadPrec DeleteBucketEncryption
$creadPrec :: ReadPrec DeleteBucketEncryption
readList :: ReadS [DeleteBucketEncryption]
$creadList :: ReadS [DeleteBucketEncryption]
readsPrec :: Int -> ReadS DeleteBucketEncryption
$creadsPrec :: Int -> ReadS DeleteBucketEncryption
Prelude.Read, Int -> DeleteBucketEncryption -> ShowS
[DeleteBucketEncryption] -> ShowS
DeleteBucketEncryption -> String
(Int -> DeleteBucketEncryption -> ShowS)
-> (DeleteBucketEncryption -> String)
-> ([DeleteBucketEncryption] -> ShowS)
-> Show DeleteBucketEncryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBucketEncryption] -> ShowS
$cshowList :: [DeleteBucketEncryption] -> ShowS
show :: DeleteBucketEncryption -> String
$cshow :: DeleteBucketEncryption -> String
showsPrec :: Int -> DeleteBucketEncryption -> ShowS
$cshowsPrec :: Int -> DeleteBucketEncryption -> ShowS
Prelude.Show, (forall x. DeleteBucketEncryption -> Rep DeleteBucketEncryption x)
-> (forall x.
    Rep DeleteBucketEncryption x -> DeleteBucketEncryption)
-> Generic DeleteBucketEncryption
forall x. Rep DeleteBucketEncryption x -> DeleteBucketEncryption
forall x. DeleteBucketEncryption -> Rep DeleteBucketEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBucketEncryption x -> DeleteBucketEncryption
$cfrom :: forall x. DeleteBucketEncryption -> Rep DeleteBucketEncryption x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBucketEncryption' 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', 'deleteBucketEncryption_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', 'deleteBucketEncryption_bucket' - The name of the bucket containing the server-side encryption
-- configuration to delete.
newDeleteBucketEncryption ::
  -- | 'bucket'
  BucketName ->
  DeleteBucketEncryption
newDeleteBucketEncryption :: BucketName -> DeleteBucketEncryption
newDeleteBucketEncryption BucketName
pBucket_ =
  DeleteBucketEncryption' :: Maybe Text -> BucketName -> DeleteBucketEncryption
DeleteBucketEncryption'
    { $sel:expectedBucketOwner:DeleteBucketEncryption' :: Maybe Text
expectedBucketOwner =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:DeleteBucketEncryption' :: 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.
deleteBucketEncryption_expectedBucketOwner :: Lens.Lens' DeleteBucketEncryption (Prelude.Maybe Prelude.Text)
deleteBucketEncryption_expectedBucketOwner :: (Maybe Text -> f (Maybe Text))
-> DeleteBucketEncryption -> f DeleteBucketEncryption
deleteBucketEncryption_expectedBucketOwner = (DeleteBucketEncryption -> Maybe Text)
-> (DeleteBucketEncryption -> Maybe Text -> DeleteBucketEncryption)
-> Lens
     DeleteBucketEncryption
     DeleteBucketEncryption
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketEncryption' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:DeleteBucketEncryption' :: DeleteBucketEncryption -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: DeleteBucketEncryption
s@DeleteBucketEncryption' {} Maybe Text
a -> DeleteBucketEncryption
s {$sel:expectedBucketOwner:DeleteBucketEncryption' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: DeleteBucketEncryption)

-- | The name of the bucket containing the server-side encryption
-- configuration to delete.
deleteBucketEncryption_bucket :: Lens.Lens' DeleteBucketEncryption BucketName
deleteBucketEncryption_bucket :: (BucketName -> f BucketName)
-> DeleteBucketEncryption -> f DeleteBucketEncryption
deleteBucketEncryption_bucket = (DeleteBucketEncryption -> BucketName)
-> (DeleteBucketEncryption -> BucketName -> DeleteBucketEncryption)
-> Lens
     DeleteBucketEncryption DeleteBucketEncryption BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketEncryption' {BucketName
bucket :: BucketName
$sel:bucket:DeleteBucketEncryption' :: DeleteBucketEncryption -> BucketName
bucket} -> BucketName
bucket) (\s :: DeleteBucketEncryption
s@DeleteBucketEncryption' {} BucketName
a -> DeleteBucketEncryption
s {$sel:bucket:DeleteBucketEncryption' :: BucketName
bucket = BucketName
a} :: DeleteBucketEncryption)

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

instance Prelude.Hashable DeleteBucketEncryption

instance Prelude.NFData DeleteBucketEncryption

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

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

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

instance
  Prelude.NFData
    DeleteBucketEncryptionResponse