{-# 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.DeleteBucketWebsite
-- 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 action removes the website configuration for a bucket. Amazon S3
-- returns a @200 OK@ response upon successfully deleting a website
-- configuration on the specified bucket. You will get a @200 OK@ response
-- if the website configuration you are trying to delete does not exist on
-- the bucket. Amazon S3 returns a @404@ response if the bucket specified
-- in the request does not exist.
--
-- This DELETE action requires the @S3:DeleteBucketWebsite@ permission. By
-- default, only the bucket owner can delete the website configuration
-- attached to a bucket. However, bucket owners can grant other users
-- permission to delete the website configuration by writing a bucket
-- policy granting them the @S3:DeleteBucketWebsite@ permission.
--
-- For more information about hosting websites, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html Hosting Websites on Amazon S3>.
--
-- The following operations are related to @DeleteBucketWebsite@:
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketWebsite.html GetBucketWebsite>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketWebsite.html PutBucketWebsite>
module Amazonka.S3.DeleteBucketWebsite
  ( -- * Creating a Request
    DeleteBucketWebsite (..),
    newDeleteBucketWebsite,

    -- * Request Lenses
    deleteBucketWebsite_expectedBucketOwner,
    deleteBucketWebsite_bucket,

    -- * Destructuring the Response
    DeleteBucketWebsiteResponse (..),
    newDeleteBucketWebsiteResponse,
  )
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:/ 'newDeleteBucketWebsite' smart constructor.
data DeleteBucketWebsite = DeleteBucketWebsite'
  { -- | 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.
    DeleteBucketWebsite -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The bucket name for which you want to remove the website configuration.
    DeleteBucketWebsite -> BucketName
bucket :: BucketName
  }
  deriving (DeleteBucketWebsite -> DeleteBucketWebsite -> Bool
(DeleteBucketWebsite -> DeleteBucketWebsite -> Bool)
-> (DeleteBucketWebsite -> DeleteBucketWebsite -> Bool)
-> Eq DeleteBucketWebsite
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBucketWebsite -> DeleteBucketWebsite -> Bool
$c/= :: DeleteBucketWebsite -> DeleteBucketWebsite -> Bool
== :: DeleteBucketWebsite -> DeleteBucketWebsite -> Bool
$c== :: DeleteBucketWebsite -> DeleteBucketWebsite -> Bool
Prelude.Eq, ReadPrec [DeleteBucketWebsite]
ReadPrec DeleteBucketWebsite
Int -> ReadS DeleteBucketWebsite
ReadS [DeleteBucketWebsite]
(Int -> ReadS DeleteBucketWebsite)
-> ReadS [DeleteBucketWebsite]
-> ReadPrec DeleteBucketWebsite
-> ReadPrec [DeleteBucketWebsite]
-> Read DeleteBucketWebsite
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBucketWebsite]
$creadListPrec :: ReadPrec [DeleteBucketWebsite]
readPrec :: ReadPrec DeleteBucketWebsite
$creadPrec :: ReadPrec DeleteBucketWebsite
readList :: ReadS [DeleteBucketWebsite]
$creadList :: ReadS [DeleteBucketWebsite]
readsPrec :: Int -> ReadS DeleteBucketWebsite
$creadsPrec :: Int -> ReadS DeleteBucketWebsite
Prelude.Read, Int -> DeleteBucketWebsite -> ShowS
[DeleteBucketWebsite] -> ShowS
DeleteBucketWebsite -> String
(Int -> DeleteBucketWebsite -> ShowS)
-> (DeleteBucketWebsite -> String)
-> ([DeleteBucketWebsite] -> ShowS)
-> Show DeleteBucketWebsite
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBucketWebsite] -> ShowS
$cshowList :: [DeleteBucketWebsite] -> ShowS
show :: DeleteBucketWebsite -> String
$cshow :: DeleteBucketWebsite -> String
showsPrec :: Int -> DeleteBucketWebsite -> ShowS
$cshowsPrec :: Int -> DeleteBucketWebsite -> ShowS
Prelude.Show, (forall x. DeleteBucketWebsite -> Rep DeleteBucketWebsite x)
-> (forall x. Rep DeleteBucketWebsite x -> DeleteBucketWebsite)
-> Generic DeleteBucketWebsite
forall x. Rep DeleteBucketWebsite x -> DeleteBucketWebsite
forall x. DeleteBucketWebsite -> Rep DeleteBucketWebsite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBucketWebsite x -> DeleteBucketWebsite
$cfrom :: forall x. DeleteBucketWebsite -> Rep DeleteBucketWebsite x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBucketWebsite' 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', 'deleteBucketWebsite_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', 'deleteBucketWebsite_bucket' - The bucket name for which you want to remove the website configuration.
newDeleteBucketWebsite ::
  -- | 'bucket'
  BucketName ->
  DeleteBucketWebsite
newDeleteBucketWebsite :: BucketName -> DeleteBucketWebsite
newDeleteBucketWebsite BucketName
pBucket_ =
  DeleteBucketWebsite' :: Maybe Text -> BucketName -> DeleteBucketWebsite
DeleteBucketWebsite'
    { $sel:expectedBucketOwner:DeleteBucketWebsite' :: Maybe Text
expectedBucketOwner =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:DeleteBucketWebsite' :: 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.
deleteBucketWebsite_expectedBucketOwner :: Lens.Lens' DeleteBucketWebsite (Prelude.Maybe Prelude.Text)
deleteBucketWebsite_expectedBucketOwner :: (Maybe Text -> f (Maybe Text))
-> DeleteBucketWebsite -> f DeleteBucketWebsite
deleteBucketWebsite_expectedBucketOwner = (DeleteBucketWebsite -> Maybe Text)
-> (DeleteBucketWebsite -> Maybe Text -> DeleteBucketWebsite)
-> Lens
     DeleteBucketWebsite DeleteBucketWebsite (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketWebsite' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:DeleteBucketWebsite' :: DeleteBucketWebsite -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: DeleteBucketWebsite
s@DeleteBucketWebsite' {} Maybe Text
a -> DeleteBucketWebsite
s {$sel:expectedBucketOwner:DeleteBucketWebsite' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: DeleteBucketWebsite)

-- | The bucket name for which you want to remove the website configuration.
deleteBucketWebsite_bucket :: Lens.Lens' DeleteBucketWebsite BucketName
deleteBucketWebsite_bucket :: (BucketName -> f BucketName)
-> DeleteBucketWebsite -> f DeleteBucketWebsite
deleteBucketWebsite_bucket = (DeleteBucketWebsite -> BucketName)
-> (DeleteBucketWebsite -> BucketName -> DeleteBucketWebsite)
-> Lens
     DeleteBucketWebsite DeleteBucketWebsite BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketWebsite' {BucketName
bucket :: BucketName
$sel:bucket:DeleteBucketWebsite' :: DeleteBucketWebsite -> BucketName
bucket} -> BucketName
bucket) (\s :: DeleteBucketWebsite
s@DeleteBucketWebsite' {} BucketName
a -> DeleteBucketWebsite
s {$sel:bucket:DeleteBucketWebsite' :: BucketName
bucket = BucketName
a} :: DeleteBucketWebsite)

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

instance Prelude.Hashable DeleteBucketWebsite

instance Prelude.NFData DeleteBucketWebsite

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

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

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

instance Prelude.NFData DeleteBucketWebsiteResponse