{-# 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.ListInstances
(
listInstances
, ListInstances
, liInstanceGroupTypes
, liInstanceFleetType
, liMarker
, liInstanceFleetId
, liInstanceStates
, liInstanceGroupId
, liClusterId
, listInstancesResponse
, ListInstancesResponse
, lirsMarker
, lirsInstances
, lirsResponseStatus
) 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 ListInstances = ListInstances'
{ _liInstanceGroupTypes :: !(Maybe [InstanceGroupType])
, _liInstanceFleetType :: !(Maybe InstanceFleetType)
, _liMarker :: !(Maybe Text)
, _liInstanceFleetId :: !(Maybe Text)
, _liInstanceStates :: !(Maybe [InstanceState])
, _liInstanceGroupId :: !(Maybe Text)
, _liClusterId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listInstances
:: Text
-> ListInstances
listInstances pClusterId_ =
ListInstances'
{ _liInstanceGroupTypes = Nothing
, _liInstanceFleetType = Nothing
, _liMarker = Nothing
, _liInstanceFleetId = Nothing
, _liInstanceStates = Nothing
, _liInstanceGroupId = Nothing
, _liClusterId = pClusterId_
}
liInstanceGroupTypes :: Lens' ListInstances [InstanceGroupType]
liInstanceGroupTypes = lens _liInstanceGroupTypes (\ s a -> s{_liInstanceGroupTypes = a}) . _Default . _Coerce
liInstanceFleetType :: Lens' ListInstances (Maybe InstanceFleetType)
liInstanceFleetType = lens _liInstanceFleetType (\ s a -> s{_liInstanceFleetType = a})
liMarker :: Lens' ListInstances (Maybe Text)
liMarker = lens _liMarker (\ s a -> s{_liMarker = a})
liInstanceFleetId :: Lens' ListInstances (Maybe Text)
liInstanceFleetId = lens _liInstanceFleetId (\ s a -> s{_liInstanceFleetId = a})
liInstanceStates :: Lens' ListInstances [InstanceState]
liInstanceStates = lens _liInstanceStates (\ s a -> s{_liInstanceStates = a}) . _Default . _Coerce
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 .?> "Marker") <*> (x .?> "Instances" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable ListInstances where
instance NFData ListInstances where
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,
("InstanceFleetType" .=) <$> _liInstanceFleetType,
("Marker" .=) <$> _liMarker,
("InstanceFleetId" .=) <$> _liInstanceFleetId,
("InstanceStates" .=) <$> _liInstanceStates,
("InstanceGroupId" .=) <$> _liInstanceGroupId,
Just ("ClusterId" .= _liClusterId)])
instance ToPath ListInstances where
toPath = const "/"
instance ToQuery ListInstances where
toQuery = const mempty
data ListInstancesResponse = ListInstancesResponse'
{ _lirsMarker :: !(Maybe Text)
, _lirsInstances :: !(Maybe [Instance])
, _lirsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listInstancesResponse
:: Int
-> ListInstancesResponse
listInstancesResponse pResponseStatus_ =
ListInstancesResponse'
{ _lirsMarker = Nothing
, _lirsInstances = Nothing
, _lirsResponseStatus = pResponseStatus_
}
lirsMarker :: Lens' ListInstancesResponse (Maybe Text)
lirsMarker = lens _lirsMarker (\ s a -> s{_lirsMarker = a})
lirsInstances :: Lens' ListInstancesResponse [Instance]
lirsInstances = lens _lirsInstances (\ s a -> s{_lirsInstances = a}) . _Default . _Coerce
lirsResponseStatus :: Lens' ListInstancesResponse Int
lirsResponseStatus = lens _lirsResponseStatus (\ s a -> s{_lirsResponseStatus = a})
instance NFData ListInstancesResponse where