module Network.AWS.StorageGateway.ListVolumes
(
listVolumes
, ListVolumes
, lvMarker
, lvLimit
, lvGatewayARN
, listVolumesResponse
, ListVolumesResponse
, lvrsGatewayARN
, lvrsMarker
, lvrsVolumeInfos
, lvrsResponseStatus
) 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 ListVolumes = ListVolumes'
{ _lvMarker :: !(Maybe Text)
, _lvLimit :: !(Maybe Nat)
, _lvGatewayARN :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listVolumes
:: Text
-> ListVolumes
listVolumes pGatewayARN_ =
ListVolumes'
{ _lvMarker = Nothing
, _lvLimit = Nothing
, _lvGatewayARN = pGatewayARN_
}
lvMarker :: Lens' ListVolumes (Maybe Text)
lvMarker = lens _lvMarker (\ s a -> s{_lvMarker = a});
lvLimit :: Lens' ListVolumes (Maybe Natural)
lvLimit = lens _lvLimit (\ s a -> s{_lvLimit = a}) . mapping _Nat;
lvGatewayARN :: Lens' ListVolumes Text
lvGatewayARN = lens _lvGatewayARN (\ s a -> s{_lvGatewayARN = a});
instance AWSPager ListVolumes where
page rq rs
| stop (rs ^. lvrsMarker) = Nothing
| stop (rs ^. lvrsVolumeInfos) = Nothing
| otherwise =
Just $ rq & lvMarker .~ rs ^. lvrsMarker
instance AWSRequest ListVolumes where
type Rs ListVolumes = ListVolumesResponse
request = postJSON storageGateway
response
= receiveJSON
(\ s h x ->
ListVolumesResponse' <$>
(x .?> "GatewayARN") <*> (x .?> "Marker") <*>
(x .?> "VolumeInfos" .!@ mempty)
<*> (pure (fromEnum s)))
instance ToHeaders ListVolumes where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("StorageGateway_20130630.ListVolumes" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListVolumes where
toJSON ListVolumes'{..}
= object
(catMaybes
[("Marker" .=) <$> _lvMarker,
("Limit" .=) <$> _lvLimit,
Just ("GatewayARN" .= _lvGatewayARN)])
instance ToPath ListVolumes where
toPath = const "/"
instance ToQuery ListVolumes where
toQuery = const mempty
data ListVolumesResponse = ListVolumesResponse'
{ _lvrsGatewayARN :: !(Maybe Text)
, _lvrsMarker :: !(Maybe Text)
, _lvrsVolumeInfos :: !(Maybe [VolumeInfo])
, _lvrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listVolumesResponse
:: Int
-> ListVolumesResponse
listVolumesResponse pResponseStatus_ =
ListVolumesResponse'
{ _lvrsGatewayARN = Nothing
, _lvrsMarker = Nothing
, _lvrsVolumeInfos = Nothing
, _lvrsResponseStatus = pResponseStatus_
}
lvrsGatewayARN :: Lens' ListVolumesResponse (Maybe Text)
lvrsGatewayARN = lens _lvrsGatewayARN (\ s a -> s{_lvrsGatewayARN = a});
lvrsMarker :: Lens' ListVolumesResponse (Maybe Text)
lvrsMarker = lens _lvrsMarker (\ s a -> s{_lvrsMarker = a});
lvrsVolumeInfos :: Lens' ListVolumesResponse [VolumeInfo]
lvrsVolumeInfos = lens _lvrsVolumeInfos (\ s a -> s{_lvrsVolumeInfos = a}) . _Default . _Coerce;
lvrsResponseStatus :: Lens' ListVolumesResponse Int
lvrsResponseStatus = lens _lvrsResponseStatus (\ s a -> s{_lvrsResponseStatus = a});