{-# 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.DataSync.CancelTaskExecution
-- 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 execution of a task.
--
-- When you cancel a task execution, the transfer of some files is abruptly
-- interrupted. The contents of files that are transferred to the
-- destination might be incomplete or inconsistent with the source files.
-- However, if you start a new task execution on the same task and you
-- allow the task execution to complete, file content on the destination is
-- complete and consistent. This applies to other unexpected failures that
-- interrupt a task execution. In all of these cases, DataSync successfully
-- complete the transfer when you start the next task execution.
module Amazonka.DataSync.CancelTaskExecution
  ( -- * Creating a Request
    CancelTaskExecution (..),
    newCancelTaskExecution,

    -- * Request Lenses
    cancelTaskExecution_taskExecutionArn,

    -- * Destructuring the Response
    CancelTaskExecutionResponse (..),
    newCancelTaskExecutionResponse,

    -- * Response Lenses
    cancelTaskExecutionResponse_httpStatus,
  )
where

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

-- | CancelTaskExecutionRequest
--
-- /See:/ 'newCancelTaskExecution' smart constructor.
data CancelTaskExecution = CancelTaskExecution'
  { -- | The Amazon Resource Name (ARN) of the task execution to cancel.
    CancelTaskExecution -> Text
taskExecutionArn :: Prelude.Text
  }
  deriving (CancelTaskExecution -> CancelTaskExecution -> Bool
(CancelTaskExecution -> CancelTaskExecution -> Bool)
-> (CancelTaskExecution -> CancelTaskExecution -> Bool)
-> Eq CancelTaskExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelTaskExecution -> CancelTaskExecution -> Bool
$c/= :: CancelTaskExecution -> CancelTaskExecution -> Bool
== :: CancelTaskExecution -> CancelTaskExecution -> Bool
$c== :: CancelTaskExecution -> CancelTaskExecution -> Bool
Prelude.Eq, ReadPrec [CancelTaskExecution]
ReadPrec CancelTaskExecution
Int -> ReadS CancelTaskExecution
ReadS [CancelTaskExecution]
(Int -> ReadS CancelTaskExecution)
-> ReadS [CancelTaskExecution]
-> ReadPrec CancelTaskExecution
-> ReadPrec [CancelTaskExecution]
-> Read CancelTaskExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelTaskExecution]
$creadListPrec :: ReadPrec [CancelTaskExecution]
readPrec :: ReadPrec CancelTaskExecution
$creadPrec :: ReadPrec CancelTaskExecution
readList :: ReadS [CancelTaskExecution]
$creadList :: ReadS [CancelTaskExecution]
readsPrec :: Int -> ReadS CancelTaskExecution
$creadsPrec :: Int -> ReadS CancelTaskExecution
Prelude.Read, Int -> CancelTaskExecution -> ShowS
[CancelTaskExecution] -> ShowS
CancelTaskExecution -> String
(Int -> CancelTaskExecution -> ShowS)
-> (CancelTaskExecution -> String)
-> ([CancelTaskExecution] -> ShowS)
-> Show CancelTaskExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelTaskExecution] -> ShowS
$cshowList :: [CancelTaskExecution] -> ShowS
show :: CancelTaskExecution -> String
$cshow :: CancelTaskExecution -> String
showsPrec :: Int -> CancelTaskExecution -> ShowS
$cshowsPrec :: Int -> CancelTaskExecution -> ShowS
Prelude.Show, (forall x. CancelTaskExecution -> Rep CancelTaskExecution x)
-> (forall x. Rep CancelTaskExecution x -> CancelTaskExecution)
-> Generic CancelTaskExecution
forall x. Rep CancelTaskExecution x -> CancelTaskExecution
forall x. CancelTaskExecution -> Rep CancelTaskExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelTaskExecution x -> CancelTaskExecution
$cfrom :: forall x. CancelTaskExecution -> Rep CancelTaskExecution x
Prelude.Generic)

-- |
-- Create a value of 'CancelTaskExecution' 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:
--
-- 'taskExecutionArn', 'cancelTaskExecution_taskExecutionArn' - The Amazon Resource Name (ARN) of the task execution to cancel.
newCancelTaskExecution ::
  -- | 'taskExecutionArn'
  Prelude.Text ->
  CancelTaskExecution
