{-# 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.Snowball.ListJobs
(
listJobs
, ListJobs
, ljNextToken
, ljMaxResults
, listJobsResponse
, ListJobsResponse
, ljrsJobListEntries
, ljrsNextToken
, ljrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.Snowball.Types
import Network.AWS.Snowball.Types.Product
data ListJobs = ListJobs'
{ _ljNextToken :: !(Maybe Text)
, _ljMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listJobs
:: ListJobs
listJobs = ListJobs' {_ljNextToken = Nothing, _ljMaxResults = Nothing}
ljNextToken :: Lens' ListJobs (Maybe Text)
ljNextToken = lens _ljNextToken (\ s a -> s{_ljNextToken = a})
ljMaxResults :: Lens' ListJobs (Maybe Natural)
ljMaxResults = lens _ljMaxResults (\ s a -> s{_ljMaxResults = a}) . mapping _Nat
instance AWSPager ListJobs where
page rq rs
| stop (rs ^. ljrsNextToken) = Nothing
| stop (rs ^. ljrsJobListEntries) = Nothing
| otherwise =
Just $ rq & ljNextToken .~ rs ^. ljrsNextToken
instance AWSRequest ListJobs where
type Rs ListJobs = ListJobsResponse
request = postJSON snowball
response
= receiveJSON
(\ s h x ->
ListJobsResponse' <$>
(x .?> "JobListEntries" .!@ mempty) <*>
(x .?> "NextToken")
<*> (pure (fromEnum s)))
instance Hashable ListJobs where
instance NFData ListJobs where
instance ToHeaders ListJobs where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSIESnowballJobManagementService.ListJobs" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListJobs where
toJSON ListJobs'{..}
= object
(catMaybes
[("NextToken" .=) <$> _ljNextToken,
("MaxResults" .=) <$> _ljMaxResults])
instance ToPath ListJobs where
toPath = const "/"
instance ToQuery ListJobs where
toQuery = const mempty
data ListJobsResponse = ListJobsResponse'
{ _ljrsJobListEntries :: !(Maybe [JobListEntry])
, _ljrsNextToken :: !(Maybe Text)
, _ljrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listJobsResponse
:: Int
-> ListJobsResponse
listJobsResponse pResponseStatus_ =
ListJobsResponse'
{ _ljrsJobListEntries = Nothing
, _ljrsNextToken = Nothing
, _ljrsResponseStatus = pResponseStatus_
}
ljrsJobListEntries :: Lens' ListJobsResponse [JobListEntry]
ljrsJobListEntries = lens _ljrsJobListEntries (\ s a -> s{_ljrsJobListEntries = a}) . _Default . _Coerce
ljrsNextToken :: Lens' ListJobsResponse (Maybe Text)
ljrsNextToken = lens _ljrsNextToken (\ s a -> s{_ljrsNextToken = a})
ljrsResponseStatus :: Lens' ListJobsResponse Int
ljrsResponseStatus = lens _ljrsResponseStatus (\ s a -> s{_ljrsResponseStatus = a})
instance NFData ListJobsResponse where