{-# 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.EMRContainers.ListJobRuns
-- 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)
--
-- Lists job runs based on a set of parameters. A job run is a unit of
-- work, such as a Spark jar, PySpark script, or SparkSQL query, that you
-- submit to Amazon EMR on EKS.
--
-- This operation returns paginated results.
module Amazonka.EMRContainers.ListJobRuns
  ( -- * Creating a Request
    ListJobRuns (..),
    newListJobRuns,

    -- * Request Lenses
    listJobRuns_states,
    listJobRuns_createdAfter,
    listJobRuns_nextToken,
    listJobRuns_name,
    listJobRuns_maxResults,
    listJobRuns_createdBefore,
    listJobRuns_virtualClusterId,

    -- * Destructuring the Response
    ListJobRunsResponse (..),
    newListJobRunsResponse,

    -- * Response Lenses
    listJobRunsResponse_nextToken,
    listJobRunsResponse_jobRuns,
    listJobRunsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.EMRContainers.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListJobRuns' smart constructor.
data ListJobRuns = ListJobRuns'
  { -- | The states of the job run.
    ListJobRuns -> Maybe [JobRunState]
states :: Prelude.Maybe [JobRunState],
    -- | The date and time after which the job runs were submitted.
    ListJobRuns -> Maybe POSIX
createdAfter :: Prelude.Maybe Core.POSIX,
    -- | The token for the next set of job runs to return.
    ListJobRuns -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the job run.
    ListJobRuns -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of job runs that can be listed.
    ListJobRuns -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The date and time before which the job runs were submitted.
    ListJobRuns -> Maybe POSIX
createdBefore :: Prelude.Maybe Core.POSIX,
    -- | The ID of the virtual cluster for which to list the job run.
    ListJobRuns -> Text
virtualClusterId :: Prelude.Text
  }
  deriving (ListJobRuns -> ListJobRuns -> Bool
(ListJobRuns -> ListJobRuns -> Bool)
-> (ListJobRuns -> ListJobRuns -> Bool) -> Eq ListJobRuns
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListJobRuns -> ListJobRuns -> Bool
$c/= :: ListJobRuns -> ListJobRuns -> Bool
== :: ListJobRuns -> ListJobRuns -> Bool
$c== :: ListJobRuns -> ListJobRuns -> Bool
Prelude.Eq, ReadPrec [ListJobRuns]
ReadPrec ListJobRuns
Int -> ReadS ListJobRuns
ReadS [ListJobRuns]
(Int -> ReadS ListJobRuns)
-> ReadS [ListJobRuns]
-> ReadPrec ListJobRuns
-> ReadPrec [ListJobRuns]
-> Read ListJobRuns
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListJobRuns]
$creadListPrec :: ReadPrec [ListJobRuns]
readPrec :: ReadPrec ListJobRuns
$creadPrec :: ReadPrec ListJobRuns
readList :: ReadS [ListJobRuns]
$creadList :: ReadS [ListJobRuns]
readsPrec :: Int -> ReadS ListJobRuns
$creadsPrec :: Int -> ReadS ListJobRuns
Prelude.Read, Int -> ListJobRuns -> ShowS
[ListJobRuns] -> ShowS
ListJobRuns -> String
(Int -> ListJobRuns -> ShowS)
-> (ListJobRuns -> String)
-> ([ListJobRuns] -> ShowS)
-> Show ListJobRuns
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListJobRuns] -> ShowS
$cshowList :: [ListJobRuns] -> ShowS
show :: ListJobRuns -> String
$cshow :: ListJobRuns -> String
showsPrec :: Int -> ListJobRuns -> ShowS
$cshowsPrec :: Int -> ListJobRuns -> ShowS
Prelude.Show, (forall x. ListJobRuns -> Rep ListJobRuns x)
-> (forall x. Rep ListJobRuns x -> ListJobRuns)
-> Generic ListJobRuns
forall x. Rep ListJobRuns x -> ListJobRuns
forall x. ListJobRuns -> Rep ListJobRuns x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListJobRuns x -> ListJobRuns
$cfrom :: forall x. ListJobRuns -> Rep ListJobRuns x
Prelude.Generic)

