{-# 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.Sign
(
Sign (..),
newSign,
sign_grantTokens,
sign_messageType,
sign_keyId,
sign_message,
sign_signingAlgorithm,
SignResponse (..),
newSignResponse,
signResponse_keyId,
signResponse_signature,
signResponse_signingAlgorithm,
signResponse_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 Sign = Sign'
{
Sign -> Maybe [Text]
grantTokens :: Prelude.Maybe [Prelude.Text],
Sign -> Maybe MessageType
messageType :: Prelude.Maybe MessageType,
Sign -> Text
keyId :: Prelude.Text,
Sign -> Sensitive Base64
message :: Data.Sensitive Data.Base64,
Sign -> SigningAlgorithmSpec
signingAlgorithm :: SigningAlgorithmSpec
}
deriving (Sign -> Sign -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sign -> Sign -> Bool
$c/= :: Sign -> Sign -> Bool
== :: Sign -> Sign -> Bool
$c== :: Sign -> Sign -> Bool
Prelude.Eq, Int -> Sign -> ShowS
[Sign] -> ShowS
Sign -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sign] -> ShowS
$cshowList :: [Sign] -> ShowS
show :: Sign -> String
$cshow :: Sign -> String
showsPrec :: Int -> Sign -> ShowS
$cshowsPrec :: Int -> Sign -> ShowS
Prelude.Show, forall x. Rep Sign x -> Sign
forall x. Sign -> Rep Sign x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Sign x -> Sign
$cfrom :: forall x. Sign -> Rep Sign x
Prelude.Generic)
newSign ::
Prelude.Text ->
Prelude.ByteString ->
SigningAlgorithmSpec ->
Sign
newSign :: Text -> ByteString -> SigningAlgorithmSpec -> Sign
newSign Text
pKeyId_ ByteString
pMessage_ SigningAlgorithmSpec
pSigningAlgorithm_ =
Sign'
{ $sel:grantTokens:Sign' :: Maybe [Text]
grantTokens = forall a. Maybe a
Prelude.Nothing,
$sel:messageType:Sign' :: Maybe MessageType
messageType = forall a. Maybe a
Prelude.Nothing,
$sel:keyId:Sign' :: Text
keyId = Text
pKeyId_,
$sel:message:Sign' :: Sensitive Base64
message =
forall a. Iso' (Sensitive a) a
Data._Sensitive
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64
forall t b. AReview t b -> b -> t
Lens.# ByteString
pMessage_,
$sel:signingAlgorithm:Sign' :: SigningAlgorithmSpec
signingAlgorithm = SigningAlgorithmSpec
pSigningAlgorithm_
}
sign_grantTokens :: Lens.Lens' Sign (Prelude.Maybe [Prelude.Text])
sign_grantTokens :: Lens' Sign (Maybe [Text])
sign_grantTokens = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sign' {Maybe [Text]
grantTokens :: Maybe [Text]
$sel:grantTokens:Sign' :: Sign -> Maybe [Text]
grantTokens} -> Maybe [Text]
grantTokens) (\s :: Sign
s@Sign' {} Maybe [Text]
a -> Sign
s {$sel:grantTokens:Sign' :: Maybe [Text]
grantTokens = Maybe [Text]
a} :: Sign) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
sign_messageType :: Lens.Lens' Sign (Prelude.Maybe MessageType)
sign_messageType :: Lens' Sign (Maybe MessageType)
sign_messageType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sign' {Maybe MessageType
messageType :: Maybe MessageType
$sel:messageType:Sign' :: Sign -> Maybe MessageType
messageType} -> Maybe MessageType
messageType) (\s :: Sign
s@Sign' {} Maybe MessageType
a -> Sign
s {$sel:messageType:Sign' :: Maybe MessageType
messageType = Maybe MessageType
a} :: Sign)
sign_keyId :: Lens.Lens' Sign Prelude.Text
sign_keyId :: Lens' Sign Text
sign_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sign' {Text
keyId :: Text
$sel:keyId:Sign' :: Sign -> Text
keyId} -> Text
keyId) (\s :: Sign
s@Sign' {} Text
a -> Sign
s {$sel:keyId:Sign' :: Text
keyId = Text
a} :: Sign)
sign_message :: Lens.Lens' Sign Prelude.ByteString
sign_message :: Lens' Sign ByteString
sign_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sign' {Sensitive Base64
message :: Sensitive Base64
$sel:message:Sign' :: Sign -> Sensitive Base64
message} -> Sensitive Base64
message) (\s :: Sign
s@Sign' {} Sensitive Base64
a -> Sign
s {$sel:message:Sign' :: Sensitive Base64
message = Sensitive Base64
a} :: Sign) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64
sign_signingAlgorithm :: Lens.Lens' Sign SigningAlgorithmSpec
sign_signingAlgorithm :: Lens' Sign SigningAlgorithmSpec
sign_signingAlgorithm = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sign' {SigningAlgorithmSpec
signingAlgorithm :: SigningAlgorithmSpec
$sel:signingAlgorithm:Sign' :: Sign -> SigningAlgorithmSpec
signingAlgorithm} -> SigningAlgorithmSpec
signingAlgorithm) (\s :: Sign
s@Sign' {} SigningAlgorithmSpec
a -> Sign
s {$sel:signingAlgorithm:Sign' :: SigningAlgorithmSpec
signingAlgorithm = SigningAlgorithmSpec
a} :: Sign)
instance Core.AWSRequest Sign where
type AWSResponse Sign = SignResponse
request :: (Service -> Service) -> Sign -> Request Sign
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 Sign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse Sign)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text
-> Maybe Base64
-> Maybe SigningAlgorithmSpec
-> Int
-> SignResponse
SignResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"KeyId")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Signature")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"SigningAlgorithm")
forall (f :: * -> *) a b. Applicative f => 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 Sign where
hashWithSalt :: Int -> Sign -> Int
hashWithSalt Int
_salt Sign' {Maybe [Text]
Maybe MessageType
Text
Sensitive Base64
SigningAlgorithmSpec
signingAlgorithm :: SigningAlgorithmSpec
message :: Sensitive Base64
keyId :: Text
messageType :: Maybe MessageType
grantTokens :: Maybe [Text]
$sel:signingAlgorithm:Sign' :: Sign -> SigningAlgorithmSpec
$sel:message:Sign' :: Sign -> Sensitive Base64
$sel:keyId:Sign' :: Sign -> Text
$sel:messageType:Sign' :: Sign -> Maybe MessageType
$sel:grantTokens:Sign' :: Sign -> Maybe [Text]
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
grantTokens
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MessageType
messageType
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
keyId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Base64
message
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SigningAlgorithmSpec
signingAlgorithm
instance Prelude.NFData Sign where
rnf :: Sign -> ()
rnf Sign' {Maybe [Text]
Maybe MessageType
Text
Sensitive Base64
SigningAlgorithmSpec
signingAlgorithm :: SigningAlgorithmSpec
message :: Sensitive Base64
keyId :: Text
messageType :: Maybe MessageType
grantTokens :: Maybe [Text]
$sel:signingAlgorithm:Sign' :: Sign -> SigningAlgorithmSpec
$sel:message:Sign' :: Sign -> Sensitive Base64
$sel:keyId:Sign' :: Sign -> Text
$sel:messageType:Sign' :: Sign -> Maybe MessageType
$sel:grantTokens:Sign' :: Sign -> Maybe [Text]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
grantTokens
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MessageType
messageType
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 Sensitive Base64
message
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SigningAlgorithmSpec
signingAlgorithm
instance Data.ToHeaders Sign where
toHeaders :: Sign -> 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.Sign" :: 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 Sign where
toJSON :: Sign -> Value
toJSON Sign' {Maybe [Text]
Maybe MessageType
Text
Sensitive Base64
SigningAlgorithmSpec
signingAlgorithm :: SigningAlgorithmSpec
message :: Sensitive Base64
keyId :: Text
messageType :: Maybe MessageType
grantTokens :: Maybe [Text]
$sel:signingAlgorithm:Sign' :: Sign -> SigningAlgorithmSpec
$sel:message:Sign' :: Sign -> Sensitive Base64
$sel:keyId:Sign' :: Sign -> Text
$sel:messageType:Sign' :: Sign -> Maybe MessageType
$sel:grantTokens:Sign' :: Sign -> Maybe [Text]
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"GrantTokens" 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 [Text]
grantTokens,
(Key
"MessageType" 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 MessageType
messageType,
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
"Message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Base64
message),
forall a. a -> Maybe a
Prelude.Just
(Key
"SigningAlgorithm" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SigningAlgorithmSpec
signingAlgorithm)
]
)
instance Data.ToPath Sign where
toPath :: Sign -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery Sign where
toQuery :: Sign -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data SignResponse = SignResponse'
{
SignResponse -> Maybe Text
keyId :: Prelude.Maybe Prelude.Text,
SignResponse -> Maybe Base64
signature :: Prelude.Maybe Data.Base64,
SignResponse -> Maybe SigningAlgorithmSpec
signingAlgorithm :: Prelude.Maybe SigningAlgorithmSpec,
SignResponse -> Int
httpStatus :: Prelude.Int
}
deriving (SignResponse -> SignResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignResponse -> SignResponse -> Bool
$c/= :: SignResponse -> SignResponse -> Bool
== :: SignResponse -> SignResponse -> Bool
$c== :: SignResponse -> SignResponse -> Bool
Prelude.Eq, ReadPrec [SignResponse]
ReadPrec SignResponse
Int -> ReadS SignResponse
ReadS [SignResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignResponse]
$creadListPrec :: ReadPrec [SignResponse]
readPrec :: ReadPrec SignResponse
$creadPrec :: ReadPrec SignResponse
readList :: ReadS [SignResponse]
$creadList :: ReadS [SignResponse]
readsPrec :: Int -> ReadS SignResponse
$creadsPrec :: Int -> ReadS SignResponse
Prelude.Read, Int -> SignResponse -> ShowS
[SignResponse] -> ShowS
SignResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignResponse] -> ShowS
$cshowList :: [SignResponse] -> ShowS
show :: SignResponse -> String
$cshow :: SignResponse -> String
showsPrec :: Int -> SignResponse -> ShowS
$cshowsPrec :: Int -> SignResponse -> ShowS
Prelude.Show, forall x. Rep SignResponse x -> SignResponse
forall x. SignResponse -> Rep SignResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SignResponse x -> SignResponse
$cfrom :: forall x. SignResponse -> Rep SignResponse x
Prelude.Generic)
newSignResponse ::
Prelude.Int ->
SignResponse
newSignResponse :: Int -> SignResponse
newSignResponse Int
pHttpStatus_ =
SignResponse'
{ $sel:keyId:SignResponse' :: Maybe Text
keyId = forall a. Maybe a
Prelude.Nothing,
$sel:signature:SignResponse' :: Maybe Base64
signature = forall a. Maybe a
Prelude.Nothing,
$sel:signingAlgorithm:SignResponse' :: Maybe SigningAlgorithmSpec
signingAlgorithm = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:SignResponse' :: Int
httpStatus = Int
pHttpStatus_
}
signResponse_keyId :: Lens.Lens' SignResponse (Prelude.Maybe Prelude.Text)
signResponse_keyId :: Lens' SignResponse (Maybe Text)
signResponse_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignResponse' {Maybe Text
keyId :: Maybe Text
$sel:keyId:SignResponse' :: SignResponse -> Maybe Text
keyId} -> Maybe Text
keyId) (\s :: SignResponse
s@SignResponse' {} Maybe Text
a -> SignResponse
s {$sel:keyId:SignResponse' :: Maybe Text
keyId = Maybe Text
a} :: SignResponse)
signResponse_signature :: Lens.Lens' SignResponse (Prelude.Maybe Prelude.ByteString)
signResponse_signature :: Lens' SignResponse (Maybe ByteString)
signResponse_signature = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignResponse' {Maybe Base64
signature :: Maybe Base64
$sel:signature:SignResponse' :: SignResponse -> Maybe Base64
signature} -> Maybe Base64
signature) (\s :: SignResponse
s@SignResponse' {} Maybe Base64
a -> SignResponse
s {$sel:signature:SignResponse' :: Maybe Base64
signature = Maybe Base64
a} :: SignResponse) 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 Iso' Base64 ByteString
Data._Base64
signResponse_signingAlgorithm :: Lens.Lens' SignResponse (Prelude.Maybe SigningAlgorithmSpec)
signResponse_signingAlgorithm :: Lens' SignResponse (Maybe SigningAlgorithmSpec)
signResponse_signingAlgorithm = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignResponse' {Maybe SigningAlgorithmSpec
signingAlgorithm :: Maybe SigningAlgorithmSpec
$sel:signingAlgorithm:SignResponse' :: SignResponse -> Maybe SigningAlgorithmSpec
signingAlgorithm} -> Maybe SigningAlgorithmSpec
signingAlgorithm) (\s :: SignResponse
s@SignResponse' {} Maybe SigningAlgorithmSpec
a -> SignResponse
s {$sel:signingAlgorithm:SignResponse' :: Maybe SigningAlgorithmSpec
signingAlgorithm = Maybe SigningAlgorithmSpec
a} :: SignResponse)
signResponse_httpStatus :: Lens.Lens' SignResponse Prelude.Int
signResponse_httpStatus :: Lens' SignResponse Int
signResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignResponse' {Int
httpStatus :: Int
$sel:httpStatus:SignResponse' :: SignResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SignResponse
s@SignResponse' {} Int
a -> SignResponse
s {$sel:httpStatus:SignResponse' :: Int
httpStatus = Int
a} :: SignResponse)
instance Prelude.NFData SignResponse where
rnf :: SignResponse -> ()
rnf SignResponse' {Int
Maybe Text
Maybe Base64
Maybe SigningAlgorithmSpec
httpStatus :: Int
signingAlgorithm :: Maybe SigningAlgorithmSpec
signature :: Maybe Base64
keyId :: Maybe Text
$sel:httpStatus:SignResponse' :: SignResponse -> Int
$sel:signingAlgorithm:SignResponse' :: SignResponse -> Maybe SigningAlgorithmSpec
$sel:signature:SignResponse' :: SignResponse -> Maybe Base64
$sel:keyId:SignResponse' :: SignResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Base64
signature
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SigningAlgorithmSpec
signingAlgorithm
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus