{-# 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.Batch.ListJobs
-- 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 a list of Batch jobs.
--
-- You must specify only one of the following items:
--
-- -   A job queue ID to return a list of jobs in that job queue
--
-- -   A multi-node parallel job ID to return a list of nodes for that job
--
-- -   An array job ID to return a list of the children for that job
--
-- You can filter the results by job status with the @jobStatus@ parameter.
-- If you don\'t specify a status, only @RUNNING@ jobs are returned.
--
-- This operation returns paginated results.
module Amazonka.Batch.ListJobs
  ( -- * Creating a Request
    ListJobs (..),
    newListJobs,

    -- * Request Lenses
    listJobs_arrayJobId,
    listJobs_filters,
    listJobs_jobQueue,
    listJobs_jobStatus,
    listJobs_maxResults,
    listJobs_multiNodeJobId,
    listJobs_nextToken,

    -- * Destructuring the Response
    ListJobsResponse (..),
    newListJobsResponse,

    -- * Response Lenses
    listJobsResponse_nextToken,
    listJobsResponse_httpStatus,
    listJobsResponse_jobSummaryList,
  )
where

import Amazonka.Batch.Types
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

-- | Contains the parameters for @ListJobs@.
--
-- /See:/ 'newListJobs' smart constructor.
data ListJobs = ListJobs'
  { -- | The job ID for an array job. Specifying an array job ID with this
    -- parameter lists all child jobs from within the specified array.
    ListJobs -> Maybe Text
arrayJobId :: Prelude.Maybe Prelude.Text,
    -- | The filter to apply to the query. Only one filter can be used at a time.
    -- When the filter is used, @jobStatus@ is ignored. The filter doesn\'t
    -- apply to child jobs in an array or multi-node parallel (MNP) jobs. The
    -- results are sorted by the @createdAt@ field, with the most recent jobs
    -- being first.
    --
    -- [JOB_NAME]
    --     The value of the filter is a case-insensitive match for the job
    --     name. If the value ends with an asterisk (*), the filter matches any
    --     job name that begins with the string before the \'*\'. This
    --     corresponds to the @jobName@ value. For example, @test1@ matches
    --     both @Test1@ and @test1@, and @test1*@ matches both @test1@ and
    --     @Test10@. When the @JOB_NAME@ filter is used, the results are
    --     grouped by the job name and version.
    --
    -- [JOB_DEFINITION]
    --     The value for the filter is the name or Amazon Resource Name (ARN)
    --     of the job definition. This corresponds to the @jobDefinition@
    --     value. The value is case sensitive. When the value for the filter is
    --     the job definition name, the results include all the jobs that used
    --     any revision of that job definition name. If the value ends with an
    --     asterisk (*), the filter matches any job definition name that begins
    --     with the string before the \'*\'. For example, @jd1@ matches only
    --     @jd1@, and @jd1*@ matches both @jd1@ and @jd1A@. The version of the
    --     job definition that\'s used doesn\'t affect the sort order. When the
    --     @JOB_DEFINITION@ filter is used and the ARN is used (which is in the
    --     form
    --     @arn:${Partition}:batch:${Region}:${Account}:job-definition\/${JobDefinitionName}:${Revision}@),
    --     the results include jobs that used the specified revision of the job
    --     definition. Asterisk (*) isn\'t supported when the ARN is used.
    --
    -- [BEFORE_CREATED_AT]
    --     The value for the filter is the time that\'s before the job was
    --     created. This corresponds to the @createdAt@ value. The value is a
    --     string representation of the number of milliseconds since 00:00:00
    --     UTC (midnight) on January 1, 1970.
    --
    -- [AFTER_CREATED_AT]
    --     The value for the filter is the time that\'s after the job was
    --     created. This corresponds to the @createdAt@ value. The value is a
    --     string representation of the number of milliseconds since 00:00:00
    --     UTC (midnight) on January 1, 1970.
    ListJobs -> Maybe [KeyValuesPair]
filters :: Prelude.Maybe [KeyValuesPair],
    -- | The name or full Amazon Resource Name (ARN) of the job queue used to
    -- list jobs.
    ListJobs -> Maybe Text
jobQueue :: Prelude.Maybe Prelude.Text,
    -- | The job status used to filter jobs in the specified queue. If the
    -- @filters@ parameter is specified, the @jobStatus@ parameter is ignored
    -- and jobs with any status are returned. If you don\'t specify a status,
    -- only @RUNNING@ jobs are returned.
    ListJobs -> Maybe JobStatus
jobStatus :: Prelude.Maybe JobStatus,
    -- | The maximum number of results returned by @ListJobs@ in paginated
    -- output. When this parameter is used, @ListJobs@ only returns
    -- @maxResults@ results in a single page and a @nextToken@ response
    -- element. The remaining results of the initial request can be seen by
    -- sending another @ListJobs@ request with the returned @nextToken@ value.
    -- This value can be between 1 and 100. If this parameter isn\'t used, then
    -- @ListJobs@ returns up to 100 results and a @nextToken@ value if
    -- applicable.
    ListJobs -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The job ID for a multi-node parallel job. Specifying a multi-node
    -- parallel job ID with this parameter lists all nodes that are associated
    -- with the specified job.
    ListJobs -> Maybe Text
multiNodeJobId :: Prelude.Maybe Prelude.Text,
    -- | The @nextToken@ value returned from a previous paginated @ListJobs@
    -- request where @maxResults@ was used and the results exceeded the value
    -- of that parameter. Pagination continues from the end of the previous
    -- results that returned the @nextToken@ value. This value is @null@ when
    -- there are no more results to return.
    --
    -- Treat this token as an opaque identifier that\'s only used to retrieve
    -- the next items in a list and not for other programmatic purposes.
    ListJobs -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListJobs -> ListJobs -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListJobs -> ListJobs -> Bool
$c/= :: ListJobs -> ListJobs -> Bool
== :: ListJobs -> ListJobs -> Bool
$c== :: ListJobs -> ListJobs -> Bool
Prelude.Eq, ReadPrec [ListJobs]
ReadPrec ListJobs
Int -> ReadS ListJobs
ReadS [ListJobs]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListJobs]
$creadListPrec :: ReadPrec [ListJobs]
readPrec :: ReadPrec ListJobs
$creadPrec :: ReadPrec ListJobs
readList :: ReadS [ListJobs]
$creadList :: ReadS [ListJobs]
readsPrec :: Int -> ReadS ListJobs
$creadsPrec :: Int -> ReadS ListJobs
Prelude.Read, Int -> ListJobs -> ShowS
[ListJobs] -> ShowS
ListJobs -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListJobs] -> ShowS
$cshowList :: [ListJobs] -> ShowS
show :: ListJobs -> String
$cshow :: ListJobs -> String
showsPrec :: Int -> ListJobs -> ShowS
$cshowsPrec :: Int -> ListJobs -> ShowS
Prelude.Show, forall x. Rep ListJobs x -> ListJobs
forall x. ListJobs -> Rep ListJobs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListJobs x -> ListJobs
$cfrom :: forall x. ListJobs -> Rep ListJobs x
Prelude.Generic)

-- |
-- Create a value of 'ListJobs' 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:
--
-- 'arrayJobId', 'listJobs_arrayJobId' - The job ID for an array job. Specifying an array job ID with this
-- parameter lists all child jobs from within the specified array.
--
-- 'filters', 'listJobs_filters' - The filter to apply to the query. Only one filter can be used at a time.
-- When the filter is used, @jobStatus@ is ignored. The filter doesn\'t
-- apply to child jobs in an array or multi-node parallel (MNP) jobs. The
-- results are sorted by the @createdAt@ field, with the most recent jobs
-- being first.
--
-- [JOB_NAME]
--     The value of the filter is a case-insensitive match for the job
--     name. If the value ends with an asterisk (*), the filter matches any
--     job name that begins with the string before the \'*\'. This
--     corresponds to the @jobName@ value. For example, @test1@ matches
--     both @Test1@ and @test1@, and @test1*@ matches both @test1@ and
--     @Test10@. When the @JOB_NAME@ filter is used, the results are
--     grouped by the job name and version.
--
-- [JOB_DEFINITION]
--     The value for the filter is the name or Amazon Resource Name (ARN)
--     of the job definition. This corresponds to the @jobDefinition@
--     value. The value is case sensitive. When the value for the filter is
--     the job definition name, the results include all the jobs that used
--     any revision of that job definition name. If the value ends with an
--     asterisk (*), the filter matches any job definition name that begins
--     with the string before the \'*\'. For example, @jd1@ matches only
--     @jd1@, and @jd1*@ matches both @jd1@ and @jd1A@. The version of the
--     job definition that\'s used doesn\'t affect the sort order. When the
--     @JOB_DEFINITION@ filter is used and the ARN is used (which is in the
--     form
--     @arn:${Partition}:batch:${Region}:${Account}:job-definition\/${JobDefinitionName}:${Revision}@),
--     the results include jobs that used the specified revision of the job
--     definition. Asterisk (*) isn\'t supported when the ARN is used.
--
-- [BEFORE_CREATED_AT]
--     The value for the filter is the time that\'s before the job was
--     created. This corresponds to the @createdAt@ value. The value is a
--     string representation of the number of milliseconds since 00:00:00
--     UTC (midnight) on January 1, 1970.
--
-- [AFTER_CREATED_AT]
--     The value for the filter is the time that\'s after the job was
--     created. This corresponds to the @createdAt@ value. The value is a
--     string representation of the number of milliseconds since 00:00:00
--     UTC (midnight) on January 1, 1970.
--
-- 'jobQueue', 'listJobs_jobQueue' - The name or full Amazon Resource Name (ARN) of the job queue used to
-- list jobs.
--
-- 'jobStatus', 'listJobs_jobStatus' - The job status used to filter jobs in the specified queue. If the
-- @filters@ parameter is specified, the @jobStatus@ parameter is ignored
-- and jobs with any status are returned. If you don\'t specify a status,
-- only @RUNNING@ jobs are returned.
--
-- 'maxResults', 'listJobs_maxResults' - The maximum number of results returned by @ListJobs@ in paginated
-- output. When this parameter is used, @ListJobs@ only returns
-- @maxResults@ results in a single page and a @nextToken@ response
-- element. The remaining results of the initial request can be seen by
-- sending another @ListJobs@ request with the returned @nextToken@ value.
-- This value can be between 1 and 100. If this parameter isn\'t used, then
-- @ListJobs@ returns up to 100 results and a @nextToken@ value if
-- applicable.
--
-- 'multiNodeJobId', 'listJobs_multiNodeJobId' - The job ID for a multi-node parallel job. Specifying a multi-node
-- parallel job ID with this parameter lists all nodes that are associated
-- with the specified job.
--
-- 'nextToken', 'listJobs_nextToken' - The @nextToken@ value returned from a previous paginated @ListJobs@
-- request where @maxResults@ was used and the results exceeded the value
-- of that parameter. Pagination continues from the end of the previous
-- results that returned the @nextToken@ value. This value is @null@ when
-- there are no more results to return.
--
-- Treat this token as an opaque identifier that\'s only used to retrieve
-- the next items in a list and not for other programmatic purposes.
newListJobs ::
  ListJobs
