{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 :: Data.Sensitive Prelude.Text
  }
  deriving (SendTaskSuccess -> SendTaskSuccess -> Bool
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
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. 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'
    { $sel:taskToken:SendTaskSuccess' :: Text
taskToken = Text
pTaskToken_,
      $sel:output:SendTaskSuccess' :: Sensitive Text
output = forall a. Iso' (Sensitive a) a
Data._Sensitive 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 :: Lens' SendTaskSuccess Text
sendTaskSuccess_taskToken = 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 :: Lens' SendTaskSuccess Text
sendTaskSuccess_output = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

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

instance Prelude.Hashable SendTaskSuccess where
  hashWithSalt :: Int -> SendTaskSuccess -> Int
hashWithSalt Int
_salt SendTaskSuccess' {Text
Sensitive Text
output :: Sensitive Text
taskToken :: Text
$sel:output:SendTaskSuccess' :: SendTaskSuccess -> Sensitive Text
$sel:taskToken:SendTaskSuccess' :: SendTaskSuccess -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
taskToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
output

instance Prelude.NFData SendTaskSuccess where
  rnf :: SendTaskSuccess -> ()
rnf SendTaskSuccess' {Text
Sensitive Text
output :: Sensitive Text
taskToken :: Text
$sel:output:SendTaskSuccess' :: SendTaskSuccess -> Sensitive Text
$sel:taskToken:SendTaskSuccess' :: SendTaskSuccess -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
taskToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
output

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

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"taskToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
taskToken),
            forall a. a -> Maybe a
Prelude.Just (Key
"output" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
output)
          ]
      )

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

instance Data.ToQuery SendTaskSuccess where
  toQuery :: SendTaskSuccess -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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' {$sel:httpStatus:SendTaskSuccessResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
sendTaskSuccessResponse_httpStatus :: Lens.Lens' SendTaskSuccessResponse Prelude.Int
sendTaskSuccessResponse_httpStatus :: Lens' SendTaskSuccessResponse Int
sendTaskSuccessResponse_httpStatus = 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 where
  rnf :: SendTaskSuccessResponse -> ()
rnf SendTaskSuccessResponse' {Int
httpStatus :: Int
$sel:httpStatus:SendTaskSuccessResponse' :: SendTaskSuccessResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus