{-# 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 #-}
module Amazonka.MediaStore.PutMetricPolicy
(
PutMetricPolicy (..),
newPutMetricPolicy,
putMetricPolicy_containerName,
putMetricPolicy_metricPolicy,
PutMetricPolicyResponse (..),
newPutMetricPolicyResponse,
putMetricPolicyResponse_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
data PutMetricPolicy = PutMetricPolicy'
{
PutMetricPolicy -> Text
containerName :: Prelude.Text,
PutMetricPolicy -> MetricPolicy
metricPolicy :: MetricPolicy
}
deriving (PutMetricPolicy -> PutMetricPolicy -> Bool
(PutMetricPolicy -> PutMetricPolicy -> Bool)
-> (PutMetricPolicy -> PutMetricPolicy -> Bool)
-> Eq PutMetricPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutMetricPolicy -> PutMetricPolicy -> Bool
$c/= :: PutMetricPolicy -> PutMetricPolicy -> Bool
== :: PutMetricPolicy -> PutMetricPolicy -> Bool
$c== :: PutMetricPolicy -> PutMetricPolicy -> Bool
Prelude.Eq, ReadPrec [PutMetricPolicy]
ReadPrec PutMetricPolicy
Int -> ReadS PutMetricPolicy
ReadS [PutMetricPolicy]
(Int -> ReadS PutMetricPolicy)
-> ReadS [PutMetricPolicy]
-> ReadPrec PutMetricPolicy
-> ReadPrec [PutMetricPolicy]
-> Read PutMetricPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutMetricPolicy]
$creadListPrec :: ReadPrec [PutMetricPolicy]
readPrec :: ReadPrec PutMetricPolicy
$creadPrec :: ReadPrec PutMetricPolicy
readList :: ReadS [PutMetricPolicy]
$creadList :: ReadS [PutMetricPolicy]
readsPrec :: Int -> ReadS PutMetricPolicy
$creadsPrec :: Int -> ReadS PutMetricPolicy
Prelude.Read, Int -> PutMetricPolicy -> ShowS
[PutMetricPolicy] -> ShowS
PutMetricPolicy -> String
(Int -> PutMetricPolicy -> ShowS)
-> (PutMetricPolicy -> String)
-> ([PutMetricPolicy] -> ShowS)
-> Show PutMetricPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutMetricPolicy] -> ShowS
$cshowList :: [PutMetricPolicy] -> ShowS
show :: PutMetricPolicy -> String
$cshow :: PutMetricPolicy -> String
showsPrec :: Int -> PutMetricPolicy -> ShowS
$cshowsPrec :: Int -> PutMetricPolicy -> ShowS
Prelude.Show, (forall x. PutMetricPolicy -> Rep PutMetricPolicy x)
-> (forall x. Rep PutMetricPolicy x -> PutMetricPolicy)
-> Generic PutMetricPolicy
forall x. Rep PutMetricPolicy x -> PutMetricPolicy
forall x. PutMetricPolicy -> Rep PutMetricPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutMetricPolicy x -> PutMetricPolicy
$cfrom :: forall x. PutMetricPolicy -> Rep PutMetricPolicy x
Prelude.Generic)
newPutMetricPolicy ::
Prelude.Text ->
MetricPolicy ->
PutMetricPolicy
newPutMetricPolicy :: Text -> MetricPolicy -> PutMetricPolicy
newPutMetricPolicy Text
pContainerName_ MetricPolicy
pMetricPolicy_ =
PutMetricPolicy' :: Text -> MetricPolicy -> PutMetricPolicy
PutMetricPolicy'
{ $sel:containerName:PutMetricPolicy' :: Text
containerName = Text
pContainerName_,
$sel:metricPolicy:PutMetricPolicy' :: MetricPolicy
metricPolicy = MetricPolicy
pMetricPolicy_
}
putMetricPolicy_containerName :: Lens.Lens' PutMetricPolicy Prelude.Text
putMetricPolicy_containerName :: (Text -> f Text) -> PutMetricPolicy -> f PutMetricPolicy
putMetricPolicy_containerName = (PutMetricPolicy -> Text)
-> (PutMetricPolicy -> Text -> PutMetricPolicy)
-> Lens PutMetricPolicy PutMetricPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricPolicy' {Text
containerName :: Text
$sel:containerName:PutMetricPolicy' :: PutMetricPolicy -> Text
containerName} -> Text
containerName) (\s :: PutMetricPolicy
s@PutMetricPolicy' {} Text
a -> PutMetricPolicy
s {$sel:containerName:PutMetricPolicy' :: Text
containerName = Text
a} :: PutMetricPolicy)
putMetricPolicy_metricPolicy :: Lens.Lens' PutMetricPolicy MetricPolicy
putMetricPolicy_metricPolicy :: (MetricPolicy -> f MetricPolicy)
-> PutMetricPolicy -> f PutMetricPolicy
putMetricPolicy_metricPolicy = (PutMetricPolicy -> MetricPolicy)
-> (PutMetricPolicy -> MetricPolicy -> PutMetricPolicy)
-> Lens PutMetricPolicy PutMetricPolicy MetricPolicy MetricPolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricPolicy' {MetricPolicy
metricPolicy :: MetricPolicy
$sel:metricPolicy:PutMetricPolicy' :: PutMetricPolicy -> MetricPolicy
metricPolicy} -> MetricPolicy
metricPolicy) (\s :: PutMetricPolicy
s@PutMetricPolicy' {} MetricPolicy
a -> PutMetricPolicy
s {$sel:metricPolicy:PutMetricPolicy' :: MetricPolicy
metricPolicy = MetricPolicy
a} :: PutMetricPolicy)
instance Core.AWSRequest PutMetricPolicy where
type
AWSResponse PutMetricPolicy =
PutMetricPolicyResponse
request :: PutMetricPolicy -> Request PutMetricPolicy
request = Service -> PutMetricPolicy -> Request PutMetricPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutMetricPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMetricPolicy)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse PutMetricPolicy))
-> Logger
-> Service
-> Proxy PutMetricPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutMetricPolicy)))
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 -> PutMetricPolicyResponse
PutMetricPolicyResponse'
(Int -> PutMetricPolicyResponse)
-> Either String Int -> Either String PutMetricPolicyResponse
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 PutMetricPolicy
instance Prelude.NFData PutMetricPolicy
instance Core.ToHeaders PutMetricPolicy where
toHeaders :: PutMetricPolicy -> ResponseHeaders
toHeaders =
ResponseHeaders -> PutMetricPolicy -> 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.PutMetricPolicy" ::
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 PutMetricPolicy where
toJSON :: PutMetricPolicy -> Value
toJSON PutMetricPolicy' {Text
MetricPolicy
metricPolicy :: MetricPolicy
containerName :: Text
$sel:metricPolicy:PutMetricPolicy' :: PutMetricPolicy -> MetricPolicy
$sel:containerName:PutMetricPolicy' :: PutMetricPolicy -> 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),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MetricPolicy" Text -> MetricPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MetricPolicy
metricPolicy)
]
)
instance Core.ToPath PutMetricPolicy where
toPath :: PutMetricPolicy -> ByteString
toPath = ByteString -> PutMetricPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PutMetricPolicy where
toQuery :: PutMetricPolicy -> QueryString
toQuery = QueryString -> PutMetricPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutMetricPolicyResponse = PutMetricPolicyResponse'
{
PutMetricPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutMetricPolicyResponse -> PutMetricPolicyResponse -> Bool
(PutMetricPolicyResponse -> PutMetricPolicyResponse -> Bool)
-> (PutMetricPolicyResponse -> PutMetricPolicyResponse -> Bool)
-> Eq PutMetricPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutMetricPolicyResponse -> PutMetricPolicyResponse -> Bool
$c/= :: PutMetricPolicyResponse -> PutMetricPolicyResponse -> Bool
== :: PutMetricPolicyResponse -> PutMetricPolicyResponse -> Bool
$c== :: PutMetricPolicyResponse -> PutMetricPolicyResponse -> Bool
Prelude.Eq, ReadPrec [PutMetricPolicyResponse]
ReadPrec PutMetricPolicyResponse
Int -> ReadS PutMetricPolicyResponse
ReadS [PutMetricPolicyResponse]
(Int -> ReadS PutMetricPolicyResponse)
-> ReadS [PutMetricPolicyResponse]
-> ReadPrec PutMetricPolicyResponse
-> ReadPrec [PutMetricPolicyResponse]
-> Read PutMetricPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutMetricPolicyResponse]
$creadListPrec :: ReadPrec [PutMetricPolicyResponse]
readPrec :: ReadPrec PutMetricPolicyResponse
$creadPrec :: ReadPrec PutMetricPolicyResponse
readList :: ReadS [PutMetricPolicyResponse]
$creadList :: ReadS [PutMetricPolicyResponse]
readsPrec :: Int -> ReadS PutMetricPolicyResponse
$creadsPrec :: Int -> ReadS PutMetricPolicyResponse
Prelude.Read, Int -> PutMetricPolicyResponse -> ShowS
[PutMetricPolicyResponse] -> ShowS
PutMetricPolicyResponse -> String
(Int -> PutMetricPolicyResponse -> ShowS)
-> (PutMetricPolicyResponse -> String)
-> ([PutMetricPolicyResponse] -> ShowS)
-> Show PutMetricPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutMetricPolicyResponse] -> ShowS
$cshowList :: [PutMetricPolicyResponse] -> ShowS
show :: PutMetricPolicyResponse -> String
$cshow :: PutMetricPolicyResponse -> String
showsPrec :: Int -> PutMetricPolicyResponse -> ShowS
$cshowsPrec :: Int -> PutMetricPolicyResponse -> ShowS
Prelude.Show, (forall x.
PutMetricPolicyResponse -> Rep PutMetricPolicyResponse x)
-> (forall x.
Rep PutMetricPolicyResponse x -> PutMetricPolicyResponse)
-> Generic PutMetricPolicyResponse
forall x. Rep PutMetricPolicyResponse x -> PutMetricPolicyResponse
forall x. PutMetricPolicyResponse -> Rep PutMetricPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutMetricPolicyResponse x -> PutMetricPolicyResponse
$cfrom :: forall x. PutMetricPolicyResponse -> Rep PutMetricPolicyResponse x
Prelude.Generic)
newPutMetricPolicyResponse ::
Prelude.Int ->
PutMetricPolicyResponse
newPutMetricPolicyResponse :: Int -> PutMetricPolicyResponse
newPutMetricPolicyResponse Int
pHttpStatus_ =
PutMetricPolicyResponse' :: Int -> PutMetricPolicyResponse
PutMetricPolicyResponse' {$sel:httpStatus:PutMetricPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_}
putMetricPolicyResponse_httpStatus :: Lens.Lens' PutMetricPolicyResponse Prelude.Int
putMetricPolicyResponse_httpStatus :: (Int -> f Int)
-> PutMetricPolicyResponse -> f PutMetricPolicyResponse
putMetricPolicyResponse_httpStatus = (PutMetricPolicyResponse -> Int)
-> (PutMetricPolicyResponse -> Int -> PutMetricPolicyResponse)
-> Lens PutMetricPolicyResponse PutMetricPolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutMetricPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutMetricPolicyResponse' :: PutMetricPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutMetricPolicyResponse
s@PutMetricPolicyResponse' {} Int
a -> PutMetricPolicyResponse
s {$sel:httpStatus:PutMetricPolicyResponse' :: Int
httpStatus = Int
a} :: PutMetricPolicyResponse)
instance Prelude.NFData PutMetricPolicyResponse