{-# 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.PollForDecisionTask
-- 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 deciders to get a DecisionTask from the specified decision
-- @taskList@. A decision task may be returned for any open workflow
-- execution that is using the specified task list. The task includes a
-- paginated view of the history of the workflow execution. The decider
-- should use the workflow type and the history to determine how to
-- properly handle the task.
--
-- This action initiates a long poll, where the service holds the HTTP
-- connection open and responds as soon a task becomes available. If no
-- decision task is available in the specified task list before the timeout
-- of 60 seconds expires, an empty result is returned. An empty result, in
-- this context, means that a DecisionTask is returned, but that the value
-- of taskToken is an empty string.
--
-- Deciders should set their client side socket timeout to at least 70
-- seconds (10 seconds higher than the timeout).
--
-- Because the number of workflow history events for a single workflow
-- execution might be very large, the result returned might be split up
-- across a number of pages. To retrieve subsequent pages, make additional
-- calls to @PollForDecisionTask@ using the @nextPageToken@ returned by the
-- initial call. Note that you do /not/ call @GetWorkflowExecutionHistory@
-- with this @nextPageToken@. Instead, call @PollForDecisionTask@ again.
--
-- __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.
--
-- -   Constrain the @taskList.name@ parameter by using a @Condition@
--     element with the @swf:taskList.name@ key to allow the action to
--     access only certain task lists.
--
-- 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/.
--
-- This operation returns paginated results.
module Amazonka.SWF.PollForDecisionTask
  ( -- * Creating a Request
    PollForDecisionTask (..),
    newPollForDecisionTask,

    -- * Request Lenses
    pollForDecisionTask_nextPageToken,
    pollForDecisionTask_reverseOrder,
    pollForDecisionTask_maximumPageSize,
    pollForDecisionTask_identity,
    pollForDecisionTask_domain,
    pollForDecisionTask_taskList,

    -- * Destructuring the Response
    PollForDecisionTaskResponse (..),
    newPollForDecisionTaskResponse,

    -- * Response Lenses
    pollForDecisionTaskResponse_nextPageToken,
    pollForDecisionTaskResponse_workflowType,
    pollForDecisionTaskResponse_previousStartedEventId,
    pollForDecisionTaskResponse_events,
    pollForDecisionTaskResponse_taskToken,
    pollForDecisionTaskResponse_workflowExecution,
    pollForDecisionTaskResponse_httpStatus,
    pollForDecisionTaskResponse_startedEventId,
  )
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:/ 'newPollForDecisionTask' smart constructor.
data PollForDecisionTask = PollForDecisionTask'
  { -- | If @NextPageToken@ is returned there are more results available. The
    -- value of @NextPageToken@ is a unique pagination token for each page.
    -- Make the call again using the returned token to retrieve the next page.
    -- Keep all other arguments unchanged. Each pagination token expires after
    -- 60 seconds. Using an expired pagination token will return a @400@ error:
    -- \"@Specified token has exceeded its maximum lifetime@\".
    --
    -- The configured @maximumPageSize@ determines how many results can be
    -- returned in a single call.
    --
    -- The @nextPageToken@ returned by this action cannot be used with
    -- GetWorkflowExecutionHistory to get the next page. You must call
    -- PollForDecisionTask again (with the @nextPageToken@) to retrieve the
    -- next page of history records. Calling PollForDecisionTask with a
    -- @nextPageToken@ doesn\'t return a new decision task.
    PollForDecisionTask -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | When set to @true@, returns the events in reverse order. By default the
    -- results are returned in ascending order of the @eventTimestamp@ of the
    -- events.
    PollForDecisionTask -> Maybe Bool
reverseOrder :: Prelude.Maybe Prelude.Bool,
    -- | The maximum number of results that are returned per call. Use
    -- @nextPageToken@ to obtain further pages of results.
    --
    -- This is an upper limit only; the actual number of results returned per
    -- call may be fewer than the specified maximum.
    PollForDecisionTask -> Maybe Natural
maximumPageSize :: Prelude.Maybe Prelude.Natural,
    -- | Identity of the decider making the request, which is recorded in the
    -- DecisionTaskStarted event in the workflow history. This enables
    -- diagnostic tracing when problems arise. The form of this identity is
    -- user defined.
    PollForDecisionTask -> Maybe Text
identity :: Prelude.Maybe Prelude.Text,
    -- | The name of the domain containing the task lists to poll.
    PollForDecisionTask -> Text
domain :: Prelude.Text,
    -- | Specifies the task list to poll for decision tasks.
    --
    -- The specified string must not start or end with whitespace. It must not
    -- contain a @:@ (colon), @\/@ (slash), @|@ (vertical bar), or any control
    -- characters (@\\u0000-\\u001f@ | @\\u007f-\\u009f@). Also, it must not
    -- /be/ the literal string @arn@.
    PollForDecisionTask -> TaskList
taskList :: TaskList
  }
  deriving (PollForDecisionTask -> PollForDecisionTask -> Bool
(PollForDecisionTask -> PollForDecisionTask -> Bool)
-> (PollForDecisionTask -> PollForDecisionTask -> Bool)
-> Eq PollForDecisionTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PollForDecisionTask -> PollForDecisionTask -> Bool
$c/= :: PollForDecisionTask -> PollForDecisionTask -> Bool
== :: PollForDecisionTask -> PollForDecisionTask -> Bool
$c== :: PollForDecisionTask -> PollForDecisionTask -> Bool
Prelude.Eq, ReadPrec [PollForDecisionTask]
ReadPrec PollForDecisionTask
Int -> ReadS PollForDecisionTask
ReadS [PollForDecisionTask]
(Int -> ReadS PollForDecisionTask)
-> ReadS [PollForDecisionTask]
-> ReadPrec PollForDecisionTask
-> ReadPrec [PollForDecisionTask]
-> Read PollForDecisionTask
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PollForDecisionTask]
$creadListPrec :: ReadPrec [PollForDecisionTask]
readPrec :: ReadPrec PollForDecisionTask
$creadPrec :: ReadPrec PollForDecisionTask
readList :: ReadS [PollForDecisionTask]
$creadList :: ReadS [PollForDecisionTask]
readsPrec :: Int -> ReadS PollForDecisionTask
$creadsPrec :: Int -> ReadS PollForDecisionTask
Prelude.Read, Int -> PollForDecisionTask -> ShowS
[PollForDecisionTask] -> ShowS
PollForDecisionTask -> String
(Int -> PollForDecisionTask -> ShowS)
-> (PollForDecisionTask -> String)
-> ([PollForDecisionTask] -> ShowS)
-> Show PollForDecisionTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PollForDecisionTask] -> ShowS
$cshowList :: [PollForDecisionTask] -> ShowS
show :: PollForDecisionTask -> String
$cshow :: PollForDecisionTask -> String
showsPrec :: Int -> PollForDecisionTask -> ShowS
$cshowsPrec :: Int -> PollForDecisionTask -> ShowS
Prelude.Show, (forall x. PollForDecisionTask -> Rep PollForDecisionTask x)
-> (forall x. Rep PollForDecisionTask x -> PollForDecisionTask)
-> Generic PollForDecisionTask
forall x. Rep PollForDecisionTask x -> PollForDecisionTask
forall x. PollForDecisionTask -> Rep PollForDecisionTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PollForDecisionTask x -> PollForDecisionTask
$cfrom :: forall x. PollForDecisionTask -> Rep PollForDecisionTask x
Prelude.Generic)

-- |
-- Create a value of 'PollForDecisionTask' 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:
--
-- 'nextPageToken', 'pollForDecisionTask_nextPageToken' - If @NextPageToken@ is returned there are more results available. The
-- value of @NextPageToken@ is a unique pagination token for each page.
-- Make the call again using the returned token to retrieve the next page.
-- Keep all other arguments unchanged. Each pagination token expires after
-- 60 seconds. Using an expired pagination token will return a @400@ error:
-- \"@Specified token has exceeded its maximum lifetime@\".
--
-- The configured @maximumPageSize@ determines how many results can be
-- returned in a single call.
--
-- The @nextPageToken@ returned by this action cannot be used with
-- GetWorkflowExecutionHistory to get the next page. You must call
-- PollForDecisionTask again (with the @nextPageToken@) to retrieve the
-- next page of history records. Calling PollForDecisionTask with a
-- @nextPageToken@ doesn\'t return a new decision task.
--
-- 'reverseOrder', 'pollForDecisionTask_reverseOrder' - When set to @true@, returns the events in reverse order. By default the
-- results are returned in ascending order of the @eventTimestamp@ of the
-- events.
--
-- 'maximumPageSize', 'pollForDecisionTask_maximumPageSize' - The maximum number of results that are returned per call. Use
-- @nextPageToken@ to obtain further pages of results.
--
-- This is an upper limit only; the actual number of results returned per
-- call may be fewer than the specified maximum.
--
-- 'identity', 'pollForDecisionTask_identity' - Identity of the decider making the request, which is recorded in the
-- DecisionTaskStarted event in the workflow history. This enables
-- diagnostic tracing when problems arise. The form of this identity is
-- user defined.
--
-- 'domain', 'pollForDecisionTask_domain' - The name of the domain containing the task lists to poll.
--
-- 'taskList', 'pollForDecisionTask_taskList' - Specifies the task list to poll for decision tasks.
--
-- The specified string must not start or end with whitespace. It must not
-- contain a @:@ (colon), @\/@ (slash), @|@ (vertical bar), or any control
-- characters (@\\u0000-\\u001f@ | @\\u007f-\\u009f@). Also, it must not
-- /be/ the literal string @arn@.
newPollForDecisionTask ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'taskList'
  TaskList ->
  PollForDecisionTask
newPollForDecisionTask :: Text -> TaskList -> PollForDecisionTask
newPollForDecisionTask Text
pDomain_ TaskList
pTaskList_ =
  PollForDecisionTask' :: Maybe Text
-> Maybe Bool
-> Maybe Natural
-> Maybe Text
-> Text
-> TaskList
-> PollForDecisionTask
PollForDecisionTask'
    { $sel:nextPageToken:PollForDecisionTask' :: Maybe Text
nextPageToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reverseOrder:PollForDecisionTask' :: Maybe Bool
reverseOrder = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumPageSize:PollForDecisionTask' :: Maybe Natural
maximumPageSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:identity:PollForDecisionTask' :: Maybe Text
identity = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domain:PollForDecisionTask' :: Text
domain = Text
pDomain_,
      $sel:taskList:PollForDecisionTask' :: TaskList
taskList = TaskList
pTaskList_
    }

-- | If @NextPageToken@ is returned there are more results available. The
-- value of @NextPageToken@ is a unique pagination token for each page.
-- Make the call again using the returned token to retrieve the next page.
-- Keep all other arguments unchanged. Each pagination token expires after
-- 60 seconds. Using an expired pagination token will return a @400@ error:
-- \"@Specified token has exceeded its maximum lifetime@\".
--
-- The configured @maximumPageSize@ determines how many results can be
-- returned in a single call.
--
-- The @nextPageToken@ returned by this action cannot be used with
-- GetWorkflowExecutionHistory to get the next page. You must call
-- PollForDecisionTask again (with the @nextPageToken@) to retrieve the
-- next page of history records. Calling PollForDecisionTask with a
-- @nextPageToken@ doesn\'t return a new decision task.
pollForDecisionTask_nextPageToken :: Lens.Lens' PollForDecisionTask (Prelude.Maybe Prelude.Text)
pollForDecisionTask_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> PollForDecisionTask -> f PollForDecisionTask
pollForDecisionTask_nextPageToken = (PollForDecisionTask -> Maybe Text)
-> (PollForDecisionTask -> Maybe Text -> PollForDecisionTask)
-> Lens
     PollForDecisionTask PollForDecisionTask (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTask' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:PollForDecisionTask' :: PollForDecisionTask -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: PollForDecisionTask
s@PollForDecisionTask' {} Maybe Text
a -> PollForDecisionTask
s {$sel:nextPageToken:PollForDecisionTask' :: Maybe Text
nextPageToken = Maybe Text
a} :: PollForDecisionTask)

-- | When set to @true@, returns the events in reverse order. By default the
-- results are returned in ascending order of the @eventTimestamp@ of the
-- events.
pollForDecisionTask_reverseOrder :: Lens.Lens' PollForDecisionTask (Prelude.Maybe Prelude.Bool)
pollForDecisionTask_reverseOrder :: (Maybe Bool -> f (Maybe Bool))
-> PollForDecisionTask -> f PollForDecisionTask
pollForDecisionTask_reverseOrder = (PollForDecisionTask -> Maybe Bool)
-> (PollForDecisionTask -> Maybe Bool -> PollForDecisionTask)
-> Lens
     PollForDecisionTask PollForDecisionTask (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTask' {Maybe Bool
reverseOrder :: Maybe Bool
$sel:reverseOrder:PollForDecisionTask' :: PollForDecisionTask -> Maybe Bool
reverseOrder} -> Maybe Bool
reverseOrder) (\s :: PollForDecisionTask
s@PollForDecisionTask' {} Maybe Bool
a -> PollForDecisionTask
s {$sel:reverseOrder:PollForDecisionTask' :: Maybe Bool
reverseOrder = Maybe Bool
a} :: PollForDecisionTask)

-- | The maximum number of results that are returned per call. Use
-- @nextPageToken@ to obtain further pages of results.
--
-- This is an upper limit only; the actual number of results returned per
-- call may be fewer than the specified maximum.
pollForDecisionTask_maximumPageSize :: Lens.Lens' PollForDecisionTask (Prelude.Maybe Prelude.Natural)
pollForDecisionTask_maximumPageSize :: (Maybe Natural -> f (Maybe Natural))
-> PollForDecisionTask -> f PollForDecisionTask
pollForDecisionTask_maximumPageSize = (PollForDecisionTask -> Maybe Natural)
-> (PollForDecisionTask -> Maybe Natural -> PollForDecisionTask)
-> Lens
     PollForDecisionTask
     PollForDecisionTask
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTask' {Maybe Natural
maximumPageSize :: Maybe Natural
$sel:maximumPageSize:PollForDecisionTask' :: PollForDecisionTask -> Maybe Natural
maximumPageSize} -> Maybe Natural
maximumPageSize) (\s :: PollForDecisionTask
s@PollForDecisionTask' {} Maybe Natural
a -> PollForDecisionTask
s {$sel:maximumPageSize:PollForDecisionTask' :: Maybe Natural
maximumPageSize = Maybe Natural
a} :: PollForDecisionTask)

-- | Identity of the decider making the request, which is recorded in the
-- DecisionTaskStarted event in the workflow history. This enables
-- diagnostic tracing when problems arise. The form of this identity is
-- user defined.
pollForDecisionTask_identity :: Lens.Lens' PollForDecisionTask (Prelude.Maybe Prelude.Text)
pollForDecisionTask_identity :: (Maybe Text -> f (Maybe Text))
-> PollForDecisionTask -> f PollForDecisionTask
pollForDecisionTask_identity = (PollForDecisionTask -> Maybe Text)
-> (PollForDecisionTask -> Maybe Text -> PollForDecisionTask)
-> Lens
     PollForDecisionTask PollForDecisionTask (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTask' {Maybe Text
identity :: Maybe Text
$sel:identity:PollForDecisionTask' :: PollForDecisionTask -> Maybe Text
identity} -> Maybe Text
identity) (\s :: PollForDecisionTask
s@PollForDecisionTask' {} Maybe Text
a -> PollForDecisionTask
s {$sel:identity:PollForDecisionTask' :: Maybe Text
identity = Maybe Text
a} :: PollForDecisionTask)

-- | The name of the domain containing the task lists to poll.
pollForDecisionTask_domain :: Lens.Lens' PollForDecisionTask Prelude.Text
pollForDecisionTask_domain :: (Text -> f Text) -> PollForDecisionTask -> f PollForDecisionTask
pollForDecisionTask_domain = (PollForDecisionTask -> Text)
-> (PollForDecisionTask -> Text -> PollForDecisionTask)
-> Lens PollForDecisionTask PollForDecisionTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTask' {Text
domain :: Text
$sel:domain:PollForDecisionTask' :: PollForDecisionTask -> Text
domain} -> Text
domain) (\s :: PollForDecisionTask
s@PollForDecisionTask' {} Text
a -> PollForDecisionTask
s {$sel:domain:PollForDecisionTask' :: Text
domain = Text
a} :: PollForDecisionTask)

