{-# 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.ScheduleKeyDeletion
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Schedules the deletion of a KMS key. By default, KMS applies a waiting
-- period of 30 days, but you can specify a waiting period of 7-30 days.
-- When this operation is successful, the key state of the KMS key changes
-- to @PendingDeletion@ and the key can\'t be used in any cryptographic
-- operations. It remains in this state for the duration of the waiting
-- period. Before the waiting period ends, you can use CancelKeyDeletion to
-- cancel the deletion of the KMS key. After the waiting period ends, KMS
-- deletes the KMS key, its key material, and all KMS data associated with
-- it, including all aliases that refer to it.
--
-- Deleting a KMS key is a destructive and potentially dangerous operation.
-- When a KMS key is deleted, all data that was encrypted under the KMS key
-- is unrecoverable. (The only exception is a multi-Region replica key.) To
-- prevent the use of a KMS key without deleting it, use DisableKey.
--
-- You can schedule the deletion of a multi-Region primary key and its
-- replica keys at any time. However, KMS will not delete a multi-Region
-- primary key with existing replica keys. If you schedule the deletion of
-- a primary key with replicas, its key state changes to
-- @PendingReplicaDeletion@ and it cannot be replicated or used in
-- cryptographic operations. This status can continue indefinitely. When
-- the last of its replicas keys is deleted (not just scheduled), the key
-- state of the primary key changes to @PendingDeletion@ and its waiting
-- period (@PendingWindowInDays@) begins. For details, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-delete.html Deleting multi-Region keys>
-- in the /Key Management Service Developer Guide/.
--
-- When KMS
-- <https://docs.aws.amazon.com/kms/latest/developerguide/delete-cmk-keystore.html deletes a KMS key from an CloudHSM key store>,
-- it makes a best effort to delete the associated key material from the
-- associated CloudHSM cluster. However, you might need to manually
-- <https://docs.aws.amazon.com/kms/latest/developerguide/fix-keystore.html#fix-keystore-orphaned-key delete the orphaned key material>
-- from the cluster and its backups.
-- <https://docs.aws.amazon.com/kms/latest/developerguide/delete-xks-key.html Deleting a KMS key from an external key store>
-- has no effect on the associated external key. However, for both types of
-- custom key stores, deleting a KMS key is destructive and irreversible.
-- You cannot decrypt ciphertext encrypted under the KMS key by using only
-- its associated external key or CloudHSM key. Also, you cannot recreate a
-- KMS key in an external key store by creating a new KMS key with the same
-- key material.
--
-- For more information about scheduling a KMS key for deletion, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/deleting-keys.html Deleting KMS keys>
-- in the /Key Management Service Developer Guide/.
--
-- 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__: No. You cannot perform this operation on a KMS
-- key in a different Amazon Web Services account.
--
-- __Required permissions__: kms:ScheduleKeyDeletion (key policy)
--
-- __Related operations__
--
-- -   CancelKeyDeletion
--
-- -   DisableKey
module Amazonka.KMS.ScheduleKeyDeletion
  ( -- * Creating a Request
    ScheduleKeyDeletion (..),
    newScheduleKeyDeletion,

    -- * Request Lenses
    scheduleKeyDeletion_pendingWindowInDays,
    scheduleKeyDeletion_keyId,

    -- * Destructuring the Response
    ScheduleKeyDeletionResponse (..),
    newScheduleKeyDeletionResponse,

    -- * Response Lenses
    scheduleKeyDeletionResponse_deletionDate,
    scheduleKeyDeletionResponse_keyId,
    scheduleKeyDeletionResponse_keyState,
    scheduleKeyDeletionResponse_pendingWindowInDays,
    scheduleKeyDeletionResponse_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:/ 'newScheduleKeyDeletion' smart constructor.
data ScheduleKeyDeletion = ScheduleKeyDeletion'
  { -- | The waiting period, specified in number of days. After the waiting
    -- period ends, KMS deletes the KMS key.
    --
    -- If the KMS key is a multi-Region primary key with replica keys, the
    -- waiting period begins when the last of its replica keys is deleted.
    -- Otherwise, the waiting period begins immediately.
    --
    -- This value is optional. If you include a value, it must be between 7 and
    -- 30, inclusive. If you do not include a value, it defaults to 30.
    ScheduleKeyDeletion -> Maybe Natural
pendingWindowInDays :: Prelude.Maybe Prelude.Natural,
    -- | The unique identifier of the KMS key to delete.
    --
    -- 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.
    ScheduleKeyDeletion -> Text
keyId :: Prelude.Text
  }
  deriving (ScheduleKeyDeletion -> ScheduleKeyDeletion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduleKeyDeletion -> ScheduleKeyDeletion -> Bool
$c/= :: ScheduleKeyDeletion -> ScheduleKeyDeletion -> Bool
== :: ScheduleKeyDeletion -> ScheduleKeyDeletion -> Bool
$c== :: ScheduleKeyDeletion -> ScheduleKeyDeletion -> Bool
Prelude.Eq, ReadPrec [ScheduleKeyDeletion]
ReadPrec ScheduleKeyDeletion
Int -> ReadS ScheduleKeyDeletion
ReadS [ScheduleKeyDeletion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduleKeyDeletion]
$creadListPrec :: ReadPrec [ScheduleKeyDeletion]
readPrec :: ReadPrec ScheduleKeyDeletion
$creadPrec :: ReadPrec ScheduleKeyDeletion
readList :: ReadS [ScheduleKeyDeletion]
$creadList :: ReadS [ScheduleKeyDeletion]
readsPrec :: Int -> ReadS ScheduleKeyDeletion
$creadsPrec :: Int -> ReadS ScheduleKeyDeletion
Prelude.Read, Int -> ScheduleKeyDeletion -> ShowS
[ScheduleKeyDeletion] -> ShowS
ScheduleKeyDeletion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduleKeyDeletion] -> ShowS
$cshowList :: [ScheduleKeyDeletion] -> ShowS
show :: ScheduleKeyDeletion -> String
$cshow :: ScheduleKeyDeletion -> String
showsPrec :: Int -> ScheduleKeyDeletion -> ShowS
$cshowsPrec :: Int -> ScheduleKeyDeletion -> ShowS
Prelude.Show, forall x. Rep ScheduleKeyDeletion x -> ScheduleKeyDeletion
forall x. ScheduleKeyDeletion -> Rep ScheduleKeyDeletion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScheduleKeyDeletion x -> ScheduleKeyDeletion
$cfrom :: forall x. ScheduleKeyDeletion -> Rep ScheduleKeyDeletion x
Prelude.Generic)

-- |
-- Create a value of 'ScheduleKeyDeletion' 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:
--
-- 'pendingWindowInDays', 'scheduleKeyDeletion_pendingWindowInDays' - The waiting period, specified in number of days. After the waiting
-- period ends, KMS deletes the KMS key.
--
-- If the KMS key is a multi-Region primary key with replica keys, the
-- waiting period begins when the last of its replica keys is deleted.
-- Otherwise, the waiting period begins immediately.
--
-- This value is optional. If you include a value, it must be between 7 and
-- 30, inclusive. If you do not include a value, it defaults to 30.
--
-- 'keyId', 'scheduleKeyDeletion_keyId' - The unique identifier of the KMS key to delete.
--
-- 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.
newScheduleKeyDeletion ::
  -- | 'keyId'
  Prelude.Text ->
  ScheduleKeyDeletion
newScheduleKeyDeletion :: Text -> ScheduleKeyDeletion
newScheduleKeyDeletion Text
pKeyId_ =
  ScheduleKeyDeletion'
    { $sel:pendingWindowInDays:ScheduleKeyDeletion' :: Maybe Natural
pendingWindowInDays =
        forall a. Maybe a
Prelude.Nothing,
      $sel:keyId:ScheduleKeyDeletion' :: Text
keyId = Text
pKeyId_
    }

-- | The waiting period, specified in number of days. After the waiting
-- period ends, KMS deletes the KMS key.
--
-- If the KMS key is a multi-Region primary key with replica keys, the
-- waiting period begins when the last of its replica keys is deleted.
-- Otherwise, the waiting period begins immediately.
--
-- This value is optional. If you include a value, it must be between 7 and
-- 30, inclusive. If you do not include a value, it defaults to 30.
scheduleKeyDeletion_pendingWindowInDays :: Lens.Lens' ScheduleKeyDeletion (Prelude.Maybe Prelude.Natural)
scheduleKeyDeletion_pendingWindowInDays :: Lens' ScheduleKeyDeletion (Maybe Natural)
scheduleKeyDeletion_pendingWindowInDays = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleKeyDeletion' {Maybe Natural
pendingWindowInDays :: Maybe Natural
$sel:pendingWindowInDays:ScheduleKeyDeletion' :: ScheduleKeyDeletion -> Maybe Natural
pendingWindowInDays} -> Maybe Natural
pendingWindowInDays) (\s :: ScheduleKeyDeletion
s@ScheduleKeyDeletion' {} Maybe Natural
a -> ScheduleKeyDeletion
s {$sel:pendingWindowInDays:ScheduleKeyDeletion' :: Maybe Natural
pendingWindowInDays = Maybe Natural
a} :: ScheduleKeyDeletion)

-- | The unique identifier of the KMS key to delete.
--
-- 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.
scheduleKeyDeletion_keyId :: Lens.Lens' ScheduleKeyDeletion Prelude.Text
scheduleKeyDeletion_keyId :: Lens' ScheduleKeyDeletion Text
scheduleKeyDeletion_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleKeyDeletion' {Text
keyId :: Text
$sel:keyId:ScheduleKeyDeletion' :: ScheduleKeyDeletion -> Text
keyId} -> Text
keyId) (\s :: ScheduleKeyDeletion
s@ScheduleKeyDeletion' {} Text
a -> ScheduleKeyDeletion
s {$sel:keyId:ScheduleKeyDeletion' :: Text
keyId = Text
a} :: ScheduleKeyDeletion)

instance Core.AWSRequest ScheduleKeyDeletion where
  type
    AWSResponse ScheduleKeyDeletion =
      ScheduleKeyDeletionResponse
  request :: (Service -> Service)
-> ScheduleKeyDeletion -> Request ScheduleKeyDeletion
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 ScheduleKeyDeletion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ScheduleKeyDeletion)))
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 POSIX
-> Maybe Text
-> Maybe KeyState
-> Maybe Natural
-> Int
-> ScheduleKeyDeletionResponse
ScheduleKeyDeletionResponse'
            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
