{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.AccessAnalyzer.Types.KmsGrantConfiguration where
import Amazonka.AccessAnalyzer.Types.KmsGrantConstraints
import Amazonka.AccessAnalyzer.Types.KmsGrantOperation
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data KmsGrantConfiguration = KmsGrantConfiguration'
{
KmsGrantConfiguration -> Maybe Text
retiringPrincipal :: Prelude.Maybe Prelude.Text,
KmsGrantConfiguration -> Maybe KmsGrantConstraints
constraints :: Prelude.Maybe KmsGrantConstraints,
KmsGrantConfiguration -> Text
granteePrincipal :: Prelude.Text,
KmsGrantConfiguration -> Text
issuingAccount :: Prelude.Text,
KmsGrantConfiguration -> [KmsGrantOperation]
operations :: [KmsGrantOperation]
}
deriving (KmsGrantConfiguration -> KmsGrantConfiguration -> Bool
(KmsGrantConfiguration -> KmsGrantConfiguration -> Bool)
-> (KmsGrantConfiguration -> KmsGrantConfiguration -> Bool)
-> Eq KmsGrantConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KmsGrantConfiguration -> KmsGrantConfiguration -> Bool
$c/= :: KmsGrantConfiguration -> KmsGrantConfiguration -> Bool
== :: KmsGrantConfiguration -> KmsGrantConfiguration -> Bool
$c== :: KmsGrantConfiguration -> KmsGrantConfiguration -> Bool
Prelude.Eq, ReadPrec [KmsGrantConfiguration]
ReadPrec KmsGrantConfiguration
Int -> ReadS KmsGrantConfiguration
ReadS [KmsGrantConfiguration]
(Int -> ReadS KmsGrantConfiguration)
-> ReadS [KmsGrantConfiguration]
-> ReadPrec KmsGrantConfiguration
-> ReadPrec [KmsGrantConfiguration]
-> Read KmsGrantConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KmsGrantConfiguration]
$creadListPrec :: ReadPrec [KmsGrantConfiguration]
readPrec :: ReadPrec KmsGrantConfiguration
$creadPrec :: ReadPrec KmsGrantConfiguration
readList :: ReadS [KmsGrantConfiguration]
$creadList :: ReadS [KmsGrantConfiguration]
readsPrec :: Int -> ReadS KmsGrantConfiguration
$creadsPrec :: Int -> ReadS KmsGrantConfiguration
Prelude.Read, Int -> KmsGrantConfiguration -> ShowS
[KmsGrantConfiguration] -> ShowS
KmsGrantConfiguration -> String
(Int -> KmsGrantConfiguration -> ShowS)
-> (KmsGrantConfiguration -> String)
-> ([KmsGrantConfiguration] -> ShowS)
-> Show KmsGrantConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KmsGrantConfiguration] -> ShowS
$cshowList :: [KmsGrantConfiguration] -> ShowS
show :: KmsGrantConfiguration -> String
$cshow :: KmsGrantConfiguration -> String
showsPrec :: Int -> KmsGrantConfiguration -> ShowS
$cshowsPrec :: Int -> KmsGrantConfiguration -> ShowS
Prelude.Show, (forall x. KmsGrantConfiguration -> Rep KmsGrantConfiguration x)
-> (forall x. Rep KmsGrantConfiguration x -> KmsGrantConfiguration)
-> Generic KmsGrantConfiguration
forall x. Rep KmsGrantConfiguration x -> KmsGrantConfiguration
forall x. KmsGrantConfiguration -> Rep KmsGrantConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KmsGrantConfiguration x -> KmsGrantConfiguration
$cfrom :: forall x. KmsGrantConfiguration -> Rep KmsGrantConfiguration x
Prelude.Generic)
newKmsGrantConfiguration ::
Prelude.Text ->
Prelude.Text ->
KmsGrantConfiguration
newKmsGrantConfiguration :: Text -> Text -> KmsGrantConfiguration
newKmsGrantConfiguration
Text
pGranteePrincipal_
Text
pIssuingAccount_ =
KmsGrantConfiguration' :: Maybe Text
-> Maybe KmsGrantConstraints
-> Text
-> Text
-> [KmsGrantOperation]
-> KmsGrantConfiguration
KmsGrantConfiguration'
{ $sel:retiringPrincipal:KmsGrantConfiguration' :: Maybe Text
retiringPrincipal =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:constraints:KmsGrantConfiguration' :: Maybe KmsGrantConstraints
constraints = Maybe KmsGrantConstraints
forall a. Maybe a
Prelude.Nothing,
$sel:granteePrincipal:KmsGrantConfiguration' :: Text
granteePrincipal = Text
pGranteePrincipal_,
$sel:issuingAccount:KmsGrantConfiguration' :: Text
issuingAccount = Text
pIssuingAccount_,
$sel:operations:KmsGrantConfiguration' :: [KmsGrantOperation]
operations = [KmsGrantOperation]
forall a. Monoid a => a
Prelude.mempty
}
kmsGrantConfiguration_retiringPrincipal :: Lens.Lens' KmsGrantConfiguration (Prelude.Maybe Prelude.Text)
kmsGrantConfiguration_retiringPrincipal :: (Maybe Text -> f (Maybe Text))
-> KmsGrantConfiguration -> f KmsGrantConfiguration
kmsGrantConfiguration_retiringPrincipal = (KmsGrantConfiguration -> Maybe Text)
-> (KmsGrantConfiguration -> Maybe Text -> KmsGrantConfiguration)
-> Lens
KmsGrantConfiguration
KmsGrantConfiguration
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KmsGrantConfiguration' {Maybe Text
retiringPrincipal :: Maybe Text
$sel:retiringPrincipal:KmsGrantConfiguration' :: KmsGrantConfiguration -> Maybe Text
retiringPrincipal} -> Maybe Text
retiringPrincipal) (\s :: KmsGrantConfiguration
s@KmsGrantConfiguration' {} Maybe Text
a -> KmsGrantConfiguration
s {$sel:retiringPrincipal:KmsGrantConfiguration' :: Maybe Text
retiringPrincipal = Maybe Text
a} :: KmsGrantConfiguration)
kmsGrantConfiguration_constraints :: Lens.Lens' KmsGrantConfiguration (Prelude.Maybe KmsGrantConstraints)
kmsGrantConfiguration_constraints :: (Maybe KmsGrantConstraints -> f (Maybe KmsGrantConstraints))
-> KmsGrantConfiguration -> f KmsGrantConfiguration
kmsGrantConfiguration_constraints = (KmsGrantConfiguration -> Maybe KmsGrantConstraints)
-> (KmsGrantConfiguration
-> Maybe KmsGrantConstraints -> KmsGrantConfiguration)
-> Lens
KmsGrantConfiguration
KmsGrantConfiguration
(Maybe KmsGrantConstraints)
(Maybe KmsGrantConstraints)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KmsGrantConfiguration' {Maybe KmsGrantConstraints
constraints :: Maybe KmsGrantConstraints
$sel:constraints:KmsGrantConfiguration' :: KmsGrantConfiguration -> Maybe KmsGrantConstraints
constraints} -> Maybe KmsGrantConstraints
constraints) (\s :: KmsGrantConfiguration
s@KmsGrantConfiguration' {} Maybe KmsGrantConstraints
a -> KmsGrantConfiguration
s {$sel:constraints:KmsGrantConfiguration' :: Maybe KmsGrantConstraints
constraints = Maybe KmsGrantConstraints
a} :: KmsGrantConfiguration)
kmsGrantConfiguration_granteePrincipal :: Lens.Lens' KmsGrantConfiguration Prelude.Text
kmsGrantConfiguration_granteePrincipal :: (Text -> f Text)
-> KmsGrantConfiguration -> f KmsGrantConfiguration
kmsGrantConfiguration_granteePrincipal = (KmsGrantConfiguration -> Text)
-> (KmsGrantConfiguration -> Text -> KmsGrantConfiguration)
-> Lens KmsGrantConfiguration KmsGrantConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KmsGrantConfiguration' {Text
granteePrincipal :: Text
$sel:granteePrincipal:KmsGrantConfiguration' :: KmsGrantConfiguration -> Text
granteePrincipal} -> Text
granteePrincipal) (\s :: KmsGrantConfiguration
s@KmsGrantConfiguration' {} Text
a -> KmsGrantConfiguration
s {$sel:granteePrincipal:KmsGrantConfiguration' :: Text
granteePrincipal = Text
a} :: KmsGrantConfiguration)
kmsGrantConfiguration_issuingAccount :: Lens.Lens' KmsGrantConfiguration Prelude.Text
kmsGrantConfiguration_issuingAccount :: (Text -> f Text)
-> KmsGrantConfiguration -> f KmsGrantConfiguration
kmsGrantConfiguration_issuingAccount = (KmsGrantConfiguration -> Text)
-> (KmsGrantConfiguration -> Text -> KmsGrantConfiguration)
-> Lens KmsGrantConfiguration KmsGrantConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KmsGrantConfiguration' {Text
issuingAccount :: Text
$sel:issuingAccount:KmsGrantConfiguration' :: KmsGrantConfiguration -> Text
issuingAccount} -> Text
issuingAccount) (\s :: KmsGrantConfiguration
s@KmsGrantConfiguration' {} Text
a -> KmsGrantConfiguration
s {$sel:issuingAccount:KmsGrantConfiguration' :: Text
issuingAccount = Text
a} :: KmsGrantConfiguration)
kmsGrantConfiguration_operations :: Lens.Lens' KmsGrantConfiguration [KmsGrantOperation]
kmsGrantConfiguration_operations :: ([KmsGrantOperation] -> f [KmsGrantOperation])
-> KmsGrantConfiguration -> f KmsGrantConfiguration
kmsGrantConfiguration_operations = (KmsGrantConfiguration -> [KmsGrantOperation])
-> (KmsGrantConfiguration
-> [KmsGrantOperation] -> KmsGrantConfiguration)
-> Lens
KmsGrantConfiguration
KmsGrantConfiguration
[KmsGrantOperation]
[KmsGrantOperation]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KmsGrantConfiguration' {[KmsGrantOperation]
operations :: [KmsGrantOperation]
$sel:operations:KmsGrantConfiguration' :: KmsGrantConfiguration -> [KmsGrantOperation]
operations} -> [KmsGrantOperation]
operations) (\s :: KmsGrantConfiguration
s@KmsGrantConfiguration' {} [KmsGrantOperation]
a -> KmsGrantConfiguration
s {$sel:operations:KmsGrantConfiguration' :: [KmsGrantOperation]
operations = [KmsGrantOperation]
a} :: KmsGrantConfiguration) (([KmsGrantOperation] -> f [KmsGrantOperation])
-> KmsGrantConfiguration -> f KmsGrantConfiguration)
-> (([KmsGrantOperation] -> f [KmsGrantOperation])
-> [KmsGrantOperation] -> f [KmsGrantOperation])
-> ([KmsGrantOperation] -> f [KmsGrantOperation])
-> KmsGrantConfiguration
-> f KmsGrantConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([KmsGrantOperation] -> f [KmsGrantOperation])
-> [KmsGrantOperation] -> f [KmsGrantOperation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON KmsGrantConfiguration where
parseJSON :: Value -> Parser KmsGrantConfiguration
parseJSON =
String
-> (Object -> Parser KmsGrantConfiguration)
-> Value
-> Parser KmsGrantConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"KmsGrantConfiguration"
( \Object
x ->
Maybe Text
-> Maybe KmsGrantConstraints
-> Text
-> Text
-> [KmsGrantOperation]
-> KmsGrantConfiguration
KmsGrantConfiguration'
(Maybe Text
-> Maybe KmsGrantConstraints
-> Text
-> Text
-> [KmsGrantOperation]
-> KmsGrantConfiguration)
-> Parser (Maybe Text)
-> Parser
(Maybe KmsGrantConstraints
-> Text -> Text -> [KmsGrantOperation] -> KmsGrantConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"retiringPrincipal")
Parser
(Maybe KmsGrantConstraints
-> Text -> Text -> [KmsGrantOperation] -> KmsGrantConfiguration)
-> Parser (Maybe KmsGrantConstraints)
-> Parser
(Text -> Text -> [KmsGrantOperation] -> KmsGrantConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe KmsGrantConstraints)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"constraints")
Parser
(Text -> Text -> [KmsGrantOperation] -> KmsGrantConfiguration)
-> Parser Text
-> Parser (Text -> [KmsGrantOperation] -> KmsGrantConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"granteePrincipal")
Parser (Text -> [KmsGrantOperation] -> KmsGrantConfiguration)
-> Parser Text
-> Parser ([KmsGrantOperation] -> KmsGrantConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"issuingAccount")
Parser ([KmsGrantOperation] -> KmsGrantConfiguration)
-> Parser [KmsGrantOperation] -> Parser KmsGrantConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [KmsGrantOperation])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"operations" Parser (Maybe [KmsGrantOperation])
-> [KmsGrantOperation] -> Parser [KmsGrantOperation]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [KmsGrantOperation]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable KmsGrantConfiguration
instance Prelude.NFData KmsGrantConfiguration
instance Core.ToJSON KmsGrantConfiguration where
toJSON :: KmsGrantConfiguration -> Value
toJSON KmsGrantConfiguration' {[KmsGrantOperation]
Maybe Text
Maybe KmsGrantConstraints
Text
operations :: [KmsGrantOperation]
issuingAccount :: Text
granteePrincipal :: Text
constraints :: Maybe KmsGrantConstraints
retiringPrincipal :: Maybe Text
$sel:operations:KmsGrantConfiguration' :: KmsGrantConfiguration -> [KmsGrantOperation]
$sel:issuingAccount:KmsGrantConfiguration' :: KmsGrantConfiguration -> Text
$sel:granteePrincipal:KmsGrantConfiguration' :: KmsGrantConfiguration -> Text
$sel:constraints:KmsGrantConfiguration' :: KmsGrantConfiguration -> Maybe KmsGrantConstraints
$sel:retiringPrincipal:KmsGrantConfiguration' :: KmsGrantConfiguration -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"retiringPrincipal" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
retiringPrincipal,
(Text
"constraints" Text -> KmsGrantConstraints -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (KmsGrantConstraints -> Pair)
-> Maybe KmsGrantConstraints -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KmsGrantConstraints
constraints,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"granteePrincipal" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
granteePrincipal),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"issuingAccount" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
issuingAccount),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"operations" Text -> [KmsGrantOperation] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [KmsGrantOperation]
operations)
]
)