{-# 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.GetParametersForImport
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the items you need to import key material into a symmetric,
-- customer managed KMS key. For more information about importing key
-- material into KMS, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html Importing Key Material>
-- in the /Key Management Service Developer Guide/.
--
-- This operation returns a public key and an import token. Use the public
-- key to encrypt the symmetric key material. Store the import token to
-- send with a subsequent ImportKeyMaterial request.
--
-- You must specify the key ID of the symmetric KMS key into which you will
-- import key material. This KMS key\'s @Origin@ must be @EXTERNAL@. You
-- must also specify the wrapping algorithm and type of wrapping key
-- (public key) that you will use to encrypt the key material. You cannot
-- perform this operation on an asymmetric KMS key or on any KMS key in a
-- different Amazon Web Services account.
--
-- To import key material, you must use the public key and import token
-- from the same response. These items are valid for 24 hours. The
-- expiration date and time appear in the @GetParametersForImport@
-- response. You cannot use an expired token in an ImportKeyMaterial
-- request. If your key and token expire, send another
-- @GetParametersForImport@ request.
--
-- 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 state: Effect on your KMS key>
-- in the /Key Management Service Developer Guide/.
--
-- __Cross-account use__: No. You cannot perform this operation on a KMS
-- key in a different Amazon Web Services account.
--
-- __Required permissions__:
-- <https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html kms:GetParametersForImport>
-- (key policy)
--
-- __Related operations:__
--
-- -   ImportKeyMaterial
--
-- -   DeleteImportedKeyMaterial
module Amazonka.KMS.GetParametersForImport
  ( -- * Creating a Request
    GetParametersForImport (..),
    newGetParametersForImport,

    -- * Request Lenses
    getParametersForImport_keyId,
    getParametersForImport_wrappingAlgorithm,
    getParametersForImport_wrappingKeySpec,

    -- * Destructuring the Response
    GetParametersForImportResponse (..),
    newGetParametersForImportResponse,

    -- * Response Lenses
    getParametersForImportResponse_keyId,
    getParametersForImportResponse_publicKey,
    getParametersForImportResponse_parametersValidTo,
    getParametersForImportResponse_importToken,
    getParametersForImportResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.KMS.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetParametersForImport' smart constructor.
data GetParametersForImport = GetParametersForImport'
  { -- | The identifier of the symmetric KMS key into which you will import key
    -- material. The @Origin@ of the KMS key must be @EXTERNAL@.
    --
    -- Specify the key ID or key ARN of the KMS key.
    --
    -- For example:
    --
    -- -   Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
    --
    -- -   Key ARN:
    --     @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
    --
    -- To get the key ID and key ARN for a KMS key, use ListKeys or
    -- DescribeKey.
    GetParametersForImport -> Text
keyId :: Prelude.Text,
    -- | The algorithm you will use to encrypt the key material before importing
    -- it with ImportKeyMaterial. For more information, see
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys-encrypt-key-material.html Encrypt the Key Material>
    -- in the /Key Management Service Developer Guide/.
    GetParametersForImport -> AlgorithmSpec
wrappingAlgorithm :: AlgorithmSpec,
    -- | The type of wrapping key (public key) to return in the response. Only
    -- 2048-bit RSA public keys are supported.
    GetParametersForImport -> WrappingKeySpec
wrappingKeySpec :: WrappingKeySpec
  }
  deriving (GetParametersForImport -> GetParametersForImport -> Bool
(GetParametersForImport -> GetParametersForImport -> Bool)
-> (GetParametersForImport -> GetParametersForImport -> Bool)
-> Eq GetParametersForImport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetParametersForImport -> GetParametersForImport -> Bool
$c/= :: GetParametersForImport -> GetParametersForImport -> Bool
== :: GetParametersForImport -> GetParametersForImport -> Bool
$c== :: GetParametersForImport -> GetParametersForImport -> Bool
Prelude.Eq, ReadPrec [GetParametersForImport]
ReadPrec GetParametersForImport
Int -> ReadS GetParametersForImport
ReadS [GetParametersForImport]
(Int -> ReadS GetParametersForImport)
-> ReadS [GetParametersForImport]
-> ReadPrec GetParametersForImport
-> ReadPrec [GetParametersForImport]
-> Read GetParametersForImport
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetParametersForImport]
$creadListPrec :: ReadPrec [GetParametersForImport]
readPrec :: ReadPrec GetParametersForImport
$creadPrec :: ReadPrec GetParametersForImport
readList :: ReadS [GetParametersForImport]
$creadList :: ReadS [GetParametersForImport]
readsPrec :: Int -> ReadS GetParametersForImport
$creadsPrec :: Int -> ReadS GetParametersForImport
Prelude.Read, Int -> GetParametersForImport -> ShowS
[GetParametersForImport] -> ShowS
GetParametersForImport -> String
(Int -> GetParametersForImport -> ShowS)
-> (GetParametersForImport -> String)
-> ([GetParametersForImport] -> ShowS)
-> Show GetParametersForImport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetParametersForImport] -> ShowS
$cshowList :: [GetParametersForImport] -> ShowS
show :: GetParametersForImport -> String
$cshow :: GetParametersForImport -> String
showsPrec :: Int -> GetParametersForImport -> ShowS
$cshowsPrec :: Int -> GetParametersForImport -> ShowS
Prelude.Show, (forall x. GetParametersForImport -> Rep GetParametersForImport x)
-> (forall x.
    Rep GetParametersForImport x -> GetParametersForImport)
-> Generic GetParametersForImport
forall x. Rep GetParametersForImport x -> GetParametersForImport
forall x. GetParametersForImport -> Rep GetParametersForImport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetParametersForImport x -> GetParametersForImport
$cfrom :: forall x. GetParametersForImport -> Rep GetParametersForImport x
Prelude.Generic)

