{-# 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.DeleteBucketMetricsConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a metrics configuration for the Amazon CloudWatch request
-- metrics (specified by the metrics configuration ID) from the bucket.
-- Note that this doesn\'t include the daily storage metrics.
--
-- To use this operation, you must have permissions to perform the
-- @s3:PutMetricsConfiguration@ 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>.
--
-- For information about CloudWatch request metrics for Amazon S3, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/cloudwatch-monitoring.html Monitoring Metrics with Amazon CloudWatch>.
--
-- The following operations are related to
-- @DeleteBucketMetricsConfiguration@:
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetricsConfiguration.html GetBucketMetricsConfiguration>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketMetricsConfiguration.html PutBucketMetricsConfiguration>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketMetricsConfigurations.html ListBucketMetricsConfigurations>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/dev/cloudwatch-monitoring.html Monitoring Metrics with Amazon CloudWatch>
module Amazonka.S3.DeleteBucketMetricsConfiguration
  ( -- * Creating a Request
    DeleteBucketMetricsConfiguration (..),
    newDeleteBucketMetricsConfiguration,

    -- * Request Lenses
    deleteBucketMetricsConfiguration_expectedBucketOwner,
    deleteBucketMetricsConfiguration_bucket,
    deleteBucketMetricsConfiguration_id,

    -- * Destructuring the Response
    DeleteBucketMetricsConfigurationResponse (..),
    newDeleteBucketMetricsConfigurationResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.S3.Types

-- | /See:/ 'newDeleteBucketMetricsConfiguration' smart constructor.
data DeleteBucketMetricsConfiguration = DeleteBucketMetricsConfiguration'
  { -- | The account ID of the expected bucket owner. If the bucket is owned by a
    -- different account, the request fails with the HTTP status code
    -- @403 Forbidden@ (access denied).
    DeleteBucketMetricsConfiguration -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the bucket containing the metrics configuration to delete.
    DeleteBucketMetricsConfiguration -> BucketName
bucket :: BucketName,
    -- | The ID used to identify the metrics configuration.
    DeleteBucketMetricsConfiguration -> Text
id :: Prelude.Text
  }
  deriving (DeleteBucketMetricsConfiguration
-> DeleteBucketMetricsConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBucketMetricsConfiguration
-> DeleteBucketMetricsConfiguration -> Bool
$c/= :: DeleteBucketMetricsConfiguration
-> DeleteBucketMetricsConfiguration -> Bool
== :: DeleteBucketMetricsConfiguration
-> DeleteBucketMetricsConfiguration -> Bool
$c== :: DeleteBucketMetricsConfiguration
-> DeleteBucketMetricsConfiguration -> Bool
Prelude.Eq, ReadPrec [DeleteBucketMetricsConfiguration]
ReadPrec DeleteBucketMetricsConfiguration
Int -> ReadS DeleteBucketMetricsConfiguration
ReadS [DeleteBucketMetricsConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBucketMetricsConfiguration]
$creadListPrec :: ReadPrec [DeleteBucketMetricsConfiguration]
readPrec :: ReadPrec DeleteBucketMetricsConfiguration
$creadPrec :: ReadPrec DeleteBucketMetricsConfiguration
readList :: ReadS [DeleteBucketMetricsConfiguration]
$creadList :: ReadS [DeleteBucketMetricsConfiguration]
readsPrec :: Int -> ReadS DeleteBucketMetricsConfiguration
$creadsPrec :: Int -> ReadS DeleteBucketMetricsConfiguration
Prelude.Read, Int -> DeleteBucketMetricsConfiguration -> ShowS
[DeleteBucketMetricsConfiguration] -> ShowS
DeleteBucketMetricsConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBucketMetricsConfiguration] -> ShowS
$cshowList :: [DeleteBucketMetricsConfiguration] -> ShowS
show :: DeleteBucketMetricsConfiguration -> String
$cshow :: DeleteBucketMetricsConfiguration -> String
showsPrec :: Int -> DeleteBucketMetricsConfiguration -> ShowS
$cshowsPrec :: Int -> DeleteBucketMetricsConfiguration -> ShowS
Prelude.Show, forall x.
Rep DeleteBucketMetricsConfiguration x
-> DeleteBucketMetricsConfiguration
forall x.
DeleteBucketMetricsConfiguration
-> Rep DeleteBucketMetricsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteBucketMetricsConfiguration x
-> DeleteBucketMetricsConfiguration
$cfrom :: forall x.
DeleteBucketMetricsConfiguration
-> Rep DeleteBucketMetricsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBucketMetricsConfiguration' 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', 'deleteBucketMetricsConfiguration_expectedBucketOwner' - The account ID of the expected bucket owner. If the bucket is owned by a
-- different account, the request fails with the HTTP status code
-- @403 Forbidden@ (access denied).
--
-- 'bucket', 'deleteBucketMetricsConfiguration_bucket' - The name of the bucket containing the metrics configuration to delete.
--
-- 'id', 'deleteBucketMetricsConfiguration_id' - The ID used to identify the metrics configuration.
newDeleteBucketMetricsConfiguration ::
  -- | 'bucket'
  BucketName ->
  -- | 'id'
  Prelude.Text ->
  DeleteBucketMetricsConfiguration
newDeleteBucketMetricsConfiguration :: BucketName -> Text -> DeleteBucketMetricsConfiguration
newDeleteBucketMetricsConfiguration BucketName
pBucket_ Text
pId_ =
  DeleteBucketMetricsConfiguration'
    { $sel:expectedBucketOwner:DeleteBucketMetricsConfiguration' :: Maybe Text
expectedBucketOwner =
        forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:DeleteBucketMetricsConfiguration' :: BucketName
bucket = BucketName
pBucket_,
      $sel:id:DeleteBucketMetricsConfiguration' :: Text
id = Text
pId_
    }

-- | The account ID of the expected bucket owner. If the bucket is owned by a
-- different account, the request fails with the HTTP status code
-- @403 Forbidden@ (access denied).
deleteBucketMetricsConfiguration_expectedBucketOwner :: Lens.Lens' DeleteBucketMetricsConfiguration (Prelude.Maybe Prelude.Text)
deleteBucketMetricsConfiguration_expectedBucketOwner :: Lens' DeleteBucketMetricsConfiguration (Maybe Text)
deleteBucketMetricsConfiguration_expectedBucketOwner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketMetricsConfiguration' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: DeleteBucketMetricsConfiguration
s@DeleteBucketMetricsConfiguration' {} Maybe Text
a -> DeleteBucketMetricsConfiguration
s {$sel:expectedBucketOwner:DeleteBucketMetricsConfiguration' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: DeleteBucketMetricsConfiguration)

-- | The name of the bucket containing the metrics configuration to delete.
deleteBucketMetricsConfiguration_bucket :: Lens.Lens' DeleteBucketMetricsConfiguration BucketName
deleteBucketMetricsConfiguration_bucket :: Lens' DeleteBucketMetricsConfiguration BucketName
deleteBucketMetricsConfiguration_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketMetricsConfiguration' {BucketName
bucket :: BucketName
$sel:bucket:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> BucketName
bucket} -> BucketName
bucket) (\s :: DeleteBucketMetricsConfiguration
s@DeleteBucketMetricsConfiguration' {} BucketName
a -> DeleteBucketMetricsConfiguration
s {$sel:bucket:DeleteBucketMetricsConfiguration' :: BucketName
bucket = BucketName
a} :: DeleteBucketMetricsConfiguration)

-- | The ID used to identify the metrics configuration.
deleteBucketMetricsConfiguration_id :: Lens.Lens' DeleteBucketMetricsConfiguration Prelude.Text
deleteBucketMetricsConfiguration_id :: Lens' DeleteBucketMetricsConfiguration Text
deleteBucketMetricsConfiguration_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketMetricsConfiguration' {Text
id :: Text
$sel:id:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Text
id} -> Text
id) (\s :: DeleteBucketMetricsConfiguration
s@DeleteBucketMetricsConfiguration' {} Text
a -> DeleteBucketMetricsConfiguration
s {$sel:id:DeleteBucketMetricsConfiguration' :: Text
id = Text
a} :: DeleteBucketMetricsConfiguration)

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