"DeletionDate")
            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
"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
"KeyState")
            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
"PendingWindowInDays")
            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 ScheduleKeyDeletion where
  hashWithSalt :: Int -> ScheduleKeyDeletion -> Int
hashWithSalt Int
_salt ScheduleKeyDeletion' {Maybe Natural
Text
keyId :: Text
pendingWindowInDays :: Maybe Natural
$sel:keyId:ScheduleKeyDeletion' :: ScheduleKeyDeletion -> Text
$sel:pendingWindowInDays:ScheduleKeyDeletion' :: ScheduleKeyDeletion -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
pendingWindowInDays
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
keyId

instance Prelude.NFData ScheduleKeyDeletion where
  rnf :: ScheduleKeyDeletion -> ()
rnf ScheduleKeyDeletion' {Maybe Natural
Text
keyId :: Text
pendingWindowInDays :: Maybe Natural
$sel:keyId:ScheduleKeyDeletion' :: ScheduleKeyDeletion -> Text
$sel:pendingWindowInDays:ScheduleKeyDeletion' :: ScheduleKeyDeletion -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
pendingWindowInDays
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
keyId

instance Data.ToHeaders ScheduleKeyDeletion where
  toHeaders :: ScheduleKeyDeletion -> 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.ScheduleKeyDeletion" ::
                          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 ScheduleKeyDeletion where
  toJSON :: ScheduleKeyDeletion -> Value