-- |
-- Create a value of 'GetParametersForImport' 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', 'getParametersForImport_keyId' - The identifier of the symmetric KMS key into which you will import key
-- material. The @Origin@ of the KMS key must be @EXTERNAL@.
--
-- Specify the key ID or key ARN of the KMS key.
--
-- For example:
--
-- -   Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- -   Key ARN:
--     @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- To get the key ID and key ARN for a KMS key, use ListKeys or
-- DescribeKey.
--
-- 'wrappingAlgorithm', 'getParametersForImport_wrappingAlgorithm' - The algorithm you will use to encrypt the key material before importing
-- it with ImportKeyMaterial. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys-encrypt-key-material.html Encrypt the Key Material>
-- in the /Key Management Service Developer Guide/.
--
-- 'wrappingKeySpec', 'getParametersForImport_wrappingKeySpec' - The type of wrapping key (public key) to return in the response. Only
-- 2048-bit RSA public keys are supported.
newGetParametersForImport ::
  -- | 'keyId'
  Prelude.Text ->
  -- | 'wrappingAlgorithm'
  AlgorithmSpec ->
  -- | 'wrappingKeySpec'
  WrappingKeySpec ->
  GetParametersForImport
newGetParametersForImport :: Text -> AlgorithmSpec -> WrappingKeySpec -> GetParametersForImport
newGetParametersForImport
  Text
pKeyId_
  AlgorithmSpec
pWrappingAlgorithm_
  WrappingKeySpec
pWrappingKeySpec_ =
    GetParametersForImport' :: Text -> AlgorithmSpec -> WrappingKeySpec -> GetParametersForImport
GetParametersForImport'
      { $sel:keyId:GetParametersForImport' :: Text
keyId = Text
pKeyId_,
        $sel:wrappingAlgorithm:GetParametersForImport' :: AlgorithmSpec
wrappingAlgorithm = AlgorithmSpec
pWrappingAlgorithm_,
        $sel:wrappingKeySpec:GetParametersForImport' :: WrappingKeySpec
wrappingKeySpec = WrappingKeySpec
pWrappingKeySpec_
      }

