{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.StepFunctions.GetExecutionHistory
-- 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 execution as a list of events. By
-- default, the results are returned in ascending order of the @timeStamp@
-- of the events. Use the @reverseOrder@ parameter to get the latest events
-- first.
--
-- If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ 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 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
--
-- This API action is not supported by @EXPRESS@ state machines.
--
-- This operation returns paginated results.
module Amazonka.StepFunctions.GetExecutionHistory
  ( -- * Creating a Request
    GetExecutionHistory (..),
    newGetExecutionHistory,

    -- * Request Lenses
    getExecutionHistory_reverseOrder,
    getExecutionHistory_includeExecutionData,
    getExecutionHistory_nextToken,
    getExecutionHistory_maxResults,
    getExecutionHistory_executionArn,

    -- * Destructuring the Response
    GetExecutionHistoryResponse (..),
    newGetExecutionHistoryResponse,

    -- * Response Lenses
    getExecutionHistoryResponse_nextToken,
    getExecutionHistoryResponse_httpStatus,
    getExecutionHistoryResponse_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.StepFunctions.Types

-- | /See:/ 'newGetExecutionHistory' smart constructor.
data GetExecutionHistory = GetExecutionHistory'
  { -- | Lists events in descending order of their @timeStamp@.
    GetExecutionHistory -> Maybe Bool
reverseOrder :: Prelude.Maybe Prelude.Bool,
    -- | You can select whether execution data (input or output of a history
    -- event) is returned. The default is @true@.
    GetExecutionHistory -> Maybe Bool
includeExecutionData :: Prelude.Maybe Prelude.Bool,
    -- | If @nextToken@ is returned, there are more results available. The value
    -- of @nextToken@ 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 24 hours. Using
    -- an expired pagination token will return an /HTTP 400 InvalidToken/
    -- error.
    GetExecutionHistory -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results that are returned per call. You can use
    -- @nextToken@ to obtain further pages of results. The default is 100 and
    -- the maximum allowed page size is 1000. A value of 0 uses the default.
    --
    -- This is only an upper limit. The actual number of results returned per
    -- call might be fewer than the specified maximum.
    GetExecutionHistory -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Name (ARN) of the execution.
    GetExecutionHistory -> Text
executionArn :: Prelude.Text
  }
  deriving (GetExecutionHistory -> GetExecutionHistory -> Bool
(GetExecutionHistory -> GetExecutionHistory -> Bool)
-> (GetExecutionHistory -> GetExecutionHistory -> Bool)
-> Eq GetExecutionHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetExecutionHistory -> GetExecutionHistory -> Bool
$c/= :: GetExecutionHistory -> GetExecutionHistory -> Bool
== :: GetExecutionHistory -> GetExecutionHistory -> Bool
$c== :: GetExecutionHistory -> GetExecutionHistory -> Bool
Prelude.Eq, ReadPrec [GetExecutionHistory]
ReadPrec GetExecutionHistory
Int -> ReadS GetExecutionHistory
ReadS [GetExecutionHistory]
(Int -> ReadS GetExecutionHistory)
-> ReadS [GetExecutionHistory]
-> ReadPrec GetExecutionHistory
-> ReadPrec [GetExecutionHistory]
-> Read GetExecutionHistory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetExecutionHistory]
$creadListPrec :: ReadPrec [GetExecutionHistory]
readPrec :: ReadPrec GetExecutionHistory
$creadPrec :: ReadPrec GetExecutionHistory
readList :: ReadS [GetExecutionHistory]
$creadList :: ReadS [GetExecutionHistory]
readsPrec :: Int -> ReadS GetExecutionHistory
$creadsPrec :: Int -> ReadS GetExecutionHistory
Prelude.Read, Int -> GetExecutionHistory -> ShowS
[GetExecutionHistory] -> ShowS
GetExecutionHistory -> String
(Int -> GetExecutionHistory -> ShowS)
-> (GetExecutionHistory -> String)
-> ([GetExecutionHistory] -> ShowS)
-> Show GetExecutionHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetExecutionHistory] -> ShowS
$cshowList :: [GetExecutionHistory] -> ShowS
show :: GetExecutionHistory -> String
$cshow :: GetExecutionHistory -> String
showsPrec :: Int -> GetExecutionHistory -> ShowS
$cshowsPrec :: Int -> GetExecutionHistory -> ShowS
Prelude.Show, (forall x. GetExecutionHistory -> Rep GetExecutionHistory x)
-> (forall x. Rep GetExecutionHistory x -> GetExecutionHistory)
-> Generic GetExecutionHistory
forall x. Rep GetExecutionHistory x -> GetExecutionHistory
forall x. GetExecutionHistory -> Rep GetExecutionHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetExecutionHistory x -> GetExecutionHistory
$cfrom :: forall x. GetExecutionHistory -> Rep GetExecutionHistory x
Prelude.Generic)

