module Network.AWS.ImportExport.ListJobs
(
ListJobs
, listJobs
, ljMarker
, ljMaxJobs
, ListJobsResponse
, listJobsResponse
, ljrIsTruncated
, ljrJobs
) where
import Network.AWS.Prelude
import Network.AWS.Request.Query
import Network.AWS.ImportExport.Types
import qualified GHC.Exts
data ListJobs = ListJobs
{ _ljMarker :: Maybe Text
, _ljMaxJobs :: Maybe Int
} deriving (Eq, Ord, Show)
listJobs :: ListJobs
listJobs = ListJobs
{ _ljMaxJobs = Nothing
, _ljMarker = Nothing
}
ljMarker :: Lens' ListJobs (Maybe Text)
ljMarker = lens _ljMarker (\s a -> s { _ljMarker = a })
ljMaxJobs :: Lens' ListJobs (Maybe Int)
ljMaxJobs = lens _ljMaxJobs (\s a -> s { _ljMaxJobs = a })
data ListJobsResponse = ListJobsResponse
{ _ljrIsTruncated :: Maybe Bool
, _ljrJobs :: List "member" Job
} deriving (Eq, Show)
listJobsResponse :: ListJobsResponse
listJobsResponse = ListJobsResponse
{ _ljrJobs = mempty
, _ljrIsTruncated = Nothing
}
ljrIsTruncated :: Lens' ListJobsResponse (Maybe Bool)
ljrIsTruncated = lens _ljrIsTruncated (\s a -> s { _ljrIsTruncated = a })
ljrJobs :: Lens' ListJobsResponse [Job]
ljrJobs = lens _ljrJobs (\s a -> s { _ljrJobs = a }) . _List
instance ToPath ListJobs where
toPath = const "/"
instance ToQuery ListJobs where
toQuery ListJobs{..} = mconcat
[ "Marker" =? _ljMarker
, "MaxJobs" =? _ljMaxJobs
]
instance ToHeaders ListJobs
instance AWSRequest ListJobs where
type Sv ListJobs = ImportExport
type Rs ListJobs = ListJobsResponse
request = post "ListJobs"
response = xmlResponse
instance FromXML ListJobsResponse where
parseXML = withElement "ListJobsResult" $ \x -> ListJobsResponse
<$> x .@? "IsTruncated"
<*> x .@? "Jobs" .!@ mempty
instance AWSPager ListJobs where
page rq rs
| stop (rs ^. ljrIsTruncated) = Nothing
| otherwise = Just $ rq
& ljMarker .~ rs ^. index ljrJobs jobJobId