-- | The identifier of the symmetric KMS key into which you will import key
-- material. The @Origin@ of the KMS key must be @EXTERNAL@.
--
-- Specify the key ID or key ARN of the KMS key.
--
-- For example:
--
-- -   Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- -   Key ARN:
--     @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- To get the key ID and key ARN for a KMS key, use ListKeys or
-- DescribeKey.
getParametersForImport_keyId :: Lens.Lens' GetParametersForImport Prelude.Text
getParametersForImport_keyId :: (Text -> f Text)
-> GetParametersForImport -> f GetParametersForImport
getParametersForImport_keyId = (GetParametersForImport -> Text)
-> (GetParametersForImport -> Text -> GetParametersForImport)
-> Lens GetParametersForImport GetParametersForImport Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersForImport' {Text
keyId :: Text
$sel:keyId:GetParametersForImport' :: GetParametersForImport -> Text
keyId} -> Text
keyId) (\s :: GetParametersForImport
s@GetParametersForImport' {} Text
a -> GetParametersForImport
s {$sel:keyId:GetParametersForImport' :: Text
keyId = Text
a} :: GetParametersForImport)

-- | The algorithm you will use to encrypt the key material before importing
-- it with ImportKeyMaterial. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys-encrypt-key-material.html Encrypt the Key Material>
-- in the /Key Management Service Developer Guide/.
getParametersForImport_wrappingAlgorithm :: Lens.Lens' GetParametersForImport AlgorithmSpec
getParametersForImport_wrappingAlgorithm :: (AlgorithmSpec -> f AlgorithmSpec)
-> GetParametersForImport -> f GetParametersForImport
getParametersForImport_wrappingAlgorithm = (GetParametersForImport -> AlgorithmSpec)
-> (GetParametersForImport
    -> AlgorithmSpec -> GetParametersForImport)
-> Lens
     GetParametersForImport
     GetParametersForImport
     AlgorithmSpec
     AlgorithmSpec
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersForImport' {AlgorithmSpec
wrappingAlgorithm :: AlgorithmSpec
$sel:wrappingAlgorithm:GetParametersForImport' :: GetParametersForImport -> AlgorithmSpec
wrappingAlgorithm} -> AlgorithmSpec
wrappingAlgorithm) (\s :: GetParametersForImport
s@GetParametersForImport' {} AlgorithmSpec
a -> GetParametersForImport
s {$sel:wrappingAlgorithm:GetParametersForImport' :: AlgorithmSpec
wrappingAlgorithm = AlgorithmSpec
a} :: GetParametersForImport)

-- | The type of wrapping key (public key) to return in the response. Only
-- 2048-bit RSA public keys are supported.
getParametersForImport_wrappingKeySpec :: Lens.Lens' GetParametersForImport WrappingKeySpec
getParametersForImport_wrappingKeySpec :: (WrappingKeySpec -> f WrappingKeySpec)
-> GetParametersForImport -> f GetParametersForImport
getParametersForImport_wrappingKeySpec = (GetParametersForImport -> WrappingKeySpec)
-> (GetParametersForImport
    -> WrappingKeySpec -> GetParametersForImport)
-> Lens
     GetParametersForImport
     GetParametersForImport
     WrappingKeySpec
     WrappingKeySpec
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersForImport' {WrappingKeySpec
wrappingKeySpec :: WrappingKeySpec
$sel:wrappingKeySpec:GetParametersForImport' :: GetParametersForImport -> WrappingKeySpec
wrappingKeySpec} -> WrappingKeySpec
wrappingKeySpec) (\s :: GetParametersForImport
s@GetParametersForImport' {} WrappingKeySpec
a -> GetParametersForImport
s {$sel:wrappingKeySpec:GetParametersForImport' :: WrappingKeySpec
wrappingKeySpec = WrappingKeySpec
a} :: GetParametersForImport)

