{-# 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.KMS.PutKeyPolicy
(
PutKeyPolicy (..),
newPutKeyPolicy,
putKeyPolicy_bypassPolicyLockoutSafetyCheck,
putKeyPolicy_keyId,
putKeyPolicy_policyName,
putKeyPolicy_policy,
PutKeyPolicyResponse (..),
newPutKeyPolicyResponse,
)
where
import qualified Amazonka.Core as Core
import Amazonka.KMS.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data PutKeyPolicy = PutKeyPolicy'
{
PutKeyPolicy -> Maybe Bool
bypassPolicyLockoutSafetyCheck :: Prelude.Maybe Prelude.Bool,
PutKeyPolicy -> Text
keyId :: Prelude.Text,
PutKeyPolicy -> Text
policyName :: Prelude.Text,
PutKeyPolicy -> Text
policy :: Prelude.Text
}
deriving (PutKeyPolicy -> PutKeyPolicy -> Bool
(PutKeyPolicy -> PutKeyPolicy -> Bool)
-> (PutKeyPolicy -> PutKeyPolicy -> Bool) -> Eq PutKeyPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutKeyPolicy -> PutKeyPolicy -> Bool
$c/= :: PutKeyPolicy -> PutKeyPolicy -> Bool
== :: PutKeyPolicy -> PutKeyPolicy -> Bool
$c== :: PutKeyPolicy -> PutKeyPolicy -> Bool
Prelude.Eq, ReadPrec [PutKeyPolicy]
ReadPrec PutKeyPolicy
Int -> ReadS PutKeyPolicy
ReadS [PutKeyPolicy]
(Int -> ReadS PutKeyPolicy)
-> ReadS [PutKeyPolicy]
-> ReadPrec PutKeyPolicy
-> ReadPrec [PutKeyPolicy]
-> Read PutKeyPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutKeyPolicy]
$creadListPrec :: ReadPrec [PutKeyPolicy]
readPrec :: ReadPrec PutKeyPolicy
$creadPrec :: ReadPrec PutKeyPolicy
readList :: ReadS [PutKeyPolicy]
$creadList :: ReadS [PutKeyPolicy]
readsPrec :: Int -> ReadS PutKeyPolicy
$creadsPrec :: Int -> ReadS PutKeyPolicy
Prelude.Read, Int -> PutKeyPolicy -> ShowS
[PutKeyPolicy] -> ShowS
PutKeyPolicy -> String
(Int -> PutKeyPolicy -> ShowS)
-> (PutKeyPolicy -> String)
-> ([PutKeyPolicy] -> ShowS)
-> Show PutKeyPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutKeyPolicy] -> ShowS
$cshowList :: [PutKeyPolicy] -> ShowS
show :: PutKeyPolicy -> String
$cshow :: PutKeyPolicy -> String
showsPrec :: Int -> PutKeyPolicy -> ShowS
$cshowsPrec :: Int -> PutKeyPolicy -> ShowS
Prelude.Show, (forall x. PutKeyPolicy -> Rep PutKeyPolicy x)
-> (forall x. Rep PutKeyPolicy x -> PutKeyPolicy)
-> Generic PutKeyPolicy
forall x. Rep PutKeyPolicy x -> PutKeyPolicy
forall x. PutKeyPolicy -> Rep PutKeyPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutKeyPolicy x -> PutKeyPolicy
$cfrom :: forall x. PutKeyPolicy -> Rep PutKeyPolicy x
Prelude.Generic)
newPutKeyPolicy ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
PutKeyPolicy
newPutKeyPolicy :: Text -> Text -> Text -> PutKeyPolicy
newPutKeyPolicy Text
pKeyId_ Text
pPolicyName_ Text
pPolicy_ =
PutKeyPolicy' :: Maybe Bool -> Text -> Text -> Text -> PutKeyPolicy
PutKeyPolicy'
{ $sel:bypassPolicyLockoutSafetyCheck:PutKeyPolicy' :: Maybe Bool
bypassPolicyLockoutSafetyCheck =
Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:keyId:PutKeyPolicy' :: Text
keyId = Text
pKeyId_,
$sel:policyName:PutKeyPolicy' :: Text
policyName = Text
pPolicyName_,
$sel:policy:PutKeyPolicy' :: Text
policy = Text
pPolicy_
}
putKeyPolicy_bypassPolicyLockoutSafetyCheck :: Lens.Lens' PutKeyPolicy (Prelude.Maybe Prelude.Bool)
putKeyPolicy_bypassPolicyLockoutSafetyCheck :: (Maybe Bool -> f (Maybe Bool)) -> PutKeyPolicy -> f PutKeyPolicy
putKeyPolicy_bypassPolicyLockoutSafetyCheck = (PutKeyPolicy -> Maybe Bool)
-> (PutKeyPolicy -> Maybe Bool -> PutKeyPolicy)
-> Lens PutKeyPolicy PutKeyPolicy (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutKeyPolicy' {Maybe Bool
bypassPolicyLockoutSafetyCheck :: Maybe Bool
$sel:bypassPolicyLockoutSafetyCheck:PutKeyPolicy' :: PutKeyPolicy -> Maybe Bool
bypassPolicyLockoutSafetyCheck} -> Maybe Bool
bypassPolicyLockoutSafetyCheck) (\s :: PutKeyPolicy
s@PutKeyPolicy' {} Maybe Bool
a -> PutKeyPolicy
s {$sel:bypassPolicyLockoutSafetyCheck:PutKeyPolicy' :: Maybe Bool
bypassPolicyLockoutSafetyCheck = Maybe Bool
a} :: PutKeyPolicy)
putKeyPolicy_keyId :: Lens.Lens' PutKeyPolicy Prelude.Text
putKeyPolicy_keyId :: (Text -> f Text) -> PutKeyPolicy -> f PutKeyPolicy
putKeyPolicy_keyId = (PutKeyPolicy -> Text)
-> (PutKeyPolicy -> Text -> PutKeyPolicy)
-> Lens PutKeyPolicy PutKeyPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutKeyPolicy' {Text
keyId :: Text
$sel:keyId:PutKeyPolicy' :: PutKeyPolicy -> Text
keyId} -> Text
keyId) (\s :: PutKeyPolicy
s@PutKeyPolicy' {} Text
a -> PutKeyPolicy
s {$sel:keyId:PutKeyPolicy' :: Text
keyId = Text
a} :: PutKeyPolicy)
putKeyPolicy_policyName :: Lens.Lens' PutKeyPolicy Prelude.Text
putKeyPolicy_policyName :: (Text -> f Text) -> PutKeyPolicy -> f PutKeyPolicy
putKeyPolicy_policyName = (PutKeyPolicy -> Text)
-> (PutKeyPolicy -> Text -> PutKeyPolicy)
-> Lens PutKeyPolicy PutKeyPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutKeyPolicy' {Text
policyName :: Text
$sel:policyName:PutKeyPolicy' :: PutKeyPolicy -> Text
policyName} -> Text
policyName) (\s :: PutKeyPolicy
s@PutKeyPolicy' {} Text
a -> PutKeyPolicy
s {$sel:policyName:PutKeyPolicy' :: Text
policyName = Text
a} :: PutKeyPolicy)
putKeyPolicy_policy :: Lens.Lens' PutKeyPolicy Prelude.Text
putKeyPolicy_policy :: (Text -> f Text) -> PutKeyPolicy -> f PutKeyPolicy
putKeyPolicy_policy = (PutKeyPolicy -> Text)
-> (PutKeyPolicy -> Text -> PutKeyPolicy)
-> Lens PutKeyPolicy PutKeyPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutKeyPolicy' {Text
policy :: Text
$sel:policy:PutKeyPolicy' :: PutKeyPolicy -> Text
policy} -> Text
policy) (\s :: PutKeyPolicy
s@PutKeyPolicy' {} Text
a -> PutKeyPolicy
s {$sel:policy:PutKeyPolicy' :: Text
policy = Text
a} :: PutKeyPolicy)
instance Core.AWSRequest PutKeyPolicy where
type AWSResponse PutKeyPolicy = PutKeyPolicyResponse
request :: PutKeyPolicy -> Request PutKeyPolicy
request = Service -> PutKeyPolicy -> Request PutKeyPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutKeyPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutKeyPolicy)))
response = AWSResponse PutKeyPolicy
-> Logger
-> Service
-> Proxy PutKeyPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutKeyPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse PutKeyPolicy
PutKeyPolicyResponse
PutKeyPolicyResponse'
instance Prelude.Hashable PutKeyPolicy
instance Prelude.NFData PutKeyPolicy
instance Core.ToHeaders PutKeyPolicy where
toHeaders :: PutKeyPolicy -> [Header]
toHeaders =
[Header] -> PutKeyPolicy -> [Header]
forall a b. a -> b -> a
Prelude.const
( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# (ByteString
"TrentService.PutKeyPolicy" :: Prelude.ByteString),
HeaderName
"Content-Type"
HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON PutKeyPolicy where
toJSON :: PutKeyPolicy -> Value
toJSON PutKeyPolicy' {Maybe Bool
Text
policy :: Text
policyName :: Text
keyId :: Text
bypassPolicyLockoutSafetyCheck :: Maybe Bool
$sel:policy:PutKeyPolicy' :: PutKeyPolicy -> Text
$sel:policyName:PutKeyPolicy' :: PutKeyPolicy -> Text
$sel:keyId:PutKeyPolicy' :: PutKeyPolicy -> Text
$sel:bypassPolicyLockoutSafetyCheck:PutKeyPolicy' :: PutKeyPolicy -> Maybe Bool
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"BypassPolicyLockoutSafetyCheck" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
bypassPolicyLockoutSafetyCheck,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"KeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
keyId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PolicyName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
policyName),
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 PutKeyPolicy where
toPath :: PutKeyPolicy -> ByteString
toPath = ByteString -> PutKeyPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PutKeyPolicy where
toQuery :: PutKeyPolicy -> QueryString
toQuery = QueryString -> PutKeyPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutKeyPolicyResponse = PutKeyPolicyResponse'
{
}
deriving (PutKeyPolicyResponse -> PutKeyPolicyResponse -> Bool
(PutKeyPolicyResponse -> PutKeyPolicyResponse -> Bool)
-> (PutKeyPolicyResponse -> PutKeyPolicyResponse -> Bool)
-> Eq PutKeyPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutKeyPolicyResponse -> PutKeyPolicyResponse -> Bool
$c/= :: PutKeyPolicyResponse -> PutKeyPolicyResponse -> Bool
== :: PutKeyPolicyResponse -> PutKeyPolicyResponse -> Bool
$c== :: PutKeyPolicyResponse -> PutKeyPolicyResponse -> Bool
Prelude.Eq, ReadPrec [PutKeyPolicyResponse]
ReadPrec PutKeyPolicyResponse
Int -> ReadS PutKeyPolicyResponse
ReadS [PutKeyPolicyResponse]
(Int -> ReadS PutKeyPolicyResponse)
-> ReadS [PutKeyPolicyResponse]
-> ReadPrec PutKeyPolicyResponse
-> ReadPrec [PutKeyPolicyResponse]
-> Read PutKeyPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutKeyPolicyResponse]
$creadListPrec :: ReadPrec [PutKeyPolicyResponse]
readPrec :: ReadPrec PutKeyPolicyResponse
$creadPrec :: ReadPrec PutKeyPolicyResponse
readList :: ReadS [PutKeyPolicyResponse]
$creadList :: ReadS [PutKeyPolicyResponse]
readsPrec :: Int -> ReadS PutKeyPolicyResponse
$creadsPrec :: Int -> ReadS PutKeyPolicyResponse
Prelude.Read, Int -> PutKeyPolicyResponse -> ShowS
[PutKeyPolicyResponse] -> ShowS
PutKeyPolicyResponse -> String
(Int -> PutKeyPolicyResponse -> ShowS)
-> (PutKeyPolicyResponse -> String)
-> ([PutKeyPolicyResponse] -> ShowS)
-> Show PutKeyPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutKeyPolicyResponse] -> ShowS
$cshowList :: [PutKeyPolicyResponse] -> ShowS
show :: PutKeyPolicyResponse -> String
$cshow :: PutKeyPolicyResponse -> String
showsPrec :: Int -> PutKeyPolicyResponse -> ShowS
$cshowsPrec :: Int -> PutKeyPolicyResponse -> ShowS
Prelude.Show, (forall x. PutKeyPolicyResponse -> Rep PutKeyPolicyResponse x)
-> (forall x. Rep PutKeyPolicyResponse x -> PutKeyPolicyResponse)
-> Generic PutKeyPolicyResponse
forall x. Rep PutKeyPolicyResponse x -> PutKeyPolicyResponse
forall x. PutKeyPolicyResponse -> Rep PutKeyPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutKeyPolicyResponse x -> PutKeyPolicyResponse
$cfrom :: forall x. PutKeyPolicyResponse -> Rep PutKeyPolicyResponse x
Prelude.Generic)
newPutKeyPolicyResponse ::
PutKeyPolicyResponse
newPutKeyPolicyResponse :: PutKeyPolicyResponse
newPutKeyPolicyResponse = PutKeyPolicyResponse
PutKeyPolicyResponse'
instance Prelude.NFData PutKeyPolicyResponse