{-# 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 #-}
module Amazonka.Glue.GetJobs
(
GetJobs (..),
newGetJobs,
getJobs_nextToken,
getJobs_maxResults,
GetJobsResponse (..),
newGetJobsResponse,
getJobsResponse_nextToken,
getJobsResponse_jobs,
getJobsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.Glue.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GetJobs = GetJobs'
{
GetJobs -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
GetJobs -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
}
deriving (GetJobs -> GetJobs -> Bool
(GetJobs -> GetJobs -> Bool)
-> (GetJobs -> GetJobs -> Bool) -> Eq GetJobs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetJobs -> GetJobs -> Bool
$c/= :: GetJobs -> GetJobs -> Bool
== :: GetJobs -> GetJobs -> Bool
$c== :: GetJobs -> GetJobs -> Bool
Prelude.Eq, ReadPrec [GetJobs]
ReadPrec GetJobs
Int -> ReadS GetJobs
ReadS [GetJobs]
(Int -> ReadS GetJobs)
-> ReadS [GetJobs]
-> ReadPrec GetJobs
-> ReadPrec [GetJobs]
-> Read GetJobs
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetJobs]
$creadListPrec :: ReadPrec [GetJobs]
readPrec :: ReadPrec GetJobs
$creadPrec :: ReadPrec GetJobs
readList :: ReadS [GetJobs]
$creadList :: ReadS [GetJobs]
readsPrec :: Int -> ReadS GetJobs
$creadsPrec :: Int -> ReadS GetJobs
Prelude.Read, Int -> GetJobs -> ShowS
[GetJobs] -> ShowS
GetJobs -> String
(Int -> GetJobs -> ShowS)
-> (GetJobs -> String) -> ([GetJobs] -> ShowS) -> Show GetJobs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetJobs] -> ShowS
$cshowList :: [GetJobs] -> ShowS
show :: GetJobs -> String
$cshow :: GetJobs -> String
showsPrec :: Int -> GetJobs -> ShowS
$cshowsPrec :: Int -> GetJobs -> ShowS
Prelude.Show, (forall x. GetJobs -> Rep GetJobs x)
-> (forall x. Rep GetJobs x -> GetJobs) -> Generic GetJobs
forall x. Rep GetJobs x -> GetJobs
forall x. GetJobs -> Rep GetJobs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetJobs x -> GetJobs
$cfrom :: forall x. GetJobs -> Rep GetJobs x
Prelude.Generic)
newGetJobs ::
GetJobs
newGetJobs :: GetJobs
newGetJobs =
GetJobs' :: Maybe Text -> Maybe Natural -> GetJobs
GetJobs'
{ $sel:nextToken:GetJobs' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:GetJobs' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
}
getJobs_nextToken :: Lens.Lens' GetJobs (Prelude.Maybe Prelude.Text)
getJobs_nextToken :: (Maybe Text -> f (Maybe Text)) -> GetJobs -> f GetJobs
getJobs_nextToken = (GetJobs -> Maybe Text)
-> (GetJobs -> Maybe Text -> GetJobs)
-> Lens GetJobs GetJobs (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJobs' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetJobs' :: GetJobs -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetJobs
s@GetJobs' {} Maybe Text
a -> GetJobs
s {$sel:nextToken:GetJobs' :: Maybe Text
nextToken = Maybe Text
a} :: GetJobs)
getJobs_maxResults :: Lens.Lens' GetJobs (Prelude.Maybe Prelude.Natural)
getJobs_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> GetJobs -> f GetJobs
getJobs_maxResults = (GetJobs -> Maybe Natural)
-> (GetJobs -> Maybe Natural -> GetJobs)
-> Lens GetJobs GetJobs (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJobs' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetJobs' :: GetJobs -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetJobs
s@GetJobs' {} Maybe Natural
a -> GetJobs
s {$sel:maxResults:GetJobs' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetJobs)
instance Core.AWSPager GetJobs where
page :: GetJobs -> AWSResponse GetJobs -> Maybe GetJobs
page GetJobs
rq AWSResponse GetJobs
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse GetJobs
GetJobsResponse
rs
GetJobsResponse
-> Getting (First Text) GetJobsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetJobsResponse -> Const (First Text) GetJobsResponse
Lens' GetJobsResponse (Maybe Text)
getJobsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> GetJobsResponse -> Const (First Text) GetJobsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetJobsResponse 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 GetJobs
forall a. Maybe a
Prelude.Nothing
| Maybe [Job] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse GetJobs
GetJobsResponse
rs
GetJobsResponse
-> Getting (First [Job]) GetJobsResponse [Job] -> Maybe [Job]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Job] -> Const (First [Job]) (Maybe [Job]))
-> GetJobsResponse -> Const (First [Job]) GetJobsResponse
Lens' GetJobsResponse (Maybe [Job])
getJobsResponse_jobs ((Maybe [Job] -> Const (First [Job]) (Maybe [Job]))
-> GetJobsResponse -> Const (First [Job]) GetJobsResponse)
-> (([Job] -> Const (First [Job]) [Job])
-> Maybe [Job] -> Const (First [Job]) (Maybe [Job]))
-> Getting (First [Job]) GetJobsResponse [Job]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Job] -> Const (First [Job]) [Job])
-> Maybe [Job] -> Const (First [Job]) (Maybe [Job])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe GetJobs
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
GetJobs -> Maybe GetJobs
forall a. a -> Maybe a
Prelude.Just (GetJobs -> Maybe GetJobs) -> GetJobs -> Maybe GetJobs
forall a b. (a -> b) -> a -> b
Prelude.$
GetJobs
rq
GetJobs -> (GetJobs -> GetJobs) -> GetJobs
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetJobs -> Identity GetJobs
Lens GetJobs GetJobs (Maybe Text) (Maybe Text)
getJobs_nextToken
((Maybe Text -> Identity (Maybe Text))
-> GetJobs -> Identity GetJobs)
-> Maybe Text -> GetJobs -> GetJobs
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetJobs
GetJobsResponse
rs
GetJobsResponse
-> Getting (First Text) GetJobsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetJobsResponse -> Const (First Text) GetJobsResponse
Lens' GetJobsResponse (Maybe Text)
getJobsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> GetJobsResponse -> Const (First Text) GetJobsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetJobsResponse 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 GetJobs where
type AWSResponse GetJobs = GetJobsResponse
request :: GetJobs -> Request GetJobs
request = Service -> GetJobs -> Request GetJobs
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetJobs
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetJobs)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetJobs))
-> Logger
-> Service
-> Proxy GetJobs
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetJobs)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Maybe [Job] -> Int -> GetJobsResponse
GetJobsResponse'
(Maybe Text -> Maybe [Job] -> Int -> GetJobsResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [Job] -> Int -> GetJobsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
Either String (Maybe [Job] -> Int -> GetJobsResponse)
-> Either String (Maybe [Job])
-> Either String (Int -> GetJobsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Job]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Jobs" Either String (Maybe (Maybe [Job]))
-> Maybe [Job] -> Either String (Maybe [Job])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Job]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> GetJobsResponse)
-> Either String Int -> Either String GetJobsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable GetJobs
instance Prelude.NFData GetJobs
instance Core.ToHeaders GetJobs where
toHeaders :: GetJobs -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetJobs -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"AWSGlue.GetJobs" :: Prelude.ByteString),
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 GetJobs where
toJSON :: GetJobs -> Value
toJSON GetJobs' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:GetJobs' :: GetJobs -> Maybe Natural
$sel:nextToken:GetJobs' :: GetJobs -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
]
)
instance Core.ToPath GetJobs where
toPath :: GetJobs -> ByteString
toPath = ByteString -> GetJobs -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetJobs where
toQuery :: GetJobs -> QueryString
toQuery = QueryString -> GetJobs -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetJobsResponse = GetJobsResponse'
{
GetJobsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
GetJobsResponse -> Maybe [Job]
jobs :: Prelude.Maybe [Job],
GetJobsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetJobsResponse -> GetJobsResponse -> Bool
(GetJobsResponse -> GetJobsResponse -> Bool)
-> (GetJobsResponse -> GetJobsResponse -> Bool)
-> Eq GetJobsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetJobsResponse -> GetJobsResponse -> Bool
$c/= :: GetJobsResponse -> GetJobsResponse -> Bool
== :: GetJobsResponse -> GetJobsResponse -> Bool
$c== :: GetJobsResponse -> GetJobsResponse -> Bool
Prelude.Eq, ReadPrec [GetJobsResponse]
ReadPrec GetJobsResponse
Int -> ReadS GetJobsResponse
ReadS [GetJobsResponse]
(Int -> ReadS GetJobsResponse)
-> ReadS [GetJobsResponse]
-> ReadPrec GetJobsResponse
-> ReadPrec [GetJobsResponse]
-> Read GetJobsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetJobsResponse]
$creadListPrec :: ReadPrec [GetJobsResponse]
readPrec :: ReadPrec GetJobsResponse
$creadPrec :: ReadPrec GetJobsResponse
readList :: ReadS [GetJobsResponse]
$creadList :: ReadS [GetJobsResponse]
readsPrec :: Int -> ReadS GetJobsResponse
$creadsPrec :: Int -> ReadS GetJobsResponse
Prelude.Read, Int -> GetJobsResponse -> ShowS
[GetJobsResponse] -> ShowS
GetJobsResponse -> String
(Int -> GetJobsResponse -> ShowS)
-> (GetJobsResponse -> String)
-> ([GetJobsResponse] -> ShowS)
-> Show GetJobsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetJobsResponse] -> ShowS
$cshowList :: [GetJobsResponse] -> ShowS
show :: GetJobsResponse -> String
$cshow :: GetJobsResponse -> String
showsPrec :: Int -> GetJobsResponse -> ShowS
$cshowsPrec :: Int -> GetJobsResponse -> ShowS
Prelude.Show, (forall x. GetJobsResponse -> Rep GetJobsResponse x)
-> (forall x. Rep GetJobsResponse x -> GetJobsResponse)
-> Generic GetJobsResponse
forall x. Rep GetJobsResponse x -> GetJobsResponse
forall x. GetJobsResponse -> Rep GetJobsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetJobsResponse x -> GetJobsResponse
$cfrom :: forall x. GetJobsResponse -> Rep GetJobsResponse x
Prelude.Generic)
newGetJobsResponse ::
Prelude.Int ->
GetJobsResponse
newGetJobsResponse :: Int -> GetJobsResponse
newGetJobsResponse Int
pHttpStatus_ =
GetJobsResponse' :: Maybe Text -> Maybe [Job] -> Int -> GetJobsResponse
GetJobsResponse'
{ $sel:nextToken:GetJobsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:jobs:GetJobsResponse' :: Maybe [Job]
jobs = Maybe [Job]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetJobsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getJobsResponse_nextToken :: Lens.Lens' GetJobsResponse (Prelude.Maybe Prelude.Text)
getJobsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetJobsResponse -> f GetJobsResponse
getJobsResponse_nextToken = (GetJobsResponse -> Maybe Text)
-> (GetJobsResponse -> Maybe Text -> GetJobsResponse)
-> Lens' GetJobsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJobsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetJobsResponse' :: GetJobsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetJobsResponse
s@GetJobsResponse' {} Maybe Text
a -> GetJobsResponse
s {$sel:nextToken:GetJobsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetJobsResponse)
getJobsResponse_jobs :: Lens.Lens' GetJobsResponse (Prelude.Maybe [Job])
getJobsResponse_jobs :: (Maybe [Job] -> f (Maybe [Job]))
-> GetJobsResponse -> f GetJobsResponse
getJobsResponse_jobs = (GetJobsResponse -> Maybe [Job])
-> (GetJobsResponse -> Maybe [Job] -> GetJobsResponse)
-> Lens' GetJobsResponse (Maybe [Job])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJobsResponse' {Maybe [Job]
jobs :: Maybe [Job]
$sel:jobs:GetJobsResponse' :: GetJobsResponse -> Maybe [Job]
jobs} -> Maybe [Job]
jobs) (\s :: GetJobsResponse
s@GetJobsResponse' {} Maybe [Job]
a -> GetJobsResponse
s {$sel:jobs:GetJobsResponse' :: Maybe [Job]
jobs = Maybe [Job]
a} :: GetJobsResponse) ((Maybe [Job] -> f (Maybe [Job]))
-> GetJobsResponse -> f GetJobsResponse)
-> ((Maybe [Job] -> f (Maybe [Job]))
-> Maybe [Job] -> f (Maybe [Job]))
-> (Maybe [Job] -> f (Maybe [Job]))
-> GetJobsResponse
-> f GetJobsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Job] [Job] [Job] [Job]
-> Iso (Maybe [Job]) (Maybe [Job]) (Maybe [Job]) (Maybe [Job])
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 [Job] [Job] [Job] [Job]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getJobsResponse_httpStatus :: Lens.Lens' GetJobsResponse Prelude.Int
getJobsResponse_httpStatus :: (Int -> f Int) -> GetJobsResponse -> f GetJobsResponse
getJobsResponse_httpStatus = (GetJobsResponse -> Int)
-> (GetJobsResponse -> Int -> GetJobsResponse)
-> Lens GetJobsResponse GetJobsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetJobsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetJobsResponse' :: GetJobsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetJobsResponse
s@GetJobsResponse' {} Int
a -> GetJobsResponse
s {$sel:httpStatus:GetJobsResponse' :: Int
httpStatus = Int
a} :: GetJobsResponse)
instance Prelude.NFData GetJobsResponse