{-# 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.CloudWatchLogs.DisassociateKmsKey
-- 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)
--
-- Disassociates the associated Key Management Service customer master key
-- (CMK) from the specified log group.
--
-- After the KMS CMK is disassociated from the log group, CloudWatch Logs
-- stops encrypting newly ingested data for the log group. All previously
-- ingested data remains encrypted, and CloudWatch Logs requires
-- permissions for the CMK whenever the encrypted data is requested.
--
-- Note that it can take up to 5 minutes for this operation to take effect.
module Amazonka.CloudWatchLogs.DisassociateKmsKey
  ( -- * Creating a Request
    DisassociateKmsKey (..),
    newDisassociateKmsKey,

    -- * Request Lenses
    disassociateKmsKey_logGroupName,

    -- * Destructuring the Response
    DisassociateKmsKeyResponse (..),
    newDisassociateKmsKeyResponse,
  )
where

import Amazonka.CloudWatchLogs.Types
import qualified Amazonka.Core as Core
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:/ 'newDisassociateKmsKey' smart constructor.
data DisassociateKmsKey = DisassociateKmsKey'
  { -- | The name of the log group.
    DisassociateKmsKey -> Text
logGroupName :: Prelude.Text
  }
  deriving (DisassociateKmsKey -> DisassociateKmsKey -> Bool
(DisassociateKmsKey -> DisassociateKmsKey -> Bool)
-> (DisassociateKmsKey -> DisassociateKmsKey -> Bool)
-> Eq DisassociateKmsKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateKmsKey -> DisassociateKmsKey -> Bool
$c/= :: DisassociateKmsKey -> DisassociateKmsKey -> Bool
== :: DisassociateKmsKey -> DisassociateKmsKey -> Bool
$c== :: DisassociateKmsKey -> DisassociateKmsKey -> Bool
Prelude.Eq, ReadPrec [DisassociateKmsKey]
ReadPrec DisassociateKmsKey
Int -> ReadS DisassociateKmsKey
ReadS [DisassociateKmsKey]
(Int -> ReadS DisassociateKmsKey)
-> ReadS [DisassociateKmsKey]
-> ReadPrec DisassociateKmsKey
-> ReadPrec [DisassociateKmsKey]
-> Read DisassociateKmsKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateKmsKey]
$creadListPrec :: ReadPrec [DisassociateKmsKey]
readPrec :: ReadPrec DisassociateKmsKey
$creadPrec :: ReadPrec DisassociateKmsKey
readList :: ReadS [DisassociateKmsKey]
$creadList :: ReadS [DisassociateKmsKey]
readsPrec :: Int -> ReadS DisassociateKmsKey
$creadsPrec :: Int -> ReadS DisassociateKmsKey
Prelude.Read, Int -> DisassociateKmsKey -> ShowS
[DisassociateKmsKey] -> ShowS
DisassociateKmsKey -> String
(Int -> DisassociateKmsKey -> ShowS)
-> (DisassociateKmsKey -> String)
-> ([DisassociateKmsKey] -> ShowS)
-> Show DisassociateKmsKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateKmsKey] -> ShowS
$cshowList :: [DisassociateKmsKey] -> ShowS
show :: DisassociateKmsKey -> String
$cshow :: DisassociateKmsKey -> String
showsPrec :: Int -> DisassociateKmsKey -> ShowS
$cshowsPrec :: Int -> DisassociateKmsKey -> ShowS
Prelude.Show, (forall x. DisassociateKmsKey -> Rep DisassociateKmsKey x)
-> (forall x. Rep DisassociateKmsKey x -> DisassociateKmsKey)
-> Generic DisassociateKmsKey
forall x. Rep DisassociateKmsKey x -> DisassociateKmsKey
forall x. DisassociateKmsKey -> Rep DisassociateKmsKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateKmsKey x -> DisassociateKmsKey
$cfrom :: forall x. DisassociateKmsKey -> Rep DisassociateKmsKey x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateKmsKey' 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:
--
-- 'logGroupName', 'disassociateKmsKey_logGroupName' - The name of the log group.
newDisassociateKmsKey ::
  -- | 'logGroupName'
  Prelude.Text ->
  DisassociateKmsKey
newDisassociateKmsKey :: Text -> DisassociateKmsKey
newDisassociateKmsKey Text
pLogGroupName_ =
  DisassociateKmsKey' :: Text -> DisassociateKmsKey
DisassociateKmsKey' {$sel:logGroupName:DisassociateKmsKey' :: Text
logGroupName = Text
pLogGroupName_}

-- | The name of the log group.
disassociateKmsKey_logGroupName :: Lens.Lens' DisassociateKmsKey Prelude.Text
disassociateKmsKey_logGroupName :: (Text -> f Text) -> DisassociateKmsKey -> f DisassociateKmsKey
disassociateKmsKey_logGroupName = (DisassociateKmsKey -> Text)
-> (DisassociateKmsKey -> Text -> DisassociateKmsKey)
-> Lens DisassociateKmsKey DisassociateKmsKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateKmsKey' {Text
logGroupName :: Text
$sel:logGroupName:DisassociateKmsKey' :: DisassociateKmsKey -> Text
logGroupName} -> Text
logGroupName) (\s :: DisassociateKmsKey
s@DisassociateKmsKey' {} Text
a -> DisassociateKmsKey
s {$sel:logGroupName:DisassociateKmsKey' :: Text
logGroupName = Text
a} :: DisassociateKmsKey)

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

instance Prelude.Hashable DisassociateKmsKey

instance Prelude.NFData DisassociateKmsKey

instance Core.ToHeaders DisassociateKmsKey where
  toHeaders :: DisassociateKmsKey -> [Header]
toHeaders =
    [Header] -> DisassociateKmsKey -> [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
"Logs_20140328.DisassociateKmsKey" ::
                          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 DisassociateKmsKey where
  toJSON :: DisassociateKmsKey -> Value
toJSON DisassociateKmsKey' {Text
logGroupName :: Text
$sel:logGroupName:DisassociateKmsKey' :: DisassociateKmsKey -> 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
"logGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logGroupName)]
      )

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

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

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

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

instance Prelude.NFData DisassociateKmsKeyResponse