{-# 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.GetWorkflowExecutionHistory
-- 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)
--
-- Returns the history of the specified workflow execution. The results may
-- be split into multiple pages. To retrieve subsequent pages, make the
-- call again using the @nextPageToken@ returned by the initial call.
--
-- This operation is eventually consistent. The results are best effort and
-- may not exactly reflect recent updates and changes.
--
-- __Access Control__
--
-- You can use IAM policies to control this action\'s access to Amazon SWF
-- resources as follows:
--
-- -   Use a @Resource@ element with the domain name to limit the action to
--     only specified domains.
--
-- -   Use an @Action@ element to allow or deny permission to call this
--     action.
--
-- -   You cannot use an IAM policy to constrain this action\'s parameters.
--
-- If the caller doesn\'t have sufficient permissions to invoke the action,
-- or the parameter values fall outside the specified constraints, the
-- action fails. The associated event attribute\'s @cause@ parameter is set
-- to @OPERATION_NOT_PERMITTED@. For details and example IAM policies, see
-- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html Using IAM to Manage Access to Amazon SWF Workflows>
-- in the /Amazon SWF Developer Guide/.
--
-- This operation returns paginated results.
module Amazonka.SWF.GetWorkflowExecutionHistory
  ( -- * Creating a Request
    GetWorkflowExecutionHistory (..),
    newGetWorkflowExecutionHistory,

    -- * Request Lenses
    getWorkflowExecutionHistory_nextPageToken,
    getWorkflowExecutionHistory_reverseOrder,
    getWorkflowExecutionHistory_maximumPageSize,
    getWorkflowExecutionHistory_domain,
    getWorkflowExecutionHistory_execution,

    -- * Destructuring the Response
    GetWorkflowExecutionHistoryResponse (..),
    newGetWorkflowExecutionHistoryResponse,

    -- * Response Lenses
    getWorkflowExecutionHistoryResponse_nextPageToken,
    getWorkflowExecutionHistoryResponse_httpStatus,
    getWorkflowExecutionHistoryResponse_events,
  )
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:/ 'newGetWorkflowExecutionHistory' smart constructor.
data GetWorkflowExecutionHistory = GetWorkflowExecutionHistory'
  { -- | 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.
    GetWorkflowExecutionHistory -> 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.
    GetWorkflowExecutionHistory -> 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.
    GetWorkflowExecutionHistory -> Maybe Natural
maximumPageSize :: Prelude.Maybe Prelude.Natural,
    -- | The name of the domain containing the workflow execution.
    GetWorkflowExecutionHistory -> Text
domain :: Prelude.Text,
    -- | Specifies the workflow execution for which to return the history.
    GetWorkflowExecutionHistory -> WorkflowExecution
execution :: WorkflowExecution
  }
  deriving (GetWorkflowExecutionHistory -> GetWorkflowExecutionHistory -> Bool
(GetWorkflowExecutionHistory
 -> GetWorkflowExecutionHistory -> Bool)
-> (GetWorkflowExecutionHistory
    -> GetWorkflowExecutionHistory -> Bool)
-> Eq GetWorkflowExecutionHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetWorkflowExecutionHistory -> GetWorkflowExecutionHistory -> Bool
$c/= :: GetWorkflowExecutionHistory -> GetWorkflowExecutionHistory -> Bool
== :: GetWorkflowExecutionHistory -> GetWorkflowExecutionHistory -> Bool
$c== :: GetWorkflowExecutionHistory -> GetWorkflowExecutionHistory -> Bool
Prelude.Eq, ReadPrec [GetWorkflowExecutionHistory]
ReadPrec GetWorkflowExecutionHistory
Int -> ReadS GetWorkflowExecutionHistory
ReadS [GetWorkflowExecutionHistory]
(Int -> ReadS GetWorkflowExecutionHistory)
-> ReadS [GetWorkflowExecutionHistory]
-> ReadPrec GetWorkflowExecutionHistory
-> ReadPrec [GetWorkflowExecutionHistory]
-> Read GetWorkflowExecutionHistory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetWorkflowExecutionHistory]
$creadListPrec :: ReadPrec [GetWorkflowExecutionHistory]
readPrec :: ReadPrec GetWorkflowExecutionHistory
$creadPrec :: ReadPrec GetWorkflowExecutionHistory
readList :: ReadS [GetWorkflowExecutionHistory]
$creadList :: ReadS [GetWorkflowExecutionHistory]
readsPrec :: Int -> ReadS GetWorkflowExecutionHistory
$creadsPrec :: Int -> ReadS GetWorkflowExecutionHistory
Prelude.Read, Int -> GetWorkflowExecutionHistory -> ShowS
[GetWorkflowExecutionHistory] -> ShowS
GetWorkflowExecutionHistory -> String
(Int -> GetWorkflowExecutionHistory -> ShowS)
-> (GetWorkflowExecutionHistory -> String)
-> ([GetWorkflowExecutionHistory] -> ShowS)
-> Show GetWorkflowExecutionHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetWorkflowExecutionHistory] -> ShowS
$cshowList :: [GetWorkflowExecutionHistory] -> ShowS
show :: GetWorkflowExecutionHistory -> String
$cshow :: GetWorkflowExecutionHistory -> String
showsPrec :: Int -> GetWorkflowExecutionHistory -> ShowS
$cshowsPrec :: Int -> GetWorkflowExecutionHistory -> ShowS
Prelude.Show, (forall x.
 GetWorkflowExecutionHistory -> Rep GetWorkflowExecutionHistory x)
