{-# 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-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)
--
-- 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.
--
-- If you schedule deletion of a KMS key from a
-- <https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html custom key store>,
-- when the waiting period expires, @ScheduleKeyDeletion@ deletes the KMS
-- key from KMS. Then KMS makes a best effort to delete the 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.
--
-- 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/.
--
-- 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 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__: 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_keyId,
    scheduleKeyDeletionResponse_keyState,
    scheduleKeyDeletionResponse_deletionDate,
    scheduleKeyDeletionResponse_pendingWindowInDays,
    scheduleKeyDeletionResponse_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:/ '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 replicas, 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
(ScheduleKeyDeletion -> ScheduleKeyDeletion -> Bool)
-> (ScheduleKeyDeletion -> ScheduleKeyDeletion -> Bool)
-> Eq ScheduleKeyDeletion
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]
(Int -> ReadS ScheduleKeyDeletion)
-> ReadS [ScheduleKeyDeletion]
-> ReadPrec ScheduleKeyDeletion
-> ReadPrec [ScheduleKeyDeletion]
-> Read 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
(Int -> ScheduleKeyDeletion -> ShowS)
-> (ScheduleKeyDeletion -> String)
-> ([ScheduleKeyDeletion] -> ShowS)
-> Show ScheduleKeyDeletion
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. ScheduleKeyDeletion -> Rep ScheduleKeyDeletion x)
-> (forall x. Rep ScheduleKeyDeletion x -> ScheduleKeyDeletion)
-> Generic ScheduleKeyDeletion
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 replicas, 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' :: Maybe Natural -> Text -> ScheduleKeyDeletion
ScheduleKeyDeletion'
    { $sel:pendingWindowInDays:ScheduleKeyDeletion' :: Maybe Natural
pendingWindowInDays =
        Maybe Natural
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 replicas, 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 :: (Maybe Natural -> f (Maybe Natural))
-> ScheduleKeyDeletion -> f ScheduleKeyDeletion
scheduleKeyDeletion_pendingWindowInDays = (ScheduleKeyDeletion -> Maybe Natural)
-> (ScheduleKeyDeletion -> Maybe Natural -> ScheduleKeyDeletion)
-> Lens
     ScheduleKeyDeletion
     ScheduleKeyDeletion
     (Maybe Natural)
     (Maybe Natural)
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 :: (Text -> f Text) -> ScheduleKeyDeletion -> f ScheduleKeyDeletion
scheduleKeyDeletion_keyId = (ScheduleKeyDeletion -> Text)
-> (ScheduleKeyDeletion -> Text -> ScheduleKeyDeletion)
-> Lens ScheduleKeyDeletion ScheduleKeyDeletion Text Text
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 :: ScheduleKeyDeletion -> Request ScheduleKeyDeletion
request = Service -> ScheduleKeyDeletion -> Request ScheduleKeyDeletion
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ScheduleKeyDeletion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ScheduleKeyDeletion)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ScheduleKeyDeletion))
-> Logger
-> Service
-> Proxy ScheduleKeyDeletion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ScheduleKeyDeletion)))
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 KeyState
-> Maybe POSIX
-> Maybe Natural
-> Int
-> ScheduleKeyDeletionResponse
ScheduleKeyDeletionResponse'
            (Maybe Text
 -> Maybe KeyState
 -> Maybe POSIX
 -> Maybe Natural
 -> Int
 -> ScheduleKeyDeletionResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe KeyState
      -> Maybe POSIX
      -> Maybe Natural
      -> Int
      -> ScheduleKeyDeletionResponse)
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 KeyState
   -> Maybe POSIX
   -> Maybe Natural
   -> Int
   -> ScheduleKeyDeletionResponse)
-> Either String (Maybe KeyState)
-> Either
     String
     (Maybe POSIX
      -> Maybe Natural -> Int -> ScheduleKeyDeletionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe KeyState)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"KeyState")
            Either
  String
  (Maybe POSIX
   -> Maybe Natural -> Int -> ScheduleKeyDeletionResponse)
-> Either String (Maybe POSIX)
-> Either
     String (Maybe Natural -> Int -> ScheduleKeyDeletionResponse)
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
"DeletionDate")
            Either String (Maybe Natural -> Int -> ScheduleKeyDeletionResponse)
-> Either String (Maybe Natural)
-> Either String (Int -> ScheduleKeyDeletionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PendingWindowInDays")
            Either String (Int -> ScheduleKeyDeletionResponse)
-> Either String Int -> Either String ScheduleKeyDeletionResponse
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 ScheduleKeyDeletion

instance Prelude.NFData ScheduleKeyDeletion

instance Core.ToHeaders ScheduleKeyDeletion where
  toHeaders :: ScheduleKeyDeletion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ScheduleKeyDeletion -> 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.ScheduleKeyDeletion" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PendingWindowInDays" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
pendingWindowInDays,
            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)
          ]
      )

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

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

