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