{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates the associated KMS key from the specified log group.
--
-- After the KMS key 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 KMS key 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:logGroupName:DisassociateKmsKey' :: Text
logGroupName = Text
pLogGroupName_}

-- | The name of the log group.
disassociateKmsKey_logGroupName :: Lens.Lens' DisassociateKmsKey Prelude.Text
disassociateKmsKey_logGroupName :: Lens' DisassociateKmsKey Text
disassociateKmsKey_logGroupName = 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 :: (Service -> Service)
-> DisassociateKmsKey -> Request DisassociateKmsKey
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 DisassociateKmsKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateKmsKey)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DisassociateKmsKeyResponse
DisassociateKmsKeyResponse'

instance Prelude.Hashable DisassociateKmsKey where
  hashWithSalt :: Int -> DisassociateKmsKey -> Int
hashWithSalt Int
_salt DisassociateKmsKey' {Text
logGroupName :: Text
$sel:logGroupName:DisassociateKmsKey' :: DisassociateKmsKey -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
logGroupName

instance Prelude.NFData DisassociateKmsKey where
  rnf :: DisassociateKmsKey -> ()
rnf DisassociateKmsKey' {Text
logGroupName :: Text
$sel:logGroupName:DisassociateKmsKey' :: DisassociateKmsKey -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
logGroupName

instance Data.ToHeaders DisassociateKmsKey where
  toHeaders :: DisassociateKmsKey -> [Header]
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 -> [Header]
Data.=# ( ByteString
"Logs_20140328.DisassociateKmsKey" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DisassociateKmsKey where
  toJSON :: DisassociateKmsKey -> Value
toJSON DisassociateKmsKey' {Text
logGroupName :: Text
$sel:logGroupName:DisassociateKmsKey' :: DisassociateKmsKey -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"logGroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
logGroupName)]
      )

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

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

-- | /See:/ 'newDisassociateKmsKeyResponse' smart constructor.
data DisassociateKmsKeyResponse = DisassociateKmsKeyResponse'
  {
  }
  deriving (DisassociateKmsKeyResponse -> DisassociateKmsKeyResponse -> Bool
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]
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
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.
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 where
  rnf :: DisassociateKmsKeyResponse -> ()
rnf DisassociateKmsKeyResponse
_ = ()