{-# 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.FMS.PutPolicy
(
PutPolicy (..),
newPutPolicy,
putPolicy_tagList,
putPolicy_policy,
PutPolicyResponse (..),
newPutPolicyResponse,
putPolicyResponse_policy,
putPolicyResponse_policyArn,
putPolicyResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data PutPolicy = PutPolicy'
{
PutPolicy -> Maybe [Tag]
tagList :: Prelude.Maybe [Tag],
PutPolicy -> Policy
policy :: Policy
}
deriving (PutPolicy -> PutPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutPolicy -> PutPolicy -> Bool
$c/= :: PutPolicy -> PutPolicy -> Bool
== :: PutPolicy -> PutPolicy -> Bool
$c== :: PutPolicy -> PutPolicy -> Bool
Prelude.Eq, ReadPrec [PutPolicy]
ReadPrec PutPolicy
Int -> ReadS PutPolicy
ReadS [PutPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutPolicy]
$creadListPrec :: ReadPrec [PutPolicy]
readPrec :: ReadPrec PutPolicy
$creadPrec :: ReadPrec PutPolicy
readList :: ReadS [PutPolicy]
$creadList :: ReadS [PutPolicy]
readsPrec :: Int -> ReadS PutPolicy
$creadsPrec :: Int -> ReadS PutPolicy
Prelude.Read, Int -> PutPolicy -> ShowS
[PutPolicy] -> ShowS
PutPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutPolicy] -> ShowS
$cshowList :: [PutPolicy] -> ShowS
show :: PutPolicy -> String
$cshow :: PutPolicy -> String
showsPrec :: Int -> PutPolicy -> ShowS
$cshowsPrec :: Int -> PutPolicy -> ShowS
Prelude.Show, forall x. Rep PutPolicy x -> PutPolicy
forall x. PutPolicy -> Rep PutPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutPolicy x -> PutPolicy
$cfrom :: forall x. PutPolicy -> Rep PutPolicy x
Prelude.Generic)
newPutPolicy ::
Policy ->
PutPolicy
newPutPolicy :: Policy -> PutPolicy
newPutPolicy Policy
pPolicy_ =
PutPolicy'
{ $sel:tagList:PutPolicy' :: Maybe [Tag]
tagList = forall a. Maybe a
Prelude.Nothing,
$sel:policy:PutPolicy' :: Policy
policy = Policy
pPolicy_
}
putPolicy_tagList :: Lens.Lens' PutPolicy (Prelude.Maybe [Tag])
putPolicy_tagList :: Lens' PutPolicy (Maybe [Tag])
putPolicy_tagList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPolicy' {Maybe [Tag]
tagList :: Maybe [Tag]
$sel:tagList:PutPolicy' :: PutPolicy -> Maybe [Tag]
tagList} -> Maybe [Tag]
tagList) (\s :: PutPolicy
s@PutPolicy' {} Maybe [Tag]
a -> PutPolicy
s {$sel:tagList:PutPolicy' :: Maybe [Tag]
tagList = Maybe [Tag]
a} :: PutPolicy) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
putPolicy_policy :: Lens.Lens' PutPolicy Policy
putPolicy_policy :: Lens' PutPolicy Policy
putPolicy_policy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPolicy' {Policy
policy :: Policy
$sel:policy:PutPolicy' :: PutPolicy -> Policy
policy} -> Policy
policy) (\s :: PutPolicy
s@PutPolicy' {} Policy
a -> PutPolicy
s {$sel:policy:PutPolicy' :: Policy
policy = Policy
a} :: PutPolicy)
instance Core.AWSRequest PutPolicy where
type AWSResponse PutPolicy = PutPolicyResponse
request :: (Service -> Service) -> PutPolicy -> Request PutPolicy
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutPolicy)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Policy -> Maybe Text -> Int -> PutPolicyResponse
PutPolicyResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Policy")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"PolicyArn")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable PutPolicy where
hashWithSalt :: Int -> PutPolicy -> Int
hashWithSalt Int
_salt PutPolicy' {Maybe [Tag]
Policy
policy :: Policy
tagList :: Maybe [Tag]
$sel:policy:PutPolicy' :: PutPolicy -> Policy
$sel:tagList:PutPolicy' :: PutPolicy -> Maybe [Tag]
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tagList
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Policy
policy
instance Prelude.NFData PutPolicy where
rnf :: PutPolicy -> ()
rnf PutPolicy' {Maybe [Tag]
Policy
policy :: Policy
tagList :: Maybe [Tag]
$sel:policy:PutPolicy' :: PutPolicy -> Policy
$sel:tagList:PutPolicy' :: PutPolicy -> Maybe [Tag]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tagList
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Policy
policy
instance Data.ToHeaders PutPolicy where
toHeaders :: PutPolicy -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"AWSFMS_20180101.PutPolicy" :: Prelude.ByteString),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON PutPolicy where
toJSON :: PutPolicy -> Value
toJSON PutPolicy' {Maybe [Tag]
Policy
policy :: Policy
tagList :: Maybe [Tag]
$sel:policy:PutPolicy' :: PutPolicy -> Policy
$sel:tagList:PutPolicy' :: PutPolicy -> Maybe [Tag]
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"TagList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tagList,
forall a. a -> Maybe a
Prelude.Just (Key
"Policy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Policy
policy)
]
)
instance Data.ToPath PutPolicy where
toPath :: PutPolicy -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery PutPolicy where
toQuery :: PutPolicy -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data PutPolicyResponse = PutPolicyResponse'
{
PutPolicyResponse -> Maybe Policy
policy :: Prelude.Maybe Policy,
PutPolicyResponse -> Maybe Text
policyArn :: Prelude.Maybe Prelude.Text,
PutPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutPolicyResponse -> PutPolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutPolicyResponse -> PutPolicyResponse -> Bool
$c/= :: PutPolicyResponse -> PutPolicyResponse -> Bool
== :: PutPolicyResponse -> PutPolicyResponse -> Bool
$c== :: PutPolicyResponse -> PutPolicyResponse -> Bool
Prelude.Eq, ReadPrec [PutPolicyResponse]
ReadPrec PutPolicyResponse
Int -> ReadS PutPolicyResponse
ReadS [PutPolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutPolicyResponse]
$creadListPrec :: ReadPrec [PutPolicyResponse]
readPrec :: ReadPrec PutPolicyResponse
$creadPrec :: ReadPrec PutPolicyResponse
readList :: ReadS [PutPolicyResponse]
$creadList :: ReadS [PutPolicyResponse]
readsPrec :: Int -> ReadS PutPolicyResponse
$creadsPrec :: Int -> ReadS PutPolicyResponse
Prelude.Read, Int -> PutPolicyResponse -> ShowS
[PutPolicyResponse] -> ShowS
PutPolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutPolicyResponse] -> ShowS
$cshowList :: [PutPolicyResponse] -> ShowS
show :: PutPolicyResponse -> String
$cshow :: PutPolicyResponse -> String
showsPrec :: Int -> PutPolicyResponse -> ShowS
$cshowsPrec :: Int -> PutPolicyResponse -> ShowS
Prelude.Show, forall x. Rep PutPolicyResponse x -> PutPolicyResponse
forall x. PutPolicyResponse -> Rep PutPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutPolicyResponse x -> PutPolicyResponse
$cfrom :: forall x. PutPolicyResponse -> Rep PutPolicyResponse x
Prelude.Generic)
newPutPolicyResponse ::
Prelude.Int ->
PutPolicyResponse
newPutPolicyResponse :: Int -> PutPolicyResponse
newPutPolicyResponse Int
pHttpStatus_ =
PutPolicyResponse'
{ $sel:policy:PutPolicyResponse' :: Maybe Policy
policy = forall a. Maybe a
Prelude.Nothing,
$sel:policyArn:PutPolicyResponse' :: Maybe Text
policyArn = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PutPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
putPolicyResponse_policy :: Lens.Lens' PutPolicyResponse (Prelude.Maybe Policy)
putPolicyResponse_policy :: Lens' PutPolicyResponse (Maybe Policy)
putPolicyResponse_policy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPolicyResponse' {Maybe Policy
policy :: Maybe Policy
$sel:policy:PutPolicyResponse' :: PutPolicyResponse -> Maybe Policy
policy} -> Maybe Policy
policy) (\s :: PutPolicyResponse
s@PutPolicyResponse' {} Maybe Policy
a -> PutPolicyResponse
s {$sel:policy:PutPolicyResponse' :: Maybe Policy
policy = Maybe Policy
a} :: PutPolicyResponse)
putPolicyResponse_policyArn :: Lens.Lens' PutPolicyResponse (Prelude.Maybe Prelude.Text)
putPolicyResponse_policyArn :: Lens' PutPolicyResponse (Maybe Text)
putPolicyResponse_policyArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPolicyResponse' {Maybe Text
policyArn :: Maybe Text
$sel:policyArn:PutPolicyResponse' :: PutPolicyResponse -> Maybe Text
policyArn} -> Maybe Text
policyArn) (\s :: PutPolicyResponse
s@PutPolicyResponse' {} Maybe Text
a -> PutPolicyResponse
s {$sel:policyArn:PutPolicyResponse' :: Maybe Text
policyArn = Maybe Text
a} :: PutPolicyResponse)
putPolicyResponse_httpStatus :: Lens.Lens' PutPolicyResponse Prelude.Int
putPolicyResponse_httpStatus :: Lens' PutPolicyResponse Int
putPolicyResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutPolicyResponse' :: PutPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutPolicyResponse
s@PutPolicyResponse' {} Int
a -> PutPolicyResponse
s {$sel:httpStatus:PutPolicyResponse' :: Int
httpStatus = Int
a} :: PutPolicyResponse)
instance Prelude.NFData PutPolicyResponse where
rnf :: PutPolicyResponse -> ()
rnf PutPolicyResponse' {Int
Maybe Text
Maybe Policy
httpStatus :: Int
policyArn :: Maybe Text
policy :: Maybe Policy
$sel:httpStatus:PutPolicyResponse' :: PutPolicyResponse -> Int
$sel:policyArn:PutPolicyResponse' :: PutPolicyResponse -> Maybe Text
$sel:policy:PutPolicyResponse' :: PutPolicyResponse -> Maybe Policy
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Policy
policy
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyArn
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus