{-# 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.EMR.ListSteps
(
listSteps
, ListSteps
, lsStepIds
, lsStepStates
, lsMarker
, lsClusterId
, listStepsResponse
, ListStepsResponse
, lsrsSteps
, lsrsMarker
, lsrsResponseStatus
) where
import Network.AWS.EMR.Types
import Network.AWS.EMR.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListSteps = ListSteps'
{ _lsStepIds :: !(Maybe [Text])
, _lsStepStates :: !(Maybe [StepState])
, _lsMarker :: !(Maybe Text)
, _lsClusterId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listSteps
:: Text
-> ListSteps
listSteps pClusterId_ =
ListSteps'
{ _lsStepIds = Nothing
, _lsStepStates = Nothing
, _lsMarker = Nothing
, _lsClusterId = pClusterId_
}
lsStepIds :: Lens' ListSteps [Text]
lsStepIds = lens _lsStepIds (\ s a -> s{_lsStepIds = a}) . _Default . _Coerce
lsStepStates :: Lens' ListSteps [StepState]
lsStepStates = lens _lsStepStates (\ s a -> s{_lsStepStates = a}) . _Default . _Coerce
lsMarker :: Lens' ListSteps (Maybe Text)
lsMarker = lens _lsMarker (\ s a -> s{_lsMarker = a})
lsClusterId :: Lens' ListSteps Text
lsClusterId = lens _lsClusterId (\ s a -> s{_lsClusterId = a})
instance AWSPager ListSteps where
page rq rs
| stop (rs ^. lsrsMarker) = Nothing
| stop (rs ^. lsrsSteps) = Nothing
| otherwise =
Just $ rq & lsMarker .~ rs ^. lsrsMarker
instance AWSRequest ListSteps where
type Rs ListSteps = ListStepsResponse
request = postJSON emr
response
= receiveJSON
(\ s h x ->
ListStepsResponse' <$>
(x .?> "Steps" .!@ mempty) <*> (x .?> "Marker") <*>
(pure (fromEnum s)))
instance Hashable ListSteps where
instance NFData ListSteps where
instance ToHeaders ListSteps where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("ElasticMapReduce.ListSteps" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListSteps where
toJSON ListSteps'{..}
= object
(catMaybes
[("StepIds" .=) <$> _lsStepIds,
("StepStates" .=) <$> _lsStepStates,
("Marker" .=) <$> _lsMarker,
Just ("ClusterId" .= _lsClusterId)])
instance ToPath ListSteps where
toPath = const "/"
instance ToQuery ListSteps where
toQuery = const mempty
data ListStepsResponse = ListStepsResponse'
{ _lsrsSteps :: !(Maybe [StepSummary])
, _lsrsMarker :: !(Maybe Text)
, _lsrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listStepsResponse
:: Int
-> ListStepsResponse
listStepsResponse pResponseStatus_ =
ListStepsResponse'
{ _lsrsSteps = Nothing
, _lsrsMarker = Nothing
, _lsrsResponseStatus = pResponseStatus_
}
lsrsSteps :: Lens' ListStepsResponse [StepSummary]
lsrsSteps = lens _lsrsSteps (\ s a -> s{_lsrsSteps = a}) . _Default . _Coerce
lsrsMarker :: Lens' ListStepsResponse (Maybe Text)
lsrsMarker = lens _lsrsMarker (\ s a -> s{_lsrsMarker = a})
lsrsResponseStatus :: Lens' ListStepsResponse Int
lsrsResponseStatus = lens _lsrsResponseStatus (\ s a -> s{_lsrsResponseStatus = a})
instance NFData ListStepsResponse where