{-# 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.DeleteBucketLifecycle
-- 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)
--
-- Deletes the lifecycle configuration from the specified bucket. Amazon S3
-- removes all the lifecycle configuration rules in the lifecycle
-- subresource associated with the bucket. Your objects never expire, and
-- Amazon S3 no longer automatically deletes any objects on the basis of
-- rules contained in the deleted lifecycle configuration.
--
-- To use this operation, you must have permission to perform the
-- @s3:PutLifecycleConfiguration@ action. By default, the bucket owner has
-- this permission and the bucket owner can grant this permission to
-- others.
--
-- There is usually some time lag before lifecycle configuration deletion
-- is fully propagated to all the Amazon S3 systems.
--
-- For more information about the object expiration, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/intro-lifecycle-rules.html#intro-lifecycle-rules-actions Elements to Describe Lifecycle Actions>.
--
-- Related actions include:
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycleConfiguration.html PutBucketLifecycleConfiguration>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycleConfiguration.html GetBucketLifecycleConfiguration>
module Amazonka.S3.DeleteBucketLifecycle
  ( -- * Creating a Request
    DeleteBucketLifecycle (..),
    newDeleteBucketLifecycle,

    -- * Request Lenses
    deleteBucketLifecycle_expectedBucketOwner,
    deleteBucketLifecycle_bucket,

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

-- |
-- Create a value of 'DeleteBucketLifecycle' 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', 'deleteBucketLifecycle_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', 'deleteBucketLifecycle_bucket' - The bucket name of the lifecycle to delete.
newDeleteBucketLifecycle ::
  -- | 'bucket'
  BucketName ->
  DeleteBucketLifecycle
newDeleteBucketLifecycle :: BucketName -> DeleteBucketLifecycle
newDeleteBucketLifecycle BucketName
pBucket_ =
  DeleteBucketLifecycle' :: Maybe Text -> BucketName -> DeleteBucketLifecycle
DeleteBucketLifecycle'
    { $sel:expectedBucketOwner:DeleteBucketLifecycle' :: Maybe Text
expectedBucketOwner =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:DeleteBucketLifecycle' :: 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.
deleteBucketLifecycle_expectedBucketOwner :: Lens.Lens' DeleteBucketLifecycle (Prelude.Maybe Prelude.Text)
deleteBucketLifecycle_expectedBucketOwner :: (Maybe Text -> f (Maybe Text))
-> DeleteBucketLifecycle -> f DeleteBucketLifecycle
deleteBucketLifecycle_expectedBucketOwner = (DeleteBucketLifecycle -> Maybe Text)
-> (DeleteBucketLifecycle -> Maybe Text -> DeleteBucketLifecycle)
-> Lens
     DeleteBucketLifecycle
     DeleteBucketLifecycle
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketLifecycle' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:DeleteBucketLifecycle' :: DeleteBucketLifecycle -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: DeleteBucketLifecycle
s@DeleteBucketLifecycle' {} Maybe Text
a -> DeleteBucketLifecycle
s {$sel:expectedBucketOwner:DeleteBucketLifecycle' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: DeleteBucketLifecycle)

-- | The bucket name of the lifecycle to delete.
deleteBucketLifecycle_bucket :: Lens.Lens' DeleteBucketLifecycle BucketName
deleteBucketLifecycle_bucket :: (BucketName -> f BucketName)
-> DeleteBucketLifecycle -> f DeleteBucketLifecycle
deleteBucketLifecycle_bucket = (DeleteBucketLifecycle -> BucketName)
-> (DeleteBucketLifecycle -> BucketName -> DeleteBucketLifecycle)
-> Lens
     DeleteBucketLifecycle DeleteBucketLifecycle BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketLifecycle' {BucketName
bucket :: BucketName
$sel:bucket:DeleteBucketLifecycle' :: DeleteBucketLifecycle -> BucketName
bucket} -> BucketName
bucket) (\s :: DeleteBucketLifecycle
s@DeleteBucketLifecycle' {} BucketName
a -> DeleteBucketLifecycle
s {$sel:bucket:DeleteBucketLifecycle' :: BucketName
bucket = BucketName
a} :: DeleteBucketLifecycle)

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

instance Prelude.Hashable DeleteBucketLifecycle

instance Prelude.NFData DeleteBucketLifecycle

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

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

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

instance Prelude.NFData DeleteBucketLifecycleResponse