{-# 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.RDS.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 an export task in progress that is exporting a snapshot to
-- Amazon S3. Any data that has already been written to the S3 bucket
-- isn\'t removed.
module Amazonka.RDS.CancelExportTask
  ( -- * Creating a Request
    CancelExportTask (..),
    newCancelExportTask,

    -- * Request Lenses
    cancelExportTask_exportTaskIdentifier,

    -- * Destructuring the Response
    ExportTask (..),
    newExportTask,

    -- * Response Lenses
    exportTask_totalExtractedDataInGB,
    exportTask_status,
    exportTask_iamRoleArn,
    exportTask_sourceArn,
    exportTask_exportOnly,
    exportTask_taskStartTime,
    exportTask_warningMessage,
    exportTask_snapshotTime,
    exportTask_kmsKeyId,
    exportTask_taskEndTime,
    exportTask_exportTaskIdentifier,
    exportTask_s3Prefix,
    exportTask_percentProgress,
    exportTask_s3Bucket,
    exportTask_failureCause,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDS.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCancelExportTask' smart constructor.
data CancelExportTask = CancelExportTask'
  { -- | The identifier of the snapshot export task to cancel.
    CancelExportTask -> Text
exportTaskIdentifier :: 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:
--
-- 'exportTaskIdentifier', 'cancelExportTask_exportTaskIdentifier' - The identifier of the snapshot export task to cancel.
newCancelExportTask ::
  -- | 'exportTaskIdentifier'
  Prelude.Text ->
  CancelExportTask
newCancelExportTask :: Text -> CancelExportTask
newCancelExportTask Text
pExportTaskIdentifier_ =
  CancelExportTask' :: Text -> CancelExportTask
CancelExportTask'
    { $sel:exportTaskIdentifier:CancelExportTask' :: Text
exportTaskIdentifier =
        Text
pExportTaskIdentifier_
    }

-- | The identifier of the snapshot export task to cancel.
cancelExportTask_exportTaskIdentifier :: Lens.Lens' CancelExportTask Prelude.Text
cancelExportTask_exportTaskIdentifier :: (Text -> f Text) -> CancelExportTask -> f CancelExportTask
cancelExportTask_exportTaskIdentifier = (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
exportTaskIdentifier :: Text
$sel:exportTaskIdentifier:CancelExportTask' :: CancelExportTask -> Text
exportTaskIdentifier} -> Text
exportTaskIdentifier) (\s :: CancelExportTask
s@CancelExportTask' {} Text
a -> CancelExportTask
s {$sel:exportTaskIdentifier:CancelExportTask' :: Text
exportTaskIdentifier = Text
a} :: CancelExportTask)

instance Core.AWSRequest CancelExportTask where
  type AWSResponse CancelExportTask = ExportTask
  request :: CancelExportTask -> Request CancelExportTask
request = Service -> CancelExportTask -> Request CancelExportTask
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelExportTask
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelExportTask)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CancelExportTask))
-> Logger
-> Service
-> Proxy CancelExportTask
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelExportTask)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"CancelExportTaskResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String ExportTask
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable CancelExportTask

instance Prelude.NFData CancelExportTask

instance Core.ToHeaders CancelExportTask where
  toHeaders :: CancelExportTask -> ResponseHeaders
toHeaders = ResponseHeaders -> CancelExportTask -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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 CancelExportTask' {Text
exportTaskIdentifier :: Text
$sel:exportTaskIdentifier:CancelExportTask' :: CancelExportTask -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CancelExportTask" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2014-10-31" :: Prelude.ByteString),
        ByteString
"ExportTaskIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
exportTaskIdentifier
      ]