{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_maximumPageSize,
    getWorkflowExecutionHistory_nextPageToken,
    getWorkflowExecutionHistory_reverseOrder,
    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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SWF.Types

-- | /See:/ 'newGetWorkflowExecutionHistory' smart constructor.
data GetWorkflowExecutionHistory = GetWorkflowExecutionHistory'
  { -- | 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,
    -- | 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 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
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]
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
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.
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:
--
-- 'maximumPageSize', 'getWorkflowExecutionHistory_maximumPageSize' - The maximum number of results that are returned per call. Use
-- @nextPageToken@ to obtain further pages of results.
--
-- '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.
--
-- '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'
    { $sel:maximumPageSize:GetWorkflowExecutionHistory' :: Maybe Natural
maximumPageSize =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextPageToken:GetWorkflowExecutionHistory' :: Maybe Text
nextPageToken = forall a. Maybe a
Prelude.Nothing,
      $sel:reverseOrder:GetWorkflowExecutionHistory' :: Maybe Bool
reverseOrder = forall a. Maybe a
Prelude.Nothing,
      $sel:domain:GetWorkflowExecutionHistory' :: Text
domain = Text
pDomain_,
      $sel:execution:GetWorkflowExecutionHistory' :: WorkflowExecution
execution = WorkflowExecution
pExecution_
    }

-- | 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 :: Lens' GetWorkflowExecutionHistory (Maybe Natural)
getWorkflowExecutionHistory_maximumPageSize = 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)

-- | 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 :: Lens' GetWorkflowExecutionHistory (Maybe Text)
getWorkflowExecutionHistory_nextPageToken = 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 :: Lens' GetWorkflowExecutionHistory (Maybe Bool)
getWorkflowExecutionHistory_reverseOrder = 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 name of the domain containing the workflow execution.
getWorkflowExecutionHistory_domain :: Lens.Lens' GetWorkflowExecutionHistory Prelude.Text
getWorkflowExecutionHistory_domain :: Lens' GetWorkflowExecutionHistory Text
getWorkflowExecutionHistory_domain = 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 :: Lens' GetWorkflowExecutionHistory WorkflowExecution
getWorkflowExecutionHistory_execution = 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
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetWorkflowExecutionHistory
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetWorkflowExecutionHistoryResponse (Maybe Text)
getWorkflowExecutionHistoryResponse_nextPageToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetWorkflowExecutionHistory
rs
            forall s a. s -> Getting a s a -> a
Lens.^. Lens' GetWorkflowExecutionHistoryResponse [HistoryEvent]
getWorkflowExecutionHistoryResponse_events
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ GetWorkflowExecutionHistory
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetWorkflowExecutionHistory (Maybe Text)
getWorkflowExecutionHistory_nextPageToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetWorkflowExecutionHistory
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetWorkflowExecutionHistoryResponse (Maybe Text)
getWorkflowExecutionHistoryResponse_nextPageToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetWorkflowExecutionHistory where
  type
    AWSResponse GetWorkflowExecutionHistory =
      GetWorkflowExecutionHistoryResponse
  request :: (Service -> Service)
-> GetWorkflowExecutionHistory
-> Request GetWorkflowExecutionHistory
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetWorkflowExecutionHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetWorkflowExecutionHistory)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextPageToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"events" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable GetWorkflowExecutionHistory where
  hashWithSalt :: Int -> GetWorkflowExecutionHistory -> Int
hashWithSalt Int
_salt GetWorkflowExecutionHistory' {Maybe Bool
Maybe Natural
Maybe Text
Text
WorkflowExecution
execution :: WorkflowExecution
domain :: Text
reverseOrder :: Maybe Bool
nextPageToken :: Maybe Text
maximumPageSize :: Maybe Natural
$sel:execution:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> WorkflowExecution
$sel:domain:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Text
$sel:reverseOrder:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Bool
$sel:nextPageToken:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Text
$sel:maximumPageSize:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maximumPageSize
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextPageToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
reverseOrder
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domain
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` WorkflowExecution
execution

instance Prelude.NFData GetWorkflowExecutionHistory where
  rnf :: GetWorkflowExecutionHistory -> ()
rnf GetWorkflowExecutionHistory' {Maybe Bool
Maybe Natural
Maybe Text
Text
WorkflowExecution
execution :: WorkflowExecution
domain :: Text
reverseOrder :: Maybe Bool
nextPageToken :: Maybe Text
maximumPageSize :: Maybe Natural
$sel:execution:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> WorkflowExecution
$sel:domain:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Text
$sel:reverseOrder:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Bool
$sel:nextPageToken:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Text
$sel:maximumPageSize:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maximumPageSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextPageToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
reverseOrder
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf WorkflowExecution
execution

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

instance Data.ToJSON GetWorkflowExecutionHistory where
  toJSON :: GetWorkflowExecutionHistory -> Value
toJSON GetWorkflowExecutionHistory' {Maybe Bool
Maybe Natural
Maybe Text
Text
WorkflowExecution
execution :: WorkflowExecution
domain :: Text
reverseOrder :: Maybe Bool
nextPageToken :: Maybe Text
maximumPageSize :: Maybe Natural
$sel:execution:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> WorkflowExecution
$sel:domain:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Text
$sel:reverseOrder:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Bool
$sel:nextPageToken:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Text
$sel:maximumPageSize:GetWorkflowExecutionHistory' :: GetWorkflowExecutionHistory -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maximumPageSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maximumPageSize,
            (Key
"nextPageToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextPageToken,
            (Key
"reverseOrder" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
reverseOrder,
            forall a. a -> Maybe a
Prelude.Just (Key
"domain" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
domain),
            forall a. a -> Maybe a
Prelude.Just (Key
"execution" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= WorkflowExecution
execution)
          ]
      )

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

instance Data.ToQuery GetWorkflowExecutionHistory where
  toQuery :: GetWorkflowExecutionHistory -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:nextPageToken:GetWorkflowExecutionHistoryResponse' :: Maybe Text
nextPageToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetWorkflowExecutionHistoryResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:events:GetWorkflowExecutionHistoryResponse' :: [HistoryEvent]
events = 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 :: Lens' GetWorkflowExecutionHistoryResponse (Maybe Text)
getWorkflowExecutionHistoryResponse_nextPageToken = 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 :: Lens' GetWorkflowExecutionHistoryResponse Int
getWorkflowExecutionHistoryResponse_httpStatus = 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 :: Lens' GetWorkflowExecutionHistoryResponse [HistoryEvent]
getWorkflowExecutionHistoryResponse_events = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    GetWorkflowExecutionHistoryResponse
  where
  rnf :: GetWorkflowExecutionHistoryResponse -> ()
rnf GetWorkflowExecutionHistoryResponse' {Int
[HistoryEvent]
Maybe Text
events :: [HistoryEvent]
httpStatus :: Int
nextPageToken :: Maybe Text
$sel:events:GetWorkflowExecutionHistoryResponse' :: GetWorkflowExecutionHistoryResponse -> [HistoryEvent]
$sel:httpStatus:GetWorkflowExecutionHistoryResponse' :: GetWorkflowExecutionHistoryResponse -> Int
$sel:nextPageToken:GetWorkflowExecutionHistoryResponse' :: GetWorkflowExecutionHistoryResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextPageToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [HistoryEvent]
events