{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.KMS.GenerateMac
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Generates a hash-based message authentication code (HMAC) for a message
-- using an HMAC KMS key and a MAC algorithm that the key supports. HMAC
-- KMS keys and the HMAC algorithms that KMS uses conform to industry
-- standards defined in
-- <https://datatracker.ietf.org/doc/html/rfc2104 RFC 2104>.
--
-- You can use value that GenerateMac returns in the VerifyMac operation to
-- demonstrate that the original message has not changed. Also, because a
-- secret key is used to create the hash, you can verify that the party
-- that generated the hash has the required secret key. You can also use
-- the raw result to implement HMAC-based algorithms such as key derivation
-- functions. This operation is part of KMS support for HMAC KMS keys. For
-- details, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/hmac.html HMAC keys in KMS>
-- in the //Key Management Service Developer Guide// .
--
-- Best practices recommend that you limit the time during which any
-- signing mechanism, including an HMAC, is effective. This deters an
-- attack where the actor uses a signed message to establish validity
-- repeatedly or long after the message is superseded. HMAC tags do not
-- include a timestamp, but you can include a timestamp in the token or
-- message to help you detect when its time to refresh the HMAC.
--
-- The KMS key that you use for this operation must be in a compatible key
-- state. For details, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html Key states of KMS keys>
-- in the /Key Management Service Developer Guide/.
--
-- __Cross-account use__: Yes. To perform this operation with a KMS key in
-- a different Amazon Web Services account, specify the key ARN or alias
-- ARN in the value of the @KeyId@ parameter.
--
-- __Required permissions__:
-- <https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html kms:GenerateMac>
-- (key policy)
--
-- __Related operations__: VerifyMac
module Amazonka.KMS.GenerateMac
  ( -- * Creating a Request
    GenerateMac (..),
    newGenerateMac,

    -- * Request Lenses
    generateMac_grantTokens,
    generateMac_message,
    generateMac_keyId,
    generateMac_macAlgorithm,

    -- * Destructuring the Response
    GenerateMacResponse (..),
    newGenerateMacResponse,

    -- * Response Lenses
    generateMacResponse_keyId,
    generateMacResponse_mac,
    generateMacResponse_macAlgorithm,
    generateMacResponse_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

-- | /See:/ 'newGenerateMac' smart constructor.
data GenerateMac = GenerateMac'
  { -- | A list of grant tokens.
    --
    -- Use a grant token when your permission to call this operation comes from
    -- a new grant that has not yet achieved /eventual consistency/. For more
    -- information, see
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#grant_token Grant token>
    -- and
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/grant-manage.html#using-grant-token Using a grant token>
    -- in the /Key Management Service Developer Guide/.
    GenerateMac -> Maybe [Text]
grantTokens :: Prelude.Maybe [Prelude.Text],
    -- | The message to be hashed. Specify a message of up to 4,096 bytes.
    --
    -- @GenerateMac@ and VerifyMac do not provide special handling for message
    -- digests. If you generate an HMAC for a hash digest of a message, you
    -- must verify the HMAC of the same hash digest.
    GenerateMac -> Sensitive Base64
message :: Data.Sensitive Data.Base64,
    -- | The HMAC KMS key to use in the operation. The MAC algorithm computes the
    -- HMAC for the message and the key as described in
    -- <https://datatracker.ietf.org/doc/html/rfc2104 RFC 2104>.
    --
    -- To identify an HMAC KMS key, use the DescribeKey operation and see the
    -- @KeySpec@ field in the response.
    GenerateMac -> Text
keyId :: Prelude.Text,
    -- | The MAC algorithm used in the operation.
    --
    -- The algorithm must be compatible with the HMAC KMS key that you specify.
    -- To find the MAC algorithms that your HMAC KMS key supports, use the
    -- DescribeKey operation and see the @MacAlgorithms@ field in the
    -- @DescribeKey@ response.
    GenerateMac -> MacAlgorithmSpec
macAlgorithm :: MacAlgorithmSpec
  }
  deriving (GenerateMac -> GenerateMac -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GenerateMac -> GenerateMac -> Bool
$c/= :: GenerateMac -> GenerateMac -> Bool
== :: GenerateMac -> GenerateMac -> Bool
$c== :: GenerateMac -> GenerateMac -> Bool
Prelude.Eq, Int -> GenerateMac -> ShowS
[GenerateMac] -> ShowS
GenerateMac -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GenerateMac] -> ShowS
$cshowList :: [GenerateMac] -> ShowS
show :: GenerateMac -> String
$cshow :: GenerateMac -> String
showsPrec :: Int -> GenerateMac -> ShowS
$cshowsPrec :: Int -> GenerateMac -> ShowS
Prelude.Show, forall x. Rep GenerateMac x -> GenerateMac
forall x. GenerateMac -> Rep GenerateMac x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GenerateMac x -> GenerateMac
$cfrom :: forall x. GenerateMac -> Rep GenerateMac x
Prelude.Generic)

-- |
-- Create a value of 'GenerateMac' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'grantTokens', 'generateMac_grantTokens' - A list of grant tokens.
--
-- Use a grant token when your permission to call this operation comes from
-- a new grant that has not yet achieved /eventual consistency/. For more
-- information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#grant_token Grant token>
-- and
-- <https://docs.aws.amazon.com/kms/latest/developerguide/grant-manage.html#using-grant-token Using a grant token>
-- in the /Key Management Service Developer Guide/.
--
-- 'message', 'generateMac_message' - The message to be hashed. Specify a message of up to 4,096 bytes.
--
-- @GenerateMac@ and VerifyMac do not provide special handling for message
-- digests. If you generate an HMAC for a hash digest of a message, you
-- must verify the HMAC of the same hash digest.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'keyId', 'generateMac_keyId' - The HMAC KMS key to use in the operation. The MAC algorithm computes the
-- HMAC for the message and the key as described in
-- <https://datatracker.ietf.org/doc/html/rfc2104 RFC 2104>.
--
-- To identify an HMAC KMS key, use the DescribeKey operation and see the
-- @KeySpec@ field in the response.
--
-- 'macAlgorithm', 'generateMac_macAlgorithm' - The MAC algorithm used in the operation.
--
-- The algorithm must be compatible with the HMAC KMS key that you specify.
-- To find the MAC algorithms that your HMAC KMS key supports, use the
-- DescribeKey operation and see the @MacAlgorithms@ field in the
-- @DescribeKey@ response.
newGenerateMac ::
  -- | 'message'
  Prelude.ByteString ->
  -- | 'keyId'
  Prelude.Text ->
  -- | 'macAlgorithm'
  MacAlgorithmSpec ->
  GenerateMac
newGenerateMac :: ByteString -> Text -> MacAlgorithmSpec -> GenerateMac
newGenerateMac ByteString
pMessage_ Text
pKeyId_ MacAlgorithmSpec
pMacAlgorithm_ =
  GenerateMac'
    { $sel:grantTokens:GenerateMac' :: Maybe [Text]
grantTokens = forall a. Maybe a
Prelude.Nothing,
      $sel:message:GenerateMac' :: 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:keyId:GenerateMac' :: Text
keyId = Text
pKeyId_,
      $sel:macAlgorithm:GenerateMac' :: MacAlgorithmSpec
macAlgorithm = MacAlgorithmSpec
pMacAlgorithm_
    }

-- | A list of grant tokens.
--
-- Use a grant token when your permission to call this operation comes from
-- a new grant that has not yet achieved /eventual consistency/. For more
-- information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#grant_token Grant token>
-- and
-- <https://docs.aws.amazon.com/kms/latest/developerguide/grant-manage.html#using-grant-token Using a grant token>
-- in the /Key Management Service Developer Guide/.
generateMac_grantTokens :: Lens.Lens' GenerateMac (Prelude.Maybe [Prelude.Text])
generateMac_grantTokens :: Lens' GenerateMac (Maybe [Text])
generateMac_grantTokens = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateMac' {Maybe [Text]
grantTokens :: Maybe [Text]
$sel:grantTokens:GenerateMac' :: GenerateMac -> Maybe [Text]
grantTokens} -> Maybe [Text]
grantTokens) (\s :: GenerateMac
s@GenerateMac' {} Maybe [Text]
a -> GenerateMac
s {$sel:grantTokens:GenerateMac' :: Maybe [Text]
grantTokens = Maybe [Text]
a} :: GenerateMac) 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

-- | The message to be hashed. Specify a message of up to 4,096 bytes.
--
-- @GenerateMac@ and VerifyMac do not provide special handling for message
-- digests. If you generate an HMAC for a hash digest of a message, you
-- must verify the HMAC of the same hash digest.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
generateMac_message :: Lens.Lens' GenerateMac Prelude.ByteString
generateMac_message :: Lens' GenerateMac ByteString
generateMac_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateMac' {Sensitive Base64
message :: Sensitive Base64
$sel:message:GenerateMac' :: GenerateMac -> Sensitive Base64
message} -> Sensitive Base64
message) (\s :: GenerateMac
s@GenerateMac' {} Sensitive Base64
a -> GenerateMac
s {$sel:message:GenerateMac' :: Sensitive Base64
message = Sensitive Base64
a} :: GenerateMac) 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

-- | The HMAC KMS key to use in the operation. The MAC algorithm computes the
-- HMAC for the message and the key as described in
-- <https://datatracker.ietf.org/doc/html/rfc2104 RFC 2104>.
--
-- To identify an HMAC KMS key, use the DescribeKey operation and see the
-- @KeySpec@ field in the response.
generateMac_keyId :: Lens.Lens' GenerateMac Prelude.Text
generateMac_keyId :: Lens' GenerateMac Text
generateMac_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateMac' {Text
keyId :: Text
$sel:keyId:GenerateMac' :: GenerateMac -> Text
keyId} -> Text
keyId) (\s :: GenerateMac
s@GenerateMac' {} Text
a -> GenerateMac
s {$sel:keyId:GenerateMac' :: Text
keyId = Text
a} :: GenerateMac)

