{-# 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.Transfer.SendWorkflowStepState
-- 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)
--
-- Sends a callback for asynchronous custom steps.
--
-- The @ExecutionId@, @WorkflowId@, and @Token@ are passed to the target
-- resource during execution of a custom step of a workflow. You must
-- include those with their callback as well as providing a status.
module Amazonka.Transfer.SendWorkflowStepState
  ( -- * Creating a Request
    SendWorkflowStepState (..),
    newSendWorkflowStepState,

    -- * Request Lenses
    sendWorkflowStepState_workflowId,
    sendWorkflowStepState_executionId,
    sendWorkflowStepState_token,
    sendWorkflowStepState_status,

    -- * Destructuring the Response
    SendWorkflowStepStateResponse (..),
    newSendWorkflowStepStateResponse,

    -- * Response Lenses
    sendWorkflowStepStateResponse_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.Transfer.Types

-- | /See:/ 'newSendWorkflowStepState' smart constructor.
data SendWorkflowStepState = SendWorkflowStepState'
  { -- | A unique identifier for the workflow.
    SendWorkflowStepState -> Text
workflowId :: Prelude.Text,
    -- | A unique identifier for the execution of a workflow.
    SendWorkflowStepState -> Text
executionId :: Prelude.Text,
    -- | Used to distinguish between multiple callbacks for multiple Lambda steps
    -- within the same execution.
    SendWorkflowStepState -> Text
token :: Prelude.Text,
    -- | Indicates whether the specified step succeeded or failed.
    SendWorkflowStepState -> CustomStepStatus
status :: CustomStepStatus
  }
  deriving (SendWorkflowStepState -> SendWorkflowStepState -> Bool
(SendWorkflowStepState -> SendWorkflowStepState -> Bool)
-> (SendWorkflowStepState -> SendWorkflowStepState -> Bool)
-> Eq SendWorkflowStepState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendWorkflowStepState -> SendWorkflowStepState -> Bool
$c/= :: SendWorkflowStepState -> SendWorkflowStepState -> Bool
== :: SendWorkflowStepState -> SendWorkflowStepState -> Bool
$c== :: SendWorkflowStepState -> SendWorkflowStepState -> Bool
Prelude.Eq, ReadPrec [SendWorkflowStepState]
ReadPrec SendWorkflowStepState
Int -> ReadS SendWorkflowStepState
ReadS [SendWorkflowStepState]
(Int -> ReadS SendWorkflowStepState)
-> ReadS [SendWorkflowStepState]
-> ReadPrec SendWorkflowStepState
-> ReadPrec [SendWorkflowStepState]
-> Read SendWorkflowStepState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendWorkflowStepState]
$creadListPrec :: ReadPrec [SendWorkflowStepState]
readPrec :: ReadPrec SendWorkflowStepState
$creadPrec :: ReadPrec SendWorkflowStepState
readList :: ReadS [SendWorkflowStepState]
$creadList :: ReadS [SendWorkflowStepState]
readsPrec :: Int -> ReadS SendWorkflowStepState
$creadsPrec :: Int -> ReadS SendWorkflowStepState
Prelude.Read, Int -> SendWorkflowStepState -> ShowS
[SendWorkflowStepState] -> ShowS
SendWorkflowStepState -> String
(Int -> SendWorkflowStepState -> ShowS)
-> (SendWorkflowStepState -> String)
-> ([SendWorkflowStepState] -> ShowS)
-> Show SendWorkflowStepState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendWorkflowStepState] -> ShowS
$cshowList :: [SendWorkflowStepState] -> ShowS
show :: SendWorkflowStepState -> String
$cshow :: SendWorkflowStepState -> String
showsPrec :: Int -> SendWorkflowStepState -> ShowS
$cshowsPrec :: Int -> SendWorkflowStepState -> ShowS
Prelude.Show, (forall x. SendWorkflowStepState -> Rep SendWorkflowStepState x)
-> (forall x. Rep SendWorkflowStepState x -> SendWorkflowStepState)
-> Generic SendWorkflowStepState
forall x. Rep SendWorkflowStepState x -> SendWorkflowStepState
forall x. SendWorkflowStepState -> Rep SendWorkflowStepState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendWorkflowStepState x -> SendWorkflowStepState
$cfrom :: forall x. SendWorkflowStepState -> Rep SendWorkflowStepState x
Prelude.Generic)

-- |
-- Create a value of 'SendWorkflowStepState' 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:
--
-- 'workflowId', 'sendWorkflowStepState_workflowId' - A unique identifier for the workflow.
--
-- 'executionId', 'sendWorkflowStepState_executionId' - A unique identifier for the execution of a workflow.
--
-- 'token', 'sendWorkflowStepState_token' - Used to distinguish between multiple callbacks for multiple Lambda steps
-- within the same execution.
--
-- 'status', 'sendWorkflowStepState_status' - Indicates whether the specified step succeeded or failed.
newSendWorkflowStepState ::
  -- | 'workflowId'
  Prelude.Text ->
  -- | 'executionId'
  Prelude.Text ->
  -- | 'token'
  Prelude.Text ->
  -- | 'status'
  CustomStepStatus ->
  SendWorkflowStepState
newSendWorkflowStepState :: Text -> Text -> Text -> CustomStepStatus -> SendWorkflowStepState
newSendWorkflowStepState
  Text
pWorkflowId_
  Text
pExecutionId_
  Text
pToken_
  CustomStepStatus
pStatus_ =
    SendWorkflowStepState' :: Text -> Text -> Text -> CustomStepStatus -> SendWorkflowStepState
SendWorkflowStepState'
      { $sel:workflowId:SendWorkflowStepState' :: Text
workflowId = Text
pWorkflowId_,
        $sel:executionId:SendWorkflowStepState' :: Text
executionId = Text
pExecutionId_,
        $sel:token:SendWorkflowStepState' :: Text
token = Text
pToken_,
        $sel:status:SendWorkflowStepState' :: CustomStepStatus
status = CustomStepStatus
pStatus_
      }

-- | A unique identifier for the workflow.
sendWorkflowStepState_workflowId :: Lens.Lens' SendWorkflowStepState Prelude.Text
sendWorkflowStepState_workflowId :: (Text -> f Text)
-> SendWorkflowStepState -> f SendWorkflowStepState
sendWorkflowStepState_workflowId = (SendWorkflowStepState -> Text)
-> (SendWorkflowStepState -> Text -> SendWorkflowStepState)
-> Lens SendWorkflowStepState SendWorkflowStepState Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendWorkflowStepState' {Text
workflowId :: Text
$sel:workflowId:SendWorkflowStepState' :: SendWorkflowStepState -> Text
workflowId} -> Text
workflowId) (\s :: SendWorkflowStepState
s@SendWorkflowStepState' {} Text
a -> SendWorkflowStepState
s {$sel:workflowId:SendWorkflowStepState' :: Text
workflowId = Text
a} :: SendWorkflowStepState)

-- | A unique identifier for the execution of a workflow.
sendWorkflowStepState_executionId :: Lens.Lens' SendWorkflowStepState Prelude.Text
sendWorkflowStepState_executionId :: (Text -> f Text)
-> SendWorkflowStepState -> f SendWorkflowStepState
sendWorkflowStepState_executionId = (SendWorkflowStepState -> Text)
-> (SendWorkflowStepState -> Text -> SendWorkflowStepState)
-> Lens SendWorkflowStepState SendWorkflowStepState Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendWorkflowStepState' {Text
executionId :: Text
$sel:executionId:SendWorkflowStepState' :: SendWorkflowStepState -> Text
executionId} -> Text
executionId) (\s :: SendWorkflowStepState
s@SendWorkflowStepState' {} Text
a -> SendWorkflowStepState
s {$sel:executionId:SendWorkflowStepState' :: Text
executionId = Text
a} :: SendWorkflowStepState)

-- | Used to distinguish between multiple callbacks for multiple Lambda steps
-- within the same execution.
sendWorkflowStepState_token :: Lens.Lens' SendWorkflowStepState Prelude.Text
sendWorkflowStepState_token :: (Text -> f Text)
-> SendWorkflowStepState -> f SendWorkflowStepState
sendWorkflowStepState_token = (SendWorkflowStepState -> Text)
-> (SendWorkflowStepState -> Text -> SendWorkflowStepState)
-> Lens SendWorkflowStepState SendWorkflowStepState Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendWorkflowStepState' {Text
token :: Text
$sel:token:SendWorkflowStepState' :: SendWorkflowStepState -> Text
token} -> Text
token) (\s :: SendWorkflowStepState
s@SendWorkflowStepState' {} Text
a -> SendWorkflowStepState
s {$sel:token:SendWorkflowStepState' :: Text
token = Text
a} :: SendWorkflowStepState)

-- | Indicates whether the specified step succeeded or failed.
sendWorkflowStepState_status :: Lens.Lens' SendWorkflowStepState CustomStepStatus
sendWorkflowStepState_status :: (CustomStepStatus -> f CustomStepStatus)
-> SendWorkflowStepState -> f SendWorkflowStepState
sendWorkflowStepState_status = (SendWorkflowStepState -> CustomStepStatus)
-> (SendWorkflowStepState
    -> CustomStepStatus -> SendWorkflowStepState)
-> Lens
     SendWorkflowStepState
     SendWorkflowStepState
     CustomStepStatus
     CustomStepStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendWorkflowStepState' {CustomStepStatus
status :: CustomStepStatus
$sel:status:SendWorkflowStepState' :: SendWorkflowStepState -> CustomStepStatus
status} -> CustomStepStatus
status) (\s :: SendWorkflowStepState
s@SendWorkflowStepState' {} CustomStepStatus
a -> SendWorkflowStepState
s {$sel:status:SendWorkflowStepState' :: CustomStepStatus
status = CustomStepStatus
a} :: SendWorkflowStepState)

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

instance Prelude.NFData SendWorkflowStepState

instance Core.ToHeaders SendWorkflowStepState where
  toHeaders :: SendWorkflowStepState -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SendWorkflowStepState -> 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
"TransferService.SendWorkflowStepState" ::
                          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 SendWorkflowStepState where
  toJSON :: SendWorkflowStepState -> Value
toJSON SendWorkflowStepState' {Text
CustomStepStatus
status :: CustomStepStatus
token :: Text
executionId :: Text
workflowId :: Text
$sel:status:SendWorkflowStepState' :: SendWorkflowStepState -> CustomStepStatus
$sel:token:SendWorkflowStepState' :: SendWorkflowStepState -> Text
$sel:executionId:SendWorkflowStepState' :: SendWorkflowStepState -> Text
$sel:workflowId:SendWorkflowStepState' :: SendWorkflowStepState -> 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
"WorkflowId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workflowId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ExecutionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
executionId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Token" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
token),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Status" Text -> CustomStepStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CustomStepStatus
status)
          ]
      )

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

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

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

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

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

instance Prelude.NFData SendWorkflowStepStateResponse