{-# 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.MediaStore.DeleteMetricPolicy
-- 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 metric policy that is associated with the specified
-- container. If there is no metric policy associated with the container,
-- MediaStore doesn\'t send metrics to CloudWatch.
module Amazonka.MediaStore.DeleteMetricPolicy
  ( -- * Creating a Request
    DeleteMetricPolicy (..),
    newDeleteMetricPolicy,

    -- * Request Lenses
    deleteMetricPolicy_containerName,

    -- * Destructuring the Response
    DeleteMetricPolicyResponse (..),
    newDeleteMetricPolicyResponse,

    -- * Response Lenses
    deleteMetricPolicyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaStore.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteMetricPolicy' smart constructor.
data DeleteMetricPolicy = DeleteMetricPolicy'
  { -- | The name of the container that is associated with the metric policy that
    -- you want to delete.
    DeleteMetricPolicy -> Text
containerName :: Prelude.Text
  }
  deriving (DeleteMetricPolicy -> DeleteMetricPolicy -> Bool
(DeleteMetricPolicy -> DeleteMetricPolicy -> Bool)
-> (DeleteMetricPolicy -> DeleteMetricPolicy -> Bool)
-> Eq DeleteMetricPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMetricPolicy -> DeleteMetricPolicy -> Bool
$c/= :: DeleteMetricPolicy -> DeleteMetricPolicy -> Bool
== :: DeleteMetricPolicy -> DeleteMetricPolicy -> Bool
$c== :: DeleteMetricPolicy -> DeleteMetricPolicy -> Bool
Prelude.Eq, ReadPrec [DeleteMetricPolicy]
ReadPrec DeleteMetricPolicy
Int -> ReadS DeleteMetricPolicy
ReadS [DeleteMetricPolicy]
(Int -> ReadS DeleteMetricPolicy)
-> ReadS [DeleteMetricPolicy]
-> ReadPrec DeleteMetricPolicy
-> ReadPrec [DeleteMetricPolicy]
-> Read DeleteMetricPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMetricPolicy]
$creadListPrec :: ReadPrec [DeleteMetricPolicy]
readPrec :: ReadPrec DeleteMetricPolicy
$creadPrec :: ReadPrec DeleteMetricPolicy
readList :: ReadS [DeleteMetricPolicy]
$creadList :: ReadS [DeleteMetricPolicy]
readsPrec :: Int -> ReadS DeleteMetricPolicy
$creadsPrec :: Int -> ReadS DeleteMetricPolicy
Prelude.Read, Int -> DeleteMetricPolicy -> ShowS
[DeleteMetricPolicy] -> ShowS
DeleteMetricPolicy -> String
(Int -> DeleteMetricPolicy -> ShowS)
-> (DeleteMetricPolicy -> String)
-> ([DeleteMetricPolicy] -> ShowS)
-> Show DeleteMetricPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMetricPolicy] -> ShowS
$cshowList :: [DeleteMetricPolicy] -> ShowS
show :: DeleteMetricPolicy -> String
$cshow :: DeleteMetricPolicy -> String
showsPrec :: Int -> DeleteMetricPolicy -> ShowS
$cshowsPrec :: Int -> DeleteMetricPolicy -> ShowS
Prelude.Show, (forall x. DeleteMetricPolicy -> Rep DeleteMetricPolicy x)
-> (forall x. Rep DeleteMetricPolicy x -> DeleteMetricPolicy)
-> Generic DeleteMetricPolicy
forall x. Rep DeleteMetricPolicy x -> DeleteMetricPolicy
forall x. DeleteMetricPolicy -> Rep DeleteMetricPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteMetricPolicy x -> DeleteMetricPolicy
$cfrom :: forall x. DeleteMetricPolicy -> Rep DeleteMetricPolicy x
Prelude.Generic)

-- |
-- Create a value of 'DeleteMetricPolicy' 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:
--
-- 'containerName', 'deleteMetricPolicy_containerName' - The name of the container that is associated with the metric policy that
-- you want to delete.
newDeleteMetricPolicy ::
  -- | 'containerName'
  Prelude.Text ->
  DeleteMetricPolicy
newDeleteMetricPolicy :: Text -> DeleteMetricPolicy
newDeleteMetricPolicy Text
pContainerName_ =
  DeleteMetricPolicy' :: Text -> DeleteMetricPolicy