-- | /See:/ 'newScheduleKeyDeletionResponse' smart constructor.
data ScheduleKeyDeletionResponse = ScheduleKeyDeletionResponse'
  { -- | 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 state: Effect on your KMS key>
    -- in the /Key Management Service Developer Guide/.
    ScheduleKeyDeletionResponse -> Maybe KeyState
keyState :: Prelude.Maybe KeyState,
    -- | 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 Core.POSIX,
    -- | 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
(ScheduleKeyDeletionResponse
 -> ScheduleKeyDeletionResponse -> Bool)
-> (ScheduleKeyDeletionResponse
    -> ScheduleKeyDeletionResponse -> Bool)
-> Eq ScheduleKeyDeletionResponse
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]
(Int -> ReadS ScheduleKeyDeletionResponse)
-> ReadS [ScheduleKeyDeletionResponse]
-> ReadPrec ScheduleKeyDeletionResponse
-> ReadPrec [ScheduleKeyDeletionResponse]
-> Read 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
(Int -> ScheduleKeyDeletionResponse -> ShowS)
-> (ScheduleKeyDeletionResponse -> String)
-> ([ScheduleKeyDeletionResponse] -> ShowS)
-> Show ScheduleKeyDeletionResponse
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.
 ScheduleKeyDeletionResponse -> Rep ScheduleKeyDeletionResponse x)
-> (forall x.
    Rep ScheduleKeyDeletionResponse x -> ScheduleKeyDeletionResponse)
-> Generic ScheduleKeyDeletionResponse
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:
--
-- '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 state: Effect on your KMS key>
-- in the /Key Management Service Developer Guide/.
--
-- '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.
--
-- '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' :: Maybe Text
-> Maybe KeyState
-> Maybe POSIX
-> Maybe Natural
-> Int
-> ScheduleKeyDeletionResponse
ScheduleKeyDeletionResponse'
    { $sel:keyId:ScheduleKeyDeletionResponse' :: Maybe Text
keyId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:keyState:ScheduleKeyDeletionResponse' :: Maybe KeyState
keyState = Maybe KeyState
forall a. Maybe a
Prelude.Nothing,
      $sel:deletionDate:ScheduleKeyDeletionResponse' :: Maybe POSIX
deletionDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:pendingWindowInDays:ScheduleKeyDeletionResponse' :: Maybe Natural
pendingWindowInDays = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ScheduleKeyDeletionResponse' :: 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 whose deletion is scheduled.
scheduleKeyDeletionResponse_keyId :: Lens.Lens' ScheduleKeyDeletionResponse (Prelude.Maybe Prelude.Text)
scheduleKeyDeletionResponse_keyId :: (Maybe Text -> f (Maybe Text))
-> ScheduleKeyDeletionResponse -> f ScheduleKeyDeletionResponse
scheduleKeyDeletionResponse_keyId = (ScheduleKeyDeletionResponse -> Maybe Text)
-> (ScheduleKeyDeletionResponse
    -> Maybe Text -> ScheduleKeyDeletionResponse)
-> Lens
     ScheduleKeyDeletionResponse
     ScheduleKeyDeletionResponse
     (Maybe Text)
     (Maybe Text)
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 state: Effect on your KMS key>
-- in the /Key Management Service Developer Guide/.
scheduleKeyDeletionResponse_keyState :: Lens.Lens' ScheduleKeyDeletionResponse (Prelude.Maybe KeyState)
scheduleKeyDeletionResponse_keyState :: (Maybe KeyState -> f (Maybe KeyState))
-> ScheduleKeyDeletionResponse -> f ScheduleKeyDeletionResponse
scheduleKeyDeletionResponse_keyState = (ScheduleKeyDeletionResponse -> Maybe KeyState)
-> (ScheduleKeyDeletionResponse
    -> Maybe KeyState -> ScheduleKeyDeletionResponse)
-> Lens
     ScheduleKeyDeletionResponse
     ScheduleKeyDeletionResponse
     (Maybe KeyState)
     (Maybe 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 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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ScheduleKeyDeletionResponse -> f ScheduleKeyDeletionResponse
scheduleKeyDeletionResponse_deletionDate = (ScheduleKeyDeletionResponse -> Maybe POSIX)
-> (ScheduleKeyDeletionResponse
    -> Maybe POSIX -> ScheduleKeyDeletionResponse)
-> Lens
     ScheduleKeyDeletionResponse
     ScheduleKeyDeletionResponse
     (Maybe POSIX)
     (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> ScheduleKeyDeletionResponse -> f ScheduleKeyDeletionResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ScheduleKeyDeletionResponse
-> f ScheduleKeyDeletionResponse
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 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 :: (Maybe Natural -> f (Maybe Natural))
-> ScheduleKeyDeletionResponse -> f ScheduleKeyDeletionResponse
scheduleKeyDeletionResponse_pendingWindowInDays = (ScheduleKeyDeletionResponse -> Maybe Natural)
-> (ScheduleKeyDeletionResponse
    -> Maybe Natural -> ScheduleKeyDeletionResponse)
-> Lens
     ScheduleKeyDeletionResponse
     ScheduleKeyDeletionResponse
     (Maybe Natural)
     (Maybe Natural)
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 :: (Int -> f Int)
-> ScheduleKeyDeletionResponse -> f ScheduleKeyDeletionResponse
scheduleKeyDeletionResponse_httpStatus = (ScheduleKeyDeletionResponse -> Int)
-> (ScheduleKeyDeletionResponse
    -> Int -> ScheduleKeyDeletionResponse)
-> Lens
     ScheduleKeyDeletionResponse ScheduleKeyDeletionResponse Int Int
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