-> (forall x.
    Rep GetWorkflowExecutionHistory x -> GetWorkflowExecutionHistory)
-> Generic GetWorkflowExecutionHistory
forall x.
Rep GetWorkflowExecutionHistory x -> GetWorkflowExecutionHistory
forall x.
GetWorkflowExecutionHistory -> Rep GetWorkflowExecutionHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetWorkflowExecutionHistory x -> GetWorkflowExecutionHistory
$cfrom :: forall x.
GetWorkflowExecutionHistory -> Rep GetWorkflowExecutionHistory x
Prelude.Generic)

-- |
-- Create a value of 'GetWorkflowExecutionHistory' 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', 'getWorkflowExecutionHistory_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.
--
-- 'reverseOrder', 'getWorkflowExecutionHistory_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', 'getWorkflowExecutionHistory_maximumPageSize' - The maximum number of results that are returned per call. Use
-- @nextPageToken@ to obtain further pages of results.
--
-- 'domain', 'getWorkflowExecutionHistory_domain' - The name of the domain containing the workflow execution.
--
-- 'execution', 'getWorkflowExecutionHistory_execution' - Specifies the workflow execution for which to return the history.
newGetWorkflowExecutionHistory ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'execution'
  WorkflowExecution ->
  GetWorkflowExecutionHistory
newGetWorkflowExecutionHistory :: Text -> WorkflowExecution -> GetWorkflowExecutionHistory
newGetWorkflowExecutionHistory Text
pDomain_ WorkflowExecution
pExecution_ =
  GetWorkflowExecutionHistory' :: Maybe Text
-> Maybe Bool
-> Maybe Natural
-> Text
-> WorkflowExecution
-> GetWorkflowExecutionHistory
GetWorkflowExecutionHistory'
    { $sel:nextPageToken:GetWorkflowExecutionHistory' :: Maybe Text
nextPageToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reverseOrder:GetWorkflowExecutionHistory' :: Maybe Bool
reverseOrder = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumPageSize:GetWorkflowExecutionHistory' :: Maybe Natural
maximumPageSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:domain:GetWorkflowExecutionHistory' :: Text
domain = Text
pDomain_,
      $sel:execution:GetWorkflowExecutionHistory' :: WorkflowExecution
execution = WorkflowExecution
pExecution_
    }

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

-- | 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.
getWorkflowExecutionHistory_reverseOrder :: Lens.Lens' GetWorkflowExecutionHistory (Prelude.Maybe Prelude.Bool)
getWorkflowExecutionHistory_reverseOrder :: (Maybe Bool -> f (Maybe Bool))
-> GetWorkflowExecutionHistory -> f GetWorkflowExecutionHistory
getWorkflowExecutionHistory_reverseOrder = (GetWorkflowExecutionHistory -> Maybe Bool)
-> (GetWorkflowExecutionHistory
    -> Maybe Bool -> GetWorkflowExecutionHistory)
-> Lens
     GetWorkflowExecutionHistory
     GetWorkflowExecutionHistory
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowExecutionHistory' {Maybe Bool
reverseOrder :: Maybe Bool
$sel:reverseOrder:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Bool
reverseOrder} -> Maybe Bool
reverseOrder) (\s :: GetWorkflowExecutionHistory
s@GetWorkflowExecutionHistory' {} Maybe Bool
a -> GetWorkflowExecutionHistory
s {$sel:reverseOrder:GetWorkflowExecutionHistory' :: Maybe Bool
reverseOrder = Maybe Bool
a} :: GetWorkflowExecutionHistory)

