{-# 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.DeleteLogGroup
-- 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)
--
-- Deletes the specified log group and permanently deletes all the archived
-- log events associated with the log group.
module Amazonka.CloudWatchLogs.DeleteLogGroup
  ( -- * Creating a Request
    DeleteLogGroup (..),
    newDeleteLogGroup,

    -- * Request Lenses
    deleteLogGroup_logGroupName,

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

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

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

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

instance Prelude.Hashable DeleteLogGroup

instance Prelude.NFData DeleteLogGroup

instance Core.ToHeaders DeleteLogGroup where
  toHeaders :: DeleteLogGroup -> [Header]
toHeaders =
    [Header] -> DeleteLogGroup -> [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.DeleteLogGroup" ::
                          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 DeleteLogGroup where
  toJSON :: DeleteLogGroup -> Value
toJSON DeleteLogGroup' {Text
logGroupName :: Text
$sel:logGroupName:DeleteLogGroup' :: DeleteLogGroup -> 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 DeleteLogGroup where
  toPath :: DeleteLogGroup -> ByteString
toPath = ByteString -> DeleteLogGroup -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

instance Prelude.NFData DeleteLogGroupResponse