{-# 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.ImportKeyMaterial
(
ImportKeyMaterial (..),
newImportKeyMaterial,
importKeyMaterial_expirationModel,
importKeyMaterial_validTo,
importKeyMaterial_keyId,
importKeyMaterial_importToken,
importKeyMaterial_encryptedKeyMaterial,
ImportKeyMaterialResponse (..),
newImportKeyMaterialResponse,
importKeyMaterialResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KMS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ImportKeyMaterial = ImportKeyMaterial'
{
ImportKeyMaterial -> Maybe ExpirationModelType
expirationModel :: Prelude.Maybe ExpirationModelType,
ImportKeyMaterial -> Maybe POSIX
validTo :: Prelude.Maybe Data.POSIX,
ImportKeyMaterial -> Text
keyId :: Prelude.Text,
ImportKeyMaterial -> Base64
importToken :: Data.Base64,
ImportKeyMaterial -> Base64
encryptedKeyMaterial :: Data.Base64
}
deriving (ImportKeyMaterial -> ImportKeyMaterial -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportKeyMaterial -> ImportKeyMaterial -> Bool
$c/= :: ImportKeyMaterial -> ImportKeyMaterial -> Bool
== :: ImportKeyMaterial -> ImportKeyMaterial -> Bool
$c== :: ImportKeyMaterial -> ImportKeyMaterial -> Bool
Prelude.Eq, ReadPrec [ImportKeyMaterial]
ReadPrec ImportKeyMaterial
Int -> ReadS ImportKeyMaterial
ReadS [ImportKeyMaterial]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportKeyMaterial]
$creadListPrec :: ReadPrec [ImportKeyMaterial]
readPrec :: ReadPrec ImportKeyMaterial
$creadPrec :: ReadPrec ImportKeyMaterial
readList :: ReadS [ImportKeyMaterial]
$creadList :: ReadS [ImportKeyMaterial]
readsPrec :: Int -> ReadS ImportKeyMaterial
$creadsPrec :: Int -> ReadS ImportKeyMaterial
Prelude.Read, Int -> ImportKeyMaterial -> ShowS
[ImportKeyMaterial] -> ShowS
ImportKeyMaterial -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportKeyMaterial] -> ShowS
$cshowList :: [ImportKeyMaterial] -> ShowS
show :: ImportKeyMaterial -> String
$cshow :: ImportKeyMaterial -> String
showsPrec :: Int -> ImportKeyMaterial -> ShowS
$cshowsPrec :: Int -> ImportKeyMaterial -> ShowS
Prelude.Show, forall x. Rep ImportKeyMaterial x -> ImportKeyMaterial
forall x. ImportKeyMaterial -> Rep ImportKeyMaterial x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportKeyMaterial x -> ImportKeyMaterial
$cfrom :: forall x. ImportKeyMaterial -> Rep ImportKeyMaterial x
Prelude.Generic)
newImportKeyMaterial ::
Prelude.Text ->
Prelude.ByteString ->
Prelude.ByteString ->
ImportKeyMaterial
newImportKeyMaterial :: Text -> ByteString -> ByteString -> ImportKeyMaterial
newImportKeyMaterial
Text
pKeyId_
ByteString
pImportToken_
ByteString
pEncryptedKeyMaterial_ =
ImportKeyMaterial'
{ $sel:expirationModel:ImportKeyMaterial' :: Maybe ExpirationModelType
expirationModel =
forall a. Maybe a
Prelude.Nothing,
$sel:validTo:ImportKeyMaterial' :: Maybe POSIX
validTo = forall a. Maybe a
Prelude.Nothing,
$sel:keyId:ImportKeyMaterial' :: Text
keyId = Text
pKeyId_,
$sel:importToken:ImportKeyMaterial' :: Base64
importToken = Iso' Base64 ByteString
Data._Base64 forall t b. AReview t b -> b -> t
Lens.# ByteString
pImportToken_,
$sel:encryptedKeyMaterial:ImportKeyMaterial' :: Base64
encryptedKeyMaterial =
Iso' Base64 ByteString
Data._Base64 forall t b. AReview t b -> b -> t
Lens.# ByteString
pEncryptedKeyMaterial_
}
importKeyMaterial_expirationModel :: Lens.Lens' ImportKeyMaterial (Prelude.Maybe ExpirationModelType)
importKeyMaterial_expirationModel :: Lens' ImportKeyMaterial (Maybe ExpirationModelType)
importKeyMaterial_expirationModel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportKeyMaterial' {Maybe ExpirationModelType
expirationModel :: Maybe ExpirationModelType
$sel:expirationModel:ImportKeyMaterial' :: ImportKeyMaterial -> Maybe ExpirationModelType
expirationModel} -> Maybe ExpirationModelType
expirationModel) (\s :: ImportKeyMaterial
s@ImportKeyMaterial' {} Maybe ExpirationModelType
a -> ImportKeyMaterial
s {$sel:expirationModel:ImportKeyMaterial' :: Maybe ExpirationModelType
expirationModel = Maybe ExpirationModelType
a} :: ImportKeyMaterial)
importKeyMaterial_validTo :: Lens.Lens' ImportKeyMaterial (Prelude.Maybe Prelude.UTCTime)
importKeyMaterial_validTo :: Lens' ImportKeyMaterial (Maybe UTCTime)
importKeyMaterial_validTo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportKeyMaterial' {Maybe POSIX
validTo :: Maybe POSIX
$sel:validTo:ImportKeyMaterial' :: ImportKeyMaterial -> Maybe POSIX
validTo} -> Maybe POSIX
validTo) (\s :: ImportKeyMaterial
s@ImportKeyMaterial' {} Maybe POSIX
a -> ImportKeyMaterial
s {$sel:validTo:ImportKeyMaterial' :: Maybe POSIX
validTo = Maybe POSIX
a} :: ImportKeyMaterial) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time
importKeyMaterial_keyId :: Lens.Lens' ImportKeyMaterial Prelude.Text
importKeyMaterial_keyId :: Lens' ImportKeyMaterial Text
importKeyMaterial_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportKeyMaterial' {Text
keyId :: Text
$sel:keyId:ImportKeyMaterial' :: ImportKeyMaterial -> Text
keyId} -> Text
keyId) (\s :: ImportKeyMaterial
s@ImportKeyMaterial' {} Text
a -> ImportKeyMaterial
s {$sel:keyId:ImportKeyMaterial' :: Text
keyId = Text
a} :: ImportKeyMaterial)
importKeyMaterial_importToken :: Lens.Lens' ImportKeyMaterial Prelude.ByteString
importKeyMaterial_importToken :: Lens' ImportKeyMaterial ByteString
importKeyMaterial_importToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportKeyMaterial' {Base64
importToken :: Base64
$sel:importToken:ImportKeyMaterial' :: ImportKeyMaterial -> Base64
importToken} -> Base64
importToken) (\s :: ImportKeyMaterial
s@ImportKeyMaterial' {} Base64
a -> ImportKeyMaterial
s {$sel:importToken:ImportKeyMaterial' :: Base64
importToken = Base64
a} :: ImportKeyMaterial) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64
importKeyMaterial_encryptedKeyMaterial :: Lens.Lens' ImportKeyMaterial Prelude.ByteString
importKeyMaterial_encryptedKeyMaterial :: Lens' ImportKeyMaterial ByteString
importKeyMaterial_encryptedKeyMaterial = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportKeyMaterial' {Base64
encryptedKeyMaterial :: Base64
$sel:encryptedKeyMaterial:ImportKeyMaterial' :: ImportKeyMaterial -> Base64
encryptedKeyMaterial} -> Base64
encryptedKeyMaterial) (\s :: ImportKeyMaterial
s@ImportKeyMaterial' {} Base64
a -> ImportKeyMaterial
s {$sel:encryptedKeyMaterial:ImportKeyMaterial' :: Base64
encryptedKeyMaterial = Base64
a} :: ImportKeyMaterial) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64
instance Core.AWSRequest ImportKeyMaterial where
type
AWSResponse ImportKeyMaterial =
ImportKeyMaterialResponse
request :: (Service -> Service)
-> ImportKeyMaterial -> Request ImportKeyMaterial
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 ImportKeyMaterial
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ImportKeyMaterial)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> ImportKeyMaterialResponse
ImportKeyMaterialResponse'
forall (f :: * -> *) a b. Functor 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 ImportKeyMaterial where
hashWithSalt :: Int -> ImportKeyMaterial -> Int
hashWithSalt Int
_salt ImportKeyMaterial' {Maybe POSIX
Maybe ExpirationModelType
Text
Base64
encryptedKeyMaterial :: Base64
importToken :: Base64
keyId :: Text
validTo :: Maybe POSIX
expirationModel :: Maybe ExpirationModelType
$sel:encryptedKeyMaterial:ImportKeyMaterial' :: ImportKeyMaterial -> Base64
$sel:importToken:ImportKeyMaterial' :: ImportKeyMaterial -> Base64
$sel:keyId:ImportKeyMaterial' :: ImportKeyMaterial -> Text
$sel:validTo:ImportKeyMaterial' :: ImportKeyMaterial -> Maybe POSIX
$sel:expirationModel:ImportKeyMaterial' :: ImportKeyMaterial -> Maybe ExpirationModelType
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ExpirationModelType
expirationModel
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
validTo
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
keyId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Base64
importToken
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Base64
encryptedKeyMaterial
instance Prelude.NFData ImportKeyMaterial where
rnf :: ImportKeyMaterial -> ()
rnf ImportKeyMaterial' {Maybe POSIX
Maybe ExpirationModelType
Text
Base64
encryptedKeyMaterial :: Base64
importToken :: Base64
keyId :: Text
validTo :: Maybe POSIX
expirationModel :: Maybe ExpirationModelType
$sel:encryptedKeyMaterial:ImportKeyMaterial' :: ImportKeyMaterial -> Base64
$sel:importToken:ImportKeyMaterial' :: ImportKeyMaterial -> Base64
$sel:keyId:ImportKeyMaterial' :: ImportKeyMaterial -> Text
$sel:validTo:ImportKeyMaterial' :: ImportKeyMaterial -> Maybe POSIX
$sel:expirationModel:ImportKeyMaterial' :: ImportKeyMaterial -> Maybe ExpirationModelType
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe ExpirationModelType
expirationModel
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
validTo
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
keyId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Base64
importToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Base64
encryptedKeyMaterial
instance Data.ToHeaders ImportKeyMaterial where
toHeaders :: ImportKeyMaterial -> 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
"TrentService.ImportKeyMaterial" ::
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 ImportKeyMaterial where
toJSON :: ImportKeyMaterial -> Value
toJSON ImportKeyMaterial' {Maybe POSIX
Maybe ExpirationModelType
Text
Base64
encryptedKeyMaterial :: Base64
importToken :: Base64
keyId :: Text
validTo :: Maybe POSIX
expirationModel :: Maybe ExpirationModelType
$sel:encryptedKeyMaterial:ImportKeyMaterial' :: ImportKeyMaterial -> Base64
$sel:importToken:ImportKeyMaterial' :: ImportKeyMaterial -> Base64
$sel:keyId:ImportKeyMaterial' :: ImportKeyMaterial -> Text
$sel:validTo:ImportKeyMaterial' :: ImportKeyMaterial -> Maybe POSIX
$sel:expirationModel:ImportKeyMaterial' :: ImportKeyMaterial -> Maybe ExpirationModelType
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"ExpirationModel" 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 ExpirationModelType
expirationModel,
(Key
"ValidTo" 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 POSIX
validTo,
forall a. a -> Maybe a
Prelude.Just (Key
"KeyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
keyId),
forall a. a -> Maybe a
Prelude.Just (Key
"ImportToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Base64
importToken),
forall a. a -> Maybe a
Prelude.Just
( Key
"EncryptedKeyMaterial"
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Base64
encryptedKeyMaterial
)
]
)
instance Data.ToPath ImportKeyMaterial where
toPath :: ImportKeyMaterial -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery ImportKeyMaterial where
toQuery :: ImportKeyMaterial -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data ImportKeyMaterialResponse = ImportKeyMaterialResponse'
{
ImportKeyMaterialResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ImportKeyMaterialResponse -> ImportKeyMaterialResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportKeyMaterialResponse -> ImportKeyMaterialResponse -> Bool
$c/= :: ImportKeyMaterialResponse -> ImportKeyMaterialResponse -> Bool
== :: ImportKeyMaterialResponse -> ImportKeyMaterialResponse -> Bool
$c== :: ImportKeyMaterialResponse -> ImportKeyMaterialResponse -> Bool
Prelude.Eq, ReadPrec [ImportKeyMaterialResponse]
ReadPrec ImportKeyMaterialResponse
Int -> ReadS ImportKeyMaterialResponse
ReadS [ImportKeyMaterialResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportKeyMaterialResponse]
$creadListPrec :: ReadPrec [ImportKeyMaterialResponse]
readPrec :: ReadPrec ImportKeyMaterialResponse
$creadPrec :: ReadPrec ImportKeyMaterialResponse
readList :: ReadS [ImportKeyMaterialResponse]
$creadList :: ReadS [ImportKeyMaterialResponse]
readsPrec :: Int -> ReadS ImportKeyMaterialResponse
$creadsPrec :: Int -> ReadS ImportKeyMaterialResponse
Prelude.Read, Int -> ImportKeyMaterialResponse -> ShowS
[ImportKeyMaterialResponse] -> ShowS
ImportKeyMaterialResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportKeyMaterialResponse] -> ShowS
$cshowList :: [ImportKeyMaterialResponse] -> ShowS
show :: ImportKeyMaterialResponse -> String
$cshow :: ImportKeyMaterialResponse -> String
showsPrec :: Int -> ImportKeyMaterialResponse -> ShowS
$cshowsPrec :: Int -> ImportKeyMaterialResponse -> ShowS
Prelude.Show, forall x.
Rep ImportKeyMaterialResponse x -> ImportKeyMaterialResponse
forall x.
ImportKeyMaterialResponse -> Rep ImportKeyMaterialResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ImportKeyMaterialResponse x -> ImportKeyMaterialResponse
$cfrom :: forall x.
ImportKeyMaterialResponse -> Rep ImportKeyMaterialResponse x
Prelude.Generic)
newImportKeyMaterialResponse ::
Prelude.Int ->
ImportKeyMaterialResponse
newImportKeyMaterialResponse :: Int -> ImportKeyMaterialResponse
newImportKeyMaterialResponse Int
pHttpStatus_ =
ImportKeyMaterialResponse'
{ $sel:httpStatus:ImportKeyMaterialResponse' :: Int
httpStatus =
Int
pHttpStatus_
}
importKeyMaterialResponse_httpStatus :: Lens.Lens' ImportKeyMaterialResponse Prelude.Int
importKeyMaterialResponse_httpStatus :: Lens' ImportKeyMaterialResponse Int
importKeyMaterialResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportKeyMaterialResponse' {Int
httpStatus :: Int
$sel:httpStatus:ImportKeyMaterialResponse' :: ImportKeyMaterialResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ImportKeyMaterialResponse
s@ImportKeyMaterialResponse' {} Int
a -> ImportKeyMaterialResponse
s {$sel:httpStatus:ImportKeyMaterialResponse' :: Int
httpStatus = Int
a} :: ImportKeyMaterialResponse)
instance Prelude.NFData ImportKeyMaterialResponse where
rnf :: ImportKeyMaterialResponse -> ()
rnf ImportKeyMaterialResponse' {Int
httpStatus :: Int
$sel:httpStatus:ImportKeyMaterialResponse' :: ImportKeyMaterialResponse -> Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus