{-# 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.SWF.RespondActivityTaskCanceled
-- 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)
--
-- Used by workers to tell the service that the ActivityTask identified by
-- the @taskToken@ was successfully canceled. Additional @details@ can be
-- provided using the @details@ argument.
--
-- These @details@ (if provided) appear in the @ActivityTaskCanceled@ event
-- added to the workflow history.
--
-- Only use this operation if the @canceled@ flag of a
-- RecordActivityTaskHeartbeat request returns @true@ and if the activity
-- can be safely undone or abandoned.
--
-- A task is considered open from the time that it is scheduled until it is
-- closed. Therefore a task is reported as open while a worker is
-- processing it. A task is closed after it has been specified in a call to
-- RespondActivityTaskCompleted, RespondActivityTaskCanceled,
-- RespondActivityTaskFailed, or the task has
-- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dg-basic.html#swf-dev-timeout-types timed out>.
--
-- __Access Control__
--
-- You can use IAM policies to control this action\'s access to Amazon SWF
-- resources as follows:
--
-- -   Use a @Resource@ element with the domain name to limit the action to
--     only specified domains.
--
-- -   Use an @Action@ element to allow or deny permission to call this
--     action.
--
-- -   You cannot use an IAM policy to constrain this action\'s parameters.
--
-- If the caller doesn\'t have sufficient permissions to invoke the action,
-- or the parameter values fall outside the specified constraints, the
-- action fails. The associated event attribute\'s @cause@ parameter is set
-- to @OPERATION_NOT_PERMITTED@. For details and example IAM policies, see
-- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html Using IAM to Manage Access to Amazon SWF Workflows>
-- in the /Amazon SWF Developer Guide/.
module Amazonka.SWF.RespondActivityTaskCanceled
  ( -- * Creating a Request
    RespondActivityTaskCanceled (..),
    newRespondActivityTaskCanceled,

    -- * Request Lenses
    respondActivityTaskCanceled_details,
    respondActivityTaskCanceled_taskToken,

    -- * Destructuring the Response
    RespondActivityTaskCanceledResponse (..),
    newRespondActivityTaskCanceledResponse,
  )
where

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
import Amazonka.SWF.Types

-- | /See:/ 'newRespondActivityTaskCanceled' smart constructor.
data RespondActivityTaskCanceled = RespondActivityTaskCanceled'
  { -- | Information about the cancellation.
    RespondActivityTaskCanceled -> Maybe Text
details :: Prelude.Maybe Prelude.Text,
    -- | The @taskToken@ of the ActivityTask.
    --
    -- @taskToken@ is generated by the service and should be treated as an
    -- opaque value. If the task is passed to another process, its @taskToken@
    -- must also be passed. This enables it to provide its progress and respond
    -- with results.
    RespondActivityTaskCanceled -> Text
taskToken :: Prelude.Text
  }
  deriving (RespondActivityTaskCanceled -> RespondActivityTaskCanceled -> Bool
(RespondActivityTaskCanceled
 -> RespondActivityTaskCanceled -> Bool)
-> (RespondActivityTaskCanceled
    -> RespondActivityTaskCanceled -> Bool)
-> Eq RespondActivityTaskCanceled
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RespondActivityTaskCanceled -> RespondActivityTaskCanceled -> Bool
$c/= :: RespondActivityTaskCanceled -> RespondActivityTaskCanceled -> Bool
== :: RespondActivityTaskCanceled -> RespondActivityTaskCanceled -> Bool
$c== :: RespondActivityTaskCanceled -> RespondActivityTaskCanceled -> Bool
Prelude.Eq, ReadPrec [RespondActivityTaskCanceled]
ReadPrec RespondActivityTaskCanceled
Int -> ReadS RespondActivityTaskCanceled
ReadS [RespondActivityTaskCanceled]
(Int -> ReadS RespondActivityTaskCanceled)
-> ReadS [RespondActivityTaskCanceled]
-> ReadPrec RespondActivityTaskCanceled
-> ReadPrec [RespondActivityTaskCanceled]
-> Read RespondActivityTaskCanceled
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RespondActivityTaskCanceled]
$creadListPrec :: ReadPrec [RespondActivityTaskCanceled]
readPrec :: ReadPrec RespondActivityTaskCanceled
$creadPrec :: ReadPrec RespondActivityTaskCanceled
readList :: ReadS [RespondActivityTaskCanceled]
$creadList :: ReadS [RespondActivityTaskCanceled]
readsPrec :: Int -> ReadS RespondActivityTaskCanceled
$creadsPrec :: Int -> ReadS RespondActivityTaskCanceled
Prelude.Read, Int -> RespondActivityTaskCanceled -> ShowS
[RespondActivityTaskCanceled] -> ShowS
RespondActivityTaskCanceled -> String
(Int -> RespondActivityTaskCanceled -> ShowS)
-> (RespondActivityTaskCanceled -> String)
-> ([RespondActivityTaskCanceled] -> ShowS)
-> Show RespondActivityTaskCanceled
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RespondActivityTaskCanceled] -> ShowS
$cshowList :: [RespondActivityTaskCanceled] -> ShowS
show :: RespondActivityTaskCanceled -> String
$cshow :: RespondActivityTaskCanceled -> String
showsPrec :: Int -> RespondActivityTaskCanceled -> ShowS
$cshowsPrec :: Int -> RespondActivityTaskCanceled -> ShowS
Prelude.Show, (forall x.
 RespondActivityTaskCanceled -> Rep RespondActivityTaskCanceled x)
-> (forall x.
    Rep RespondActivityTaskCanceled x -> RespondActivityTaskCanceled)
-> Generic RespondActivityTaskCanceled
forall x.
Rep RespondActivityTaskCanceled x -> RespondActivityTaskCanceled
forall x.
RespondActivityTaskCanceled -> Rep RespondActivityTaskCanceled x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RespondActivityTaskCanceled x -> RespondActivityTaskCanceled
$cfrom :: forall x.
RespondActivityTaskCanceled -> Rep RespondActivityTaskCanceled x
Prelude.Generic)

-- |
-- Create a value of 'RespondActivityTaskCanceled' 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:
--
-- 'details', 'respondActivityTaskCanceled_details' - Information about the cancellation.
--
-- 'taskToken', 'respondActivityTaskCanceled_taskToken' - The @taskToken@ of the ActivityTask.
--
-- @taskToken@ is generated by the service and should be treated as an
-- opaque value. If the task is passed to another process, its @taskToken@
-- must also be passed. This enables it to provide its progress and respond
-- with results.
newRespondActivityTaskCanceled ::
  -- | 'taskToken'
  Prelude.Text ->
  RespondActivityTaskCanceled
newRespondActivityTaskCanceled :: Text -> RespondActivityTaskCanceled
newRespondActivityTaskCanceled Text
pTaskToken_ =
  RespondActivityTaskCanceled' :: Maybe Text -> Text -> RespondActivityTaskCanceled
RespondActivityTaskCanceled'
    { $sel:details:RespondActivityTaskCanceled' :: Maybe Text
details =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:taskToken:RespondActivityTaskCanceled' :: Text
taskToken = Text
pTaskToken_
    }

-- | Information about the cancellation.
respondActivityTaskCanceled_details :: Lens.Lens' RespondActivityTaskCanceled (Prelude.Maybe Prelude.Text)
respondActivityTaskCanceled_details :: (Maybe Text -> f (Maybe Text))
-> RespondActivityTaskCanceled -> f RespondActivityTaskCanceled
respondActivityTaskCanceled_details = (RespondActivityTaskCanceled -> Maybe Text)
-> (RespondActivityTaskCanceled
    -> Maybe Text -> RespondActivityTaskCanceled)
-> Lens
     RespondActivityTaskCanceled
     RespondActivityTaskCanceled
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RespondActivityTaskCanceled' {Maybe Text
details :: Maybe Text
$sel:details:RespondActivityTaskCanceled' :: RespondActivityTaskCanceled -> Maybe Text
details} -> Maybe Text
details) (\s :: RespondActivityTaskCanceled
s@RespondActivityTaskCanceled' {} Maybe Text
a -> RespondActivityTaskCanceled
s {$sel:details:RespondActivityTaskCanceled' :: Maybe Text
details = Maybe Text
a} :: RespondActivityTaskCanceled)

-- | The @taskToken@ of the ActivityTask.
--
-- @taskToken@ is generated by the service and should be treated as an
-- opaque value. If the task is passed to another process, its @taskToken@
-- must also be passed. This enables it to provide its progress and respond
-- with results.
respondActivityTaskCanceled_taskToken :: Lens.Lens' RespondActivityTaskCanceled Prelude.Text
respondActivityTaskCanceled_taskToken :: (Text -> f Text)
-> RespondActivityTaskCanceled -> f RespondActivityTaskCanceled
respondActivityTaskCanceled_taskToken = (RespondActivityTaskCanceled -> Text)
-> (RespondActivityTaskCanceled
    -> Text -> RespondActivityTaskCanceled)
-> Lens
     RespondActivityTaskCanceled RespondActivityTaskCanceled Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RespondActivityTaskCanceled' {Text
taskToken :: Text
$sel:taskToken:RespondActivityTaskCanceled' :: RespondActivityTaskCanceled -> Text
taskToken} -> Text
taskToken) (\s :: RespondActivityTaskCanceled
s@RespondActivityTaskCanceled' {} Text
a -> RespondActivityTaskCanceled
s {$sel:taskToken:RespondActivityTaskCanceled' :: Text
taskToken = Text
a} :: RespondActivityTaskCanceled)

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

instance Prelude.Hashable RespondActivityTaskCanceled

instance Prelude.NFData RespondActivityTaskCanceled

instance Core.ToHeaders RespondActivityTaskCanceled where
  toHeaders :: RespondActivityTaskCanceled -> [Header]
toHeaders =
    [Header] -> RespondActivityTaskCanceled -> [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
"SimpleWorkflowService.RespondActivityTaskCanceled" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON RespondActivityTaskCanceled where
  toJSON :: RespondActivityTaskCanceled -> Value
toJSON RespondActivityTaskCanceled' {Maybe Text
Text
taskToken :: Text
details :: Maybe Text
$sel:taskToken:RespondActivityTaskCanceled' :: RespondActivityTaskCanceled -> Text
$sel:details:RespondActivityTaskCanceled' :: RespondActivityTaskCanceled -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"details" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
details,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"taskToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
taskToken)
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    RespondActivityTaskCanceledResponse