newListJobs :: ListJobs
newListJobs =
  ListJobs'
    { $sel:arrayJobId:ListJobs' :: Maybe Text
arrayJobId = forall a. Maybe a
Prelude.Nothing,
      $sel:filters:ListJobs' :: Maybe [KeyValuesPair]
filters = forall a. Maybe a
Prelude.Nothing,
      $sel:jobQueue:ListJobs' :: Maybe Text
jobQueue = forall a. Maybe a
Prelude.Nothing,
      $sel:jobStatus:ListJobs' :: Maybe JobStatus
jobStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListJobs' :: Maybe Int
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:multiNodeJobId:ListJobs' :: Maybe Text
multiNodeJobId = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListJobs' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The job ID for an array job. Specifying an array job ID with this
-- parameter lists all child jobs from within the specified array.
listJobs_arrayJobId :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Text)
listJobs_arrayJobId :: Lens' ListJobs (Maybe Text)
listJobs_arrayJobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe Text
arrayJobId :: Maybe Text
$sel:arrayJobId:ListJobs' :: ListJobs -> Maybe Text
arrayJobId} -> Maybe Text
arrayJobId) (\s :: ListJobs
s@ListJobs' {} Maybe Text
a -> ListJobs
s {$sel:arrayJobId:ListJobs' :: Maybe Text
arrayJobId = Maybe Text
a} :: ListJobs)

-- | The filter to apply to the query. Only one filter can be used at a time.
-- When the filter is used, @jobStatus@ is ignored. The filter doesn\'t
-- apply to child jobs in an array or multi-node parallel (MNP) jobs. The
-- results are sorted by the @createdAt@ field, with the most recent jobs
-- being first.
--
-- [JOB_NAME]
--     The value of the filter is a case-insensitive match for the job
--     name. If the value ends with an asterisk (*), the filter matches any
--     job name that begins with the string before the \'*\'. This
--     corresponds to the @jobName@ value. For example, @test1@ matches
--     both @Test1@ and @test1@, and @test1*@ matches both @test1@ and
--     @Test10@. When the @JOB_NAME@ filter is used, the results are
--     grouped by the job name and version.
--
-- [JOB_DEFINITION]
--     The value for the filter is the name or Amazon Resource Name (ARN)
--     of the job definition. This corresponds to the @jobDefinition@
--     value. The value is case sensitive. When the value for the filter is
--     the job definition name, the results include all the jobs that used
--     any revision of that job definition name. If the value ends with an
--     asterisk (*), the filter matches any job definition name that begins
--     with the string before the \'*\'. For example, @jd1@ matches only
--     @jd1@, and @jd1*@ matches both @jd1@ and @jd1A@. The version of the
--     job definition that\'s used doesn\'t affect the sort order. When the
--     @JOB_DEFINITION@ filter is used and the ARN is used (which is in the
--     form
--     @arn:${Partition}:batch:${Region}:${Account}:job-definition\/${JobDefinitionName}:${Revision}@),
--     the results include jobs that used the specified revision of the job
--     definition. Asterisk (*) isn\'t supported when the ARN is used.
--
-- [BEFORE_CREATED_AT]
--     The value for the filter is the time that\'s before the job was
--     created. This corresponds to the @createdAt@ value. The value is a
--     string representation of the number of milliseconds since 00:00:00
--     UTC (midnight) on January 1, 1970.
--
-- [AFTER_CREATED_AT]
--     The value for the filter is the time that\'s after the job was
--     created. This corresponds to the @createdAt@ value. The value is a
--     string representation of the number of milliseconds since 00:00:00
--     UTC (midnight) on January 1, 1970.
listJobs_filters :: Lens.Lens' ListJobs (Prelude.Maybe [KeyValuesPair])
listJobs_filters :: Lens' ListJobs (Maybe [KeyValuesPair])
listJobs_filters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe [KeyValuesPair]
filters :: Maybe [KeyValuesPair]
$sel:filters:ListJobs' :: ListJobs -> Maybe [KeyValuesPair]
filters} -> Maybe [KeyValuesPair]
filters) (\s :: ListJobs
s@ListJobs' {} Maybe [KeyValuesPair]
a -> ListJobs
s {$sel:filters:ListJobs' :: Maybe [KeyValuesPair]
filters = Maybe [KeyValuesPair]
a} :: ListJobs) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name or full Amazon Resource Name (ARN) of the job queue used to
-- list jobs.
listJobs_jobQueue :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Text)
listJobs_jobQueue :: Lens' ListJobs (Maybe Text)
listJobs_jobQueue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe Text
jobQueue :: Maybe Text
$sel:jobQueue:ListJobs' :: ListJobs -> Maybe Text
jobQueue} -> Maybe Text
jobQueue) (\s :: ListJobs
s@ListJobs' {} Maybe Text
a -> ListJobs
s {$sel:jobQueue:ListJobs' :: Maybe Text
jobQueue = Maybe Text
a} :: ListJobs)

