{-# 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.CancelExportTask
-- 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)
--
-- Cancels the specified export task.
--
-- The task must be in the @PENDING@ or @RUNNING@ state.
module Amazonka.CloudWatchLogs.CancelExportTask
  ( -- * Creating a Request
    CancelExportTask (..),
    newCancelExportTask,

    -- * Request Lenses
    cancelExportTask_taskId,

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

-- |
-- Create a value of 'CancelExportTask' 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:
--
-- 'taskId', 'cancelExportTask_taskId' - The ID of the export task.
newCancelExportTask ::
  -- | 'taskId'
  Prelude.Text ->
  CancelExportTask
newCancelExportTask :: Text -> CancelExportTask
newCancelExportTask Text
pTaskId_ =
  CancelExportTask' :: Text -> CancelExportTask
CancelExportTask' {$sel:taskId:CancelExportTask' :: Text
taskId = Text
pTaskId_}

-- | The ID of the export task.
cancelExportTask_taskId :: Lens.Lens' CancelExportTask Prelude.Text
cancelExportTask_taskId :: (Text -> f Text) -> CancelExportTask -> f CancelExportTask
cancelExportTask_taskId = (CancelExportTask -> Text)
-> (CancelExportTask -> Text -> CancelExportTask)
-> Lens CancelExportTask CancelExportTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelExportTask' {Text
taskId :: Text
$sel:taskId:CancelExportTask' :: CancelExportTask -> Text
taskId} -> Text
taskId) (\s :: CancelExportTask
s@CancelExportTask' {} Text
a -> CancelExportTask
s {$sel:taskId:CancelExportTask' :: Text
taskId = Text
a} :: CancelExportTask)

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

instance Prelude.Hashable CancelExportTask

instance Prelude.NFData CancelExportTask

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

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

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

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

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

instance Prelude.NFData CancelExportTaskResponse