{-# 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.StorageGateway.ListVolumes
(
listVolumes
, ListVolumes
, lvGatewayARN
, lvMarker
, lvLimit
, listVolumesResponse
, ListVolumesResponse
, lvrsGatewayARN
, lvrsMarker
, lvrsVolumeInfos
, lvrsResponseStatus
) where
import Network.AWS.Lens
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'
{ _lvGatewayARN :: !(Maybe Text)
, _lvMarker :: !(Maybe Text)
, _lvLimit :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listVolumes
:: ListVolumes
listVolumes =
ListVolumes'
{_lvGatewayARN = Nothing, _lvMarker = Nothing, _lvLimit = Nothing}
lvGatewayARN :: Lens' ListVolumes (Maybe Text)
lvGatewayARN = lens _lvGatewayARN (\ s a -> s{_lvGatewayARN = a})
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
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 Hashable ListVolumes where
instance NFData ListVolumes where
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
[("GatewayARN" .=) <$> _lvGatewayARN,
("Marker" .=) <$> _lvMarker,
("Limit" .=) <$> _lvLimit])
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})
instance NFData ListVolumesResponse where