{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ 'newCancelExportTask' smart constructor.
data CancelExportTask = CancelExportTask'
  { -- | The ID of the export task.
    CancelExportTask -> Text
taskId :: Prelude.Text
  }
  deriving (CancelExportTask -> CancelExportTask -> Bool
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]
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
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. 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' {$sel:taskId:CancelExportTask' :: Text
taskId = Text
pTaskId_}

-- | The ID of the export task.
cancelExportTask_taskId :: Lens.Lens' CancelExportTask Prelude.Text
cancelExportTask_taskId :: Lens' CancelExportTask Text
cancelExportTask_taskId = 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 :: (Service -> Service)
-> CancelExportTask -> Request CancelExportTask
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 CancelExportTask
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelExportTask)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull CancelExportTaskResponse
CancelExportTaskResponse'

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

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

instance Data.ToHeaders CancelExportTask where
  toHeaders :: CancelExportTask -> [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.CancelExportTask" ::
                          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 CancelExportTask where
  toJSON :: CancelExportTask -> Value
toJSON CancelExportTask' {Text
taskId :: Text
$sel:taskId:CancelExportTask' :: CancelExportTask -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"taskId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
taskId)]
      )

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

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

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