-- | The job status used to filter jobs in the specified queue. If the
-- @filters@ parameter is specified, the @jobStatus@ parameter is ignored
-- and jobs with any status are returned. If you don\'t specify a status,
-- only @RUNNING@ jobs are returned.
listJobs_jobStatus :: Lens.Lens' ListJobs (Prelude.Maybe JobStatus)
listJobs_jobStatus :: Lens' ListJobs (Maybe JobStatus)
listJobs_jobStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe JobStatus
jobStatus :: Maybe JobStatus
$sel:jobStatus:ListJobs' :: ListJobs -> Maybe JobStatus
jobStatus} -> Maybe JobStatus
jobStatus) (\s :: ListJobs
s@ListJobs' {} Maybe JobStatus
a -> ListJobs
s {$sel:jobStatus:ListJobs' :: Maybe JobStatus
jobStatus = Maybe JobStatus
a} :: ListJobs)

-- | The maximum number of results returned by @ListJobs@ in paginated
-- output. When this parameter is used, @ListJobs@ only returns
-- @maxResults@ results in a single page and a @nextToken@ response
-- element. The remaining results of the initial request can be seen by
-- sending another @ListJobs@ request with the returned @nextToken@ value.
-- This value can be between 1 and 100. If this parameter isn\'t used, then
-- @ListJobs@ returns up to 100 results and a @nextToken@ value if
-- applicable.
listJobs_maxResults :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Int)
listJobs_maxResults :: Lens' ListJobs (Maybe Int)
listJobs_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: ListJobs
s@ListJobs' {} Maybe Int
a -> ListJobs
s {$sel:maxResults:ListJobs' :: Maybe Int
maxResults = Maybe Int
a} :: ListJobs)

-- | The job ID for a multi-node parallel job. Specifying a multi-node
-- parallel job ID with this parameter lists all nodes that are associated
-- with the specified job.
listJobs_multiNodeJobId :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Text)
listJobs_multiNodeJobId :: Lens' ListJobs (Maybe Text)
listJobs_multiNodeJobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe Text
multiNodeJobId :: Maybe Text
$sel:multiNodeJobId:ListJobs' :: ListJobs -> Maybe Text
multiNodeJobId} -> Maybe Text
multiNodeJobId) (\s :: ListJobs
s@ListJobs' {} Maybe Text
a -> ListJobs
s {$sel:multiNodeJobId:ListJobs' :: Maybe Text
multiNodeJobId = Maybe Text
a} :: ListJobs)

-- | The @nextToken@ value returned from a previous paginated @ListJobs@
-- request where @maxResults@ was used and the results exceeded the value
-- of that parameter. Pagination continues from the end of the previous
-- results that returned the @nextToken@ value. This value is @null@ when
-- there are no more results to return.
--
-- Treat this token as an opaque identifier that\'s only used to retrieve
-- the next items in a list and not for other programmatic purposes.
listJobs_nextToken :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Text)
listJobs_nextToken :: Lens' ListJobs (Maybe Text)
listJobs_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListJobs
s@ListJobs' {} Maybe Text
a -> ListJobs
s {$sel:nextToken:ListJobs' :: Maybe Text
nextToken = Maybe Text
a} :: ListJobs)

instance Core.AWSPager ListJobs where
  page :: ListJobs -> AWSResponse ListJobs -> Maybe ListJobs
page ListJobs
rq AWSResponse ListJobs
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListJobs
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListJobsResponse (Maybe Text)
listJobsResponse_nextToken
            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 ListJobs
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListJobsResponse [JobSummary]
listJobsResponse_jobSummaryList) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListJobs
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListJobs (Maybe Text)
listJobs_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListJobs
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListJobsResponse (Maybe Text)
listJobsResponse_nextToken
          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 ListJobs where
  type AWSResponse ListJobs = ListJobsResponse
  request :: (Service -> Service) -> ListJobs -> Request ListJobs
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 ListJobs
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListJobs)))
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 -> [JobSummary] -> ListJobsResponse
ListJobsResponse'
            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
"nextToken")
            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
"jobSummaryList"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ListJobs where
  hashWithSalt :: Int -> ListJobs -> Int
