{-# 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.DataBrew.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)
--
-- Lists all of the DataBrew jobs that are defined.
--
-- This operation returns paginated results.
module Amazonka.DataBrew.ListJobs
  ( -- * Creating a Request
    ListJobs (..),
    newListJobs,

    -- * Request Lenses
    listJobs_datasetName,
    listJobs_maxResults,
    listJobs_nextToken,
    listJobs_projectName,

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

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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataBrew.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListJobs' smart constructor.
data ListJobs = ListJobs'
  { -- | The name of a dataset. Using this parameter indicates to return only
    -- those jobs that act on the specified dataset.
    ListJobs -> Maybe Text
datasetName :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return in this request.
    ListJobs -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A token generated by DataBrew that specifies where to continue
    -- pagination if a previous request was truncated. To get the next set of
    -- pages, pass in the NextToken value from the response object of the
    -- previous page call.
    ListJobs -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of a project. Using this parameter indicates to return only
    -- those jobs that are associated with the specified project.
    ListJobs -> Maybe Text
projectName :: 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:
--
-- 'datasetName', 'listJobs_datasetName' - The name of a dataset. Using this parameter indicates to return only
-- those jobs that act on the specified dataset.
--
-- 'maxResults', 'listJobs_maxResults' - The maximum number of results to return in this request.
--
-- 'nextToken', 'listJobs_nextToken' - A token generated by DataBrew that specifies where to continue
-- pagination if a previous request was truncated. To get the next set of
-- pages, pass in the NextToken value from the response object of the
-- previous page call.
--
-- 'projectName', 'listJobs_projectName' - The name of a project. Using this parameter indicates to return only
-- those jobs that are associated with the specified project.
newListJobs ::
  ListJobs
newListJobs :: ListJobs
newListJobs =
  ListJobs'
    { $sel:datasetName:ListJobs' :: Maybe Text
datasetName = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListJobs' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListJobs' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:projectName:ListJobs' :: Maybe Text
projectName = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of a dataset. Using this parameter indicates to return only
-- those jobs that act on the specified dataset.
listJobs_datasetName :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Text)
listJobs_datasetName :: Lens' ListJobs (Maybe Text)
listJobs_datasetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe Text
datasetName :: Maybe Text
$sel:datasetName:ListJobs' :: ListJobs -> Maybe Text
datasetName} -> Maybe Text
datasetName) (\s :: ListJobs
s@ListJobs' {} Maybe Text
a -> ListJobs
s {$sel:datasetName:ListJobs' :: Maybe Text
datasetName = Maybe Text
a} :: ListJobs)

-- | The maximum number of results to return in this request.
listJobs_maxResults :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Natural)
listJobs_maxResults :: Lens' ListJobs (Maybe Natural)
listJobs_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListJobs
s@ListJobs' {} Maybe Natural
a -> ListJobs
s {$sel:maxResults:ListJobs' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListJobs)

-- | A token generated by DataBrew that specifies where to continue
-- pagination if a previous request was truncated. To get the next set of
-- pages, pass in the NextToken value from the response object of the
-- previous page call.
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)

-- | The name of a project. Using this parameter indicates to return only
-- those jobs that are associated with the specified project.
listJobs_projectName :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Text)
listJobs_projectName :: Lens' ListJobs (Maybe Text)
listJobs_projectName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe Text
projectName :: Maybe Text
$sel:projectName:ListJobs' :: ListJobs -> Maybe Text
projectName} -> Maybe Text
projectName) (\s :: ListJobs
s@ListJobs' {} Maybe Text
a -> ListJobs
s {$sel:projectName:ListJobs' :: Maybe Text
projectName = 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 [Job]
listJobsResponse_jobs) =
        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 => Service -> a -> Request a
Request.get (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 -> [Job] -> 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
"Jobs" 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 Natural
Maybe Text
projectName :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
datasetName :: Maybe Text
$sel:projectName:ListJobs' :: ListJobs -> Maybe Text
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Natural
$sel:datasetName:ListJobs' :: ListJobs -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
datasetName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
projectName

instance Prelude.NFData ListJobs where
  rnf :: ListJobs -> ()
rnf ListJobs' {Maybe Natural
Maybe Text
projectName :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
datasetName :: Maybe Text
$sel:projectName:ListJobs' :: ListJobs -> Maybe Text
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Natural
$sel:datasetName:ListJobs' :: ListJobs -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
datasetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Maybe Text
projectName

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.ToPath ListJobs where
  toPath :: ListJobs -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/jobs"

instance Data.ToQuery ListJobs where
  toQuery :: ListJobs -> QueryString
toQuery ListJobs' {Maybe Natural
Maybe Text
projectName :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
datasetName :: Maybe Text
$sel:projectName:ListJobs' :: ListJobs -> Maybe Text
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Natural
$sel:datasetName:ListJobs' :: ListJobs -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"datasetName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
datasetName,
        ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken,
        ByteString
"projectName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
projectName
      ]

-- | /See:/ 'newListJobsResponse' smart constructor.
data ListJobsResponse = ListJobsResponse'
  { -- | A token that you can use in a subsequent call to retrieve the next set
    -- of results.
    ListJobsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListJobsResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list of jobs that are defined.
    ListJobsResponse -> [Job]
jobs :: [Job]
  }
  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' - A token that you can use in a subsequent call to retrieve the next set
-- of results.
--
-- 'httpStatus', 'listJobsResponse_httpStatus' - The response's http status code.
--
-- 'jobs', 'listJobsResponse_jobs' - A list of jobs that are defined.
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:jobs:ListJobsResponse' :: [Job]
jobs = forall a. Monoid a => a
Prelude.mempty
    }

-- | A token that you can use in a subsequent call to retrieve the next set
-- of results.
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 jobs that are defined.
listJobsResponse_jobs :: Lens.Lens' ListJobsResponse [Job]
listJobsResponse_jobs :: Lens' ListJobsResponse [Job]
listJobsResponse_jobs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobsResponse' {[Job]
jobs :: [Job]
$sel:jobs:ListJobsResponse' :: ListJobsResponse -> [Job]
jobs} -> [Job]
jobs) (\s :: ListJobsResponse
s@ListJobsResponse' {} [Job]
a -> ListJobsResponse
s {$sel:jobs:ListJobsResponse' :: [Job]
jobs = [Job]
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
[Job]
Maybe Text
jobs :: [Job]
httpStatus :: Int
nextToken :: Maybe Text
$sel:jobs:ListJobsResponse' :: ListJobsResponse -> [Job]
$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 [Job]
jobs