{-# 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.Glue.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)
--
-- Retrieves the names of all job resources in this Amazon Web Services
-- account, or the resources with the specified tag. This operation allows
-- you to see which resources are available in your account, and their
-- names.
--
-- This operation takes the optional @Tags@ field, which you can use as a
-- filter on the response so that tagged resources can be retrieved as a
-- group. If you choose to use tags filtering, only resources with the tag
-- are retrieved.
module Amazonka.Glue.ListJobs
  ( -- * Creating a Request
    ListJobs (..),
    newListJobs,

    -- * Request Lenses
    listJobs_maxResults,
    listJobs_nextToken,
    listJobs_tags,

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

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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.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 maximum size of a list to return.
    ListJobs -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A continuation token, if this is a continuation request.
    ListJobs -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies to return only these tagged resources.
    ListJobs -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text 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:
--
-- 'maxResults', 'listJobs_maxResults' - The maximum size of a list to return.
--
-- 'nextToken', 'listJobs_nextToken' - A continuation token, if this is a continuation request.
--
-- 'tags', 'listJobs_tags' - Specifies to return only these tagged resources.
newListJobs ::
  ListJobs
newListJobs :: ListJobs
newListJobs =
  ListJobs'
    { $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:tags:ListJobs' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum size of a list to return.
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 continuation token, if this is a continuation request.
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)

-- | Specifies to return only these tagged resources.
listJobs_tags :: Lens.Lens' ListJobs (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
listJobs_tags :: Lens' ListJobs (Maybe (HashMap Text Text))
listJobs_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobs' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:ListJobs' :: ListJobs -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: ListJobs
s@ListJobs' {} Maybe (HashMap Text Text)
a -> ListJobs
s {$sel:tags:ListJobs' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
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

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] -> Maybe Text -> Int -> 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
"JobNames" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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
"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))
      )

instance Prelude.Hashable ListJobs where
  hashWithSalt :: Int -> ListJobs -> Int
hashWithSalt Int
_salt ListJobs' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:tags:ListJobs' :: ListJobs -> Maybe (HashMap Text Text)
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Natural
..} =
    Int
_salt
      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 (HashMap Text Text)
tags

instance Prelude.NFData ListJobs where
  rnf :: ListJobs -> ()
rnf ListJobs' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:tags:ListJobs' :: ListJobs -> Maybe (HashMap Text Text)
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Natural
..} =
    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 (HashMap Text Text)
tags

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
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"AWSGlue.ListJobs" :: Prelude.ByteString),
            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 Natural
Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:tags:ListJobs' :: ListJobs -> Maybe (HashMap Text Text)
$sel:nextToken:ListJobs' :: ListJobs -> Maybe Text
$sel:maxResults:ListJobs' :: ListJobs -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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 Natural
maxResults,
            (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,
            (Key
"Tags" 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 (HashMap Text Text)
tags
          ]
      )

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

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 names of all jobs in the account, or the jobs with the specified
    -- tags.
    ListJobsResponse -> Maybe [Text]
jobNames :: Prelude.Maybe [Prelude.Text],
    -- | A continuation token, if the returned list does not contain the last
    -- metric available.
    ListJobsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListJobsResponse -> Int
httpStatus :: Prelude.Int
  }
  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:
--
-- 'jobNames', 'listJobsResponse_jobNames' - The names of all jobs in the account, or the jobs with the specified
-- tags.
--
-- 'nextToken', 'listJobsResponse_nextToken' - A continuation token, if the returned list does not contain the last
-- metric available.
--
-- 'httpStatus', 'listJobsResponse_httpStatus' - The response's http status code.
newListJobsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListJobsResponse
newListJobsResponse :: Int -> ListJobsResponse
newListJobsResponse Int
pHttpStatus_ =
  ListJobsResponse'
    { $sel:jobNames:ListJobsResponse' :: Maybe [Text]
jobNames = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListJobsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListJobsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The names of all jobs in the account, or the jobs with the specified
-- tags.
listJobsResponse_jobNames :: Lens.Lens' ListJobsResponse (Prelude.Maybe [Prelude.Text])
listJobsResponse_jobNames :: Lens' ListJobsResponse (Maybe [Text])
listJobsResponse_jobNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobsResponse' {Maybe [Text]
jobNames :: Maybe [Text]
$sel:jobNames:ListJobsResponse' :: ListJobsResponse -> Maybe [Text]
jobNames} -> Maybe [Text]
jobNames) (\s :: ListJobsResponse
s@ListJobsResponse' {} Maybe [Text]
a -> ListJobsResponse
s {$sel:jobNames:ListJobsResponse' :: Maybe [Text]
jobNames = Maybe [Text]
a} :: ListJobsResponse) 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

-- | A continuation token, if the returned list does not contain the last
-- metric available.
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)

instance Prelude.NFData ListJobsResponse where
  rnf :: ListJobsResponse -> ()
rnf ListJobsResponse' {Int
Maybe [Text]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
jobNames :: Maybe [Text]
$sel:httpStatus:ListJobsResponse' :: ListJobsResponse -> Int
$sel:nextToken:ListJobsResponse' :: ListJobsResponse -> Maybe Text
$sel:jobNames:ListJobsResponse' :: ListJobsResponse -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
jobNames
      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 Int
httpStatus