{-# 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.KmsKeyConfiguration where
import Amazonka.AccessAnalyzer.Types.KmsGrantConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data KmsKeyConfiguration = KmsKeyConfiguration'
{
KmsKeyConfiguration -> Maybe [KmsGrantConfiguration]
grants :: Prelude.Maybe [KmsGrantConfiguration],
KmsKeyConfiguration -> Maybe (HashMap Text Text)
keyPolicies :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
}
deriving (KmsKeyConfiguration -> KmsKeyConfiguration -> Bool
(KmsKeyConfiguration -> KmsKeyConfiguration -> Bool)
-> (KmsKeyConfiguration -> KmsKeyConfiguration -> Bool)
-> Eq KmsKeyConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KmsKeyConfiguration -> KmsKeyConfiguration -> Bool
$c/= :: KmsKeyConfiguration -> KmsKeyConfiguration -> Bool
== :: KmsKeyConfiguration -> KmsKeyConfiguration -> Bool
$c== :: KmsKeyConfiguration -> KmsKeyConfiguration -> Bool
Prelude.Eq, ReadPrec [KmsKeyConfiguration]
ReadPrec KmsKeyConfiguration
Int -> ReadS KmsKeyConfiguration
ReadS [KmsKeyConfiguration]
(Int -> ReadS KmsKeyConfiguration)
-> ReadS [KmsKeyConfiguration]
-> ReadPrec KmsKeyConfiguration
-> ReadPrec [KmsKeyConfiguration]
-> Read KmsKeyConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KmsKeyConfiguration]
$creadListPrec :: ReadPrec [KmsKeyConfiguration]
readPrec :: ReadPrec KmsKeyConfiguration
$creadPrec :: ReadPrec KmsKeyConfiguration
readList :: ReadS [KmsKeyConfiguration]
$creadList :: ReadS [KmsKeyConfiguration]
readsPrec :: Int -> ReadS KmsKeyConfiguration
$creadsPrec :: Int -> ReadS KmsKeyConfiguration
Prelude.Read, Int -> KmsKeyConfiguration -> ShowS
[KmsKeyConfiguration] -> ShowS
KmsKeyConfiguration -> String
(Int -> KmsKeyConfiguration -> ShowS)
-> (KmsKeyConfiguration -> String)
-> ([KmsKeyConfiguration] -> ShowS)
-> Show KmsKeyConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KmsKeyConfiguration] -> ShowS
$cshowList :: [KmsKeyConfiguration] -> ShowS
show :: KmsKeyConfiguration -> String
$cshow :: KmsKeyConfiguration -> String
showsPrec :: Int -> KmsKeyConfiguration -> ShowS
$cshowsPrec :: Int -> KmsKeyConfiguration -> ShowS
Prelude.Show, (forall x. KmsKeyConfiguration -> Rep KmsKeyConfiguration x)
-> (forall x. Rep KmsKeyConfiguration x -> KmsKeyConfiguration)
-> Generic KmsKeyConfiguration
forall x. Rep KmsKeyConfiguration x -> KmsKeyConfiguration
forall x. KmsKeyConfiguration -> Rep KmsKeyConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KmsKeyConfiguration x -> KmsKeyConfiguration
$cfrom :: forall x. KmsKeyConfiguration -> Rep KmsKeyConfiguration x
Prelude.Generic)
newKmsKeyConfiguration ::
KmsKeyConfiguration
newKmsKeyConfiguration :: KmsKeyConfiguration
newKmsKeyConfiguration =
KmsKeyConfiguration' :: Maybe [KmsGrantConfiguration]
-> Maybe (HashMap Text Text) -> KmsKeyConfiguration
KmsKeyConfiguration'
{ $sel:grants:KmsKeyConfiguration' :: Maybe [KmsGrantConfiguration]
grants = Maybe [KmsGrantConfiguration]
forall a. Maybe a
Prelude.Nothing,
$sel:keyPolicies:KmsKeyConfiguration' :: Maybe (HashMap Text Text)
keyPolicies = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
}
kmsKeyConfiguration_grants :: Lens.Lens' KmsKeyConfiguration (Prelude.Maybe [KmsGrantConfiguration])
kmsKeyConfiguration_grants :: (Maybe [KmsGrantConfiguration]
-> f (Maybe [KmsGrantConfiguration]))
-> KmsKeyConfiguration -> f KmsKeyConfiguration
kmsKeyConfiguration_grants = (KmsKeyConfiguration -> Maybe [KmsGrantConfiguration])
-> (KmsKeyConfiguration
-> Maybe [KmsGrantConfiguration] -> KmsKeyConfiguration)
-> Lens
KmsKeyConfiguration
KmsKeyConfiguration
(Maybe [KmsGrantConfiguration])
(Maybe [KmsGrantConfiguration])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KmsKeyConfiguration' {Maybe [KmsGrantConfiguration]
grants :: Maybe [KmsGrantConfiguration]
$sel:grants:KmsKeyConfiguration' :: KmsKeyConfiguration -> Maybe [KmsGrantConfiguration]
grants} -> Maybe [KmsGrantConfiguration]
grants) (\s :: KmsKeyConfiguration
s@KmsKeyConfiguration' {} Maybe [KmsGrantConfiguration]
a -> KmsKeyConfiguration
s {$sel:grants:KmsKeyConfiguration' :: Maybe [KmsGrantConfiguration]
grants = Maybe [KmsGrantConfiguration]
a} :: KmsKeyConfiguration) ((Maybe [KmsGrantConfiguration]
-> f (Maybe [KmsGrantConfiguration]))
-> KmsKeyConfiguration -> f KmsKeyConfiguration)
-> ((Maybe [KmsGrantConfiguration]
-> f (Maybe [KmsGrantConfiguration]))
-> Maybe [KmsGrantConfiguration]
-> f (Maybe [KmsGrantConfiguration]))
-> (Maybe [KmsGrantConfiguration]
-> f (Maybe [KmsGrantConfiguration]))
-> KmsKeyConfiguration
-> f KmsKeyConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[KmsGrantConfiguration]
[KmsGrantConfiguration]
[KmsGrantConfiguration]
[KmsGrantConfiguration]
-> Iso
(Maybe [KmsGrantConfiguration])
(Maybe [KmsGrantConfiguration])
(Maybe [KmsGrantConfiguration])
(Maybe [KmsGrantConfiguration])
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 AnIso
[KmsGrantConfiguration]
[KmsGrantConfiguration]
[KmsGrantConfiguration]
[KmsGrantConfiguration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
kmsKeyConfiguration_keyPolicies :: Lens.Lens' KmsKeyConfiguration (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
kmsKeyConfiguration_keyPolicies :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> KmsKeyConfiguration -> f KmsKeyConfiguration
kmsKeyConfiguration_keyPolicies = (KmsKeyConfiguration -> Maybe (HashMap Text Text))
-> (KmsKeyConfiguration
-> Maybe (HashMap Text Text) -> KmsKeyConfiguration)
-> Lens
KmsKeyConfiguration
KmsKeyConfiguration
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KmsKeyConfiguration' {Maybe (HashMap Text Text)
keyPolicies :: Maybe (HashMap Text Text)
$sel:keyPolicies:KmsKeyConfiguration' :: KmsKeyConfiguration -> Maybe (HashMap Text Text)
keyPolicies} -> Maybe (HashMap Text Text)
keyPolicies) (\s :: KmsKeyConfiguration
s@KmsKeyConfiguration' {} Maybe (HashMap Text Text)
a -> KmsKeyConfiguration
s {$sel:keyPolicies:KmsKeyConfiguration' :: Maybe (HashMap Text Text)
keyPolicies = Maybe (HashMap Text Text)
a} :: KmsKeyConfiguration) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> KmsKeyConfiguration -> f KmsKeyConfiguration)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> KmsKeyConfiguration
-> f KmsKeyConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
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 AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON KmsKeyConfiguration where
parseJSON :: Value -> Parser KmsKeyConfiguration
parseJSON =
String
-> (Object -> Parser KmsKeyConfiguration)
-> Value
-> Parser KmsKeyConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"KmsKeyConfiguration"
( \Object
x ->
Maybe [KmsGrantConfiguration]
-> Maybe (HashMap Text Text) -> KmsKeyConfiguration
KmsKeyConfiguration'
(Maybe [KmsGrantConfiguration]
-> Maybe (HashMap Text Text) -> KmsKeyConfiguration)
-> Parser (Maybe [KmsGrantConfiguration])
-> Parser (Maybe (HashMap Text Text) -> KmsKeyConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [KmsGrantConfiguration]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"grants" Parser (Maybe (Maybe [KmsGrantConfiguration]))
-> Maybe [KmsGrantConfiguration]
-> Parser (Maybe [KmsGrantConfiguration])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [KmsGrantConfiguration]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe (HashMap Text Text) -> KmsKeyConfiguration)
-> Parser (Maybe (HashMap Text Text)) -> Parser KmsKeyConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"keyPolicies" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable KmsKeyConfiguration
instance Prelude.NFData KmsKeyConfiguration
instance Core.ToJSON KmsKeyConfiguration where
toJSON :: KmsKeyConfiguration -> Value
toJSON KmsKeyConfiguration' {Maybe [KmsGrantConfiguration]
Maybe (HashMap Text Text)
keyPolicies :: Maybe (HashMap Text Text)
grants :: Maybe [KmsGrantConfiguration]
$sel:keyPolicies:KmsKeyConfiguration' :: KmsKeyConfiguration -> Maybe (HashMap Text Text)
$sel:grants:KmsKeyConfiguration' :: KmsKeyConfiguration -> Maybe [KmsGrantConfiguration]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"grants" Text -> [KmsGrantConfiguration] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([KmsGrantConfiguration] -> Pair)
-> Maybe [KmsGrantConfiguration] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [KmsGrantConfiguration]
grants,
(Text
"keyPolicies" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
keyPolicies
]
)