{-# 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.RespondActivityTaskFailed
-- 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@ has failed with @reason@ (if specified). The @reason@
-- and @details@ appear in the @ActivityTaskFailed@ event added to the
-- workflow history.
--
-- 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.RespondActivityTaskFailed
  ( -- * Creating a Request
    RespondActivityTaskFailed (..),
    newRespondActivityTaskFailed,

    -- * Request Lenses
    respondActivityTaskFailed_reason,
    respondActivityTaskFailed_details,
    respondActivityTaskFailed_taskToken,

    -- * Destructuring the Response
    RespondActivityTaskFailedResponse (..),
    newRespondActivityTaskFailedResponse,
  )
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:/ 'newRespondActivityTaskFailed' smart constructor.
data RespondActivityTaskFailed = RespondActivityTaskFailed'
  { -- | Description of the error that may assist in diagnostics.
    RespondActivityTaskFailed -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | Detailed information about the failure.
    RespondActivityTaskFailed -> 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.
    RespondActivityTaskFailed -> Text
taskToken :: Prelude.Text
  }
  deriving (RespondActivityTaskFailed -> RespondActivityTaskFailed -> Bool
(RespondActivityTaskFailed -> RespondActivityTaskFailed -> Bool)
-> (RespondActivityTaskFailed -> RespondActivityTaskFailed -> Bool)
-> Eq RespondActivityTaskFailed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RespondActivityTaskFailed -> RespondActivityTaskFailed -> Bool
$c/= :: RespondActivityTaskFailed -> RespondActivityTaskFailed -> Bool
== :: RespondActivityTaskFailed -> RespondActivityTaskFailed -> Bool
$c== :: RespondActivityTaskFailed -> RespondActivityTaskFailed -> Bool
Prelude.Eq, ReadPrec [RespondActivityTaskFailed]
ReadPrec RespondActivityTaskFailed
Int -> ReadS RespondActivityTaskFailed
ReadS [RespondActivityTaskFailed]
(Int -> ReadS RespondActivityTaskFailed)
-> ReadS [RespondActivityTaskFailed]
-> ReadPrec RespondActivityTaskFailed
-> ReadPrec [RespondActivityTaskFailed]
-> Read RespondActivityTaskFailed
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RespondActivityTaskFailed]
$creadListPrec :: ReadPrec [RespondActivityTaskFailed]
readPrec :: ReadPrec RespondActivityTaskFailed
$creadPrec :: ReadPrec RespondActivityTaskFailed
readList :: ReadS [RespondActivityTaskFailed]
$creadList :: ReadS [RespondActivityTaskFailed]
readsPrec :: Int -> ReadS RespondActivityTaskFailed
$creadsPrec :: Int -> ReadS RespondActivityTaskFailed
Prelude.Read, Int -> RespondActivityTaskFailed -> ShowS
[RespondActivityTaskFailed] -> ShowS
RespondActivityTaskFailed -> String
(Int -> RespondActivityTaskFailed -> ShowS)
-> (RespondActivityTaskFailed -> String)
-> ([RespondActivityTaskFailed] -> ShowS)
-> Show RespondActivityTaskFailed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RespondActivityTaskFailed] -> ShowS
$cshowList :: [RespondActivityTaskFailed] -> ShowS
show :: RespondActivityTaskFailed -> String
$cshow :: RespondActivityTaskFailed -> String
showsPrec :: Int -> RespondActivityTaskFailed -> ShowS
$cshowsPrec :: Int -> RespondActivityTaskFailed -> ShowS
Prelude.Show, (forall x.
 RespondActivityTaskFailed -> Rep RespondActivityTaskFailed x)
-> (forall x.
    Rep RespondActivityTaskFailed x -> RespondActivityTaskFailed)
-> Generic RespondActivityTaskFailed
forall x.
Rep RespondActivityTaskFailed x -> RespondActivityTaskFailed
forall x.
RespondActivityTaskFailed -> Rep RespondActivityTaskFailed x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RespondActivityTaskFailed x -> RespondActivityTaskFailed
$cfrom :: forall x.
RespondActivityTaskFailed -> Rep RespondActivityTaskFailed x
Prelude.Generic)

-- |
-- Create a value of 'RespondActivityTaskFailed' 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:
--
-- 'reason', 'respondActivityTaskFailed_reason' - Description of the error that may assist in diagnostics.
--
-- 'details', 'respondActivityTaskFailed_details' - Detailed information about the failure.
--
-- 'taskToken', 'respondActivityTaskFailed_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.
newRespondActivityTaskFailed ::
  -- | 'taskToken'
  Prelude.Text ->
  RespondActivityTaskFailed
newRespondActivityTaskFailed :: Text -> RespondActivityTaskFailed
newRespondActivityTaskFailed Text
pTaskToken_ =
  RespondActivityTaskFailed' :: Maybe Text -> Maybe Text -> Text -> RespondActivityTaskFailed
RespondActivityTaskFailed'
    { $sel:reason:RespondActivityTaskFailed' :: Maybe Text
reason =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:details:RespondActivityTaskFailed' :: Maybe Text
details = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:taskToken:RespondActivityTaskFailed' :: Text
taskToken = Text
pTaskToken_
    }

-- | Description of the error that may assist in diagnostics.
respondActivityTaskFailed_reason :: Lens.Lens' RespondActivityTaskFailed (Prelude.Maybe Prelude.Text)
respondActivityTaskFailed_reason :: (Maybe Text -> f (Maybe Text))
-> RespondActivityTaskFailed -> f RespondActivityTaskFailed
respondActivityTaskFailed_reason = (RespondActivityTaskFailed -> Maybe Text)
-> (RespondActivityTaskFailed
    -> Maybe Text -> RespondActivityTaskFailed)
-> Lens
     RespondActivityTaskFailed
     RespondActivityTaskFailed
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RespondActivityTaskFailed' {Maybe Text
reason :: Maybe Text
$sel:reason:RespondActivityTaskFailed' :: RespondActivityTaskFailed -> Maybe Text
reason} -> Maybe Text
reason) (\s :: RespondActivityTaskFailed
s@RespondActivityTaskFailed' {} Maybe Text
a -> RespondActivityTaskFailed
s {$sel:reason:RespondActivityTaskFailed' :: Maybe Text
reason = Maybe Text
a} :: RespondActivityTaskFailed)

-- | Detailed information about the failure.
respondActivityTaskFailed_details :: Lens.Lens' RespondActivityTaskFailed (Prelude.Maybe Prelude.Text)
respondActivityTaskFailed_details :: (Maybe Text -> f (Maybe Text))
-> RespondActivityTaskFailed -> f RespondActivityTaskFailed
respondActivityTaskFailed_details = (RespondActivityTaskFailed -> Maybe Text)
-> (RespondActivityTaskFailed
    -> Maybe Text -> RespondActivityTaskFailed)
-> Lens
     RespondActivityTaskFailed
     RespondActivityTaskFailed
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RespondActivityTaskFailed' {Maybe Text
details :: Maybe Text
$sel:details:RespondActivityTaskFailed' :: RespondActivityTaskFailed -> Maybe Text
details} -> Maybe Text
details) (\s :: RespondActivityTaskFailed
s@RespondActivityTaskFailed' {} Maybe Text
a -> RespondActivityTaskFailed
s {$sel:details:RespondActivityTaskFailed' :: Maybe Text
details = Maybe Text
a} :: RespondActivityTaskFailed)

-- | 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.
respondActivityTaskFailed_taskToken :: Lens.Lens' RespondActivityTaskFailed Prelude.Text
respondActivityTaskFailed_taskToken :: (Text -> f Text)
-> RespondActivityTaskFailed -> f RespondActivityTaskFailed
respondActivityTaskFailed_taskToken = (RespondActivityTaskFailed -> Text)
-> (RespondActivityTaskFailed -> Text -> RespondActivityTaskFailed)
-> Lens
     RespondActivityTaskFailed RespondActivityTaskFailed Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RespondActivityTaskFailed' {Text
taskToken :: Text
$sel:taskToken:RespondActivityTaskFailed' :: RespondActivityTaskFailed -> Text
taskToken} -> Text
taskToken) (\s :: RespondActivityTaskFailed
s@RespondActivityTaskFailed' {} Text
a -> RespondActivityTaskFailed
s {$sel:taskToken:RespondActivityTaskFailed' :: Text
taskToken = Text
a} :: RespondActivityTaskFailed)

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

instance Prelude.Hashable RespondActivityTaskFailed

instance Prelude.NFData RespondActivityTaskFailed

instance Core.ToHeaders RespondActivityTaskFailed where
  toHeaders :: RespondActivityTaskFailed -> [Header]
toHeaders =
    [Header] -> RespondActivityTaskFailed -> [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.RespondActivityTaskFailed" ::
                          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 RespondActivityTaskFailed where
  toJSON :: RespondActivityTaskFailed -> Value
toJSON RespondActivityTaskFailed' {Maybe Text
Text
taskToken :: Text
details :: Maybe Text
reason :: Maybe Text
$sel:taskToken:RespondActivityTaskFailed' :: RespondActivityTaskFailed -> Text
$sel:details:RespondActivityTaskFailed' :: RespondActivityTaskFailed -> Maybe Text
$sel:reason:RespondActivityTaskFailed' :: RespondActivityTaskFailed -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"reason" 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
reason,
            (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 RespondActivityTaskFailed where
  toPath :: RespondActivityTaskFailed -> ByteString
toPath = ByteString -> RespondActivityTaskFailed -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

instance
  Prelude.NFData
    RespondActivityTaskFailedResponse