{-# 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.Glacier.Types.Encryption where
import qualified Amazonka.Core as Core
import Amazonka.Glacier.Types.EncryptionType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Encryption = Encryption'
{
Encryption -> Maybe EncryptionType
encryptionType :: Prelude.Maybe EncryptionType,
Encryption -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
Encryption -> Maybe Text
kmsContext :: Prelude.Maybe Prelude.Text
}
deriving (Encryption -> Encryption -> Bool
(Encryption -> Encryption -> Bool)
-> (Encryption -> Encryption -> Bool) -> Eq Encryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Encryption -> Encryption -> Bool
$c/= :: Encryption -> Encryption -> Bool
== :: Encryption -> Encryption -> Bool
$c== :: Encryption -> Encryption -> Bool
Prelude.Eq, ReadPrec [Encryption]
ReadPrec Encryption
Int -> ReadS Encryption
ReadS [Encryption]
(Int -> ReadS Encryption)
-> ReadS [Encryption]
-> ReadPrec Encryption
-> ReadPrec [Encryption]
-> Read Encryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Encryption]
$creadListPrec :: ReadPrec [Encryption]
readPrec :: ReadPrec Encryption
$creadPrec :: ReadPrec Encryption
readList :: ReadS [Encryption]
$creadList :: ReadS [Encryption]
readsPrec :: Int -> ReadS Encryption
$creadsPrec :: Int -> ReadS Encryption
Prelude.Read, Int -> Encryption -> ShowS
[Encryption] -> ShowS
Encryption -> String
(Int -> Encryption -> ShowS)
-> (Encryption -> String)
-> ([Encryption] -> ShowS)
-> Show Encryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Encryption] -> ShowS
$cshowList :: [Encryption] -> ShowS
show :: Encryption -> String
$cshow :: Encryption -> String
showsPrec :: Int -> Encryption -> ShowS
$cshowsPrec :: Int -> Encryption -> ShowS
Prelude.Show, (forall x. Encryption -> Rep Encryption x)
-> (forall x. Rep Encryption x -> Encryption) -> Generic Encryption
forall x. Rep Encryption x -> Encryption
forall x. Encryption -> Rep Encryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Encryption x -> Encryption
$cfrom :: forall x. Encryption -> Rep Encryption x
Prelude.Generic)
newEncryption ::
Encryption
newEncryption :: Encryption
newEncryption =
Encryption' :: Maybe EncryptionType -> Maybe Text -> Maybe Text -> Encryption
Encryption'
{ $sel:encryptionType:Encryption' :: Maybe EncryptionType
encryptionType = Maybe EncryptionType
forall a. Maybe a
Prelude.Nothing,
$sel:kmsKeyId:Encryption' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:kmsContext:Encryption' :: Maybe Text
kmsContext = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
encryption_encryptionType :: Lens.Lens' Encryption (Prelude.Maybe EncryptionType)
encryption_encryptionType :: (Maybe EncryptionType -> f (Maybe EncryptionType))
-> Encryption -> f Encryption
encryption_encryptionType = (Encryption -> Maybe EncryptionType)
-> (Encryption -> Maybe EncryptionType -> Encryption)
-> Lens
Encryption Encryption (Maybe EncryptionType) (Maybe EncryptionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Encryption' {Maybe EncryptionType
encryptionType :: Maybe EncryptionType
$sel:encryptionType:Encryption' :: Encryption -> Maybe EncryptionType
encryptionType} -> Maybe EncryptionType
encryptionType) (\s :: Encryption
s@Encryption' {} Maybe EncryptionType
a -> Encryption
s {$sel:encryptionType:Encryption' :: Maybe EncryptionType
encryptionType = Maybe EncryptionType
a} :: Encryption)
encryption_kmsKeyId :: Lens.Lens' Encryption (Prelude.Maybe Prelude.Text)
encryption_kmsKeyId :: (Maybe Text -> f (Maybe Text)) -> Encryption -> f Encryption
encryption_kmsKeyId = (Encryption -> Maybe Text)
-> (Encryption -> Maybe Text -> Encryption)
-> Lens Encryption Encryption (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Encryption' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:Encryption' :: Encryption -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: Encryption
s@Encryption' {} Maybe Text
a -> Encryption
s {$sel:kmsKeyId:Encryption' :: Maybe Text
kmsKeyId = Maybe Text
a} :: Encryption)
encryption_kmsContext :: Lens.Lens' Encryption (Prelude.Maybe Prelude.Text)
encryption_kmsContext :: (Maybe Text -> f (Maybe Text)) -> Encryption -> f Encryption
encryption_kmsContext = (Encryption -> Maybe Text)
-> (Encryption -> Maybe Text -> Encryption)
-> Lens Encryption Encryption (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Encryption' {Maybe Text
kmsContext :: Maybe Text
$sel:kmsContext:Encryption' :: Encryption -> Maybe Text
kmsContext} -> Maybe Text
kmsContext) (\s :: Encryption
s@Encryption' {} Maybe Text
a -> Encryption
s {$sel:kmsContext:Encryption' :: Maybe Text
kmsContext = Maybe Text
a} :: Encryption)
instance Core.FromJSON Encryption where
parseJSON :: Value -> Parser Encryption
parseJSON =
String
-> (Object -> Parser Encryption) -> Value -> Parser Encryption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Encryption"
( \Object
x ->
Maybe EncryptionType -> Maybe Text -> Maybe Text -> Encryption
Encryption'
(Maybe EncryptionType -> Maybe Text -> Maybe Text -> Encryption)
-> Parser (Maybe EncryptionType)
-> Parser (Maybe Text -> Maybe Text -> Encryption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EncryptionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EncryptionType")
Parser (Maybe Text -> Maybe Text -> Encryption)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Encryption)
forall (f :: * -> *) a b. Applicative f => 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
"KMSKeyId")
Parser (Maybe Text -> Encryption)
-> Parser (Maybe Text) -> Parser Encryption
forall (f :: * -> *) a b. Applicative f => 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
"KMSContext")
)
instance Prelude.Hashable Encryption
instance Prelude.NFData Encryption
instance Core.ToJSON Encryption where
toJSON :: Encryption -> Value
toJSON Encryption' {Maybe Text
Maybe EncryptionType
kmsContext :: Maybe Text
kmsKeyId :: Maybe Text
encryptionType :: Maybe EncryptionType
$sel:kmsContext:Encryption' :: Encryption -> Maybe Text
$sel:kmsKeyId:Encryption' :: Encryption -> Maybe Text
$sel:encryptionType:Encryption' :: Encryption -> Maybe EncryptionType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"EncryptionType" Text -> EncryptionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(EncryptionType -> Pair) -> Maybe EncryptionType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionType
encryptionType,
(Text
"KMSKeyId" 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
kmsKeyId,
(Text
"KMSContext" 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
kmsContext
]
)