{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.Glue.GetJobRuns
(
getJobRuns
, GetJobRuns
, gjrNextToken
, gjrMaxResults
, gjrJobName
, getJobRunsResponse
, GetJobRunsResponse
, gjrrsNextToken
, gjrrsJobRuns
, gjrrsResponseStatus
) where
import Network.AWS.Glue.Types
import Network.AWS.Glue.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetJobRuns = GetJobRuns'
{ _gjrNextToken :: !(Maybe Text)
, _gjrMaxResults :: !(Maybe Nat)
, _gjrJobName :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getJobRuns
:: Text
-> GetJobRuns
getJobRuns pJobName_ =
GetJobRuns'
{_gjrNextToken = Nothing, _gjrMaxResults = Nothing, _gjrJobName = pJobName_}
gjrNextToken :: Lens' GetJobRuns (Maybe Text)
gjrNextToken = lens _gjrNextToken (\ s a -> s{_gjrNextToken = a})
gjrMaxResults :: Lens' GetJobRuns (Maybe Natural)
gjrMaxResults = lens _gjrMaxResults (\ s a -> s{_gjrMaxResults = a}) . mapping _Nat
gjrJobName :: Lens' GetJobRuns Text
gjrJobName = lens _gjrJobName (\ s a -> s{_gjrJobName = a})
instance AWSPager GetJobRuns where
page rq rs
| stop (rs ^. gjrrsNextToken) = Nothing
| stop (rs ^. gjrrsJobRuns) = Nothing
| otherwise =
Just $ rq & gjrNextToken .~ rs ^. gjrrsNextToken
instance AWSRequest GetJobRuns where
type Rs GetJobRuns = GetJobRunsResponse
request = postJSON glue
response
= receiveJSON
(\ s h x ->
GetJobRunsResponse' <$>
(x .?> "NextToken") <*> (x .?> "JobRuns" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable GetJobRuns where
instance NFData GetJobRuns where
instance ToHeaders GetJobRuns where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSGlue.GetJobRuns" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetJobRuns where
toJSON GetJobRuns'{..}
= object
(catMaybes
[("NextToken" .=) <$> _gjrNextToken,
("MaxResults" .=) <$> _gjrMaxResults,
Just ("JobName" .= _gjrJobName)])
instance ToPath GetJobRuns where
toPath = const "/"
instance ToQuery GetJobRuns where
toQuery = const mempty
data GetJobRunsResponse = GetJobRunsResponse'
{ _gjrrsNextToken :: !(Maybe Text)
, _gjrrsJobRuns :: !(Maybe [JobRun])
, _gjrrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getJobRunsResponse
:: Int
-> GetJobRunsResponse
getJobRunsResponse pResponseStatus_ =
GetJobRunsResponse'
{ _gjrrsNextToken = Nothing
, _gjrrsJobRuns = Nothing
, _gjrrsResponseStatus = pResponseStatus_
}
gjrrsNextToken :: Lens' GetJobRunsResponse (Maybe Text)
gjrrsNextToken = lens _gjrrsNextToken (\ s a -> s{_gjrrsNextToken = a})
gjrrsJobRuns :: Lens' GetJobRunsResponse [JobRun]
gjrrsJobRuns = lens _gjrrsJobRuns (\ s a -> s{_gjrrsJobRuns = a}) . _Default . _Coerce
gjrrsResponseStatus :: Lens' GetJobRunsResponse Int
gjrrsResponseStatus = lens _gjrrsResponseStatus (\ s a -> s{_gjrrsResponseStatus = a})
instance NFData GetJobRunsResponse where