-- |
-- Create a value of 'GetExecutionHistory' 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:
--
-- 'reverseOrder', 'getExecutionHistory_reverseOrder' - Lists events in descending order of their @timeStamp@.
--
-- 'includeExecutionData', 'getExecutionHistory_includeExecutionData' - You can select whether execution data (input or output of a history
-- event) is returned. The default is @true@.
--
-- 'nextToken', 'getExecutionHistory_nextToken' - If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ 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 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
--
-- 'maxResults', 'getExecutionHistory_maxResults' - The maximum number of results that are returned per call. You can use
-- @nextToken@ to obtain further pages of results. The default is 100 and
-- the maximum allowed page size is 1000. A value of 0 uses the default.
--
-- This is only an upper limit. The actual number of results returned per
-- call might be fewer than the specified maximum.
--
-- 'executionArn', 'getExecutionHistory_executionArn' - The Amazon Resource Name (ARN) of the execution.
newGetExecutionHistory ::
  -- | 'executionArn'
  Prelude.Text ->
  GetExecutionHistory
newGetExecutionHistory :: Text -> GetExecutionHistory
newGetExecutionHistory Text
pExecutionArn_ =
  GetExecutionHistory' :: Maybe Bool
-> Maybe Bool
-> Maybe Text
-> Maybe Natural
-> Text
-> GetExecutionHistory
GetExecutionHistory'
    { $sel:reverseOrder:GetExecutionHistory' :: Maybe Bool
reverseOrder =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:includeExecutionData:GetExecutionHistory' :: Maybe Bool
includeExecutionData = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetExecutionHistory' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetExecutionHistory' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:executionArn:GetExecutionHistory' :: Text
executionArn = Text
pExecutionArn_
    }

-- | Lists events in descending order of their @timeStamp@.
getExecutionHistory_reverseOrder :: Lens.Lens' GetExecutionHistory (Prelude.Maybe Prelude.Bool)
getExecutionHistory_reverseOrder :: (Maybe Bool -> f (Maybe Bool))
-> GetExecutionHistory -> f GetExecutionHistory
getExecutionHistory_reverseOrder = (GetExecutionHistory -> Maybe Bool)
-> (GetExecutionHistory -> Maybe Bool -> GetExecutionHistory)
-> Lens
     GetExecutionHistory GetExecutionHistory (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExecutionHistory' {Maybe Bool
reverseOrder :: Maybe Bool
$sel:reverseOrder:GetExecutionHistory' :: GetExecutionHistory -> Maybe Bool
reverseOrder} -> Maybe Bool
reverseOrder) (\s :: GetExecutionHistory
s@GetExecutionHistory' {} Maybe Bool
a -> GetExecutionHistory
s {$sel:reverseOrder:GetExecutionHistory' :: Maybe Bool
reverseOrder = Maybe Bool
a} :: GetExecutionHistory)

-- | You can select whether execution data (input or output of a history
-- event) is returned. The default is @true@.
getExecutionHistory_includeExecutionData :: Lens.Lens' GetExecutionHistory (Prelude.Maybe Prelude.Bool)
getExecutionHistory_includeExecutionData :: (Maybe Bool -> f (Maybe Bool))
-> GetExecutionHistory -> f GetExecutionHistory
getExecutionHistory_includeExecutionData = (GetExecutionHistory -> Maybe Bool)
-> (GetExecutionHistory -> Maybe Bool -> GetExecutionHistory)
-> Lens
     GetExecutionHistory GetExecutionHistory (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExecutionHistory' {Maybe Bool
includeExecutionData :: Maybe Bool
$sel:includeExecutionData:GetExecutionHistory' :: GetExecutionHistory -> Maybe Bool
includeExecutionData} -> Maybe Bool
includeExecutionData) (\s :: GetExecutionHistory
s@GetExecutionHistory' {} Maybe Bool
a -> GetExecutionHistory
s {$sel:includeExecutionData:GetExecutionHistory' :: Maybe Bool
includeExecutionData = Maybe Bool
a} :: GetExecutionHistory)

-- | If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ 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 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
getExecutionHistory_nextToken :: Lens.Lens' GetExecutionHistory (Prelude.Maybe Prelude.Text)
getExecutionHistory_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetExecutionHistory -> f GetExecutionHistory
getExecutionHistory_nextToken = (GetExecutionHistory -> Maybe Text)
-> (GetExecutionHistory -> Maybe Text -> GetExecutionHistory)
-> Lens
     GetExecutionHistory GetExecutionHistory (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExecutionHistory' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetExecutionHistory' :: GetExecutionHistory -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetExecutionHistory
s@GetExecutionHistory' {} Maybe Text
a -> GetExecutionHistory
s {$sel:nextToken:GetExecutionHistory' :: Maybe Text
nextToken = Maybe Text
a} :: GetExecutionHistory)

-- | The maximum number of results that are returned per call. You can use
-- @nextToken@ to obtain further pages of results. The default is 100 and
-- the maximum allowed page size is 1000. A value of 0 uses the default.
--
-- This is only an upper limit. The actual number of results returned per
-- call might be fewer than the specified maximum.
getExecutionHistory_maxResults :: Lens.Lens' GetExecutionHistory (Prelude.Maybe Prelude.Natural)
getExecutionHistory_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> GetExecutionHistory -> f GetExecutionHistory
getExecutionHistory_maxResults = (GetExecutionHistory -> Maybe Natural)
-> (GetExecutionHistory -> Maybe Natural -> GetExecutionHistory)
-> Lens
     GetExecutionHistory
     GetExecutionHistory
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExecutionHistory' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetExecutionHistory' :: GetExecutionHistory -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetExecutionHistory
s@GetExecutionHistory' {} Maybe Natural
a -> GetExecutionHistory
s {$sel:maxResults:GetExecutionHistory' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetExecutionHistory)

-- | The Amazon Resource Name (ARN) of the execution.
getExecutionHistory_executionArn :: Lens.Lens' GetExecutionHistory Prelude.Text
getExecutionHistory_executionArn :: (Text -> f Text) -> GetExecutionHistory -> f GetExecutionHistory
getExecutionHistory_executionArn = (GetExecutionHistory -> Text)
-> (GetExecutionHistory -> Text -> GetExecutionHistory)
-> Lens GetExecutionHistory GetExecutionHistory Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExecutionHistory' {Text
executionArn :: Text
$sel:executionArn:GetExecutionHistory' :: GetExecutionHistory -> Text
executionArn} -> Text
executionArn) (\s :: GetExecutionHistory
s@GetExecutionHistory' {} Text
a -> GetExecutionHistory
s {$sel:executionArn:GetExecutionHistory' :: Text
executionArn = Text
a} :: GetExecutionHistory)

instance Core.AWSPager GetExecutionHistory where
  page :: GetExecutionHistory
-> AWSResponse GetExecutionHistory -> Maybe GetExecutionHistory
page GetExecutionHistory
rq AWSResponse GetExecutionHistory
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetExecutionHistory
GetExecutionHistoryResponse
rs
            GetExecutionHistoryResponse
-> Getting (First Text) GetExecutionHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetExecutionHistoryResponse
-> Const (First Text) GetExecutionHistoryResponse
Lens' GetExecutionHistoryResponse (Maybe Text)
getExecutionHistoryResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetExecutionHistoryResponse
 -> Const (First Text) GetExecutionHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetExecutionHistoryResponse 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 GetExecutionHistory
forall a. Maybe a
Prelude.Nothing
    | [HistoryEvent] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        (AWSResponse GetExecutionHistory
GetExecutionHistoryResponse
rs GetExecutionHistoryResponse
-> Getting
     [HistoryEvent] GetExecutionHistoryResponse [HistoryEvent]
-> [HistoryEvent]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [HistoryEvent] GetExecutionHistoryResponse [HistoryEvent]
Lens' GetExecutionHistoryResponse [HistoryEvent]
getExecutionHistoryResponse_events) =
      Maybe GetExecutionHistory
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetExecutionHistory -> Maybe GetExecutionHistory
forall a. a -> Maybe a
Prelude.Just (GetExecutionHistory -> Maybe GetExecutionHistory)
-> GetExecutionHistory -> Maybe GetExecutionHistory
forall a b. (a -> b) -> a -> b
Prelude.$
        GetExecutionHistory
rq
          GetExecutionHistory
-> (GetExecutionHistory -> GetExecutionHistory)
-> GetExecutionHistory
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetExecutionHistory -> Identity GetExecutionHistory
Lens
  GetExecutionHistory GetExecutionHistory (Maybe Text) (Maybe Text)
getExecutionHistory_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetExecutionHistory -> Identity GetExecutionHistory)
-> Maybe Text -> GetExecutionHistory -> GetExecutionHistory
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetExecutionHistory
GetExecutionHistoryResponse
rs
          GetExecutionHistoryResponse
-> Getting (First Text) GetExecutionHistoryResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetExecutionHistoryResponse
-> Const (First Text) GetExecutionHistoryResponse
Lens' GetExecutionHistoryResponse (Maybe Text)
getExecutionHistoryResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetExecutionHistoryResponse
 -> Const (First Text) GetExecutionHistoryResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetExecutionHistoryResponse 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 GetExecutionHistory where
  type
    AWSResponse GetExecutionHistory =
      GetExecutionHistoryResponse
  request :: GetExecutionHistory -> Request GetExecutionHistory
request = Service -> GetExecutionHistory -> Request GetExecutionHistory
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetExecutionHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetExecutionHistory)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetExecutionHistory))
-> Logger
-> Service
-> Proxy GetExecutionHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetExecutionHistory)))
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] -> GetExecutionHistoryResponse
GetExecutionHistoryResponse'
            (Maybe Text
 -> Int -> [HistoryEvent] -> GetExecutionHistoryResponse)
-> Either String (Maybe Text)
-> Either
     String (Int -> [HistoryEvent] -> GetExecutionHistoryResponse)
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
"nextToken")
            Either
  String (Int -> [HistoryEvent] -> GetExecutionHistoryResponse)
-> Either String Int
-> Either String ([HistoryEvent] -> GetExecutionHistoryResponse)
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] -> GetExecutionHistoryResponse)
-> Either String [HistoryEvent]
-> Either String GetExecutionHistoryResponse
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 GetExecutionHistory

instance Prelude.NFData GetExecutionHistory

instance Core.ToHeaders GetExecutionHistory where
  toHeaders :: GetExecutionHistory -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetExecutionHistory -> 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
"AWSStepFunctions.GetExecutionHistory" ::
                          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 GetExecutionHistory where
  toJSON :: GetExecutionHistory -> Value
toJSON GetExecutionHistory' {Maybe Bool
Maybe Natural
Maybe Text
Text
executionArn :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
includeExecutionData :: Maybe Bool
reverseOrder :: Maybe Bool
$sel:executionArn:GetExecutionHistory' :: GetExecutionHistory -> Text
$sel:maxResults:GetExecutionHistory' :: GetExecutionHistory -> Maybe Natural
$sel:nextToken:GetExecutionHistory' :: GetExecutionHistory -> Maybe Text
$sel:includeExecutionData:GetExecutionHistory' :: GetExecutionHistory -> Maybe Bool
$sel:reverseOrder:GetExecutionHistory' :: GetExecutionHistory -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"includeExecutionData" 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
includeExecutionData,
            (Text
"nextToken" 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
nextToken,
            (Text
"maxResults" 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
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"executionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
executionArn)
          ]
      )

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

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

-- | /See:/ 'newGetExecutionHistoryResponse' smart constructor.
data GetExecutionHistoryResponse = GetExecutionHistoryResponse'
  { -- | If @nextToken@ is returned, there are more results available. The value
    -- of @nextToken@ 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 24 hours. Using
    -- an expired pagination token will return an /HTTP 400 InvalidToken/
    -- error.
    GetExecutionHistoryResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetExecutionHistoryResponse -> Int
httpStatus :: Prelude.Int,
    -- | The list of events that occurred in the execution.
    GetExecutionHistoryResponse -> [HistoryEvent]
events :: [HistoryEvent]
  }
  deriving (GetExecutionHistoryResponse -> GetExecutionHistoryResponse -> Bool
(GetExecutionHistoryResponse
 -> GetExecutionHistoryResponse -> Bool)
-> (GetExecutionHistoryResponse
    -> GetExecutionHistoryResponse -> Bool)
-> Eq GetExecutionHistoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetExecutionHistoryResponse -> GetExecutionHistoryResponse -> Bool
$c/= :: GetExecutionHistoryResponse -> GetExecutionHistoryResponse -> Bool
== :: GetExecutionHistoryResponse -> GetExecutionHistoryResponse -> Bool
$c== :: GetExecutionHistoryResponse -> GetExecutionHistoryResponse -> Bool
Prelude.Eq, Int -> GetExecutionHistoryResponse -> ShowS
[GetExecutionHistoryResponse] -> ShowS
GetExecutionHistoryResponse -> String
(Int -> GetExecutionHistoryResponse -> ShowS)
-> (GetExecutionHistoryResponse -> String)
-> ([GetExecutionHistoryResponse] -> ShowS)
-> Show GetExecutionHistoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetExecutionHistoryResponse] -> ShowS
$cshowList :: [GetExecutionHistoryResponse] -> ShowS
show :: GetExecutionHistoryResponse -> String
$cshow :: GetExecutionHistoryResponse -> String
showsPrec :: Int -> GetExecutionHistoryResponse -> ShowS
$cshowsPrec :: Int -> GetExecutionHistoryResponse -> ShowS
Prelude.Show, (forall x.
 GetExecutionHistoryResponse -> Rep GetExecutionHistoryResponse x)
-> (forall x.
    Rep GetExecutionHistoryResponse x -> GetExecutionHistoryResponse)
-> Generic GetExecutionHistoryResponse
forall x.
Rep GetExecutionHistoryResponse x -> GetExecutionHistoryResponse
forall x.
GetExecutionHistoryResponse -> Rep GetExecutionHistoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetExecutionHistoryResponse x -> GetExecutionHistoryResponse
$cfrom :: forall x.
GetExecutionHistoryResponse -> Rep GetExecutionHistoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetExecutionHistoryResponse' 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:
--
-- 'nextToken', 'getExecutionHistoryResponse_nextToken' - If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ 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 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
--
-- 'httpStatus', 'getExecutionHistoryResponse_httpStatus' - The response's http status code.
--
-- 'events', 'getExecutionHistoryResponse_events' - The list of events that occurred in the execution.
newGetExecutionHistoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetExecutionHistoryResponse
newGetExecutionHistoryResponse :: Int -> GetExecutionHistoryResponse
newGetExecutionHistoryResponse Int
pHttpStatus_ =
  GetExecutionHistoryResponse' :: Maybe Text -> Int -> [HistoryEvent] -> GetExecutionHistoryResponse
GetExecutionHistoryResponse'
    { $sel:nextToken:GetExecutionHistoryResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetExecutionHistoryResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:events:GetExecutionHistoryResponse' :: [HistoryEvent]
events = [HistoryEvent]
forall a. Monoid a => a
Prelude.mempty
    }

-- | If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ 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 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
getExecutionHistoryResponse_nextToken :: Lens.Lens' GetExecutionHistoryResponse (Prelude.Maybe Prelude.Text)
getExecutionHistoryResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetExecutionHistoryResponse -> f GetExecutionHistoryResponse
getExecutionHistoryResponse_nextToken = (GetExecutionHistoryResponse -> Maybe Text)
-> (GetExecutionHistoryResponse
    -> Maybe Text -> GetExecutionHistoryResponse)
-> Lens' GetExecutionHistoryResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExecutionHistoryResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetExecutionHistoryResponse' :: GetExecutionHistoryResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetExecutionHistoryResponse
s@GetExecutionHistoryResponse' {} Maybe Text
a -> GetExecutionHistoryResponse
s {$sel:nextToken:GetExecutionHistoryResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetExecutionHistoryResponse)

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

-- | The list of events that occurred in the execution.
getExecutionHistoryResponse_events :: Lens.Lens' GetExecutionHistoryResponse [HistoryEvent]
getExecutionHistoryResponse_events :: ([HistoryEvent] -> f [HistoryEvent])
-> GetExecutionHistoryResponse -> f GetExecutionHistoryResponse
getExecutionHistoryResponse_events = (GetExecutionHistoryResponse -> [HistoryEvent])
-> (GetExecutionHistoryResponse
    -> [HistoryEvent] -> GetExecutionHistoryResponse)
-> Lens' GetExecutionHistoryResponse [HistoryEvent]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetExecutionHistoryResponse' {[HistoryEvent]
events :: [HistoryEvent]
$sel:events:GetExecutionHistoryResponse' :: GetExecutionHistoryResponse -> [HistoryEvent]
events} -> [HistoryEvent]
events) (\s :: GetExecutionHistoryResponse
s@GetExecutionHistoryResponse' {} [HistoryEvent]
a -> GetExecutionHistoryResponse
s {$sel:events:GetExecutionHistoryResponse' :: [HistoryEvent]
events = [HistoryEvent]
a} :: GetExecutionHistoryResponse) (([HistoryEvent] -> f [HistoryEvent])
 -> GetExecutionHistoryResponse -> f GetExecutionHistoryResponse)
-> (([HistoryEvent] -> f [HistoryEvent])
    -> [HistoryEvent] -> f [HistoryEvent])
-> ([HistoryEvent] -> f [HistoryEvent])
-> GetExecutionHistoryResponse
-> f GetExecutionHistoryResponse
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 GetExecutionHistoryResponse