hashWithSalt Int
_salt ListJobs' {Maybe Int
Maybe [KeyValuesPair]
Maybe Text
Maybe JobStatus
nextToken :: Maybe Text
multiNodeJobId :: Maybe Text
maxResults :: Maybe Int
jobStatus :: Maybe JobStatus
jobQueue :: Maybe Text
filters :: Maybe [KeyValuesPair]
arrayJobId :: Maybe Text
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:multiNodeJobId:ListJobs' :: ListJobs -> Maybe Text
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Int
$sel:jobStatus:ListJobs' :: ListJobs -> Maybe JobStatus
$sel:jobQueue:ListJobs' :: ListJobs -> Maybe Text
$sel:filters:ListJobs' :: ListJobs -> Maybe [KeyValuesPair]
$sel:arrayJobId:ListJobs' :: ListJobs -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arrayJobId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [KeyValuesPair]
filters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
jobQueue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JobStatus
jobStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
multiNodeJobId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListJobs where
  rnf :: ListJobs -> ()
rnf ListJobs' {Maybe Int
Maybe [KeyValuesPair]
Maybe Text
Maybe JobStatus
nextToken :: Maybe Text
multiNodeJobId :: Maybe Text
maxResults :: Maybe Int
jobStatus :: Maybe JobStatus
jobQueue :: Maybe Text
filters :: Maybe [KeyValuesPair]
arrayJobId :: Maybe Text
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:multiNodeJobId:ListJobs' :: ListJobs -> Maybe Text
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Int
$sel:jobStatus:ListJobs' :: ListJobs -> Maybe JobStatus
$sel:jobQueue:ListJobs' :: ListJobs -> Maybe Text
$sel:filters:ListJobs' :: ListJobs -> Maybe [KeyValuesPair]
$sel:arrayJobId:ListJobs' :: ListJobs -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arrayJobId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [KeyValuesPair]
filters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
jobQueue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe JobStatus
jobStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
multiNodeJobId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

instance Data.ToJSON ListJobs where
  toJSON :: ListJobs -> Value
toJSON ListJobs' {Maybe Int
Maybe [KeyValuesPair]
Maybe Text
Maybe JobStatus
nextToken :: Maybe Text
multiNodeJobId :: Maybe Text
maxResults :: Maybe Int
jobStatus :: Maybe JobStatus
jobQueue :: Maybe Text
filters :: Maybe [KeyValuesPair]
arrayJobId :: Maybe Text
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:multiNodeJobId:ListJobs' :: ListJobs -> Maybe Text
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Int
$sel:jobStatus:ListJobs' :: ListJobs -> Maybe JobStatus
$sel:jobQueue:ListJobs' :: ListJobs -> Maybe Text
$sel:filters:ListJobs' :: ListJobs -> Maybe [KeyValuesPair]
$sel:arrayJobId:ListJobs' :: ListJobs -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"arrayJobId" 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
arrayJobId,
            (Key
"filters" 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 [KeyValuesPair]
filters,
            (Key
"jobQueue" 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
jobQueue,
            (Key
"jobStatus" 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 JobStatus
jobStatus,
            (Key
"maxResults" 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 Int
maxResults,
            (Key
"multiNodeJobId" 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
multiNodeJobId,
            (Key
"nextToken" 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
nextToken
          ]
      )

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

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

-- | /See:/ 'newListJobsResponse' smart constructor.
data ListJobsResponse = ListJobsResponse'
  { -- | The @nextToken@ value to include in a future @ListJobs@ request. When
    -- the results of a @ListJobs@ request exceed @maxResults@, this value can
    -- be used to retrieve the next page of results. This value is @null@ when
    -- there are no more results to return.
    ListJobsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListJobsResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list of job summaries that match the request.
    ListJobsResponse -> [JobSummary]
jobSummaryList :: [JobSummary]
  }
  deriving (ListJobsResponse -> ListJobsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListJobsResponse -> ListJobsResponse -> Bool
$c/= :: ListJobsResponse -> ListJobsResponse -> Bool
== :: ListJobsResponse -> ListJobsResponse -> Bool
$c== :: ListJobsResponse -> ListJobsResponse -> Bool
Prelude.Eq, ReadPrec [ListJobsResponse]
ReadPrec ListJobsResponse
Int -> ReadS ListJobsResponse
ReadS [ListJobsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListJobsResponse]
$creadListPrec :: ReadPrec [ListJobsResponse]
readPrec :: ReadPrec ListJobsResponse
$creadPrec :: ReadPrec ListJobsResponse
readList :: ReadS [ListJobsResponse]
$creadList :: ReadS [ListJobsResponse]
readsPrec :: Int -> ReadS ListJobsResponse
$creadsPrec :: Int -> ReadS ListJobsResponse
Prelude.Read, Int -> ListJobsResponse -> ShowS
[ListJobsResponse] -> ShowS
ListJobsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListJobsResponse] -> ShowS
$cshowList :: [ListJobsResponse] -> ShowS
show :: ListJobsResponse -> String
$cshow :: ListJobsResponse -> String
showsPrec :: Int -> ListJobsResponse -> ShowS
$cshowsPrec :: Int -> ListJobsResponse -> ShowS
Prelude.Show, forall x. Rep ListJobsResponse x -> ListJobsResponse
forall x. ListJobsResponse -> Rep ListJobsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListJobsResponse x -> ListJobsResponse
$cfrom :: forall x. ListJobsResponse -> Rep ListJobsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListJobsResponse' 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', 'listJobsResponse_nextToken' - The @nextToken@ value to include in a future @ListJobs@ request. When
-- the results of a @ListJobs@ request exceed @maxResults@, this value can
-- be used to retrieve the next page of results. This value is @null@ when
-- there are no more results to return.
--
-- 'httpStatus', 'listJobsResponse_httpStatus' - The response's http status code.
--
-- 'jobSummaryList', 'listJobsResponse_jobSummaryList' - A list of job summaries that match the request.
newListJobsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListJobsResponse
newListJobsResponse :: Int -> ListJobsResponse
newListJobsResponse Int
pHttpStatus_ =
  ListJobsResponse'
    { $sel:nextToken:ListJobsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListJobsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:jobSummaryList:ListJobsResponse' :: [JobSummary]
jobSummaryList = forall a. Monoid a => a
Prelude.mempty
    }

-- | The @nextToken@ value to include in a future @ListJobs@ request. When
-- the results of a @ListJobs@ request exceed @maxResults@, this value can
-- be used to retrieve the next page of results. This value is @null@ when
-- there are no more results to return.
listJobsResponse_nextToken :: Lens.Lens' ListJobsResponse (Prelude.Maybe Prelude.Text)
listJobsResponse_nextToken :: Lens' ListJobsResponse (Maybe Text)
listJobsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListJobsResponse' :: ListJobsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListJobsResponse
s@ListJobsResponse' {} Maybe Text
a -> ListJobsResponse
s {$sel:nextToken:ListJobsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListJobsResponse)

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

-- | A list of job summaries that match the request.
listJobsResponse_jobSummaryList :: Lens.Lens' ListJobsResponse [JobSummary]
listJobsResponse_jobSummaryList :: Lens' ListJobsResponse [JobSummary]
listJobsResponse_jobSummaryList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobsResponse' {[JobSummary]
jobSummaryList :: [JobSummary]
$sel:jobSummaryList:ListJobsResponse' :: ListJobsResponse -> [JobSummary]
jobSummaryList} -> [JobSummary]
jobSummaryList) (\s :: ListJobsResponse
s@ListJobsResponse' {} [JobSummary]
a -> ListJobsResponse
s {$sel:jobSummaryList:ListJobsResponse' :: [JobSummary]
jobSummaryList = [JobSummary]
a} :: ListJobsResponse) 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 ListJobsResponse where
  rnf :: ListJobsResponse -> ()
rnf ListJobsResponse' {Int
[JobSummary]
Maybe Text
jobSummaryList :: [JobSummary]
httpStatus :: Int
nextToken :: Maybe Text
$sel:jobSummaryList:ListJobsResponse' :: ListJobsResponse -> [JobSummary]
$sel:httpStatus:ListJobsResponse' :: ListJobsResponse -> Int
$sel:nextToken:ListJobsResponse' :: ListJobsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      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 [JobSummary]
jobSummaryList