instance
  Prelude.Hashable
    DeleteBucketMetricsConfiguration
  where
  hashWithSalt :: Int -> DeleteBucketMetricsConfiguration -> Int
hashWithSalt
    Int
_salt
    DeleteBucketMetricsConfiguration' {Maybe Text
Text
BucketName
id :: Text
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:id:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Text
$sel:bucket:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> BucketName
$sel:expectedBucketOwner:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
expectedBucketOwner
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` BucketName
bucket
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance
  Prelude.NFData
    DeleteBucketMetricsConfiguration
  where
  rnf :: DeleteBucketMetricsConfiguration -> ()
rnf DeleteBucketMetricsConfiguration' {Maybe Text
Text
BucketName
id :: Text
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:id:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Text
$sel:bucket:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> BucketName
$sel:expectedBucketOwner:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
expectedBucketOwner
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf BucketName
bucket
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance
  Data.ToHeaders
    DeleteBucketMetricsConfiguration
  where
  toHeaders :: DeleteBucketMetricsConfiguration -> [Header]
toHeaders DeleteBucketMetricsConfiguration' {Maybe Text
Text
BucketName
id :: Text
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:id:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Text
$sel:bucket:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> BucketName
$sel:expectedBucketOwner:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-expected-bucket-owner"
          forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# Maybe Text
expectedBucketOwner
      ]

instance Data.ToPath DeleteBucketMetricsConfiguration where
  toPath :: DeleteBucketMetricsConfiguration -> ByteString
toPath DeleteBucketMetricsConfiguration' {Maybe Text
Text
BucketName
id :: Text
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:id:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Text
$sel:bucket:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> BucketName
$sel:expectedBucketOwner:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/", forall a. ToByteString a => a -> ByteString
Data.toBS BucketName
bucket]

instance
  Data.ToQuery
    DeleteBucketMetricsConfiguration
  where
  toQuery :: DeleteBucketMetricsConfiguration -> QueryString
toQuery DeleteBucketMetricsConfiguration' {Maybe Text
Text
BucketName
id :: Text
bucket :: BucketName
expectedBucketOwner :: Maybe Text
$sel:id:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Text
$sel:bucket:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> BucketName
$sel:expectedBucketOwner:DeleteBucketMetricsConfiguration' :: DeleteBucketMetricsConfiguration -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"id" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
id, QueryString
"metrics"]

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

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

instance
  Prelude.NFData
    DeleteBucketMetricsConfigurationResponse
  where
  rnf :: DeleteBucketMetricsConfigurationResponse -> ()
rnf DeleteBucketMetricsConfigurationResponse
_ = ()