module Network.AWS.StorageGateway.ListGateways
(
listGateways
, ListGateways
, lgMarker
, lgLimit
, listGatewaysResponse
, ListGatewaysResponse
, lgrsMarker
, lgrsGateways
, lgrsResponseStatus
) where
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.StorageGateway.Types
import Network.AWS.StorageGateway.Types.Product
data ListGateways = ListGateways'
{ _lgMarker :: !(Maybe Text)
, _lgLimit :: !(Maybe Nat)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listGateways
:: ListGateways
listGateways =
ListGateways'
{ _lgMarker = Nothing
, _lgLimit = Nothing
}
lgMarker :: Lens' ListGateways (Maybe Text)
lgMarker = lens _lgMarker (\ s a -> s{_lgMarker = a});
lgLimit :: Lens' ListGateways (Maybe Natural)
lgLimit = lens _lgLimit (\ s a -> s{_lgLimit = a}) . mapping _Nat;
instance AWSPager ListGateways where
page rq rs
| stop (rs ^. lgrsMarker) = Nothing
| stop (rs ^. lgrsGateways) = Nothing
| otherwise =
Just $ rq & lgMarker .~ rs ^. lgrsMarker
instance AWSRequest ListGateways where
type Rs ListGateways = ListGatewaysResponse
request = postJSON storageGateway
response
= receiveJSON
(\ s h x ->
ListGatewaysResponse' <$>
(x .?> "Marker") <*> (x .?> "Gateways" .!@ mempty)
<*> (pure (fromEnum s)))
instance ToHeaders ListGateways where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("StorageGateway_20130630.ListGateways" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListGateways where
toJSON ListGateways'{..}
= object
(catMaybes
[("Marker" .=) <$> _lgMarker,
("Limit" .=) <$> _lgLimit])
instance ToPath ListGateways where
toPath = const "/"
instance ToQuery ListGateways where
toQuery = const mempty
data ListGatewaysResponse = ListGatewaysResponse'
{ _lgrsMarker :: !(Maybe Text)
, _lgrsGateways :: !(Maybe [GatewayInfo])
, _lgrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listGatewaysResponse
:: Int
-> ListGatewaysResponse
listGatewaysResponse pResponseStatus_ =
ListGatewaysResponse'
{ _lgrsMarker = Nothing
, _lgrsGateways = Nothing
, _lgrsResponseStatus = pResponseStatus_
}
lgrsMarker :: Lens' ListGatewaysResponse (Maybe Text)
lgrsMarker = lens _lgrsMarker (\ s a -> s{_lgrsMarker = a});
lgrsGateways :: Lens' ListGatewaysResponse [GatewayInfo]
lgrsGateways = lens _lgrsGateways (\ s a -> s{_lgrsGateways = a}) . _Default . _Coerce;
lgrsResponseStatus :: Lens' ListGatewaysResponse Int
lgrsResponseStatus = lens _lgrsResponseStatus (\ s a -> s{_lgrsResponseStatus = a});