{-# 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.EC2.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 an active export task. The request removes all artifacts of the
-- export, including any partially-created Amazon S3 objects. If the export
-- task is complete or is in the process of transferring the final disk
-- image, the command fails and returns an error.
module Amazonka.EC2.CancelExportTask
  ( -- * Creating a Request
    CancelExportTask (..),
    newCancelExportTask,

    -- * Request Lenses
    cancelExportTask_exportTaskId,

    -- * Destructuring the Response
    CancelExportTaskResponse (..),
    newCancelExportTaskResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Types
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. This is the ID returned by
    -- @CreateInstanceExportTask@.
    CancelExportTask -> Text
exportTaskId :: 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:
--
-- 'exportTaskId', 'cancelExportTask_exportTaskId' - The ID of the export task. This is the ID returned by
-- @CreateInstanceExportTask@.
newCancelExportTask ::
  -- | 'exportTaskId'
  Prelude.Text ->
  CancelExportTask
newCancelExportTask :: Text -> CancelExportTask
newCancelExportTask Text
pExportTaskId_ =
  CancelExportTask' {$sel:exportTaskId:CancelExportTask' :: Text
exportTaskId = Text
pExportTaskId_}

-- | The ID of the export task. This is the ID returned by
-- @CreateInstanceExportTask@.
cancelExportTask_exportTaskId :: Lens.Lens' CancelExportTask Prelude.Text
cancelExportTask_exportTaskId :: Lens' CancelExportTask Text
cancelExportTask_exportTaskId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelExportTask' {Text
exportTaskId :: Text
$sel:exportTaskId:CancelExportTask' :: CancelExportTask -> Text
exportTaskId} -> Text
exportTaskId) (\s :: CancelExportTask
s@CancelExportTask' {} Text
a -> CancelExportTask
s {$sel:exportTaskId:CancelExportTask' :: Text
exportTaskId = 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 => Service -> a -> Request a
Request.postQuery (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
exportTaskId :: Text
$sel:exportTaskId:CancelExportTask' :: CancelExportTask -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
exportTaskId

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

instance Data.ToHeaders CancelExportTask where
  toHeaders :: CancelExportTask -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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 CancelExportTask' {Text
exportTaskId :: Text
$sel:exportTaskId:CancelExportTask' :: CancelExportTask -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CancelExportTask" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"ExportTaskId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
exportTaskId
      ]

-- | /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
_ = ()