-- | Specifies the task list to poll for decision tasks.
--
-- The specified string must not start or end with whitespace. It must not
-- contain a @:@ (colon), @\/@ (slash), @|@ (vertical bar), or any control
-- characters (@\\u0000-\\u001f@ | @\\u007f-\\u009f@). Also, it must not
-- /be/ the literal string @arn@.
pollForDecisionTask_taskList :: Lens.Lens' PollForDecisionTask TaskList
pollForDecisionTask_taskList :: (TaskList -> f TaskList)
-> PollForDecisionTask -> f PollForDecisionTask
pollForDecisionTask_taskList = (PollForDecisionTask -> TaskList)
-> (PollForDecisionTask -> TaskList -> PollForDecisionTask)
-> Lens PollForDecisionTask PollForDecisionTask TaskList TaskList
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTask' {TaskList
taskList :: TaskList
$sel:taskList:PollForDecisionTask' :: PollForDecisionTask -> TaskList
taskList} -> TaskList
taskList) (\s :: PollForDecisionTask
s@PollForDecisionTask' {} TaskList
a -> PollForDecisionTask
s {$sel:taskList:PollForDecisionTask' :: TaskList
taskList = TaskList
a} :: PollForDecisionTask)

instance Core.AWSPager PollForDecisionTask where
  page :: PollForDecisionTask
-> AWSResponse PollForDecisionTask -> Maybe PollForDecisionTask
page PollForDecisionTask
rq AWSResponse PollForDecisionTask
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse PollForDecisionTask
PollForDecisionTaskResponse
rs
            PollForDecisionTaskResponse
-> Getting (First Text) PollForDecisionTaskResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> PollForDecisionTaskResponse
-> Const (First Text) PollForDecisionTaskResponse
Lens' PollForDecisionTaskResponse (Maybe Text)
pollForDecisionTaskResponse_nextPageToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> PollForDecisionTaskResponse
 -> Const (First Text) PollForDecisionTaskResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) PollForDecisionTaskResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe PollForDecisionTask
forall a. Maybe a
Prelude.Nothing
    | Maybe [HistoryEvent] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse PollForDecisionTask
PollForDecisionTaskResponse
rs
            PollForDecisionTaskResponse
-> Getting
     (First [HistoryEvent]) PollForDecisionTaskResponse [HistoryEvent]
-> Maybe [HistoryEvent]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [HistoryEvent]
 -> Const (First [HistoryEvent]) (Maybe [HistoryEvent]))
-> PollForDecisionTaskResponse
-> Const (First [HistoryEvent]) PollForDecisionTaskResponse
Lens' PollForDecisionTaskResponse (Maybe [HistoryEvent])
pollForDecisionTaskResponse_events
              ((Maybe [HistoryEvent]
  -> Const (First [HistoryEvent]) (Maybe [HistoryEvent]))
 -> PollForDecisionTaskResponse
 -> Const (First [HistoryEvent]) PollForDecisionTaskResponse)
-> (([HistoryEvent] -> Const (First [HistoryEvent]) [HistoryEvent])
    -> Maybe [HistoryEvent]
    -> Const (First [HistoryEvent]) (Maybe [HistoryEvent]))
-> Getting
     (First [HistoryEvent]) PollForDecisionTaskResponse [HistoryEvent]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([HistoryEvent] -> Const (First [HistoryEvent]) [HistoryEvent])
-> Maybe [HistoryEvent]
-> Const (First [HistoryEvent]) (Maybe [HistoryEvent])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe PollForDecisionTask
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      PollForDecisionTask -> Maybe PollForDecisionTask
forall a. a -> Maybe a
Prelude.Just (PollForDecisionTask -> Maybe PollForDecisionTask)
-> PollForDecisionTask -> Maybe PollForDecisionTask
forall a b. (a -> b) -> a -> b
Prelude.$
        PollForDecisionTask
rq
          PollForDecisionTask
-> (PollForDecisionTask -> PollForDecisionTask)
-> PollForDecisionTask
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> PollForDecisionTask -> Identity PollForDecisionTask
Lens
  PollForDecisionTask PollForDecisionTask (Maybe Text) (Maybe Text)
pollForDecisionTask_nextPageToken
          ((Maybe Text -> Identity (Maybe Text))
 -> PollForDecisionTask -> Identity PollForDecisionTask)
-> Maybe Text -> PollForDecisionTask -> PollForDecisionTask
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse PollForDecisionTask
PollForDecisionTaskResponse
rs
          PollForDecisionTaskResponse
-> Getting (First Text) PollForDecisionTaskResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> PollForDecisionTaskResponse
-> Const (First Text) PollForDecisionTaskResponse
Lens' PollForDecisionTaskResponse (Maybe Text)
pollForDecisionTaskResponse_nextPageToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> PollForDecisionTaskResponse
 -> Const (First Text) PollForDecisionTaskResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) PollForDecisionTaskResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest PollForDecisionTask where
  type
    AWSResponse PollForDecisionTask =
      PollForDecisionTaskResponse
  request :: PollForDecisionTask -> Request PollForDecisionTask
request = Service -> PollForDecisionTask -> Request PollForDecisionTask
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PollForDecisionTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PollForDecisionTask)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PollForDecisionTask))
-> Logger
-> Service
-> Proxy PollForDecisionTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PollForDecisionTask)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe WorkflowType
-> Maybe Integer
-> Maybe [HistoryEvent]
-> Maybe Text
-> Maybe WorkflowExecution
-> Int
-> Integer
-> PollForDecisionTaskResponse
PollForDecisionTaskResponse'
            (Maybe Text
 -> Maybe WorkflowType
 -> Maybe Integer
 -> Maybe [HistoryEvent]
 -> Maybe Text
 -> Maybe WorkflowExecution
 -> Int
 -> Integer
 -> PollForDecisionTaskResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe WorkflowType
      -> Maybe Integer
      -> Maybe [HistoryEvent]
      -> Maybe Text
      -> Maybe WorkflowExecution
      -> Int
      -> Integer
      -> PollForDecisionTaskResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextPageToken")
            Either
  String
  (Maybe WorkflowType
   -> Maybe Integer
   -> Maybe [HistoryEvent]
   -> Maybe Text
   -> Maybe WorkflowExecution
   -> Int
   -> Integer
   -> PollForDecisionTaskResponse)
-> Either String (Maybe WorkflowType)
-> Either
     String
     (Maybe Integer
      -> Maybe [HistoryEvent]
      -> Maybe Text
      -> Maybe WorkflowExecution
      -> Int
      -> Integer
      -> PollForDecisionTaskResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe WorkflowType)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"workflowType")
            Either
  String
  (Maybe Integer
   -> Maybe [HistoryEvent]
   -> Maybe Text
   -> Maybe WorkflowExecution
   -> Int
   -> Integer
   -> PollForDecisionTaskResponse)