-- |
-- Create a value of 'ListJobRuns' 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:
--
-- 'states', 'listJobRuns_states' - The states of the job run.
--
-- 'createdAfter', 'listJobRuns_createdAfter' - The date and time after which the job runs were submitted.
--
-- 'nextToken', 'listJobRuns_nextToken' - The token for the next set of job runs to return.
--
-- 'name', 'listJobRuns_name' - The name of the job run.
--
-- 'maxResults', 'listJobRuns_maxResults' - The maximum number of job runs that can be listed.
--
-- 'createdBefore', 'listJobRuns_createdBefore' - The date and time before which the job runs were submitted.
--
-- 'virtualClusterId', 'listJobRuns_virtualClusterId' - The ID of the virtual cluster for which to list the job run.
newListJobRuns ::
  -- | 'virtualClusterId'
  Prelude.Text ->
  ListJobRuns
newListJobRuns :: Text -> ListJobRuns
newListJobRuns Text
pVirtualClusterId_ =
  ListJobRuns' :: Maybe [JobRunState]
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe POSIX
-> Text
-> ListJobRuns
ListJobRuns'
    { $sel:states:ListJobRuns' :: Maybe [JobRunState]
states = Maybe [JobRunState]
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAfter:ListJobRuns' :: Maybe POSIX
createdAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListJobRuns' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ListJobRuns' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListJobRuns' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:createdBefore:ListJobRuns' :: Maybe POSIX
createdBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:virtualClusterId:ListJobRuns' :: Text
virtualClusterId = Text
pVirtualClusterId_
    }

-- | The states of the job run.
listJobRuns_states :: Lens.Lens' ListJobRuns (Prelude.Maybe [JobRunState])
listJobRuns_states :: (Maybe [JobRunState] -> f (Maybe [JobRunState]))
-> ListJobRuns -> f ListJobRuns
listJobRuns_states = (ListJobRuns -> Maybe [JobRunState])
-> (ListJobRuns -> Maybe [JobRunState] -> ListJobRuns)
-> Lens
     ListJobRuns ListJobRuns (Maybe [JobRunState]) (Maybe [JobRunState])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobRuns' {Maybe [JobRunState]
states :: Maybe [JobRunState]
$sel:states:ListJobRuns' :: ListJobRuns -> Maybe [JobRunState]
states} -> Maybe [JobRunState]
states) (\s :: ListJobRuns
s@ListJobRuns' {} Maybe [JobRunState]
a -> ListJobRuns
s {$sel:states:ListJobRuns' :: Maybe [JobRunState]
states = Maybe [JobRunState]
a} :: ListJobRuns) ((Maybe [JobRunState] -> f (Maybe [JobRunState]))
 -> ListJobRuns -> f ListJobRuns)
-> ((Maybe [JobRunState] -> f (Maybe [JobRunState]))
    -> Maybe [JobRunState] -> f (Maybe [JobRunState]))
-> (Maybe [JobRunState] -> f (Maybe [JobRunState]))
-> ListJobRuns
-> f ListJobRuns
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [JobRunState] [JobRunState] [JobRunState] [JobRunState]
-> Iso
     (Maybe [JobRunState])
     (Maybe [JobRunState])
     (Maybe [JobRunState])
     (Maybe [JobRunState])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [JobRunState] [JobRunState] [JobRunState] [JobRunState]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The date and time after which the job runs were submitted.
listJobRuns_createdAfter :: Lens.Lens' ListJobRuns (Prelude.Maybe Prelude.UTCTime)
listJobRuns_createdAfter :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListJobRuns -> f ListJobRuns
listJobRuns_createdAfter = (ListJobRuns -> Maybe POSIX)
-> (ListJobRuns -> Maybe POSIX -> ListJobRuns)
-> Lens ListJobRuns ListJobRuns (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobRuns' {Maybe POSIX
createdAfter :: Maybe POSIX
$sel:createdAfter:ListJobRuns' :: ListJobRuns -> Maybe POSIX
createdAfter} -> Maybe POSIX
createdAfter) (\s :: ListJobRuns
s@ListJobRuns' {} Maybe POSIX
a -> ListJobRuns
s {$sel:createdAfter:ListJobRuns' :: Maybe POSIX
createdAfter = Maybe POSIX
a} :: ListJobRuns) ((Maybe POSIX -> f (Maybe POSIX)) -> ListJobRuns -> f ListJobRuns)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListJobRuns
-> f ListJobRuns
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The token for the next set of job runs to return.
listJobRuns_nextToken :: Lens.Lens' ListJobRuns (Prelude.Maybe Prelude.Text)
listJobRuns_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListJobRuns -> f ListJobRuns
listJobRuns_nextToken = (ListJobRuns -> Maybe Text)
-> (ListJobRuns -> Maybe Text -> ListJobRuns)
-> Lens ListJobRuns ListJobRuns (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobRuns' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListJobRuns' :: ListJobRuns -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListJobRuns
s@ListJobRuns' {} Maybe Text
a -> ListJobRuns
s {$sel:nextToken:ListJobRuns' :: Maybe Text
nextToken = Maybe Text
a} :: ListJobRuns)

-- | The name of the job run.
listJobRuns_name :: Lens.Lens' ListJobRuns (Prelude.Maybe Prelude.Text)
listJobRuns_name :: (Maybe Text -> f (Maybe Text)) -> ListJobRuns -> f ListJobRuns
listJobRuns_name = (ListJobRuns -> Maybe Text)
-> (ListJobRuns -> Maybe Text -> ListJobRuns)
-> Lens ListJobRuns ListJobRuns (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobRuns' {Maybe Text
name :: Maybe Text
$sel:name:ListJobRuns' :: ListJobRuns -> Maybe Text
name} -> Maybe Text
name) (\s :: ListJobRuns
s@ListJobRuns' {} Maybe Text
a -> ListJobRuns
s {$sel:name:ListJobRuns' :: Maybe Text
name = Maybe Text
a} :: ListJobRuns)

-- | The maximum number of job runs that can be listed.
listJobRuns_maxResults :: Lens.Lens' ListJobRuns (Prelude.Maybe Prelude.Int)
listJobRuns_maxResults :: (Maybe Int -> f (Maybe Int)) -> ListJobRuns -> f ListJobRuns
listJobRuns_maxResults = (ListJobRuns -> Maybe Int)
-> (ListJobRuns -> Maybe Int -> ListJobRuns)
-> Lens ListJobRuns ListJobRuns (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobRuns' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:ListJobRuns' :: ListJobRuns -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: ListJobRuns
s@ListJobRuns' {} Maybe Int
a -> ListJobRuns
s {$sel:maxResults:ListJobRuns' :: Maybe Int
maxResults = Maybe Int
a} :: ListJobRuns)

-- | The date and time before which the job runs were submitted.
listJobRuns_createdBefore :: Lens.Lens' ListJobRuns (Prelude.Maybe Prelude.UTCTime)
listJobRuns_createdBefore :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListJobRuns -> f ListJobRuns
listJobRuns_createdBefore = (ListJobRuns -> Maybe POSIX)
-> (ListJobRuns -> Maybe POSIX -> ListJobRuns)
-> Lens ListJobRuns ListJobRuns (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobRuns' {Maybe POSIX
createdBefore :: Maybe POSIX
$sel:createdBefore:ListJobRuns' :: ListJobRuns -> Maybe POSIX
createdBefore} -> Maybe POSIX
createdBefore) (\s :: ListJobRuns
s@ListJobRuns' {} Maybe POSIX
a -> ListJobRuns
s {$sel:createdBefore:ListJobRuns' :: Maybe POSIX
createdBefore = Maybe POSIX
a} :: ListJobRuns) ((Maybe POSIX -> f (Maybe POSIX)) -> ListJobRuns -> f ListJobRuns)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListJobRuns
-> f ListJobRuns
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The ID of the virtual cluster for which to list the job run.
listJobRuns_virtualClusterId :: Lens.Lens' ListJobRuns Prelude.Text
listJobRuns_virtualClusterId :: (Text -> f Text) -> ListJobRuns -> f ListJobRuns
listJobRuns_virtualClusterId = (ListJobRuns -> Text)
-> (ListJobRuns -> Text -> ListJobRuns)
-> Lens ListJobRuns ListJobRuns Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobRuns' {Text
virtualClusterId :: Text
$sel:virtualClusterId:ListJobRuns' :: ListJobRuns -> Text
virtualClusterId} -> Text
virtualClusterId) (\s :: ListJobRuns
s@ListJobRuns' {} Text
a -> ListJobRuns
s {$sel:virtualClusterId:ListJobRuns' :: Text
virtualClusterId = Text
a} :: ListJobRuns)

