module Network.AWS.EMR.ListInstances
(
ListInstances
, listInstances
, liClusterId
, liInstanceGroupId
, liInstanceGroupTypes
, liMarker
, ListInstancesResponse
, listInstancesResponse
, lirInstances
, lirMarker
) where
import Network.AWS.Prelude
import Network.AWS.Request.JSON
import Network.AWS.EMR.Types
import qualified GHC.Exts
data ListInstances = ListInstances
{ _liClusterId :: Text
, _liInstanceGroupId :: Maybe Text
, _liInstanceGroupTypes :: List "InstanceGroupTypes" InstanceGroupType
, _liMarker :: Maybe Text
} deriving (Eq, Show)
listInstances :: Text
-> ListInstances
listInstances p1 = ListInstances
{ _liClusterId = p1
, _liInstanceGroupId = Nothing
, _liInstanceGroupTypes = mempty
, _liMarker = Nothing
}
liClusterId :: Lens' ListInstances Text
liClusterId = lens _liClusterId (\s a -> s { _liClusterId = a })
liInstanceGroupId :: Lens' ListInstances (Maybe Text)
liInstanceGroupId =
lens _liInstanceGroupId (\s a -> s { _liInstanceGroupId = a })
liInstanceGroupTypes :: Lens' ListInstances [InstanceGroupType]
liInstanceGroupTypes =
lens _liInstanceGroupTypes (\s a -> s { _liInstanceGroupTypes = a })
. _List
liMarker :: Lens' ListInstances (Maybe Text)
liMarker = lens _liMarker (\s a -> s { _liMarker = a })
data ListInstancesResponse = ListInstancesResponse
{ _lirInstances :: List "Instances" Instance
, _lirMarker :: Maybe Text
} deriving (Eq, Show)
listInstancesResponse :: ListInstancesResponse
listInstancesResponse = ListInstancesResponse
{ _lirInstances = mempty
, _lirMarker = Nothing
}
lirInstances :: Lens' ListInstancesResponse [Instance]
lirInstances = lens _lirInstances (\s a -> s { _lirInstances = a }) . _List
lirMarker :: Lens' ListInstancesResponse (Maybe Text)
lirMarker = lens _lirMarker (\s a -> s { _lirMarker = a })
instance ToPath ListInstances where
toPath = const "/"
instance ToQuery ListInstances where
toQuery = const mempty
instance ToHeaders ListInstances
instance ToJSON ListInstances where
toJSON ListInstances{..} = object
[ "ClusterId" .= _liClusterId
, "InstanceGroupId" .= _liInstanceGroupId
, "InstanceGroupTypes" .= _liInstanceGroupTypes
, "Marker" .= _liMarker
]
instance AWSRequest ListInstances where
type Sv ListInstances = EMR
type Rs ListInstances = ListInstancesResponse
request = post "ListInstances"
response = jsonResponse
instance FromJSON ListInstancesResponse where
parseJSON = withObject "ListInstancesResponse" $ \o -> ListInstancesResponse
<$> o .:? "Instances" .!= mempty
<*> o .:? "Marker"
instance AWSPager ListInstances where
page rq rs
| stop (rq ^. liMarker) = Nothing
| otherwise = (\x -> rq & liMarker ?~ x)
<$> (rs ^. lirMarker)