{-# 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.DisableKeyRotation
-- 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)
--
-- Disables
-- <https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html automatic rotation of the key material>
-- for the specified symmetric KMS key.
--
-- You cannot enable automatic rotation of
-- <https://docs.aws.amazon.com/kms/latest/developerguide/symm-asymm-concepts.html#asymmetric-cmks asymmetric KMS keys>,
-- KMS keys with
-- <https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html imported key material>,
-- or KMS keys in a
-- <https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html custom key store>.
-- To enable or disable automatic rotation of a set of related
-- <https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html#mrk-replica-key multi-Region keys>,
-- set the property on the primary key.
--
-- 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:DisableKeyRotation>
-- (key policy)
--
-- __Related operations:__
--
-- -   EnableKeyRotation
--
-- -   GetKeyRotationStatus
module Amazonka.KMS.DisableKeyRotation
  ( -- * Creating a Request
    DisableKeyRotation (..),
    newDisableKeyRotation,

    -- * Request Lenses
    disableKeyRotation_keyId,

    -- * Destructuring the Response
    DisableKeyRotationResponse (..),
    newDisableKeyRotationResponse,
  )
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:/ 'newDisableKeyRotation' smart constructor.
data DisableKeyRotation = DisableKeyRotation'
  { -- | Identifies a symmetric KMS key. You cannot enable or disable automatic
    -- rotation of
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html#asymmetric-cmks asymmetric KMS keys>,
    -- KMS keys with
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html imported key material>,
    -- or KMS keys in a
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html custom key store>.
    --
    -- 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.
    DisableKeyRotation -> Text
keyId :: Prelude.Text
  }
  deriving (DisableKeyRotation -> DisableKeyRotation -> Bool
(DisableKeyRotation -> DisableKeyRotation -> Bool)
-> (DisableKeyRotation -> DisableKeyRotation -> Bool)
-> Eq DisableKeyRotation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableKeyRotation -> DisableKeyRotation -> Bool
$c/= :: DisableKeyRotation -> DisableKeyRotation -> Bool
== :: DisableKeyRotation -> DisableKeyRotation -> Bool
$c== :: DisableKeyRotation -> DisableKeyRotation -> Bool
Prelude.Eq, ReadPrec [DisableKeyRotation]
ReadPrec DisableKeyRotation
Int -> ReadS DisableKeyRotation
ReadS [DisableKeyRotation]
(Int -> ReadS DisableKeyRotation)
-> ReadS [DisableKeyRotation]
-> ReadPrec DisableKeyRotation
-> ReadPrec [DisableKeyRotation]
-> Read DisableKeyRotation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableKeyRotation]
$creadListPrec :: ReadPrec [DisableKeyRotation]
readPrec :: ReadPrec DisableKeyRotation
$creadPrec :: ReadPrec DisableKeyRotation
readList :: ReadS [DisableKeyRotation]
$creadList :: ReadS [DisableKeyRotation]
readsPrec :: Int -> ReadS DisableKeyRotation
$creadsPrec :: Int -> ReadS DisableKeyRotation
Prelude.Read, Int -> DisableKeyRotation -> ShowS
[DisableKeyRotation] -> ShowS
DisableKeyRotation -> String
(Int -> DisableKeyRotation -> ShowS)
-> (DisableKeyRotation -> String)
-> ([DisableKeyRotation] -> ShowS)
-> Show DisableKeyRotation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableKeyRotation] -> ShowS
$cshowList :: [DisableKeyRotation] -> ShowS
show :: DisableKeyRotation -> String
$cshow :: DisableKeyRotation -> String
showsPrec :: Int -> DisableKeyRotation -> ShowS
$cshowsPrec :: Int -> DisableKeyRotation -> ShowS
Prelude.Show, (forall x. DisableKeyRotation -> Rep DisableKeyRotation x)
-> (forall x. Rep DisableKeyRotation x -> DisableKeyRotation)
-> Generic DisableKeyRotation
forall x. Rep DisableKeyRotation x -> DisableKeyRotation
forall x. DisableKeyRotation -> Rep DisableKeyRotation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableKeyRotation x -> DisableKeyRotation
$cfrom :: forall x. DisableKeyRotation -> Rep DisableKeyRotation x
Prelude.Generic)

-- |
-- Create a value of 'DisableKeyRotation' 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', 'disableKeyRotation_keyId' - Identifies a symmetric KMS key. You cannot enable or disable automatic
-- rotation of
-- <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html#asymmetric-cmks asymmetric KMS keys>,
-- KMS keys with
-- <https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html imported key material>,
-- or KMS keys in a
-- <https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html custom key store>.
--
-- 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.
newDisableKeyRotation ::
  -- | 'keyId'
  Prelude.Text ->
  DisableKeyRotation
newDisableKeyRotation :: Text -> DisableKeyRotation
newDisableKeyRotation Text
pKeyId_ =
  DisableKeyRotation' :: Text -> DisableKeyRotation
DisableKeyRotation' {$sel:keyId:DisableKeyRotation' :: Text
keyId = Text
pKeyId_}