-- | The MAC algorithm used in the operation.
--
-- The algorithm must be compatible with the HMAC KMS key that you specify.
-- To find the MAC algorithms that your HMAC KMS key supports, use the
-- DescribeKey operation and see the @MacAlgorithms@ field in the
-- @DescribeKey@ response.
generateMac_macAlgorithm :: Lens.Lens' GenerateMac MacAlgorithmSpec
generateMac_macAlgorithm :: Lens' GenerateMac MacAlgorithmSpec
generateMac_macAlgorithm = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateMac' {MacAlgorithmSpec
macAlgorithm :: MacAlgorithmSpec
$sel:macAlgorithm:GenerateMac' :: GenerateMac -> MacAlgorithmSpec
macAlgorithm} -> MacAlgorithmSpec
macAlgorithm) (\s :: GenerateMac
s@GenerateMac' {} MacAlgorithmSpec
a -> GenerateMac
s {$sel:macAlgorithm:GenerateMac' :: MacAlgorithmSpec
macAlgorithm = MacAlgorithmSpec
a} :: GenerateMac)

instance Core.AWSRequest GenerateMac where
  type AWSResponse GenerateMac = GenerateMacResponse
  request :: (Service -> Service) -> GenerateMac -> Request GenerateMac
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 GenerateMac
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GenerateMac)))
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 MacAlgorithmSpec
-> Int
-> GenerateMacResponse
GenerateMacResponse'
            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
"Mac")
            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
"MacAlgorithm")
            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 GenerateMac where
  hashWithSalt :: Int -> GenerateMac -> Int
hashWithSalt Int
_salt GenerateMac' {Maybe [Text]
Text
Sensitive Base64
MacAlgorithmSpec
macAlgorithm :: MacAlgorithmSpec
keyId :: Text
message :: Sensitive Base64
grantTokens :: Maybe [Text]
$sel:macAlgorithm:GenerateMac' :: GenerateMac -> MacAlgorithmSpec
$sel:keyId:GenerateMac' :: GenerateMac -> Text
$sel:message:GenerateMac' :: GenerateMac -> Sensitive Base64
$sel:grantTokens:GenerateMac' :: GenerateMac -> 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` Sensitive Base64
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
keyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MacAlgorithmSpec
macAlgorithm

instance Prelude.NFData GenerateMac where
  rnf :: GenerateMac -> ()
rnf GenerateMac' {Maybe [Text]
Text
Sensitive Base64
MacAlgorithmSpec
macAlgorithm :: MacAlgorithmSpec
keyId :: Text
message :: Sensitive Base64
grantTokens :: Maybe [Text]
$sel:macAlgorithm:GenerateMac' :: GenerateMac -> MacAlgorithmSpec
$sel:keyId:GenerateMac' :: GenerateMac -> Text
$sel:message:GenerateMac' :: GenerateMac -> Sensitive Base64
$sel:grantTokens:GenerateMac' :: GenerateMac -> 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 Sensitive Base64
message
      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 MacAlgorithmSpec
macAlgorithm

instance Data.ToHeaders GenerateMac where
  toHeaders :: GenerateMac -> 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.GenerateMac" :: 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 GenerateMac where
  toJSON :: GenerateMac -> Value