-- | The maximum number of results that are returned per call. Use
-- @nextPageToken@ to obtain further pages of results.
getWorkflowExecutionHistory_maximumPageSize :: Lens.Lens' GetWorkflowExecutionHistory (Prelude.Maybe Prelude.Natural)
getWorkflowExecutionHistory_maximumPageSize :: (Maybe Natural -> f (Maybe Natural))
-> GetWorkflowExecutionHistory -> f GetWorkflowExecutionHistory
getWorkflowExecutionHistory_maximumPageSize = (GetWorkflowExecutionHistory -> Maybe Natural)
-> (GetWorkflowExecutionHistory
    -> Maybe Natural -> GetWorkflowExecutionHistory)
-> Lens
     GetWorkflowExecutionHistory
     GetWorkflowExecutionHistory
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowExecutionHistory' {Maybe Natural
maximumPageSize :: Maybe Natural
$sel:maximumPageSize:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Natural
maximumPageSize} -> Maybe Natural
maximumPageSize) (\s :: GetWorkflowExecutionHistory
s@GetWorkflowExecutionHistory' {} Maybe Natural
a -> GetWorkflowExecutionHistory
s {$sel:maximumPageSize:GetWorkflowExecutionHistory' :: Maybe Natural
maximumPageSize = Maybe Natural
a} :: GetWorkflowExecutionHistory)

-- | The name of the domain containing the workflow execution.
getWorkflowExecutionHistory_domain :: Lens.Lens' GetWorkflowExecutionHistory Prelude.Text
getWorkflowExecutionHistory_domain :: (Text -> f Text)
-> GetWorkflowExecutionHistory -> f GetWorkflowExecutionHistory
getWorkflowExecutionHistory_domain = (GetWorkflowExecutionHistory -> Text)
-> (GetWorkflowExecutionHistory
    -> Text -> GetWorkflowExecutionHistory)
-> Lens
     GetWorkflowExecutionHistory GetWorkflowExecutionHistory Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowExecutionHistory' {Text
domain :: Text
$sel:domain:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Text
domain} -> Text
domain) (\s :: GetWorkflowExecutionHistory
s@GetWorkflowExecutionHistory' {} Text
a -> GetWorkflowExecutionHistory
s {$sel:domain:GetWorkflowExecutionHistory' :: Text
domain = Text
a} :: GetWorkflowExecutionHistory)

-- | Specifies the workflow execution for which to return the history.
getWorkflowExecutionHistory_execution :: Lens.Lens' GetWorkflowExecutionHistory WorkflowExecution
getWorkflowExecutionHistory_execution :: (WorkflowExecution -> f WorkflowExecution)
-> GetWorkflowExecutionHistory -> f GetWorkflowExecutionHistory
getWorkflowExecutionHistory_execution = (GetWorkflowExecutionHistory -> WorkflowExecution)
-> (GetWorkflowExecutionHistory
    -> WorkflowExecution -> GetWorkflowExecutionHistory)
-> Lens
     GetWorkflowExecutionHistory
     GetWorkflowExecutionHistory
     WorkflowExecution
     WorkflowExecution
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowExecutionHistory' {WorkflowExecution
execution :: WorkflowExecution
$sel:execution:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> WorkflowExecution
execution} -> WorkflowExecution
execution) (\s :: GetWorkflowExecutionHistory
s@GetWorkflowExecutionHistory' {} WorkflowExecution
a -> GetWorkflowExecutionHistory
s {$sel:execution:GetWorkflowExecutionHistory' :: WorkflowExecution
execution = WorkflowExecution
a} :: GetWorkflowExecutionHistory)

instance Core.AWSPager GetWorkflowExecutionHistory where
  page :: GetWorkflowExecutionHistory
-> AWSResponse GetWorkflowExecutionHistory
-> Maybe GetWorkflowExecutionHistory
page GetWorkflowExecutionHistory
rq AWSResponse GetWorkflowExecutionHistory
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetWorkflowExecutionHistory
GetWorkflowExecutionHistoryResponse
rs
            GetWorkflowExecutionHistoryResponse