newCancelTaskExecution :: Text -> CancelTaskExecution
newCancelTaskExecution Text
pTaskExecutionArn_ =
  CancelTaskExecution' :: Text -> CancelTaskExecution
CancelTaskExecution'
    { $sel:taskExecutionArn:CancelTaskExecution' :: Text
taskExecutionArn =
        Text
pTaskExecutionArn_
    }

-- | The Amazon Resource Name (ARN) of the task execution to cancel.
cancelTaskExecution_taskExecutionArn :: Lens.Lens' CancelTaskExecution Prelude.Text
cancelTaskExecution_taskExecutionArn :: (Text -> f Text) -> CancelTaskExecution -> f CancelTaskExecution
cancelTaskExecution_taskExecutionArn = (CancelTaskExecution -> Text)
-> (CancelTaskExecution -> Text -> CancelTaskExecution)
-> Lens CancelTaskExecution CancelTaskExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelTaskExecution' {Text
taskExecutionArn :: Text
$sel:taskExecutionArn:CancelTaskExecution' :: CancelTaskExecution -> Text
taskExecutionArn} -> Text
taskExecutionArn) (\s :: CancelTaskExecution
s@CancelTaskExecution' {} Text
a -> CancelTaskExecution
s {$sel:taskExecutionArn:CancelTaskExecution' :: Text
taskExecutionArn = Text
a} :: CancelTaskExecution)

instance Core.AWSRequest CancelTaskExecution where
  type
    AWSResponse CancelTaskExecution =
      CancelTaskExecutionResponse
  request :: CancelTaskExecution -> Request CancelTaskExecution
request = Service -> CancelTaskExecution -> Request CancelTaskExecution
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelTaskExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelTaskExecution)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CancelTaskExecution))
-> Logger
-> Service
-> Proxy CancelTaskExecution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelTaskExecution)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CancelTaskExecutionResponse
CancelTaskExecutionResponse'
            (Int -> CancelTaskExecutionResponse)
-> Either String Int -> Either String CancelTaskExecutionResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CancelTaskExecution

instance Prelude.NFData CancelTaskExecution

instance Core.ToHeaders CancelTaskExecution where
  toHeaders :: CancelTaskExecution -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CancelTaskExecution -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"FmrsService.CancelTaskExecution" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CancelTaskExecution where
  toJSON :: CancelTaskExecution -> Value
toJSON CancelTaskExecution' {Text
taskExecutionArn :: Text
$sel:taskExecutionArn:CancelTaskExecution' :: CancelTaskExecution -> 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
"TaskExecutionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
taskExecutionArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'CancelTaskExecutionResponse' 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:
--
-- 'httpStatus', 'cancelTaskExecutionResponse_httpStatus' - The response's http status code.
newCancelTaskExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CancelTaskExecutionResponse
newCancelTaskExecutionResponse :: Int -> CancelTaskExecutionResponse
newCancelTaskExecutionResponse Int
pHttpStatus_ =
  CancelTaskExecutionResponse' :: Int -> CancelTaskExecutionResponse
CancelTaskExecutionResponse'
    { $sel:httpStatus:CancelTaskExecutionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
cancelTaskExecutionResponse_httpStatus :: Lens.Lens' CancelTaskExecutionResponse Prelude.Int
cancelTaskExecutionResponse_httpStatus :: (Int -> f Int)
-> CancelTaskExecutionResponse -> f CancelTaskExecutionResponse
cancelTaskExecutionResponse_httpStatus = (CancelTaskExecutionResponse -> Int)
-> (CancelTaskExecutionResponse
    -> Int -> CancelTaskExecutionResponse)
-> Lens
     CancelTaskExecutionResponse CancelTaskExecutionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelTaskExecutionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CancelTaskExecutionResponse' :: CancelTaskExecutionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CancelTaskExecutionResponse
s@CancelTaskExecutionResponse' {} Int
a -> CancelTaskExecutionResponse
s {$sel:httpStatus:CancelTaskExecutionResponse' :: Int
httpStatus = Int
a} :: CancelTaskExecutionResponse)

instance Prelude.NFData CancelTaskExecutionResponse