DeleteMetricPolicy'
    { $sel:containerName:DeleteMetricPolicy' :: Text
containerName =
        Text
pContainerName_
    }

-- | The name of the container that is associated with the metric policy that
-- you want to delete.
deleteMetricPolicy_containerName :: Lens.Lens' DeleteMetricPolicy Prelude.Text
deleteMetricPolicy_containerName :: (Text -> f Text) -> DeleteMetricPolicy -> f DeleteMetricPolicy
deleteMetricPolicy_containerName = (DeleteMetricPolicy -> Text)
-> (DeleteMetricPolicy -> Text -> DeleteMetricPolicy)
-> Lens DeleteMetricPolicy DeleteMetricPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMetricPolicy' {Text
containerName :: Text
$sel:containerName:DeleteMetricPolicy' :: DeleteMetricPolicy -> Text
containerName} -> Text
containerName) (\s :: DeleteMetricPolicy
s@DeleteMetricPolicy' {} Text
a -> DeleteMetricPolicy
s {$sel:containerName:DeleteMetricPolicy' :: Text
containerName = Text
a} :: DeleteMetricPolicy)

instance Core.AWSRequest DeleteMetricPolicy where
  type
    AWSResponse DeleteMetricPolicy =
      DeleteMetricPolicyResponse
  request :: DeleteMetricPolicy -> Request DeleteMetricPolicy
request = Service -> DeleteMetricPolicy -> Request DeleteMetricPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteMetricPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteMetricPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteMetricPolicy))
-> Logger
-> Service
-> Proxy DeleteMetricPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteMetricPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteMetricPolicyResponse
DeleteMetricPolicyResponse'
            (Int -> DeleteMetricPolicyResponse)
-> Either String Int -> Either String DeleteMetricPolicyResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteMetricPolicy

instance Prelude.NFData DeleteMetricPolicy

instance Core.ToHeaders DeleteMetricPolicy where
  toHeaders :: DeleteMetricPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteMetricPolicy -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"MediaStore_20170901.DeleteMetricPolicy" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DeleteMetricPolicy where
  toJSON :: DeleteMetricPolicy -> Value
toJSON DeleteMetricPolicy' {Text
containerName :: Text
$sel:containerName:DeleteMetricPolicy' :: DeleteMetricPolicy -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ContainerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
containerName)
          ]
      )

instance Core.ToPath DeleteMetricPolicy where
  toPath :: DeleteMetricPolicy -> ByteString
toPath = ByteString -> DeleteMetricPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DeleteMetricPolicy where
  toQuery :: DeleteMetricPolicy -> QueryString
toQuery = QueryString -> DeleteMetricPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'DeleteMetricPolicyResponse' 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:
--
-- 'httpStatus', 'deleteMetricPolicyResponse_httpStatus' - The response's http status code.
newDeleteMetricPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteMetricPolicyResponse
newDeleteMetricPolicyResponse :: Int -> DeleteMetricPolicyResponse
newDeleteMetricPolicyResponse Int
pHttpStatus_ =
  DeleteMetricPolicyResponse' :: Int -> DeleteMetricPolicyResponse
DeleteMetricPolicyResponse'
    { $sel:httpStatus:DeleteMetricPolicyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteMetricPolicyResponse_httpStatus :: Lens.Lens' DeleteMetricPolicyResponse Prelude.Int
deleteMetricPolicyResponse_httpStatus :: (Int -> f Int)
-> DeleteMetricPolicyResponse -> f DeleteMetricPolicyResponse
deleteMetricPolicyResponse_httpStatus = (DeleteMetricPolicyResponse -> Int)
-> (DeleteMetricPolicyResponse
    -> Int -> DeleteMetricPolicyResponse)
-> Lens
     DeleteMetricPolicyResponse DeleteMetricPolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMetricPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteMetricPolicyResponse' :: DeleteMetricPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteMetricPolicyResponse
s@DeleteMetricPolicyResponse' {} Int
a -> DeleteMetricPolicyResponse
s {$sel:httpStatus:DeleteMetricPolicyResponse' :: Int
httpStatus = Int
a} :: DeleteMetricPolicyResponse)

instance Prelude.NFData DeleteMetricPolicyResponse