-> Getting (First Text) GetWorkflowExecutionHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetWorkflowExecutionHistoryResponse
-> Const (First Text) GetWorkflowExecutionHistoryResponse
Lens' GetWorkflowExecutionHistoryResponse (Maybe Text)
getWorkflowExecutionHistoryResponse_nextPageToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetWorkflowExecutionHistoryResponse
 -> Const (First Text) GetWorkflowExecutionHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetWorkflowExecutionHistoryResponse 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 GetWorkflowExecutionHistory
forall a. Maybe a
Prelude.Nothing
    | [HistoryEvent] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetWorkflowExecutionHistory
GetWorkflowExecutionHistoryResponse
rs
            GetWorkflowExecutionHistoryResponse
-> Getting
     [HistoryEvent] GetWorkflowExecutionHistoryResponse [HistoryEvent]
-> [HistoryEvent]
forall s a. s -> Getting a s a -> a
Lens.^. Getting
  [HistoryEvent] GetWorkflowExecutionHistoryResponse [HistoryEvent]
Lens' GetWorkflowExecutionHistoryResponse [HistoryEvent]
getWorkflowExecutionHistoryResponse_events
        ) =
      Maybe GetWorkflowExecutionHistory
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetWorkflowExecutionHistory -> Maybe GetWorkflowExecutionHistory
forall a. a -> Maybe a
Prelude.Just (GetWorkflowExecutionHistory -> Maybe GetWorkflowExecutionHistory)
-> GetWorkflowExecutionHistory -> Maybe GetWorkflowExecutionHistory
forall a b. (a -> b) -> a -> b
Prelude.$
        GetWorkflowExecutionHistory
rq
          GetWorkflowExecutionHistory
-> (GetWorkflowExecutionHistory -> GetWorkflowExecutionHistory)
-> GetWorkflowExecutionHistory
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetWorkflowExecutionHistory
-> Identity GetWorkflowExecutionHistory
Lens
  GetWorkflowExecutionHistory
  GetWorkflowExecutionHistory
  (Maybe Text)
  (Maybe Text)
getWorkflowExecutionHistory_nextPageToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetWorkflowExecutionHistory
 -> Identity GetWorkflowExecutionHistory)
-> Maybe Text
-> GetWorkflowExecutionHistory
-> GetWorkflowExecutionHistory
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetWorkflowExecutionHistory
GetWorkflowExecutionHistoryResponse
rs
          GetWorkflowExecutionHistoryResponse
-> Getting (First Text) GetWorkflowExecutionHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetWorkflowExecutionHistoryResponse
-> Const (First Text) GetWorkflowExecutionHistoryResponse
Lens' GetWorkflowExecutionHistoryResponse (Maybe Text)
getWorkflowExecutionHistoryResponse_nextPageToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetWorkflowExecutionHistoryResponse
 -> Const (First Text) GetWorkflowExecutionHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetWorkflowExecutionHistoryResponse 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 GetWorkflowExecutionHistory where
  type
    AWSResponse GetWorkflowExecutionHistory =
      GetWorkflowExecutionHistoryResponse
  request :: GetWorkflowExecutionHistory -> Request GetWorkflowExecutionHistory
request = Service
-> GetWorkflowExecutionHistory
-> Request GetWorkflowExecutionHistory
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetWorkflowExecutionHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetWorkflowExecutionHistory)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetWorkflowExecutionHistory))
-> Logger
-> Service
-> Proxy GetWorkflowExecutionHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetWorkflowExecutionHistory)))
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
-> Int -> [HistoryEvent] -> GetWorkflowExecutionHistoryResponse
GetWorkflowExecutionHistoryResponse'
            (Maybe Text
 -> Int -> [HistoryEvent] -> GetWorkflowExecutionHistoryResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Int -> [HistoryEvent] -> GetWorkflowExecutionHistoryResponse)
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
  (Int -> [HistoryEvent] -> GetWorkflowExecutionHistoryResponse)
-> Either String Int
-> Either
     String ([HistoryEvent] -> GetWorkflowExecutionHistoryResponse)
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 ([HistoryEvent] -> GetWorkflowExecutionHistoryResponse)
-> Either String [HistoryEvent]
-> Either String GetWorkflowExecutionHistoryResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [HistoryEvent])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"events" Either String (Maybe [HistoryEvent])
-> [HistoryEvent] -> Either String [HistoryEvent]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [HistoryEvent]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable GetWorkflowExecutionHistory

instance Prelude.NFData GetWorkflowExecutionHistory

instance Core.ToHeaders GetWorkflowExecutionHistory where
  toHeaders :: GetWorkflowExecutionHistory -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetWorkflowExecutionHistory -> 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.GetWorkflowExecutionHistory" ::
                          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 GetWorkflowExecutionHistory where
  toJSON :: GetWorkflowExecutionHistory -> Value
toJSON GetWorkflowExecutionHistory' {Maybe Bool
Maybe Natural
Maybe Text
Text
WorkflowExecution
execution :: WorkflowExecution
domain :: Text
maximumPageSize :: Maybe Natural
reverseOrder :: Maybe Bool
nextPageToken :: Maybe Text
$sel:execution:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> WorkflowExecution
$sel:domain:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Text
$sel:maximumPageSize:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Natural
$sel:reverseOrder:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Bool
$sel:nextPageToken:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> 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,
            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
"execution" Text -> WorkflowExecution -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= WorkflowExecution
execution)
          ]
      )

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

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

-- | Paginated representation of a workflow history for a workflow execution.
-- This is the up to date, complete and authoritative record of the events
-- related to all tasks and events in the life of the workflow execution.
--
-- /See:/ 'newGetWorkflowExecutionHistoryResponse' smart constructor.
data GetWorkflowExecutionHistoryResponse = GetWorkflowExecutionHistoryResponse'
  { -- | 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.
    GetWorkflowExecutionHistoryResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetWorkflowExecutionHistoryResponse -> Int
httpStatus :: Prelude.Int,
    -- | The list of history events.
    GetWorkflowExecutionHistoryResponse -> [HistoryEvent]
events :: [HistoryEvent]
  }
  deriving (GetWorkflowExecutionHistoryResponse
-> GetWorkflowExecutionHistoryResponse -> Bool
(GetWorkflowExecutionHistoryResponse
 -> GetWorkflowExecutionHistoryResponse -> Bool)
-> (GetWorkflowExecutionHistoryResponse
    -> GetWorkflowExecutionHistoryResponse -> Bool)
-> Eq GetWorkflowExecutionHistoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetWorkflowExecutionHistoryResponse
-> GetWorkflowExecutionHistoryResponse -> Bool
$c/= :: GetWorkflowExecutionHistoryResponse
-> GetWorkflowExecutionHistoryResponse -> Bool
== :: GetWorkflowExecutionHistoryResponse
-> GetWorkflowExecutionHistoryResponse -> Bool
$c== :: GetWorkflowExecutionHistoryResponse
-> GetWorkflowExecutionHistoryResponse -> Bool
Prelude.Eq, ReadPrec [GetWorkflowExecutionHistoryResponse]
ReadPrec GetWorkflowExecutionHistoryResponse
Int -> ReadS GetWorkflowExecutionHistoryResponse
ReadS [GetWorkflowExecutionHistoryResponse]
(Int -> ReadS GetWorkflowExecutionHistoryResponse)
-> ReadS [GetWorkflowExecutionHistoryResponse]
-> ReadPrec GetWorkflowExecutionHistoryResponse
-> ReadPrec [GetWorkflowExecutionHistoryResponse]
-> Read GetWorkflowExecutionHistoryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetWorkflowExecutionHistoryResponse]
$creadListPrec :: ReadPrec [GetWorkflowExecutionHistoryResponse]
readPrec :: ReadPrec GetWorkflowExecutionHistoryResponse
$creadPrec :: ReadPrec GetWorkflowExecutionHistoryResponse
readList :: ReadS [GetWorkflowExecutionHistoryResponse]
$creadList :: ReadS [GetWorkflowExecutionHistoryResponse]
readsPrec :: Int -> ReadS GetWorkflowExecutionHistoryResponse
$creadsPrec :: Int -> ReadS GetWorkflowExecutionHistoryResponse
Prelude.Read, Int -> GetWorkflowExecutionHistoryResponse -> ShowS
[GetWorkflowExecutionHistoryResponse] -> ShowS
GetWorkflowExecutionHistoryResponse -> String
(Int -> GetWorkflowExecutionHistoryResponse -> ShowS)
-> (GetWorkflowExecutionHistoryResponse -> String)
-> ([GetWorkflowExecutionHistoryResponse] -> ShowS)
-> Show GetWorkflowExecutionHistoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetWorkflowExecutionHistoryResponse] -> ShowS
$cshowList :: [GetWorkflowExecutionHistoryResponse] -> ShowS
show :: GetWorkflowExecutionHistoryResponse -> String
$cshow :: GetWorkflowExecutionHistoryResponse -> String
showsPrec :: Int -> GetWorkflowExecutionHistoryResponse -> ShowS
$cshowsPrec :: Int -> GetWorkflowExecutionHistoryResponse -> ShowS
Prelude.Show, (forall x.
 GetWorkflowExecutionHistoryResponse
 -> Rep GetWorkflowExecutionHistoryResponse x)
-> (forall x.
    Rep GetWorkflowExecutionHistoryResponse x
    -> GetWorkflowExecutionHistoryResponse)
-> Generic GetWorkflowExecutionHistoryResponse
forall x.
Rep GetWorkflowExecutionHistoryResponse x
-> GetWorkflowExecutionHistoryResponse
forall x.
GetWorkflowExecutionHistoryResponse
-> Rep GetWorkflowExecutionHistoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetWorkflowExecutionHistoryResponse x
-> GetWorkflowExecutionHistoryResponse
$cfrom :: forall x.
GetWorkflowExecutionHistoryResponse
-> Rep GetWorkflowExecutionHistoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetWorkflowExecutionHistoryResponse' 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', 'getWorkflowExecutionHistoryResponse_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.
--
-- 'httpStatus', 'getWorkflowExecutionHistoryResponse_httpStatus' - The response's http status code.
--
-- 'events', 'getWorkflowExecutionHistoryResponse_events' - The list of history events.
newGetWorkflowExecutionHistoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetWorkflowExecutionHistoryResponse
newGetWorkflowExecutionHistoryResponse :: Int -> GetWorkflowExecutionHistoryResponse
newGetWorkflowExecutionHistoryResponse Int
pHttpStatus_ =
  GetWorkflowExecutionHistoryResponse' :: Maybe Text
-> Int -> [HistoryEvent] -> GetWorkflowExecutionHistoryResponse
GetWorkflowExecutionHistoryResponse'
    { $sel:nextPageToken:GetWorkflowExecutionHistoryResponse' :: Maybe Text
nextPageToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetWorkflowExecutionHistoryResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:events:GetWorkflowExecutionHistoryResponse' :: [HistoryEvent]
events = [HistoryEvent]
forall a. Monoid a => a
Prelude.mempty
    }

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

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

-- | The list of history events.
getWorkflowExecutionHistoryResponse_events :: Lens.Lens' GetWorkflowExecutionHistoryResponse [HistoryEvent]
getWorkflowExecutionHistoryResponse_events :: ([HistoryEvent] -> f [HistoryEvent])
-> GetWorkflowExecutionHistoryResponse
-> f GetWorkflowExecutionHistoryResponse
getWorkflowExecutionHistoryResponse_events = (GetWorkflowExecutionHistoryResponse -> [HistoryEvent])
-> (GetWorkflowExecutionHistoryResponse
    -> [HistoryEvent] -> GetWorkflowExecutionHistoryResponse)
-> Lens' GetWorkflowExecutionHistoryResponse [HistoryEvent]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkflowExecutionHistoryResponse' {[HistoryEvent]
events :: [HistoryEvent]
$sel:events:GetWorkflowExecutionHistoryResponse' :: GetWorkflowExecutionHistoryResponse -> [HistoryEvent]
events} -> [HistoryEvent]
events) (\s :: GetWorkflowExecutionHistoryResponse
s@GetWorkflowExecutionHistoryResponse' {} [HistoryEvent]
a -> GetWorkflowExecutionHistoryResponse
s {$sel:events:GetWorkflowExecutionHistoryResponse' :: [HistoryEvent]
events = [HistoryEvent]
a} :: GetWorkflowExecutionHistoryResponse) (([HistoryEvent] -> f [HistoryEvent])
 -> GetWorkflowExecutionHistoryResponse
 -> f GetWorkflowExecutionHistoryResponse)
-> (([HistoryEvent] -> f [HistoryEvent])
    -> [HistoryEvent] -> f [HistoryEvent])
-> ([HistoryEvent] -> f [HistoryEvent])
-> GetWorkflowExecutionHistoryResponse
-> f GetWorkflowExecutionHistoryResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([HistoryEvent] -> f [HistoryEvent])
-> [HistoryEvent] -> f [HistoryEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    GetWorkflowExecutionHistoryResponse