toJSON GenerateMac' {Maybe [Text]
Text
Sensitive Base64
MacAlgorithmSpec
macAlgorithm :: MacAlgorithmSpec
keyId :: Text
message :: Sensitive Base64
grantTokens :: Maybe [Text]
$sel:macAlgorithm:GenerateMac' :: GenerateMac -> MacAlgorithmSpec
$sel:keyId:GenerateMac' :: GenerateMac -> Text
$sel:message:GenerateMac' :: GenerateMac -> Sensitive Base64
$sel:grantTokens:GenerateMac' :: GenerateMac -> 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,
            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
"KeyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
keyId),
            forall a. a -> Maybe a
Prelude.Just (Key
"MacAlgorithm" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= MacAlgorithmSpec
macAlgorithm)
          ]
      )

instance Data.ToPath GenerateMac where
  toPath :: GenerateMac -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery GenerateMac where
  toQuery :: GenerateMac -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGenerateMacResponse' smart constructor.
data GenerateMacResponse = GenerateMacResponse'
  { -- | The HMAC KMS key used in the operation.
    GenerateMacResponse -> Maybe Text
keyId :: Prelude.Maybe Prelude.Text,
    -- | The hash-based message authentication code (HMAC) that was generated for
    -- the specified message, HMAC KMS key, and MAC algorithm.
    --
    -- This is the standard, raw HMAC defined in
    -- <https://datatracker.ietf.org/doc/html/rfc2104 RFC 2104>.
    GenerateMacResponse -> Maybe Base64
mac :: Prelude.Maybe Data.Base64,
    -- | The MAC algorithm that was used to generate the HMAC.
    GenerateMacResponse -> Maybe MacAlgorithmSpec
macAlgorithm :: Prelude.Maybe MacAlgorithmSpec,
    -- | The response's http status code.
    GenerateMacResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GenerateMacResponse -> GenerateMacResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GenerateMacResponse -> GenerateMacResponse -> Bool
$c/= :: GenerateMacResponse -> GenerateMacResponse -> Bool
== :: GenerateMacResponse -> GenerateMacResponse -> Bool
$c== :: GenerateMacResponse -> GenerateMacResponse -> Bool
Prelude.Eq, ReadPrec [GenerateMacResponse]
ReadPrec GenerateMacResponse
Int -> ReadS GenerateMacResponse
ReadS [GenerateMacResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GenerateMacResponse]
$creadListPrec :: ReadPrec [GenerateMacResponse]
readPrec :: ReadPrec GenerateMacResponse
$creadPrec :: ReadPrec GenerateMacResponse
readList :: ReadS [GenerateMacResponse]
$creadList :: ReadS [GenerateMacResponse]
readsPrec :: Int -> ReadS GenerateMacResponse
$creadsPrec :: Int -> ReadS GenerateMacResponse
Prelude.Read, Int -> GenerateMacResponse -> ShowS
[GenerateMacResponse] -> ShowS
GenerateMacResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GenerateMacResponse] -> ShowS
$cshowList :: [GenerateMacResponse] -> ShowS
show :: GenerateMacResponse -> String
$cshow :: GenerateMacResponse -> String
showsPrec :: Int -> GenerateMacResponse -> ShowS
$cshowsPrec :: Int -> GenerateMacResponse -> ShowS
Prelude.Show, forall x. Rep GenerateMacResponse x -> GenerateMacResponse
forall x. GenerateMacResponse -> Rep GenerateMacResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GenerateMacResponse x -> GenerateMacResponse
$cfrom :: forall x. GenerateMacResponse -> Rep GenerateMacResponse x
Prelude.Generic)

-- |
-- Create a value of 'GenerateMacResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'keyId', 'generateMacResponse_keyId' - The HMAC KMS key used in the operation.
--
-- 'mac', 'generateMacResponse_mac' - The hash-based message authentication code (HMAC) that was generated for
-- the specified message, HMAC KMS key, and MAC algorithm.
--
-- This is the standard, raw HMAC defined in
-- <https://datatracker.ietf.org/doc/html/rfc2104 RFC 2104>.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'macAlgorithm', 'generateMacResponse_macAlgorithm' - The MAC algorithm that was used to generate the HMAC.
--
-- 'httpStatus', 'generateMacResponse_httpStatus' - The response's http status code.
newGenerateMacResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GenerateMacResponse
newGenerateMacResponse :: Int -> GenerateMacResponse
newGenerateMacResponse Int
pHttpStatus_ =
  GenerateMacResponse'
    { $sel:keyId:GenerateMacResponse' :: Maybe Text
keyId = forall a. Maybe a
Prelude.Nothing,
      $sel:mac:GenerateMacResponse' :: Maybe Base64
mac = forall a. Maybe a
Prelude.Nothing,
      $sel:macAlgorithm:GenerateMacResponse' :: Maybe MacAlgorithmSpec
macAlgorithm = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GenerateMacResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The HMAC KMS key used in the operation.
generateMacResponse_keyId :: Lens.Lens' GenerateMacResponse (Prelude.Maybe Prelude.Text)
generateMacResponse_keyId :: Lens' GenerateMacResponse (Maybe Text)
generateMacResponse_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateMacResponse' {Maybe Text
keyId :: Maybe Text
$sel:keyId:GenerateMacResponse' :: GenerateMacResponse -> Maybe Text
keyId} -> Maybe Text
keyId) (\s :: GenerateMacResponse
s@GenerateMacResponse' {} Maybe Text
a -> GenerateMacResponse
s {$sel:keyId:GenerateMacResponse' :: Maybe Text
keyId = Maybe Text
a} :: GenerateMacResponse)

-- | The hash-based message authentication code (HMAC) that was generated for
-- the specified message, HMAC KMS key, and MAC algorithm.
--
-- This is the standard, raw HMAC defined in
-- <https://datatracker.ietf.org/doc/html/rfc2104 RFC 2104>.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
generateMacResponse_mac :: Lens.Lens' GenerateMacResponse (Prelude.Maybe Prelude.ByteString)
generateMacResponse_mac :: Lens' GenerateMacResponse (Maybe ByteString)
generateMacResponse_mac = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateMacResponse' {Maybe Base64
mac :: Maybe Base64
$sel:mac:GenerateMacResponse' :: GenerateMacResponse -> Maybe Base64
mac} -> Maybe Base64
mac) (\s :: GenerateMacResponse
s@GenerateMacResponse' {} Maybe Base64
a -> GenerateMacResponse
s {$sel:mac:GenerateMacResponse' :: Maybe Base64
mac = Maybe Base64
a} :: GenerateMacResponse) 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

-- | The MAC algorithm that was used to generate the HMAC.
generateMacResponse_macAlgorithm :: Lens.Lens' GenerateMacResponse (Prelude.Maybe MacAlgorithmSpec)
generateMacResponse_macAlgorithm :: Lens' GenerateMacResponse (Maybe MacAlgorithmSpec)
generateMacResponse_macAlgorithm = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateMacResponse' {Maybe MacAlgorithmSpec
macAlgorithm :: Maybe MacAlgorithmSpec
$sel:macAlgorithm:GenerateMacResponse' :: GenerateMacResponse -> Maybe MacAlgorithmSpec
macAlgorithm} -> Maybe MacAlgorithmSpec
macAlgorithm) (\s :: GenerateMacResponse
s@GenerateMacResponse' {} Maybe MacAlgorithmSpec
a -> GenerateMacResponse
s {$sel:macAlgorithm:GenerateMacResponse' :: Maybe MacAlgorithmSpec
macAlgorithm = Maybe MacAlgorithmSpec
a} :: GenerateMacResponse)

-- | The response's http status code.
generateMacResponse_httpStatus :: Lens.Lens' GenerateMacResponse Prelude.Int
generateMacResponse_httpStatus :: Lens' GenerateMacResponse Int
generateMacResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateMacResponse' {Int
httpStatus :: Int
$sel:httpStatus:GenerateMacResponse' :: GenerateMacResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GenerateMacResponse
s@GenerateMacResponse' {} Int
a -> GenerateMacResponse
s {$sel:httpStatus:GenerateMacResponse' :: Int
httpStatus = Int
a} :: GenerateMacResponse)

instance Prelude.NFData GenerateMacResponse where
  rnf :: GenerateMacResponse -> ()
rnf GenerateMacResponse' {Int
Maybe Text
Maybe Base64
Maybe MacAlgorithmSpec
httpStatus :: Int
macAlgorithm :: Maybe MacAlgorithmSpec
mac :: Maybe Base64
keyId :: Maybe Text
$sel:httpStatus:GenerateMacResponse' :: GenerateMacResponse -> Int
$sel:macAlgorithm:GenerateMacResponse' :: GenerateMacResponse -> Maybe MacAlgorithmSpec
$sel:mac:GenerateMacResponse' :: GenerateMacResponse -> Maybe Base64
$sel:keyId:GenerateMacResponse' :: GenerateMacResponse -> 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
mac
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MacAlgorithmSpec
macAlgorithm
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus