{-# 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-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 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_filters,
    listJobs_nextToken,
    listJobs_multiNodeJobId,
    listJobs_jobStatus,
    listJobs_arrayJobId,
    listJobs_jobQueue,
    listJobs_maxResults,

    -- * 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.Lens as Lens
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 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 will match
    --     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 will match 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 (*) is not 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 seconds 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 seconds since 00:00:00 UTC
    --     (midnight) on January 1, 1970.
    ListJobs -> Maybe [KeyValuesPair]
filters :: Prelude.Maybe [KeyValuesPair],
    -- | 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.
    --
    -- This token should be treated 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,
    -- | 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 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 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 name or full Amazon Resource Name (ARN) of the job queue used to
    -- list jobs.
    ListJobs -> Maybe Text
jobQueue :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (ListJobs -> ListJobs -> Bool
(ListJobs -> ListJobs -> Bool)
-> (ListJobs -> ListJobs -> Bool) -> Eq ListJobs
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]
(Int -> ReadS ListJobs)
-> ReadS [ListJobs]
-> ReadPrec ListJobs
-> ReadPrec [ListJobs]
-> Read 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
(Int -> ListJobs -> ShowS)
-> (ListJobs -> String) -> ([ListJobs] -> ShowS) -> Show ListJobs
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. ListJobs -> Rep ListJobs x)
-> (forall x. Rep ListJobs x -> ListJobs) -> Generic ListJobs
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:
--
-- '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 will match
--     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 will match 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 (*) is not 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 seconds 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 seconds since 00:00:00 UTC
--     (midnight) on January 1, 1970.
--
-- '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.
--
-- This token should be treated as an opaque identifier that\'s only used
-- to retrieve the next items in a list and not for other programmatic
-- purposes.
--
-- '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.
--
-- '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.
--
-- '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.
--
-- 'jobQueue', 'listJobs_jobQueue' - The name or full Amazon Resource Name (ARN) of the job queue used to
-- list jobs.
--
-- '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.
newListJobs ::
  ListJobs
newListJobs :: ListJobs
newListJobs =
  ListJobs' :: Maybe [KeyValuesPair]
-> Maybe Text
-> Maybe Text
-> Maybe JobStatus
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> ListJobs
ListJobs'
    { $sel:filters:ListJobs' :: Maybe [KeyValuesPair]
filters = Maybe [KeyValuesPair]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListJobs' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:multiNodeJobId:ListJobs' :: Maybe Text
multiNodeJobId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobStatus:ListJobs' :: Maybe JobStatus
jobStatus = Maybe JobStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:arrayJobId:ListJobs' :: Maybe Text
arrayJobId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobQueue:ListJobs' :: Maybe Text
jobQueue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListJobs' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 will match
--     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 will match 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 (*) is not 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 seconds 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 seconds since 00:00:00 UTC
--     (midnight) on January 1, 1970.
listJobs_filters :: Lens.Lens' ListJobs (Prelude.Maybe [KeyValuesPair])
listJobs_filters :: (Maybe [KeyValuesPair] -> f (Maybe [KeyValuesPair]))
-> ListJobs -> f ListJobs
listJobs_filters = (ListJobs -> Maybe [KeyValuesPair])
-> (ListJobs -> Maybe [KeyValuesPair] -> ListJobs)
-> Lens
     ListJobs ListJobs (Maybe [KeyValuesPair]) (Maybe [KeyValuesPair])
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) ((Maybe [KeyValuesPair] -> f (Maybe [KeyValuesPair]))
 -> ListJobs -> f ListJobs)
-> ((Maybe [KeyValuesPair] -> f (Maybe [KeyValuesPair]))
    -> Maybe [KeyValuesPair] -> f (Maybe [KeyValuesPair]))
-> (Maybe [KeyValuesPair] -> f (Maybe [KeyValuesPair]))
-> ListJobs
-> f ListJobs
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [KeyValuesPair] [KeyValuesPair] [KeyValuesPair] [KeyValuesPair]
-> Iso
     (Maybe [KeyValuesPair])
     (Maybe [KeyValuesPair])
     (Maybe [KeyValuesPair])
     (Maybe [KeyValuesPair])
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
  [KeyValuesPair] [KeyValuesPair] [KeyValuesPair] [KeyValuesPair]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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.
--
-- This token should be treated 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 :: (Maybe Text -> f (Maybe Text)) -> ListJobs -> f ListJobs
listJobs_nextToken = (ListJobs -> Maybe Text)
-> (ListJobs -> Maybe Text -> ListJobs)
-> Lens ListJobs ListJobs (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> ListJobs -> f ListJobs
listJobs_multiNodeJobId = (ListJobs -> Maybe Text)
-> (ListJobs -> Maybe Text -> ListJobs)
-> Lens ListJobs ListJobs (Maybe Text) (Maybe Text)
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 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 :: (Maybe JobStatus -> f (Maybe JobStatus)) -> ListJobs -> f ListJobs
listJobs_jobStatus = (ListJobs -> Maybe JobStatus)
-> (ListJobs -> Maybe JobStatus -> ListJobs)
-> Lens ListJobs ListJobs (Maybe JobStatus) (Maybe 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 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 :: (Maybe Text -> f (Maybe Text)) -> ListJobs -> f ListJobs
listJobs_arrayJobId = (ListJobs -> Maybe Text)
-> (ListJobs -> Maybe Text -> ListJobs)
-> Lens ListJobs ListJobs (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text)) -> ListJobs -> f ListJobs
listJobs_jobQueue = (ListJobs -> Maybe Text)
-> (ListJobs -> Maybe Text -> ListJobs)
-> Lens ListJobs ListJobs (Maybe Text) (Maybe Text)
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 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 :: (Maybe Int -> f (Maybe Int)) -> ListJobs -> f ListJobs
listJobs_maxResults = (ListJobs -> Maybe Int)
-> (ListJobs -> Maybe Int -> ListJobs)
-> Lens ListJobs ListJobs (Maybe Int) (Maybe Int)
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)

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

instance Prelude.Hashable ListJobs

instance Prelude.NFData ListJobs

instance Core.ToHeaders ListJobs where
  toHeaders :: ListJobs -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListJobs -> 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.ToJSON ListJobs where
  toJSON :: ListJobs -> Value
toJSON ListJobs' {Maybe Int
Maybe [KeyValuesPair]
Maybe Text
Maybe JobStatus
maxResults :: Maybe Int
jobQueue :: Maybe Text
arrayJobId :: Maybe Text
jobStatus :: Maybe JobStatus
multiNodeJobId :: Maybe Text
nextToken :: Maybe Text
filters :: Maybe [KeyValuesPair]
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Int
$sel:jobQueue:ListJobs' :: ListJobs -> Maybe Text
$sel:arrayJobId:ListJobs' :: ListJobs -> Maybe Text
$sel:jobStatus:ListJobs' :: ListJobs -> Maybe JobStatus
$sel:multiNodeJobId:ListJobs' :: ListJobs -> Maybe Text
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:filters:ListJobs' :: ListJobs -> Maybe [KeyValuesPair]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"filters" Text -> [KeyValuesPair] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([KeyValuesPair] -> Pair) -> Maybe [KeyValuesPair] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [KeyValuesPair]
filters,
            (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
"multiNodeJobId" 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
multiNodeJobId,
            (Text
"jobStatus" Text -> JobStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (JobStatus -> Pair) -> Maybe JobStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JobStatus
jobStatus,
            (Text
"arrayJobId" 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
arrayJobId,
            (Text
"jobQueue" 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
jobQueue,
            (Text
"maxResults" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults
          ]
      )

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

instance Core.ToQuery ListJobs where
  toQuery :: ListJobs -> QueryString
toQuery = QueryString -> ListJobs -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(ListJobsResponse -> ListJobsResponse -> Bool)
-> (ListJobsResponse -> ListJobsResponse -> Bool)
-> Eq ListJobsResponse
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]
(Int -> ReadS ListJobsResponse)
-> ReadS [ListJobsResponse]
-> ReadPrec ListJobsResponse
-> ReadPrec [ListJobsResponse]
-> Read 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
(Int -> ListJobsResponse -> ShowS)
-> (ListJobsResponse -> String)
-> ([ListJobsResponse] -> ShowS)
-> Show ListJobsResponse
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. ListJobsResponse -> Rep ListJobsResponse x)
-> (forall x. Rep ListJobsResponse x -> ListJobsResponse)
-> Generic ListJobsResponse
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' :: Maybe Text -> Int -> [JobSummary] -> ListJobsResponse
ListJobsResponse'
    { $sel:nextToken:ListJobsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListJobsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:jobSummaryList:ListJobsResponse' :: [JobSummary]
jobSummaryList = [JobSummary]
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 :: (Maybe Text -> f (Maybe Text))
-> ListJobsResponse -> f ListJobsResponse
listJobsResponse_nextToken = (ListJobsResponse -> Maybe Text)
-> (ListJobsResponse -> Maybe Text -> ListJobsResponse)
-> Lens' ListJobsResponse (Maybe Text)
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 :: (Int -> f Int) -> ListJobsResponse -> f ListJobsResponse
listJobsResponse_httpStatus = (ListJobsResponse -> Int)
-> (ListJobsResponse -> Int -> ListJobsResponse)
-> Lens ListJobsResponse ListJobsResponse Int Int
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 :: ([JobSummary] -> f [JobSummary])
-> ListJobsResponse -> f ListJobsResponse
listJobsResponse_jobSummaryList = (ListJobsResponse -> [JobSummary])
-> (ListJobsResponse -> [JobSummary] -> ListJobsResponse)
-> Lens' ListJobsResponse [JobSummary]
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) (([JobSummary] -> f [JobSummary])
 -> ListJobsResponse -> f ListJobsResponse)
-> (([JobSummary] -> f [JobSummary])
    -> [JobSummary] -> f [JobSummary])
-> ([JobSummary] -> f [JobSummary])
-> ListJobsResponse
-> f ListJobsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([JobSummary] -> f [JobSummary]) -> [JobSummary] -> f [JobSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListJobsResponse