module Network.AWS.EMR.ListInstances
(
listInstances
, ListInstances
, liInstanceGroupTypes
, liMarker
, liInstanceGroupId
, liClusterId
, listInstancesResponse
, ListInstancesResponse
, lirsInstances
, lirsMarker
, lirsStatus
) where
import Network.AWS.EMR.Types
import Network.AWS.EMR.Types.Product
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListInstances = ListInstances'
{ _liInstanceGroupTypes :: !(Maybe [InstanceGroupType])
, _liMarker :: !(Maybe Text)
, _liInstanceGroupId :: !(Maybe Text)
, _liClusterId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listInstances
:: Text
-> ListInstances
listInstances pClusterId_ =
ListInstances'
{ _liInstanceGroupTypes = Nothing
, _liMarker = Nothing
, _liInstanceGroupId = Nothing
, _liClusterId = pClusterId_
}
liInstanceGroupTypes :: Lens' ListInstances [InstanceGroupType]
liInstanceGroupTypes = lens _liInstanceGroupTypes (\ s a -> s{_liInstanceGroupTypes = a}) . _Default . _Coerce;
liMarker :: Lens' ListInstances (Maybe Text)
liMarker = lens _liMarker (\ s a -> s{_liMarker = a});
liInstanceGroupId :: Lens' ListInstances (Maybe Text)
liInstanceGroupId = lens _liInstanceGroupId (\ s a -> s{_liInstanceGroupId = a});
liClusterId :: Lens' ListInstances Text
liClusterId = lens _liClusterId (\ s a -> s{_liClusterId = a});
instance AWSPager ListInstances where
page rq rs
| stop (rs ^. lirsMarker) = Nothing
| stop (rs ^. lirsInstances) = Nothing
| otherwise =
Just $ rq & liMarker .~ rs ^. lirsMarker
instance AWSRequest ListInstances where
type Rs ListInstances = ListInstancesResponse
request = postJSON eMR
response
= receiveJSON
(\ s h x ->
ListInstancesResponse' <$>
(x .?> "Instances" .!@ mempty) <*> (x .?> "Marker")
<*> (pure (fromEnum s)))
instance ToHeaders ListInstances where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("ElasticMapReduce.ListInstances" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListInstances where
toJSON ListInstances'{..}
= object
(catMaybes
[("InstanceGroupTypes" .=) <$> _liInstanceGroupTypes,
("Marker" .=) <$> _liMarker,
("InstanceGroupId" .=) <$> _liInstanceGroupId,
Just ("ClusterId" .= _liClusterId)])
instance ToPath ListInstances where
toPath = const "/"
instance ToQuery ListInstances where
toQuery = const mempty
data ListInstancesResponse = ListInstancesResponse'
{ _lirsInstances :: !(Maybe [Instance])
, _lirsMarker :: !(Maybe Text)
, _lirsStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listInstancesResponse
:: Int
-> ListInstancesResponse
listInstancesResponse pStatus_ =
ListInstancesResponse'
{ _lirsInstances = Nothing
, _lirsMarker = Nothing
, _lirsStatus = pStatus_
}
lirsInstances :: Lens' ListInstancesResponse [Instance]
lirsInstances = lens _lirsInstances (\ s a -> s{_lirsInstances = a}) . _Default . _Coerce;
lirsMarker :: Lens' ListInstancesResponse (Maybe Text)
lirsMarker = lens _lirsMarker (\ s a -> s{_lirsMarker = a});
lirsStatus :: Lens' ListInstancesResponse Int
lirsStatus = lens _lirsStatus (\ s a -> s{_lirsStatus = a});