instance Core.AWSPager ListJobRuns where
  page :: ListJobRuns -> AWSResponse ListJobRuns -> Maybe ListJobRuns
page ListJobRuns
rq AWSResponse ListJobRuns
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListJobRuns
ListJobRunsResponse
rs
            ListJobRunsResponse
-> Getting (First Text) ListJobRunsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListJobRunsResponse -> Const (First Text) ListJobRunsResponse
Lens' ListJobRunsResponse (Maybe Text)
listJobRunsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListJobRunsResponse -> Const (First Text) ListJobRunsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListJobRunsResponse 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 ListJobRuns
forall a. Maybe a
Prelude.Nothing
    | Maybe [JobRun] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListJobRuns
ListJobRunsResponse
rs
            ListJobRunsResponse
-> Getting (First [JobRun]) ListJobRunsResponse [JobRun]
-> Maybe [JobRun]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [JobRun] -> Const (First [JobRun]) (Maybe [JobRun]))
-> ListJobRunsResponse
-> Const (First [JobRun]) ListJobRunsResponse
Lens' ListJobRunsResponse (Maybe [JobRun])
listJobRunsResponse_jobRuns ((Maybe [JobRun] -> Const (First [JobRun]) (Maybe [JobRun]))
 -> ListJobRunsResponse
 -> Const (First [JobRun]) ListJobRunsResponse)
-> (([JobRun] -> Const (First [JobRun]) [JobRun])
    -> Maybe [JobRun] -> Const (First [JobRun]) (Maybe [JobRun]))
-> Getting (First [JobRun]) ListJobRunsResponse [JobRun]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([JobRun] -> Const (First [JobRun]) [JobRun])
-> Maybe [JobRun] -> Const (First [JobRun]) (Maybe [JobRun])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListJobRuns
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListJobRuns -> Maybe ListJobRuns
forall a. a -> Maybe a
Prelude.Just (ListJobRuns -> Maybe ListJobRuns)
-> ListJobRuns -> Maybe ListJobRuns
forall a b. (a -> b) -> a -> b
Prelude.$
        ListJobRuns
rq
          ListJobRuns -> (ListJobRuns -> ListJobRuns) -> ListJobRuns
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListJobRuns -> Identity ListJobRuns
Lens ListJobRuns ListJobRuns (Maybe Text) (Maybe Text)
listJobRuns_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListJobRuns -> Identity ListJobRuns)
-> Maybe Text -> ListJobRuns -> ListJobRuns
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListJobRuns
ListJobRunsResponse
rs
          ListJobRunsResponse
-> Getting (First Text) ListJobRunsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListJobRunsResponse -> Const (First Text) ListJobRunsResponse
Lens' ListJobRunsResponse (Maybe Text)
listJobRunsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListJobRunsResponse -> Const (First Text) ListJobRunsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListJobRunsResponse 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 ListJobRuns where
  type AWSResponse ListJobRuns = ListJobRunsResponse
  request :: ListJobRuns -> Request ListJobRuns
request = Service -> ListJobRuns -> Request ListJobRuns
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListJobRuns
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListJobRuns)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListJobRuns))
-> Logger
-> Service
-> Proxy ListJobRuns
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListJobRuns)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe [JobRun] -> Int -> ListJobRunsResponse
ListJobRunsResponse'
            (Maybe Text -> Maybe [JobRun] -> Int -> ListJobRunsResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [JobRun] -> Int -> ListJobRunsResponse)
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 (Maybe [JobRun] -> Int -> ListJobRunsResponse)
-> Either String (Maybe [JobRun])
-> Either String (Int -> ListJobRunsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [JobRun]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"jobRuns" Either String (Maybe (Maybe [JobRun]))
-> Maybe [JobRun] -> Either String (Maybe [JobRun])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [JobRun]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListJobRunsResponse)
-> Either String Int -> Either String ListJobRunsResponse
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))
      )

instance Prelude.Hashable ListJobRuns

instance Prelude.NFData ListJobRuns

instance Core.ToHeaders ListJobRuns where
  toHeaders :: ListJobRuns -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListJobRuns -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath ListJobRuns where
  toPath :: ListJobRuns -> ByteString
toPath ListJobRuns' {Maybe Int
Maybe [JobRunState]
Maybe Text
Maybe POSIX
Text
virtualClusterId :: Text
createdBefore :: Maybe POSIX
maxResults :: Maybe Int
name :: Maybe Text
nextToken :: Maybe Text
createdAfter :: Maybe POSIX
states :: Maybe [JobRunState]
$sel:virtualClusterId:ListJobRuns' :: ListJobRuns -> Text
$sel:createdBefore:ListJobRuns' :: ListJobRuns -> Maybe POSIX
$sel:maxResults:ListJobRuns' :: ListJobRuns -> Maybe Int
$sel:name:ListJobRuns' :: ListJobRuns -> Maybe Text
$sel:nextToken:ListJobRuns' :: ListJobRuns -> Maybe Text
$sel:createdAfter:ListJobRuns' :: ListJobRuns -> Maybe POSIX
$sel:states:ListJobRuns' :: ListJobRuns -> Maybe [JobRunState]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/virtualclusters/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
virtualClusterId,
        ByteString
"/jobruns"
      ]

instance Core.ToQuery ListJobRuns where
  toQuery :: ListJobRuns -> QueryString
toQuery ListJobRuns' {Maybe Int
Maybe [JobRunState]
Maybe Text
Maybe POSIX
Text
virtualClusterId :: Text
createdBefore :: Maybe POSIX
maxResults :: Maybe Int
name :: Maybe Text
nextToken :: Maybe Text
createdAfter :: Maybe POSIX
states :: Maybe [JobRunState]
$sel:virtualClusterId:ListJobRuns' :: ListJobRuns -> Text
$sel:createdBefore:ListJobRuns' :: ListJobRuns -> Maybe POSIX
$sel:maxResults:ListJobRuns' :: ListJobRuns -> Maybe Int
$sel:name:ListJobRuns' :: ListJobRuns -> Maybe Text
$sel:nextToken:ListJobRuns' :: ListJobRuns -> Maybe Text
$sel:createdAfter:ListJobRuns' :: ListJobRuns -> Maybe POSIX
$sel:states:ListJobRuns' :: ListJobRuns -> Maybe [JobRunState]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"states"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [JobRunState] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([JobRunState] -> QueryString)
-> Maybe [JobRunState] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [JobRunState]
states),
        ByteString
"createdAfter" ByteString -> Maybe POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe POSIX
createdAfter,
        ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"name" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
name,
        ByteString
"maxResults" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
maxResults,
        ByteString
"createdBefore" ByteString -> Maybe POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe POSIX
createdBefore
      ]

-- | /See:/ 'newListJobRunsResponse' smart constructor.
data ListJobRunsResponse = ListJobRunsResponse'
  { -- | This output displays the token for the next set of job runs.
    ListJobRunsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | This output lists information about the specified job runs.
    ListJobRunsResponse -> Maybe [JobRun]
jobRuns :: Prelude.Maybe [JobRun],
    -- | The response's http status code.
    ListJobRunsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListJobRunsResponse -> ListJobRunsResponse -> Bool
(ListJobRunsResponse -> ListJobRunsResponse -> Bool)
-> (ListJobRunsResponse -> ListJobRunsResponse -> Bool)
-> Eq ListJobRunsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListJobRunsResponse -> ListJobRunsResponse -> Bool
$c/= :: ListJobRunsResponse -> ListJobRunsResponse -> Bool
== :: ListJobRunsResponse -> ListJobRunsResponse -> Bool
$c== :: ListJobRunsResponse -> ListJobRunsResponse -> Bool
Prelude.Eq, Int -> ListJobRunsResponse -> ShowS
[ListJobRunsResponse] -> ShowS
ListJobRunsResponse -> String
(Int -> ListJobRunsResponse -> ShowS)
-> (ListJobRunsResponse -> String)
-> ([ListJobRunsResponse] -> ShowS)
-> Show ListJobRunsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListJobRunsResponse] -> ShowS
$cshowList :: [ListJobRunsResponse] -> ShowS
show :: ListJobRunsResponse -> String
$cshow :: ListJobRunsResponse -> String
showsPrec :: Int -> ListJobRunsResponse -> ShowS
$cshowsPrec :: Int -> ListJobRunsResponse -> ShowS
Prelude.Show, (forall x. ListJobRunsResponse -> Rep ListJobRunsResponse x)
-> (forall x. Rep ListJobRunsResponse x -> ListJobRunsResponse)
-> Generic ListJobRunsResponse
forall x. Rep ListJobRunsResponse x -> ListJobRunsResponse
forall x. ListJobRunsResponse -> Rep ListJobRunsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListJobRunsResponse x -> ListJobRunsResponse
$cfrom :: forall x. ListJobRunsResponse -> Rep ListJobRunsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListJobRunsResponse' 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', 'listJobRunsResponse_nextToken' - This output displays the token for the next set of job runs.
--
-- 'jobRuns', 'listJobRunsResponse_jobRuns' - This output lists information about the specified job runs.
--
-- 'httpStatus', 'listJobRunsResponse_httpStatus' - The response's http status code.
newListJobRunsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListJobRunsResponse
newListJobRunsResponse :: Int -> ListJobRunsResponse
newListJobRunsResponse Int
pHttpStatus_ =
  ListJobRunsResponse' :: Maybe Text -> Maybe [JobRun] -> Int -> ListJobRunsResponse
ListJobRunsResponse'
    { $sel:nextToken:ListJobRunsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobRuns:ListJobRunsResponse' :: Maybe [JobRun]
jobRuns = Maybe [JobRun]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListJobRunsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | This output displays the token for the next set of job runs.
listJobRunsResponse_nextToken :: Lens.Lens' ListJobRunsResponse (Prelude.Maybe Prelude.Text)
listJobRunsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListJobRunsResponse -> f ListJobRunsResponse
listJobRunsResponse_nextToken = (ListJobRunsResponse -> Maybe Text)
-> (ListJobRunsResponse -> Maybe Text -> ListJobRunsResponse)
-> Lens' ListJobRunsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobRunsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListJobRunsResponse' :: ListJobRunsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListJobRunsResponse
s@ListJobRunsResponse' {} Maybe Text
a -> ListJobRunsResponse
s {$sel:nextToken:ListJobRunsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListJobRunsResponse)

-- | This output lists information about the specified job runs.
listJobRunsResponse_jobRuns :: Lens.Lens' ListJobRunsResponse (Prelude.Maybe [JobRun])
listJobRunsResponse_jobRuns :: (Maybe [JobRun] -> f (Maybe [JobRun]))
-> ListJobRunsResponse -> f ListJobRunsResponse
listJobRunsResponse_jobRuns = (ListJobRunsResponse -> Maybe [JobRun])
-> (ListJobRunsResponse -> Maybe [JobRun] -> ListJobRunsResponse)
-> Lens' ListJobRunsResponse (Maybe [JobRun])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobRunsResponse' {Maybe [JobRun]
jobRuns :: Maybe [JobRun]
$sel:jobRuns:ListJobRunsResponse' :: ListJobRunsResponse -> Maybe [JobRun]
jobRuns} -> Maybe [JobRun]
jobRuns) (\s :: ListJobRunsResponse
s@ListJobRunsResponse' {} Maybe [JobRun]
a -> ListJobRunsResponse
s {$sel:jobRuns:ListJobRunsResponse' :: Maybe [JobRun]
jobRuns = Maybe [JobRun]
a} :: ListJobRunsResponse) ((Maybe [JobRun] -> f (Maybe [JobRun]))
 -> ListJobRunsResponse -> f ListJobRunsResponse)
-> ((Maybe [JobRun] -> f (Maybe [JobRun]))
    -> Maybe [JobRun] -> f (Maybe [JobRun]))
-> (Maybe [JobRun] -> f (Maybe [JobRun]))
-> ListJobRunsResponse
-> f ListJobRunsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [JobRun] [JobRun] [JobRun] [JobRun]
-> Iso
     (Maybe [JobRun]) (Maybe [JobRun]) (Maybe [JobRun]) (Maybe [JobRun])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [JobRun] [JobRun] [JobRun] [JobRun]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListJobRunsResponse