{-# 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.DeleteLogStream
-- 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 stream and permanently deletes all the
-- archived log events associated with the log stream.
module Amazonka.CloudWatchLogs.DeleteLogStream
  ( -- * Creating a Request
    DeleteLogStream (..),
    newDeleteLogStream,

    -- * Request Lenses
    deleteLogStream_logGroupName,
    deleteLogStream_logStreamName,

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

-- |
-- Create a value of 'DeleteLogStream' 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', 'deleteLogStream_logGroupName' - The name of the log group.
--
-- 'logStreamName', 'deleteLogStream_logStreamName' - The name of the log stream.
newDeleteLogStream ::
  -- | 'logGroupName'
  Prelude.Text ->
  -- | 'logStreamName'
  Prelude.Text ->
  DeleteLogStream
newDeleteLogStream :: Text -> Text -> DeleteLogStream
newDeleteLogStream Text
pLogGroupName_ Text
pLogStreamName_ =
  DeleteLogStream' :: Text -> Text -> DeleteLogStream
DeleteLogStream'
    { $sel:logGroupName:DeleteLogStream' :: Text
logGroupName = Text
pLogGroupName_,
      $sel:logStreamName:DeleteLogStream' :: Text
logStreamName = Text
pLogStreamName_
    }

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

-- | The name of the log stream.
deleteLogStream_logStreamName :: Lens.Lens' DeleteLogStream Prelude.Text
deleteLogStream_logStreamName :: (Text -> f Text) -> DeleteLogStream -> f DeleteLogStream
deleteLogStream_logStreamName = (DeleteLogStream -> Text)
-> (DeleteLogStream -> Text -> DeleteLogStream)
-> Lens DeleteLogStream DeleteLogStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLogStream' {Text
logStreamName :: Text
$sel:logStreamName:DeleteLogStream' :: DeleteLogStream -> Text
logStreamName} -> Text
logStreamName) (\s :: DeleteLogStream
s@DeleteLogStream' {} Text
a -> DeleteLogStream
s {$sel:logStreamName:DeleteLogStream' :: Text
logStreamName = Text
a} :: DeleteLogStream)

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

instance Prelude.Hashable DeleteLogStream

instance Prelude.NFData DeleteLogStream

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

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

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

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

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

instance Prelude.NFData DeleteLogStreamResponse