module Network.AWS.EMR.ListClusters
(
ListClusters
, listClusters
, lcClusterStates
, lcCreatedAfter
, lcCreatedBefore
, lcMarker
, ListClustersResponse
, listClustersResponse
, lcrClusters
, lcrMarker
) where
import Network.AWS.Prelude
import Network.AWS.Request.JSON
import Network.AWS.EMR.Types
import qualified GHC.Exts
data ListClusters = ListClusters
{ _lcClusterStates :: List "ClusterStates" ClusterState
, _lcCreatedAfter :: Maybe POSIX
, _lcCreatedBefore :: Maybe POSIX
, _lcMarker :: Maybe Text
} deriving (Eq, Read, Show)
listClusters :: ListClusters
listClusters = ListClusters
{ _lcCreatedAfter = Nothing
, _lcCreatedBefore = Nothing
, _lcClusterStates = mempty
, _lcMarker = Nothing
}
lcClusterStates :: Lens' ListClusters [ClusterState]
lcClusterStates = lens _lcClusterStates (\s a -> s { _lcClusterStates = a }) . _List
lcCreatedAfter :: Lens' ListClusters (Maybe UTCTime)
lcCreatedAfter = lens _lcCreatedAfter (\s a -> s { _lcCreatedAfter = a }) . mapping _Time
lcCreatedBefore :: Lens' ListClusters (Maybe UTCTime)
lcCreatedBefore = lens _lcCreatedBefore (\s a -> s { _lcCreatedBefore = a }) . mapping _Time
lcMarker :: Lens' ListClusters (Maybe Text)
lcMarker = lens _lcMarker (\s a -> s { _lcMarker = a })
data ListClustersResponse = ListClustersResponse
{ _lcrClusters :: List "Clusters" ClusterSummary
, _lcrMarker :: Maybe Text
} deriving (Eq, Read, Show)
listClustersResponse :: ListClustersResponse
listClustersResponse = ListClustersResponse
{ _lcrClusters = mempty
, _lcrMarker = Nothing
}
lcrClusters :: Lens' ListClustersResponse [ClusterSummary]
lcrClusters = lens _lcrClusters (\s a -> s { _lcrClusters = a }) . _List
lcrMarker :: Lens' ListClustersResponse (Maybe Text)
lcrMarker = lens _lcrMarker (\s a -> s { _lcrMarker = a })
instance ToPath ListClusters where
toPath = const "/"
instance ToQuery ListClusters where
toQuery = const mempty
instance ToHeaders ListClusters
instance ToJSON ListClusters where
toJSON ListClusters{..} = object
[ "CreatedAfter" .= _lcCreatedAfter
, "CreatedBefore" .= _lcCreatedBefore
, "ClusterStates" .= _lcClusterStates
, "Marker" .= _lcMarker
]
instance AWSRequest ListClusters where
type Sv ListClusters = EMR
type Rs ListClusters = ListClustersResponse
request = post "ListClusters"
response = jsonResponse
instance FromJSON ListClustersResponse where
parseJSON = withObject "ListClustersResponse" $ \o -> ListClustersResponse
<$> o .:? "Clusters" .!= mempty
<*> o .:? "Marker"
instance AWSPager ListClusters where
page rq rs
| stop (rq ^. lcMarker) = Nothing
| otherwise = (\x -> rq & lcMarker ?~ x)
<$> (rs ^. lcrMarker)