toJSON ScheduleKeyDeletion' {Maybe Natural
Text
keyId :: Text
pendingWindowInDays :: Maybe Natural
$sel:keyId:ScheduleKeyDeletion' :: ScheduleKeyDeletion -> Text
$sel:pendingWindowInDays:ScheduleKeyDeletion' :: ScheduleKeyDeletion -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"PendingWindowInDays" 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 Natural
pendingWindowInDays,
            forall a. a -> Maybe a
Prelude.Just (Key
"KeyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
keyId)
          ]
      )

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

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

-- | /See:/ 'newScheduleKeyDeletionResponse' smart constructor.
data ScheduleKeyDeletionResponse = ScheduleKeyDeletionResponse'
  { -- | The date and time after which KMS deletes the KMS key.
    --
    -- If the KMS key is a multi-Region primary key with replica keys, this
    -- field does not appear. The deletion date for the primary key isn\'t
    -- known until its last replica key is deleted.
    ScheduleKeyDeletionResponse -> Maybe POSIX
deletionDate :: Prelude.Maybe Data.POSIX,
    -- | The Amazon Resource Name
    -- (<https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-key-ARN key ARN>)
    -- of the KMS key whose deletion is scheduled.
    ScheduleKeyDeletionResponse -> Maybe Text
keyId :: Prelude.Maybe Prelude.Text,
    -- | The current status of the KMS key.
    --
    -- For more information about how key state affects the use of a KMS key,
    -- see
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html Key states of KMS keys>
    -- in the /Key Management Service Developer Guide/.
    ScheduleKeyDeletionResponse -> Maybe KeyState
keyState :: Prelude.Maybe KeyState,
    -- | The waiting period before the KMS key is deleted.
    --
    -- If the KMS key is a multi-Region primary key with replicas, the waiting
    -- period begins when the last of its replica keys is deleted. Otherwise,
    -- the waiting period begins immediately.
    ScheduleKeyDeletionResponse -> Maybe Natural
pendingWindowInDays :: Prelude.Maybe Prelude.Natural,
    -- | The response's http status code.
    ScheduleKeyDeletionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ScheduleKeyDeletionResponse -> ScheduleKeyDeletionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduleKeyDeletionResponse -> ScheduleKeyDeletionResponse -> Bool
$c/= :: ScheduleKeyDeletionResponse -> ScheduleKeyDeletionResponse -> Bool
== :: ScheduleKeyDeletionResponse -> ScheduleKeyDeletionResponse -> Bool
$c== :: ScheduleKeyDeletionResponse -> ScheduleKeyDeletionResponse -> Bool
Prelude.Eq, ReadPrec [ScheduleKeyDeletionResponse]
ReadPrec ScheduleKeyDeletionResponse
Int -> ReadS ScheduleKeyDeletionResponse
ReadS [ScheduleKeyDeletionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduleKeyDeletionResponse]
$creadListPrec :: ReadPrec [ScheduleKeyDeletionResponse]
readPrec :: ReadPrec ScheduleKeyDeletionResponse
$creadPrec :: ReadPrec ScheduleKeyDeletionResponse
readList :: ReadS [ScheduleKeyDeletionResponse]
$creadList :: ReadS [ScheduleKeyDeletionResponse]
readsPrec :: Int -> ReadS ScheduleKeyDeletionResponse
$creadsPrec :: Int -> ReadS ScheduleKeyDeletionResponse
Prelude.Read, Int -> ScheduleKeyDeletionResponse -> ShowS
[ScheduleKeyDeletionResponse] -> ShowS
ScheduleKeyDeletionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduleKeyDeletionResponse] -> ShowS
$cshowList :: [ScheduleKeyDeletionResponse] -> ShowS
show :: ScheduleKeyDeletionResponse -> String
$cshow :: ScheduleKeyDeletionResponse -> String
showsPrec :: Int -> ScheduleKeyDeletionResponse -> ShowS
$cshowsPrec :: Int -> ScheduleKeyDeletionResponse -> ShowS
Prelude.Show, forall x.
Rep ScheduleKeyDeletionResponse x -> ScheduleKeyDeletionResponse
forall x.
ScheduleKeyDeletionResponse -> Rep ScheduleKeyDeletionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ScheduleKeyDeletionResponse x -> ScheduleKeyDeletionResponse
$cfrom :: forall x.
ScheduleKeyDeletionResponse -> Rep ScheduleKeyDeletionResponse x
Prelude.Generic)

-- |
-- Create a value of 'ScheduleKeyDeletionResponse' 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:
--
-- 'deletionDate', 'scheduleKeyDeletionResponse_deletionDate' - The date and time after which KMS deletes the KMS key.
--
-- If the KMS key is a multi-Region primary key with replica keys, this
-- field does not appear. The deletion date for the primary key isn\'t
-- known until its last replica key is deleted.
--
-- 'keyId', 'scheduleKeyDeletionResponse_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 whose deletion is scheduled.
--
-- 'keyState', 'scheduleKeyDeletionResponse_keyState' - The current status of the KMS key.
--
-- For more information about how key state affects the use of a KMS key,
-- see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html Key states of KMS keys>
-- in the /Key Management Service Developer Guide/.
--
-- 'pendingWindowInDays', 'scheduleKeyDeletionResponse_pendingWindowInDays' - The waiting period before the KMS key is deleted.
--
-- If the KMS key is a multi-Region primary key with replicas, the waiting
-- period begins when the last of its replica keys is deleted. Otherwise,
-- the waiting period begins immediately.
--
-- 'httpStatus', 'scheduleKeyDeletionResponse_httpStatus' - The response's http status code.
newScheduleKeyDeletionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ScheduleKeyDeletionResponse
newScheduleKeyDeletionResponse :: Int -> ScheduleKeyDeletionResponse
newScheduleKeyDeletionResponse Int
pHttpStatus_ =
  ScheduleKeyDeletionResponse'
    { $sel:deletionDate:ScheduleKeyDeletionResponse' :: Maybe POSIX
deletionDate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:keyId:ScheduleKeyDeletionResponse' :: Maybe Text
keyId = forall a. Maybe a
Prelude.Nothing,
      $sel:keyState:ScheduleKeyDeletionResponse' :: Maybe KeyState
keyState = forall a. Maybe a
Prelude.Nothing,
      $sel:pendingWindowInDays:ScheduleKeyDeletionResponse' :: Maybe Natural
pendingWindowInDays = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ScheduleKeyDeletionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The date and time after which KMS deletes the KMS key.
--
-- If the KMS key is a multi-Region primary key with replica keys, this
-- field does not appear. The deletion date for the primary key isn\'t
-- known until its last replica key is deleted.
scheduleKeyDeletionResponse_deletionDate :: Lens.Lens' ScheduleKeyDeletionResponse (Prelude.Maybe Prelude.UTCTime)
scheduleKeyDeletionResponse_deletionDate :: Lens' ScheduleKeyDeletionResponse (Maybe UTCTime)
scheduleKeyDeletionResponse_deletionDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleKeyDeletionResponse' {Maybe POSIX
deletionDate :: Maybe POSIX
$sel:deletionDate:ScheduleKeyDeletionResponse' :: ScheduleKeyDeletionResponse -> Maybe POSIX
deletionDate} -> Maybe POSIX
deletionDate) (\s :: ScheduleKeyDeletionResponse
s@ScheduleKeyDeletionResponse' {} Maybe POSIX
a -> ScheduleKeyDeletionResponse
s {$sel:deletionDate:ScheduleKeyDeletionResponse' :: Maybe POSIX
deletionDate = Maybe POSIX
a} :: ScheduleKeyDeletionResponse) 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

-- | The Amazon Resource Name
-- (<https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-key-ARN key ARN>)
-- of the KMS key whose deletion is scheduled.
scheduleKeyDeletionResponse_keyId :: Lens.Lens' ScheduleKeyDeletionResponse (Prelude.Maybe Prelude.Text)
scheduleKeyDeletionResponse_keyId :: Lens' ScheduleKeyDeletionResponse (Maybe Text)
scheduleKeyDeletionResponse_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleKeyDeletionResponse' {Maybe Text
keyId :: Maybe Text
$sel:keyId:ScheduleKeyDeletionResponse' :: ScheduleKeyDeletionResponse -> Maybe Text
keyId} -> Maybe Text
keyId) (\s :: ScheduleKeyDeletionResponse
s@ScheduleKeyDeletionResponse' {} Maybe Text
a -> ScheduleKeyDeletionResponse
s {$sel:keyId:ScheduleKeyDeletionResponse' :: Maybe Text
keyId = Maybe Text
a} :: ScheduleKeyDeletionResponse)

-- | The current status of the KMS key.
--
-- For more information about how key state affects the use of a KMS key,
-- see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html Key states of KMS keys>
-- in the /Key Management Service Developer Guide/.
scheduleKeyDeletionResponse_keyState :: Lens.Lens' ScheduleKeyDeletionResponse (Prelude.Maybe KeyState)
scheduleKeyDeletionResponse_keyState :: Lens' ScheduleKeyDeletionResponse (Maybe KeyState)
scheduleKeyDeletionResponse_keyState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleKeyDeletionResponse' {Maybe KeyState
keyState :: Maybe KeyState
$sel:keyState:ScheduleKeyDeletionResponse' :: ScheduleKeyDeletionResponse -> Maybe KeyState
keyState} -> Maybe KeyState
keyState) (\s :: ScheduleKeyDeletionResponse
s@ScheduleKeyDeletionResponse' {} Maybe KeyState
a -> ScheduleKeyDeletionResponse
s {$sel:keyState:ScheduleKeyDeletionResponse' :: Maybe KeyState
keyState = Maybe KeyState
a} :: ScheduleKeyDeletionResponse)

-- | The waiting period before the KMS key is deleted.
--
-- If the KMS key is a multi-Region primary key with replicas, the waiting
-- period begins when the last of its replica keys is deleted. Otherwise,
-- the waiting period begins immediately.
scheduleKeyDeletionResponse_pendingWindowInDays :: Lens.Lens' ScheduleKeyDeletionResponse (Prelude.Maybe Prelude.Natural)
scheduleKeyDeletionResponse_pendingWindowInDays :: Lens' ScheduleKeyDeletionResponse (Maybe Natural)
scheduleKeyDeletionResponse_pendingWindowInDays = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleKeyDeletionResponse' {Maybe Natural
pendingWindowInDays :: Maybe Natural
$sel:pendingWindowInDays:ScheduleKeyDeletionResponse' :: ScheduleKeyDeletionResponse -> Maybe Natural
pendingWindowInDays} -> Maybe Natural
pendingWindowInDays) (\s :: ScheduleKeyDeletionResponse
s@ScheduleKeyDeletionResponse' {} Maybe Natural
a -> ScheduleKeyDeletionResponse
s {$sel:pendingWindowInDays:ScheduleKeyDeletionResponse' :: Maybe Natural
pendingWindowInDays = Maybe Natural
a} :: ScheduleKeyDeletionResponse)

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

instance Prelude.NFData ScheduleKeyDeletionResponse where
  rnf :: ScheduleKeyDeletionResponse -> ()
rnf ScheduleKeyDeletionResponse' {Int
Maybe Natural
Maybe Text
Maybe POSIX
Maybe KeyState
httpStatus :: Int
pendingWindowInDays :: Maybe Natural
keyState :: Maybe KeyState
keyId :: Maybe Text
deletionDate :: Maybe POSIX
$sel:httpStatus:ScheduleKeyDeletionResponse' :: ScheduleKeyDeletionResponse -> Int
$sel:pendingWindowInDays:ScheduleKeyDeletionResponse' :: ScheduleKeyDeletionResponse -> Maybe Natural
$sel:keyState:ScheduleKeyDeletionResponse' :: ScheduleKeyDeletionResponse -> Maybe KeyState
$sel:keyId:ScheduleKeyDeletionResponse' :: ScheduleKeyDeletionResponse -> Maybe Text
$sel:deletionDate:ScheduleKeyDeletionResponse' :: ScheduleKeyDeletionResponse -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
deletionDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 KeyState
keyState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
pendingWindowInDays
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus