{-# 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.StepFunctions.SendTaskSuccess
-- 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 activity workers and task states using the
-- <https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-wait-token callback>
-- pattern to report that the task identified by the @taskToken@ completed
-- successfully.
module Amazonka.StepFunctions.SendTaskSuccess
  ( -- * Creating a Request
    SendTaskSuccess (..),
    newSendTaskSuccess,

    -- * Request Lenses
    sendTaskSuccess_taskToken,
    sendTaskSuccess_output,

    -- * Destructuring the Response
    SendTaskSuccessResponse (..),
    newSendTaskSuccessResponse,

    -- * Response Lenses
    sendTaskSuccessResponse_httpStatus,
  )
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.StepFunctions.Types

-- | /See:/ 'newSendTaskSuccess' smart constructor.
data SendTaskSuccess = SendTaskSuccess'
  { -- | The token that represents this task. Task tokens are generated by Step
    -- Functions when tasks are assigned to a worker, or in the
    -- <https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html context object>
    -- when a workflow enters a task state. See
    -- GetActivityTaskOutput$taskToken.
    SendTaskSuccess -> Text
taskToken :: Prelude.Text,
    -- | The JSON output of the task. Length constraints apply to the payload
    -- size, and are expressed as bytes in UTF-8 encoding.
    SendTaskSuccess -> Sensitive Text
output :: Core.Sensitive Prelude.Text
  }
  deriving (SendTaskSuccess -> SendTaskSuccess -> Bool
(SendTaskSuccess -> SendTaskSuccess -> Bool)
-> (SendTaskSuccess -> SendTaskSuccess -> Bool)
-> Eq SendTaskSuccess
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendTaskSuccess -> SendTaskSuccess -> Bool
$c/= :: SendTaskSuccess -> SendTaskSuccess -> Bool
== :: SendTaskSuccess -> SendTaskSuccess -> Bool
$c== :: SendTaskSuccess -> SendTaskSuccess -> Bool
Prelude.Eq, Int -> SendTaskSuccess -> ShowS
[SendTaskSuccess] -> ShowS
SendTaskSuccess -> String
(Int -> SendTaskSuccess -> ShowS)
-> (SendTaskSuccess -> String)
-> ([SendTaskSuccess] -> ShowS)
-> Show SendTaskSuccess
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendTaskSuccess] -> ShowS
$cshowList :: [SendTaskSuccess] -> ShowS
show :: SendTaskSuccess -> String
$cshow :: SendTaskSuccess -> String
showsPrec :: Int -> SendTaskSuccess -> ShowS
$cshowsPrec :: Int -> SendTaskSuccess -> ShowS
Prelude.Show, (forall x. SendTaskSuccess -> Rep SendTaskSuccess x)
-> (forall x. Rep SendTaskSuccess x -> SendTaskSuccess)
-> Generic SendTaskSuccess
forall x. Rep SendTaskSuccess x -> SendTaskSuccess
forall x. SendTaskSuccess -> Rep SendTaskSuccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendTaskSuccess x -> SendTaskSuccess
$cfrom :: forall x. SendTaskSuccess -> Rep SendTaskSuccess x
Prelude.Generic)

-- |
-- Create a value of 'SendTaskSuccess' 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:
--
-- 'taskToken', 'sendTaskSuccess_taskToken' - The token that represents this task. Task tokens are generated by Step
-- Functions when tasks are assigned to a worker, or in the
-- <https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html context object>
-- when a workflow enters a task state. See
-- GetActivityTaskOutput$taskToken.
--
-- 'output', 'sendTaskSuccess_output' - The JSON output of the task. Length constraints apply to the payload
-- size, and are expressed as bytes in UTF-8 encoding.
newSendTaskSuccess ::
  -- | 'taskToken'
  Prelude.Text ->
  -- | 'output'
  Prelude.Text ->
  SendTaskSuccess
newSendTaskSuccess :: Text -> Text -> SendTaskSuccess
newSendTaskSuccess Text
pTaskToken_ Text
pOutput_ =
  SendTaskSuccess' :: Text -> Sensitive Text -> SendTaskSuccess
SendTaskSuccess'
    { $sel:taskToken:SendTaskSuccess' :: Text
taskToken = Text
pTaskToken_,
      $sel:output:SendTaskSuccess' :: Sensitive Text
output = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pOutput_
    }

-- | The token that represents this task. Task tokens are generated by Step
-- Functions when tasks are assigned to a worker, or in the
-- <https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html context object>
-- when a workflow enters a task state. See
-- GetActivityTaskOutput$taskToken.
sendTaskSuccess_taskToken :: Lens.Lens' SendTaskSuccess Prelude.Text
sendTaskSuccess_taskToken :: (Text -> f Text) -> SendTaskSuccess -> f SendTaskSuccess
sendTaskSuccess_taskToken = (SendTaskSuccess -> Text)
-> (SendTaskSuccess -> Text -> SendTaskSuccess)
-> Lens SendTaskSuccess SendTaskSuccess Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendTaskSuccess' {Text
taskToken :: Text
$sel:taskToken:SendTaskSuccess' :: SendTaskSuccess -> Text
taskToken} -> Text
taskToken) (\s :: SendTaskSuccess
s@SendTaskSuccess' {} Text
a -> SendTaskSuccess
s {$sel:taskToken:SendTaskSuccess' :: Text
taskToken = Text
a} :: SendTaskSuccess)

-- | The JSON output of the task. Length constraints apply to the payload
-- size, and are expressed as bytes in UTF-8 encoding.
sendTaskSuccess_output :: Lens.Lens' SendTaskSuccess Prelude.Text
sendTaskSuccess_output :: (Text -> f Text) -> SendTaskSuccess -> f SendTaskSuccess
sendTaskSuccess_output = (SendTaskSuccess -> Sensitive Text)
-> (SendTaskSuccess -> Sensitive Text -> SendTaskSuccess)
-> Lens
     SendTaskSuccess SendTaskSuccess (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendTaskSuccess' {Sensitive Text
output :: Sensitive Text
$sel:output:SendTaskSuccess' :: SendTaskSuccess -> Sensitive Text
output} -> Sensitive Text
output) (\s :: SendTaskSuccess
s@SendTaskSuccess' {} Sensitive Text
a -> SendTaskSuccess
s {$sel:output:SendTaskSuccess' :: Sensitive Text
output = Sensitive Text
a} :: SendTaskSuccess) ((Sensitive Text -> f (Sensitive Text))
 -> SendTaskSuccess -> f SendTaskSuccess)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> SendTaskSuccess
-> f SendTaskSuccess
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.AWSRequest SendTaskSuccess where
  type
    AWSResponse SendTaskSuccess =
      SendTaskSuccessResponse
  request :: SendTaskSuccess -> Request SendTaskSuccess
request = Service -> SendTaskSuccess -> Request SendTaskSuccess
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SendTaskSuccess
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendTaskSuccess)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse SendTaskSuccess))
-> Logger
-> Service
-> Proxy SendTaskSuccess
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendTaskSuccess)))
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 -> SendTaskSuccessResponse
SendTaskSuccessResponse'
            (Int -> SendTaskSuccessResponse)
-> Either String Int -> Either String SendTaskSuccessResponse
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 SendTaskSuccess

instance Prelude.NFData SendTaskSuccess

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

instance Core.ToJSON SendTaskSuccess where
  toJSON :: SendTaskSuccess -> Value
toJSON SendTaskSuccess' {Text
Sensitive Text
output :: Sensitive Text
taskToken :: Text
$sel:output:SendTaskSuccess' :: SendTaskSuccess -> Sensitive Text
$sel:taskToken:SendTaskSuccess' :: SendTaskSuccess -> 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
"taskToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
taskToken),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"output" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
output)
          ]
      )

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

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

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

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

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

instance Prelude.NFData SendTaskSuccessResponse