-> Either String (Maybe Integer)
-> Either
     String
     (Maybe [HistoryEvent]
      -> Maybe Text
      -> Maybe WorkflowExecution
      -> Int
      -> Integer
      -> PollForDecisionTaskResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"previousStartedEventId")
            Either
  String
  (Maybe [HistoryEvent]
   -> Maybe Text
   -> Maybe WorkflowExecution
   -> Int
   -> Integer
   -> PollForDecisionTaskResponse)
-> Either String (Maybe [HistoryEvent])
-> Either
     String
     (Maybe Text
      -> Maybe WorkflowExecution
      -> Int
      -> Integer
      -> PollForDecisionTaskResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [HistoryEvent]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"events" Either String (Maybe (Maybe [HistoryEvent]))
-> Maybe [HistoryEvent] -> Either String (Maybe [HistoryEvent])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [HistoryEvent]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe Text
   -> Maybe WorkflowExecution
   -> Int
   -> Integer
   -> PollForDecisionTaskResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe WorkflowExecution
      -> Int -> Integer -> PollForDecisionTaskResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"taskToken")
            Either
  String
  (Maybe WorkflowExecution
   -> Int -> Integer -> PollForDecisionTaskResponse)
-> Either String (Maybe WorkflowExecution)
-> Either String (Int -> Integer -> PollForDecisionTaskResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe WorkflowExecution)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"workflowExecution")
            Either String (Int -> Integer -> PollForDecisionTaskResponse)
-> Either String Int
-> Either String (Integer -> PollForDecisionTaskResponse)
forall (f :: * -> *) a b. Applicative f => 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))
            Either String (Integer -> PollForDecisionTaskResponse)
-> Either String Integer
-> Either String PollForDecisionTaskResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Integer
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"startedEventId")
      )

instance Prelude.Hashable PollForDecisionTask

instance Prelude.NFData PollForDecisionTask

instance Core.ToHeaders PollForDecisionTask where
  toHeaders :: PollForDecisionTask -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PollForDecisionTask -> 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
"SimpleWorkflowService.PollForDecisionTask" ::
                          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 PollForDecisionTask where
  toJSON :: PollForDecisionTask -> Value
toJSON PollForDecisionTask' {Maybe Bool
Maybe Natural
Maybe Text
Text
TaskList
taskList :: TaskList
domain :: Text
identity :: Maybe Text
maximumPageSize :: Maybe Natural
reverseOrder :: Maybe Bool
nextPageToken :: Maybe Text
$sel:taskList:PollForDecisionTask' :: PollForDecisionTask -> TaskList
$sel:domain:PollForDecisionTask' :: PollForDecisionTask -> Text
$sel:identity:PollForDecisionTask' :: PollForDecisionTask -> Maybe Text
$sel:maximumPageSize:PollForDecisionTask' :: PollForDecisionTask -> Maybe Natural
$sel:reverseOrder:PollForDecisionTask' :: PollForDecisionTask -> Maybe Bool
$sel:nextPageToken:PollForDecisionTask' :: PollForDecisionTask -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"nextPageToken" 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
nextPageToken,
            (Text
"reverseOrder" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
reverseOrder,
            (Text
"maximumPageSize" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maximumPageSize,
            (Text
"identity" 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
identity,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"domain" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
domain),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"taskList" Text -> TaskList -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TaskList
taskList)
          ]
      )

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

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

-- | A structure that represents a decision task. Decision tasks are sent to
-- deciders in order for them to make decisions.
--
-- /See:/ 'newPollForDecisionTaskResponse' smart constructor.
data PollForDecisionTaskResponse = PollForDecisionTaskResponse'
  { -- | If a @NextPageToken@ was returned by a previous call, there are more
    -- results available. To retrieve the next page of results, make the call
    -- again using the returned token in @nextPageToken@. Keep all other
    -- arguments unchanged.
    --
    -- The configured @maximumPageSize@ determines how many results can be
    -- returned in a single call.
    PollForDecisionTaskResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | The type of the workflow execution for which this decision task was
    -- created.
    PollForDecisionTaskResponse -> Maybe WorkflowType
workflowType :: Prelude.Maybe WorkflowType,
    -- | The ID of the DecisionTaskStarted event of the previous decision task of
    -- this workflow execution that was processed by the decider. This can be
    -- used to determine the events in the history new since the last decision
    -- task received by the decider.
    PollForDecisionTaskResponse -> Maybe Integer
previousStartedEventId :: Prelude.Maybe Prelude.Integer,
    -- | A paginated list of history events of the workflow execution. The
    -- decider uses this during the processing of the decision task.
    PollForDecisionTaskResponse -> Maybe [HistoryEvent]
events :: Prelude.Maybe [HistoryEvent],
    -- | The opaque string used as a handle on the task. This token is used by
    -- workers to communicate progress and response information back to the
    -- system about the task.
    PollForDecisionTaskResponse -> Maybe Text
taskToken :: Prelude.Maybe Prelude.Text,
    -- | The workflow execution for which this decision task was created.
    PollForDecisionTaskResponse -> Maybe WorkflowExecution
workflowExecution :: Prelude.Maybe WorkflowExecution,
    -- | The response's http status code.
    PollForDecisionTaskResponse -> Int
httpStatus :: Prelude.Int,
    -- | The ID of the @DecisionTaskStarted@ event recorded in the history.
    PollForDecisionTaskResponse -> Integer
startedEventId :: Prelude.Integer
  }
  deriving (PollForDecisionTaskResponse -> PollForDecisionTaskResponse -> Bool
(PollForDecisionTaskResponse
 -> PollForDecisionTaskResponse -> Bool)
-> (PollForDecisionTaskResponse
    -> PollForDecisionTaskResponse -> Bool)
-> Eq PollForDecisionTaskResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PollForDecisionTaskResponse -> PollForDecisionTaskResponse -> Bool
$c/= :: PollForDecisionTaskResponse -> PollForDecisionTaskResponse -> Bool
== :: PollForDecisionTaskResponse -> PollForDecisionTaskResponse -> Bool
$c== :: PollForDecisionTaskResponse -> PollForDecisionTaskResponse -> Bool
Prelude.Eq, ReadPrec [PollForDecisionTaskResponse]
ReadPrec PollForDecisionTaskResponse
Int -> ReadS PollForDecisionTaskResponse
ReadS [PollForDecisionTaskResponse]
(Int -> ReadS PollForDecisionTaskResponse)
-> ReadS [PollForDecisionTaskResponse]
-> ReadPrec PollForDecisionTaskResponse
-> ReadPrec [PollForDecisionTaskResponse]
-> Read PollForDecisionTaskResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PollForDecisionTaskResponse]
$creadListPrec :: ReadPrec [PollForDecisionTaskResponse]
readPrec :: ReadPrec PollForDecisionTaskResponse
$creadPrec :: ReadPrec PollForDecisionTaskResponse
readList :: ReadS [PollForDecisionTaskResponse]
$creadList :: ReadS [PollForDecisionTaskResponse]
readsPrec :: Int -> ReadS PollForDecisionTaskResponse
$creadsPrec :: Int -> ReadS PollForDecisionTaskResponse
Prelude.Read, Int -> PollForDecisionTaskResponse -> ShowS
[PollForDecisionTaskResponse] -> ShowS
PollForDecisionTaskResponse -> String
(Int -> PollForDecisionTaskResponse -> ShowS)
-> (PollForDecisionTaskResponse -> String)
-> ([PollForDecisionTaskResponse] -> ShowS)
-> Show PollForDecisionTaskResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PollForDecisionTaskResponse] -> ShowS
$cshowList :: [PollForDecisionTaskResponse] -> ShowS
show :: PollForDecisionTaskResponse -> String
$cshow :: PollForDecisionTaskResponse -> String
showsPrec :: Int -> PollForDecisionTaskResponse -> ShowS
$cshowsPrec :: Int -> PollForDecisionTaskResponse -> ShowS
Prelude.Show, (forall x.
 PollForDecisionTaskResponse -> Rep PollForDecisionTaskResponse x)
-> (forall x.
    Rep PollForDecisionTaskResponse x -> PollForDecisionTaskResponse)
-> Generic PollForDecisionTaskResponse
forall x.
Rep PollForDecisionTaskResponse x -> PollForDecisionTaskResponse
forall x.
PollForDecisionTaskResponse -> Rep PollForDecisionTaskResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PollForDecisionTaskResponse x -> PollForDecisionTaskResponse
$cfrom :: forall x.
PollForDecisionTaskResponse -> Rep PollForDecisionTaskResponse x
Prelude.Generic)

-- |
-- Create a value of 'PollForDecisionTaskResponse' 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:
--
-- 'nextPageToken', 'pollForDecisionTaskResponse_nextPageToken' - If a @NextPageToken@ was returned by a previous call, there are more
-- results available. To retrieve the next page of results, make the call
-- again using the returned token in @nextPageToken@. Keep all other
-- arguments unchanged.
--
-- The configured @maximumPageSize@ determines how many results can be
-- returned in a single call.
--
-- 'workflowType', 'pollForDecisionTaskResponse_workflowType' - The type of the workflow execution for which this decision task was
-- created.
--
-- 'previousStartedEventId', 'pollForDecisionTaskResponse_previousStartedEventId' - The ID of the DecisionTaskStarted event of the previous decision task of
-- this workflow execution that was processed by the decider. This can be
-- used to determine the events in the history new since the last decision
-- task received by the decider.
--
-- 'events', 'pollForDecisionTaskResponse_events' - A paginated list of history events of the workflow execution. The
-- decider uses this during the processing of the decision task.
--
-- 'taskToken', 'pollForDecisionTaskResponse_taskToken' - The opaque string used as a handle on the task. This token is used by
-- workers to communicate progress and response information back to the
-- system about the task.
--
-- 'workflowExecution', 'pollForDecisionTaskResponse_workflowExecution' - The workflow execution for which this decision task was created.
--
-- 'httpStatus', 'pollForDecisionTaskResponse_httpStatus' - The response's http status code.
--
-- 'startedEventId', 'pollForDecisionTaskResponse_startedEventId' - The ID of the @DecisionTaskStarted@ event recorded in the history.
newPollForDecisionTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'startedEventId'
  Prelude.Integer ->
  PollForDecisionTaskResponse
newPollForDecisionTaskResponse :: Int -> Integer -> PollForDecisionTaskResponse
newPollForDecisionTaskResponse
  Int
pHttpStatus_
  Integer
pStartedEventId_ =
    PollForDecisionTaskResponse' :: Maybe Text
-> Maybe WorkflowType
-> Maybe Integer
-> Maybe [HistoryEvent]
-> Maybe Text
-> Maybe WorkflowExecution
-> Int
-> Integer
-> PollForDecisionTaskResponse
PollForDecisionTaskResponse'
      { $sel:nextPageToken:PollForDecisionTaskResponse' :: Maybe Text
nextPageToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:workflowType:PollForDecisionTaskResponse' :: Maybe WorkflowType
workflowType = Maybe WorkflowType
forall a. Maybe a
Prelude.Nothing,
        $sel:previousStartedEventId:PollForDecisionTaskResponse' :: Maybe Integer
previousStartedEventId = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
        $sel:events:PollForDecisionTaskResponse' :: Maybe [HistoryEvent]
events = Maybe [HistoryEvent]
forall a. Maybe a
Prelude.Nothing,
        $sel:taskToken:PollForDecisionTaskResponse' :: Maybe Text
taskToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:workflowExecution:PollForDecisionTaskResponse' :: Maybe WorkflowExecution
workflowExecution = Maybe WorkflowExecution
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:PollForDecisionTaskResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:startedEventId:PollForDecisionTaskResponse' :: Integer
startedEventId = Integer
pStartedEventId_
      }

-- | If a @NextPageToken@ was returned by a previous call, there are more
-- results available. To retrieve the next page of results, make the call
-- again using the returned token in @nextPageToken@. Keep all other
-- arguments unchanged.
--
-- The configured @maximumPageSize@ determines how many results can be
-- returned in a single call.
pollForDecisionTaskResponse_nextPageToken :: Lens.Lens' PollForDecisionTaskResponse (Prelude.Maybe Prelude.Text)
pollForDecisionTaskResponse_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> PollForDecisionTaskResponse -> f PollForDecisionTaskResponse
pollForDecisionTaskResponse_nextPageToken = (PollForDecisionTaskResponse -> Maybe Text)
-> (PollForDecisionTaskResponse
    -> Maybe Text -> PollForDecisionTaskResponse)
-> Lens' PollForDecisionTaskResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTaskResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:PollForDecisionTaskResponse' :: PollForDecisionTaskResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: PollForDecisionTaskResponse
s@PollForDecisionTaskResponse' {} Maybe Text
a -> PollForDecisionTaskResponse
s {$sel:nextPageToken:PollForDecisionTaskResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: PollForDecisionTaskResponse)

-- | The type of the workflow execution for which this decision task was
-- created.
pollForDecisionTaskResponse_workflowType :: Lens.Lens' PollForDecisionTaskResponse (Prelude.Maybe WorkflowType)
pollForDecisionTaskResponse_workflowType :: (Maybe WorkflowType -> f (Maybe WorkflowType))
-> PollForDecisionTaskResponse -> f PollForDecisionTaskResponse
pollForDecisionTaskResponse_workflowType = (PollForDecisionTaskResponse -> Maybe WorkflowType)
-> (PollForDecisionTaskResponse
    -> Maybe WorkflowType -> PollForDecisionTaskResponse)
-> Lens
     PollForDecisionTaskResponse
     PollForDecisionTaskResponse
     (Maybe WorkflowType)
     (Maybe WorkflowType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTaskResponse' {Maybe WorkflowType
workflowType :: Maybe WorkflowType
$sel:workflowType:PollForDecisionTaskResponse' :: PollForDecisionTaskResponse -> Maybe WorkflowType
workflowType} -> Maybe WorkflowType
workflowType) (\s :: PollForDecisionTaskResponse
s@PollForDecisionTaskResponse' {} Maybe WorkflowType
a -> PollForDecisionTaskResponse
s {$sel:workflowType:PollForDecisionTaskResponse' :: Maybe WorkflowType
workflowType = Maybe WorkflowType
a} :: PollForDecisionTaskResponse)

-- | The ID of the DecisionTaskStarted event of the previous decision task of
-- this workflow execution that was processed by the decider. This can be
-- used to determine the events in the history new since the last decision
-- task received by the decider.
pollForDecisionTaskResponse_previousStartedEventId :: Lens.Lens' PollForDecisionTaskResponse (Prelude.Maybe Prelude.Integer)
pollForDecisionTaskResponse_previousStartedEventId :: (Maybe Integer -> f (Maybe Integer))
-> PollForDecisionTaskResponse -> f PollForDecisionTaskResponse
pollForDecisionTaskResponse_previousStartedEventId = (PollForDecisionTaskResponse -> Maybe Integer)
-> (PollForDecisionTaskResponse
    -> Maybe Integer -> PollForDecisionTaskResponse)
-> Lens
     PollForDecisionTaskResponse
     PollForDecisionTaskResponse
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTaskResponse' {Maybe Integer
previousStartedEventId :: Maybe Integer
$sel:previousStartedEventId:PollForDecisionTaskResponse' :: PollForDecisionTaskResponse -> Maybe Integer
previousStartedEventId} -> Maybe Integer
previousStartedEventId) (\s :: PollForDecisionTaskResponse
s@PollForDecisionTaskResponse' {} Maybe Integer
a -> PollForDecisionTaskResponse
s {$sel:previousStartedEventId:PollForDecisionTaskResponse' :: Maybe Integer
previousStartedEventId = Maybe Integer
a} :: PollForDecisionTaskResponse)

-- | A paginated list of history events of the workflow execution. The
-- decider uses this during the processing of the decision task.
pollForDecisionTaskResponse_events :: Lens.Lens' PollForDecisionTaskResponse (Prelude.Maybe [HistoryEvent])
pollForDecisionTaskResponse_events :: (Maybe [HistoryEvent] -> f (Maybe [HistoryEvent]))
-> PollForDecisionTaskResponse -> f PollForDecisionTaskResponse
pollForDecisionTaskResponse_events = (PollForDecisionTaskResponse -> Maybe [HistoryEvent])
-> (PollForDecisionTaskResponse
    -> Maybe [HistoryEvent] -> PollForDecisionTaskResponse)
-> Lens' PollForDecisionTaskResponse (Maybe [HistoryEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTaskResponse' {Maybe [HistoryEvent]
events :: Maybe [HistoryEvent]
$sel:events:PollForDecisionTaskResponse' :: PollForDecisionTaskResponse -> Maybe [HistoryEvent]
events} -> Maybe [HistoryEvent]
events) (\s :: PollForDecisionTaskResponse
s@PollForDecisionTaskResponse' {} Maybe [HistoryEvent]
a -> PollForDecisionTaskResponse
s {$sel:events:PollForDecisionTaskResponse' :: Maybe [HistoryEvent]
events = Maybe [HistoryEvent]
a} :: PollForDecisionTaskResponse) ((Maybe [HistoryEvent] -> f (Maybe [HistoryEvent]))
 -> PollForDecisionTaskResponse -> f PollForDecisionTaskResponse)
-> ((Maybe [HistoryEvent] -> f (Maybe [HistoryEvent]))
    -> Maybe [HistoryEvent] -> f (Maybe [HistoryEvent]))
-> (Maybe [HistoryEvent] -> f (Maybe [HistoryEvent]))
-> PollForDecisionTaskResponse
-> f PollForDecisionTaskResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [HistoryEvent] [HistoryEvent] [HistoryEvent] [HistoryEvent]
-> Iso
     (Maybe [HistoryEvent])
     (Maybe [HistoryEvent])
     (Maybe [HistoryEvent])
     (Maybe [HistoryEvent])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [HistoryEvent] [HistoryEvent] [HistoryEvent] [HistoryEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The opaque string used as a handle on the task. This token is used by
-- workers to communicate progress and response information back to the
-- system about the task.
pollForDecisionTaskResponse_taskToken :: Lens.Lens' PollForDecisionTaskResponse (Prelude.Maybe Prelude.Text)
pollForDecisionTaskResponse_taskToken :: (Maybe Text -> f (Maybe Text))
-> PollForDecisionTaskResponse -> f PollForDecisionTaskResponse
pollForDecisionTaskResponse_taskToken = (PollForDecisionTaskResponse -> Maybe Text)
-> (PollForDecisionTaskResponse
    -> Maybe Text -> PollForDecisionTaskResponse)
-> Lens' PollForDecisionTaskResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTaskResponse' {Maybe Text
taskToken :: Maybe Text
$sel:taskToken:PollForDecisionTaskResponse' :: PollForDecisionTaskResponse -> Maybe Text
taskToken} -> Maybe Text
taskToken) (\s :: PollForDecisionTaskResponse
s@PollForDecisionTaskResponse' {} Maybe Text
a -> PollForDecisionTaskResponse
s {$sel:taskToken:PollForDecisionTaskResponse' :: Maybe Text
taskToken = Maybe Text
a} :: PollForDecisionTaskResponse)

-- | The workflow execution for which this decision task was created.
pollForDecisionTaskResponse_workflowExecution :: Lens.Lens' PollForDecisionTaskResponse (Prelude.Maybe WorkflowExecution)
pollForDecisionTaskResponse_workflowExecution :: (Maybe WorkflowExecution -> f (Maybe WorkflowExecution))
-> PollForDecisionTaskResponse -> f PollForDecisionTaskResponse
pollForDecisionTaskResponse_workflowExecution = (PollForDecisionTaskResponse -> Maybe WorkflowExecution)
-> (PollForDecisionTaskResponse
    -> Maybe WorkflowExecution -> PollForDecisionTaskResponse)
-> Lens
     PollForDecisionTaskResponse
     PollForDecisionTaskResponse
     (Maybe WorkflowExecution)
     (Maybe WorkflowExecution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTaskResponse' {Maybe WorkflowExecution
workflowExecution :: Maybe WorkflowExecution
$sel:workflowExecution:PollForDecisionTaskResponse' :: PollForDecisionTaskResponse -> Maybe WorkflowExecution
workflowExecution} -> Maybe WorkflowExecution
workflowExecution) (\s :: PollForDecisionTaskResponse
s@PollForDecisionTaskResponse' {} Maybe WorkflowExecution
a -> PollForDecisionTaskResponse
s {$sel:workflowExecution:PollForDecisionTaskResponse' :: Maybe WorkflowExecution
workflowExecution = Maybe WorkflowExecution
a} :: PollForDecisionTaskResponse)

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

-- | The ID of the @DecisionTaskStarted@ event recorded in the history.
pollForDecisionTaskResponse_startedEventId :: Lens.Lens' PollForDecisionTaskResponse Prelude.Integer
pollForDecisionTaskResponse_startedEventId :: (Integer -> f Integer)
-> PollForDecisionTaskResponse -> f PollForDecisionTaskResponse
pollForDecisionTaskResponse_startedEventId = (PollForDecisionTaskResponse -> Integer)
-> (PollForDecisionTaskResponse
    -> Integer -> PollForDecisionTaskResponse)
-> Lens
     PollForDecisionTaskResponse
     PollForDecisionTaskResponse
     Integer
     Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PollForDecisionTaskResponse' {Integer
startedEventId :: Integer
$sel:startedEventId:PollForDecisionTaskResponse' :: PollForDecisionTaskResponse -> Integer
startedEventId} -> Integer
startedEventId) (\s :: PollForDecisionTaskResponse
s@PollForDecisionTaskResponse' {} Integer
a -> PollForDecisionTaskResponse
s {$sel:startedEventId:PollForDecisionTaskResponse' :: Integer
startedEventId = Integer
a} :: PollForDecisionTaskResponse)

instance Prelude.NFData PollForDecisionTaskResponse