instance Core.AWSRequest GetParametersForImport where
  type
    AWSResponse GetParametersForImport =
      GetParametersForImportResponse
  request :: GetParametersForImport -> Request GetParametersForImport
request = Service -> GetParametersForImport -> Request GetParametersForImport
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetParametersForImport
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetParametersForImport)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetParametersForImport))
-> Logger
-> Service
-> Proxy GetParametersForImport
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetParametersForImport)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe (Sensitive Base64)
-> Maybe POSIX
-> Maybe Base64
-> Int
-> GetParametersForImportResponse
GetParametersForImportResponse'
            (Maybe Text
 -> Maybe (Sensitive Base64)
 -> Maybe POSIX
 -> Maybe Base64
 -> Int
 -> GetParametersForImportResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe (Sensitive Base64)
      -> Maybe POSIX
      -> Maybe Base64
      -> Int
      -> GetParametersForImportResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"KeyId")
            Either
  String
  (Maybe (Sensitive Base64)
   -> Maybe POSIX
   -> Maybe Base64
   -> Int
   -> GetParametersForImportResponse)
-> Either String (Maybe (Sensitive Base64))
-> Either
     String
     (Maybe POSIX
      -> Maybe Base64 -> Int -> GetParametersForImportResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Sensitive Base64))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PublicKey")
            Either
  String
  (Maybe POSIX
   -> Maybe Base64 -> Int -> GetParametersForImportResponse)
-> Either String (Maybe POSIX)
-> Either
     String (Maybe Base64 -> Int -> GetParametersForImportResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ParametersValidTo")
            Either
  String (Maybe Base64 -> Int -> GetParametersForImportResponse)
-> Either String (Maybe Base64)
-> Either String (Int -> GetParametersForImportResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Base64)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ImportToken")
            Either String (Int -> GetParametersForImportResponse)
-> Either String Int
-> Either String GetParametersForImportResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetParametersForImport

instance Prelude.NFData GetParametersForImport

instance Core.ToHeaders GetParametersForImport where
  toHeaders :: GetParametersForImport -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetParametersForImport -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"TrentService.GetParametersForImport" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetParametersForImport where
  toJSON :: GetParametersForImport -> Value
toJSON GetParametersForImport' {Text
AlgorithmSpec
WrappingKeySpec
wrappingKeySpec :: WrappingKeySpec
wrappingAlgorithm :: AlgorithmSpec
keyId :: Text
$sel:wrappingKeySpec:GetParametersForImport' :: GetParametersForImport -> WrappingKeySpec
$sel:wrappingAlgorithm:GetParametersForImport' :: GetParametersForImport -> AlgorithmSpec
$sel:keyId:GetParametersForImport' :: GetParametersForImport -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"KeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
keyId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"WrappingAlgorithm" Text -> AlgorithmSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AlgorithmSpec
wrappingAlgorithm),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"WrappingKeySpec" Text -> WrappingKeySpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= WrappingKeySpec
wrappingKeySpec)
          ]
      )

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

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

