{-# 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.GetMetricPolicy
-- 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)
--
-- Returns the metric policy for the specified container.
module Amazonka.MediaStore.GetMetricPolicy
  ( -- * Creating a Request
    GetMetricPolicy (..),
    newGetMetricPolicy,

    -- * Request Lenses
    getMetricPolicy_containerName,

    -- * Destructuring the Response
    GetMetricPolicyResponse (..),
    newGetMetricPolicyResponse,

    -- * Response Lenses
    getMetricPolicyResponse_httpStatus,
    getMetricPolicyResponse_metricPolicy,
  )
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:/ 'newGetMetricPolicy' smart constructor.
data GetMetricPolicy = GetMetricPolicy'
  { -- | The name of the container that is associated with the metric policy.
    GetMetricPolicy -> Text
containerName :: Prelude.Text
  }
  deriving (GetMetricPolicy -> GetMetricPolicy -> Bool
(GetMetricPolicy -> GetMetricPolicy -> Bool)
-> (GetMetricPolicy -> GetMetricPolicy -> Bool)
-> Eq GetMetricPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMetricPolicy -> GetMetricPolicy -> Bool
$c/= :: GetMetricPolicy -> GetMetricPolicy -> Bool
== :: GetMetricPolicy -> GetMetricPolicy -> Bool
$c== :: GetMetricPolicy -> GetMetricPolicy -> Bool
Prelude.Eq, ReadPrec [GetMetricPolicy]
ReadPrec GetMetricPolicy
Int -> ReadS GetMetricPolicy
ReadS [GetMetricPolicy]
(Int -> ReadS GetMetricPolicy)
-> ReadS [GetMetricPolicy]
-> ReadPrec GetMetricPolicy
-> ReadPrec [GetMetricPolicy]
-> Read GetMetricPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMetricPolicy]
$creadListPrec :: ReadPrec [GetMetricPolicy]
readPrec :: ReadPrec GetMetricPolicy
$creadPrec :: ReadPrec GetMetricPolicy
readList :: ReadS [GetMetricPolicy]
$creadList :: ReadS [GetMetricPolicy]
readsPrec :: Int -> ReadS GetMetricPolicy
$creadsPrec :: Int -> ReadS GetMetricPolicy
Prelude.Read, Int -> GetMetricPolicy -> ShowS
[GetMetricPolicy] -> ShowS
GetMetricPolicy -> String
(Int -> GetMetricPolicy -> ShowS)
-> (GetMetricPolicy -> String)
-> ([GetMetricPolicy] -> ShowS)
-> Show GetMetricPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMetricPolicy] -> ShowS
$cshowList :: [GetMetricPolicy] -> ShowS
show :: GetMetricPolicy -> String
$cshow :: GetMetricPolicy -> String
showsPrec :: Int -> GetMetricPolicy -> ShowS
$cshowsPrec :: Int -> GetMetricPolicy -> ShowS
Prelude.Show, (forall x. GetMetricPolicy -> Rep GetMetricPolicy x)
-> (forall x. Rep GetMetricPolicy x -> GetMetricPolicy)
-> Generic GetMetricPolicy
forall x. Rep GetMetricPolicy x -> GetMetricPolicy
forall x. GetMetricPolicy -> Rep GetMetricPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMetricPolicy x -> GetMetricPolicy
$cfrom :: forall x. GetMetricPolicy -> Rep GetMetricPolicy x
Prelude.Generic)

-- |
-- Create a value of 'GetMetricPolicy' 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', 'getMetricPolicy_containerName' - The name of the container that is associated with the metric policy.
newGetMetricPolicy ::
  -- | 'containerName'
  Prelude.Text ->
  GetMetricPolicy
newGetMetricPolicy :: Text -> GetMetricPolicy
newGetMetricPolicy Text
pContainerName_ =
  GetMetricPolicy' :: Text -> GetMetricPolicy
GetMetricPolicy' {$sel:containerName:GetMetricPolicy' :: Text
containerName = Text
pContainerName_}

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

instance Core.AWSRequest GetMetricPolicy where
  type
    AWSResponse GetMetricPolicy =
      GetMetricPolicyResponse
  request :: GetMetricPolicy -> Request GetMetricPolicy
request = Service -> GetMetricPolicy -> Request GetMetricPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetMetricPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMetricPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetMetricPolicy))
-> Logger
-> Service
-> Proxy GetMetricPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetMetricPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> MetricPolicy -> GetMetricPolicyResponse
GetMetricPolicyResponse'
            (Int -> MetricPolicy -> GetMetricPolicyResponse)
-> Either String Int
-> Either String (MetricPolicy -> GetMetricPolicyResponse)
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))
            Either String (MetricPolicy -> GetMetricPolicyResponse)
-> Either String MetricPolicy
-> Either String GetMetricPolicyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String MetricPolicy
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"MetricPolicy")
      )

instance Prelude.Hashable GetMetricPolicy

instance Prelude.NFData GetMetricPolicy

instance Core.ToHeaders GetMetricPolicy where
  toHeaders :: GetMetricPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetMetricPolicy -> 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.GetMetricPolicy" ::
                          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 GetMetricPolicy where
  toJSON :: GetMetricPolicy -> Value
toJSON GetMetricPolicy' {Text
containerName :: Text
$sel:containerName:GetMetricPolicy' :: GetMetricPolicy -> 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 GetMetricPolicy where
  toPath :: GetMetricPolicy -> ByteString
toPath = ByteString -> GetMetricPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetMetricPolicyResponse' 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', 'getMetricPolicyResponse_httpStatus' - The response's http status code.
--
-- 'metricPolicy', 'getMetricPolicyResponse_metricPolicy' - The metric policy that is associated with the specific container.
newGetMetricPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'metricPolicy'
  MetricPolicy ->
  GetMetricPolicyResponse
newGetMetricPolicyResponse :: Int -> MetricPolicy -> GetMetricPolicyResponse
newGetMetricPolicyResponse
  Int
pHttpStatus_
  MetricPolicy
pMetricPolicy_ =
    GetMetricPolicyResponse' :: Int -> MetricPolicy -> GetMetricPolicyResponse
GetMetricPolicyResponse'
      { $sel:httpStatus:GetMetricPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:metricPolicy:GetMetricPolicyResponse' :: MetricPolicy
metricPolicy = MetricPolicy
pMetricPolicy_
      }

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

-- | The metric policy that is associated with the specific container.
getMetricPolicyResponse_metricPolicy :: Lens.Lens' GetMetricPolicyResponse MetricPolicy
getMetricPolicyResponse_metricPolicy :: (MetricPolicy -> f MetricPolicy)
-> GetMetricPolicyResponse -> f GetMetricPolicyResponse
getMetricPolicyResponse_metricPolicy = (GetMetricPolicyResponse -> MetricPolicy)
-> (GetMetricPolicyResponse
    -> MetricPolicy -> GetMetricPolicyResponse)
-> Lens
     GetMetricPolicyResponse
     GetMetricPolicyResponse
     MetricPolicy
     MetricPolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMetricPolicyResponse' {MetricPolicy
metricPolicy :: MetricPolicy
$sel:metricPolicy:GetMetricPolicyResponse' :: GetMetricPolicyResponse -> MetricPolicy
metricPolicy} -> MetricPolicy
metricPolicy) (\s :: GetMetricPolicyResponse
s@GetMetricPolicyResponse' {} MetricPolicy
a -> GetMetricPolicyResponse
s {$sel:metricPolicy:GetMetricPolicyResponse' :: MetricPolicy
metricPolicy = MetricPolicy
a} :: GetMetricPolicyResponse)

instance Prelude.NFData GetMetricPolicyResponse