-- | Identifies a symmetric KMS key. You cannot enable or disable automatic
-- rotation of
-- <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html#asymmetric-cmks asymmetric KMS keys>,
-- KMS keys with
-- <https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html imported key material>,
-- or KMS keys in a
-- <https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html custom key store>.
--
-- 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.
disableKeyRotation_keyId :: Lens.Lens' DisableKeyRotation Prelude.Text
disableKeyRotation_keyId :: (Text -> f Text) -> DisableKeyRotation -> f DisableKeyRotation
disableKeyRotation_keyId = (DisableKeyRotation -> Text)
-> (DisableKeyRotation -> Text -> DisableKeyRotation)
-> Lens DisableKeyRotation DisableKeyRotation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableKeyRotation' {Text
keyId :: Text
$sel:keyId:DisableKeyRotation' :: DisableKeyRotation -> Text
keyId} -> Text
keyId) (\s :: DisableKeyRotation
s@DisableKeyRotation' {} Text
a -> DisableKeyRotation
s {$sel:keyId:DisableKeyRotation' :: Text
keyId = Text
a} :: DisableKeyRotation)

instance Core.AWSRequest DisableKeyRotation where
  type
    AWSResponse DisableKeyRotation =
      DisableKeyRotationResponse
  request :: DisableKeyRotation -> Request DisableKeyRotation
request = Service -> DisableKeyRotation -> Request DisableKeyRotation
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisableKeyRotation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableKeyRotation)))
response =
    AWSResponse DisableKeyRotation
-> Logger
-> Service
-> Proxy DisableKeyRotation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableKeyRotation)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DisableKeyRotation
DisableKeyRotationResponse
DisableKeyRotationResponse'

instance Prelude.Hashable DisableKeyRotation

instance Prelude.NFData DisableKeyRotation

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

instance Core.ToJSON DisableKeyRotation where
  toJSON :: DisableKeyRotation -> Value
toJSON DisableKeyRotation' {Text
keyId :: Text
$sel:keyId:DisableKeyRotation' :: DisableKeyRotation -> 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)]
      )

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

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

-- | /See:/ 'newDisableKeyRotationResponse' smart constructor.
data DisableKeyRotationResponse = DisableKeyRotationResponse'
  {
  }
  deriving (DisableKeyRotationResponse -> DisableKeyRotationResponse -> Bool
(DisableKeyRotationResponse -> DisableKeyRotationResponse -> Bool)
-> (DisableKeyRotationResponse
    -> DisableKeyRotationResponse -> Bool)
-> Eq DisableKeyRotationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableKeyRotationResponse -> DisableKeyRotationResponse -> Bool
$c/= :: DisableKeyRotationResponse -> DisableKeyRotationResponse -> Bool
== :: DisableKeyRotationResponse -> DisableKeyRotationResponse -> Bool
$c== :: DisableKeyRotationResponse -> DisableKeyRotationResponse -> Bool
Prelude.Eq, ReadPrec [DisableKeyRotationResponse]
ReadPrec DisableKeyRotationResponse
Int -> ReadS DisableKeyRotationResponse
ReadS [DisableKeyRotationResponse]
(Int -> ReadS DisableKeyRotationResponse)
-> ReadS [DisableKeyRotationResponse]
-> ReadPrec DisableKeyRotationResponse
-> ReadPrec [DisableKeyRotationResponse]
-> Read DisableKeyRotationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableKeyRotationResponse]
$creadListPrec :: ReadPrec [DisableKeyRotationResponse]
readPrec :: ReadPrec DisableKeyRotationResponse
$creadPrec :: ReadPrec DisableKeyRotationResponse
readList :: ReadS [DisableKeyRotationResponse]
$creadList :: ReadS [DisableKeyRotationResponse]
readsPrec :: Int -> ReadS DisableKeyRotationResponse
$creadsPrec :: Int -> ReadS DisableKeyRotationResponse
Prelude.Read, Int -> DisableKeyRotationResponse -> ShowS
[DisableKeyRotationResponse] -> ShowS
DisableKeyRotationResponse -> String
(Int -> DisableKeyRotationResponse -> ShowS)
-> (DisableKeyRotationResponse -> String)
-> ([DisableKeyRotationResponse] -> ShowS)
-> Show DisableKeyRotationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableKeyRotationResponse] -> ShowS
$cshowList :: [DisableKeyRotationResponse] -> ShowS
show :: DisableKeyRotationResponse -> String
$cshow :: DisableKeyRotationResponse -> String
showsPrec :: Int -> DisableKeyRotationResponse -> ShowS
$cshowsPrec :: Int -> DisableKeyRotationResponse -> ShowS
Prelude.Show, (forall x.
 DisableKeyRotationResponse -> Rep DisableKeyRotationResponse x)
-> (forall x.
    Rep DisableKeyRotationResponse x -> DisableKeyRotationResponse)
-> Generic DisableKeyRotationResponse
forall x.
Rep DisableKeyRotationResponse x -> DisableKeyRotationResponse
forall x.
DisableKeyRotationResponse -> Rep DisableKeyRotationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisableKeyRotationResponse x -> DisableKeyRotationResponse
$cfrom :: forall x.
DisableKeyRotationResponse -> Rep DisableKeyRotationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisableKeyRotationResponse' 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.
newDisableKeyRotationResponse ::
  DisableKeyRotationResponse
newDisableKeyRotationResponse :: DisableKeyRotationResponse
newDisableKeyRotationResponse =
  DisableKeyRotationResponse
DisableKeyRotationResponse'

instance Prelude.NFData DisableKeyRotationResponse