-- | /See:/ 'newGetParametersForImportResponse' smart constructor.
data GetParametersForImportResponse = GetParametersForImportResponse'
  { -- | The Amazon Resource Name
    -- (<https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-key-ARN key ARN>)
    -- of the KMS key to use in a subsequent ImportKeyMaterial request. This is
    -- the same KMS key specified in the @GetParametersForImport@ request.
    GetParametersForImportResponse -> Maybe Text
keyId :: Prelude.Maybe Prelude.Text,
    -- | The public key to use to encrypt the key material before importing it
    -- with ImportKeyMaterial.
    GetParametersForImportResponse -> Maybe (Sensitive Base64)
publicKey :: Prelude.Maybe (Core.Sensitive Core.Base64),
    -- | The time at which the import token and public key are no longer valid.
    -- After this time, you cannot use them to make an ImportKeyMaterial
    -- request and you must send another @GetParametersForImport@ request to
    -- get new ones.
    GetParametersForImportResponse -> Maybe POSIX
parametersValidTo :: Prelude.Maybe Core.POSIX,
    -- | The import token to send in a subsequent ImportKeyMaterial request.
    GetParametersForImportResponse -> Maybe Base64
importToken :: Prelude.Maybe Core.Base64,
    -- | The response's http status code.
    GetParametersForImportResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetParametersForImportResponse
-> GetParametersForImportResponse -> Bool
(GetParametersForImportResponse
 -> GetParametersForImportResponse -> Bool)
-> (GetParametersForImportResponse
    -> GetParametersForImportResponse -> Bool)
-> Eq GetParametersForImportResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetParametersForImportResponse
-> GetParametersForImportResponse -> Bool
$c/= :: GetParametersForImportResponse
-> GetParametersForImportResponse -> Bool
== :: GetParametersForImportResponse
-> GetParametersForImportResponse -> Bool
$c== :: GetParametersForImportResponse
-> GetParametersForImportResponse -> Bool
Prelude.Eq, Int -> GetParametersForImportResponse -> ShowS
[GetParametersForImportResponse] -> ShowS
GetParametersForImportResponse -> String
(Int -> GetParametersForImportResponse -> ShowS)
-> (GetParametersForImportResponse -> String)
-> ([GetParametersForImportResponse] -> ShowS)
-> Show GetParametersForImportResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetParametersForImportResponse] -> ShowS
$cshowList :: [GetParametersForImportResponse] -> ShowS
show :: GetParametersForImportResponse -> String
$cshow :: GetParametersForImportResponse -> String
showsPrec :: Int -> GetParametersForImportResponse -> ShowS
$cshowsPrec :: Int -> GetParametersForImportResponse -> ShowS
Prelude.Show, (forall x.
 GetParametersForImportResponse
 -> Rep GetParametersForImportResponse x)
-> (forall x.
    Rep GetParametersForImportResponse x
    -> GetParametersForImportResponse)
-> Generic GetParametersForImportResponse
forall x.
Rep GetParametersForImportResponse x
-> GetParametersForImportResponse
forall x.
GetParametersForImportResponse
-> Rep GetParametersForImportResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetParametersForImportResponse x
-> GetParametersForImportResponse
$cfrom :: forall x.
GetParametersForImportResponse
-> Rep GetParametersForImportResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetParametersForImportResponse' 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', 'getParametersForImportResponse_keyId' - The Amazon Resource Name
-- (<https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-key-ARN key ARN>)
-- of the KMS key to use in a subsequent ImportKeyMaterial request. This is
-- the same KMS key specified in the @GetParametersForImport@ request.
--
-- 'publicKey', 'getParametersForImportResponse_publicKey' - The public key to use to encrypt the key material before importing it
-- with ImportKeyMaterial.--
-- -- /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.
--
-- 'parametersValidTo', 'getParametersForImportResponse_parametersValidTo' - The time at which the import token and public key are no longer valid.
-- After this time, you cannot use them to make an ImportKeyMaterial
-- request and you must send another @GetParametersForImport@ request to
-- get new ones.
--
-- 'importToken', 'getParametersForImportResponse_importToken' - The import token to send in a subsequent ImportKeyMaterial request.--
-- -- /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.
--
-- 'httpStatus', 'getParametersForImportResponse_httpStatus' - The response's http status code.
newGetParametersForImportResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetParametersForImportResponse
newGetParametersForImportResponse :: Int -> GetParametersForImportResponse
newGetParametersForImportResponse Int
pHttpStatus_ =
  GetParametersForImportResponse' :: Maybe Text
-> Maybe (Sensitive Base64)
-> Maybe POSIX
-> Maybe Base64
-> Int
-> GetParametersForImportResponse
GetParametersForImportResponse'
    { $sel:keyId:GetParametersForImportResponse' :: Maybe Text
keyId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:publicKey:GetParametersForImportResponse' :: Maybe (Sensitive Base64)
publicKey = Maybe (Sensitive Base64)
forall a. Maybe a
Prelude.Nothing,
      $sel:parametersValidTo:GetParametersForImportResponse' :: Maybe POSIX
parametersValidTo = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:importToken:GetParametersForImportResponse' :: Maybe Base64
importToken = Maybe Base64
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetParametersForImportResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name
-- (<https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-key-ARN key ARN>)
-- of the KMS key to use in a subsequent ImportKeyMaterial request. This is
-- the same KMS key specified in the @GetParametersForImport@ request.
getParametersForImportResponse_keyId :: Lens.Lens' GetParametersForImportResponse (Prelude.Maybe Prelude.Text)
getParametersForImportResponse_keyId :: (Maybe Text -> f (Maybe Text))
-> GetParametersForImportResponse
-> f GetParametersForImportResponse
getParametersForImportResponse_keyId = (GetParametersForImportResponse -> Maybe Text)
-> (GetParametersForImportResponse
    -> Maybe Text -> GetParametersForImportResponse)
-> Lens
     GetParametersForImportResponse
     GetParametersForImportResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersForImportResponse' {Maybe Text
keyId :: Maybe Text
$sel:keyId:GetParametersForImportResponse' :: GetParametersForImportResponse -> Maybe Text
keyId} -> Maybe Text
keyId) (\s :: GetParametersForImportResponse
s@GetParametersForImportResponse' {} Maybe Text
a -> GetParametersForImportResponse
s {$sel:keyId:GetParametersForImportResponse' :: Maybe Text
keyId = Maybe Text
a} :: GetParametersForImportResponse)

-- | The public key to use to encrypt the key material before importing it
-- with ImportKeyMaterial.--
-- -- /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.
getParametersForImportResponse_publicKey :: Lens.Lens' GetParametersForImportResponse (Prelude.Maybe Prelude.ByteString)
getParametersForImportResponse_publicKey :: (Maybe ByteString -> f (Maybe ByteString))
-> GetParametersForImportResponse
-> f GetParametersForImportResponse
getParametersForImportResponse_publicKey = (GetParametersForImportResponse -> Maybe (Sensitive Base64))
-> (GetParametersForImportResponse
    -> Maybe (Sensitive Base64) -> GetParametersForImportResponse)
-> Lens
     GetParametersForImportResponse
     GetParametersForImportResponse
     (Maybe (Sensitive Base64))
     (Maybe (Sensitive Base64))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersForImportResponse' {Maybe (Sensitive Base64)
publicKey :: Maybe (Sensitive Base64)
$sel:publicKey:GetParametersForImportResponse' :: GetParametersForImportResponse -> Maybe (Sensitive Base64)
publicKey} -> Maybe (Sensitive Base64)
publicKey) (\s :: GetParametersForImportResponse
s@GetParametersForImportResponse' {} Maybe (Sensitive Base64)
a -> GetParametersForImportResponse
s {$sel:publicKey:GetParametersForImportResponse' :: Maybe (Sensitive Base64)
publicKey = Maybe (Sensitive Base64)
a} :: GetParametersForImportResponse) ((Maybe (Sensitive Base64) -> f (Maybe (Sensitive Base64)))
 -> GetParametersForImportResponse
 -> f GetParametersForImportResponse)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe (Sensitive Base64) -> f (Maybe (Sensitive Base64)))
-> (Maybe ByteString -> f (Maybe ByteString))
-> GetParametersForImportResponse
-> f GetParametersForImportResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Base64) (Sensitive Base64) ByteString ByteString
-> Iso
     (Maybe (Sensitive Base64))
     (Maybe (Sensitive Base64))
     (Maybe ByteString)
     (Maybe ByteString)
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 (Exchange ByteString ByteString Base64 (Identity Base64)
-> Exchange
     ByteString
     ByteString
     (Sensitive Base64)
     (Identity (Sensitive Base64))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Exchange ByteString ByteString Base64 (Identity Base64)
 -> Exchange
      ByteString
      ByteString
      (Sensitive Base64)
      (Identity (Sensitive Base64)))
-> (Exchange ByteString ByteString ByteString (Identity ByteString)
    -> Exchange ByteString ByteString Base64 (Identity Base64))
-> AnIso
     (Sensitive Base64) (Sensitive Base64) ByteString ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Exchange ByteString ByteString ByteString (Identity ByteString)
-> Exchange ByteString ByteString Base64 (Identity Base64)
Iso' Base64 ByteString
Core._Base64)

-- | The time at which the import token and public key are no longer valid.
-- After this time, you cannot use them to make an ImportKeyMaterial
-- request and you must send another @GetParametersForImport@ request to
-- get new ones.
getParametersForImportResponse_parametersValidTo :: Lens.Lens' GetParametersForImportResponse (Prelude.Maybe Prelude.UTCTime)
getParametersForImportResponse_parametersValidTo :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetParametersForImportResponse
-> f GetParametersForImportResponse
getParametersForImportResponse_parametersValidTo = (GetParametersForImportResponse -> Maybe POSIX)
-> (GetParametersForImportResponse
    -> Maybe POSIX -> GetParametersForImportResponse)
-> Lens
     GetParametersForImportResponse
     GetParametersForImportResponse
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersForImportResponse' {Maybe POSIX
parametersValidTo :: Maybe POSIX
$sel:parametersValidTo:GetParametersForImportResponse' :: GetParametersForImportResponse -> Maybe POSIX
parametersValidTo} -> Maybe POSIX
parametersValidTo) (\s :: GetParametersForImportResponse
s@GetParametersForImportResponse' {} Maybe POSIX
a -> GetParametersForImportResponse
s {$sel:parametersValidTo:GetParametersForImportResponse' :: Maybe POSIX
parametersValidTo = Maybe POSIX
a} :: GetParametersForImportResponse) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetParametersForImportResponse
 -> f GetParametersForImportResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetParametersForImportResponse
-> f GetParametersForImportResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The import token to send in a subsequent ImportKeyMaterial request.--
-- -- /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.
getParametersForImportResponse_importToken :: Lens.Lens' GetParametersForImportResponse (Prelude.Maybe Prelude.ByteString)
getParametersForImportResponse_importToken :: (Maybe ByteString -> f (Maybe ByteString))
-> GetParametersForImportResponse
-> f GetParametersForImportResponse
getParametersForImportResponse_importToken = (GetParametersForImportResponse -> Maybe Base64)
-> (GetParametersForImportResponse
    -> Maybe Base64 -> GetParametersForImportResponse)
-> Lens
     GetParametersForImportResponse
     GetParametersForImportResponse
     (Maybe Base64)
     (Maybe Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetParametersForImportResponse' {Maybe Base64
importToken :: Maybe Base64
$sel:importToken:GetParametersForImportResponse' :: GetParametersForImportResponse -> Maybe Base64
importToken} -> Maybe Base64
importToken) (\s :: GetParametersForImportResponse
s@GetParametersForImportResponse' {} Maybe Base64
a -> GetParametersForImportResponse
s {$sel:importToken:GetParametersForImportResponse' :: Maybe Base64
importToken = Maybe Base64
a} :: GetParametersForImportResponse) ((Maybe Base64 -> f (Maybe Base64))
 -> GetParametersForImportResponse
 -> f GetParametersForImportResponse)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> GetParametersForImportResponse
-> f GetParametersForImportResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Exchange ByteString ByteString ByteString (Identity ByteString)
 -> Exchange ByteString ByteString Base64 (Identity Base64))
-> Iso
     (Maybe Base64) (Maybe Base64) (Maybe ByteString) (Maybe ByteString)
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 Exchange ByteString ByteString ByteString (Identity ByteString)
-> Exchange ByteString ByteString Base64 (Identity Base64)
Iso' Base64 ByteString
Core._Base64

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

instance
  Prelude.NFData
    GetParametersForImportResponse