module Network.AWS.StorageGateway.ListVolumes
(
ListVolumes
, listVolumes
, lvGatewayARN
, lvLimit
, lvMarker
, ListVolumesResponse
, listVolumesResponse
, lvrGatewayARN
, lvrMarker
, lvrVolumeInfos
) where
import Network.AWS.Prelude
import Network.AWS.Request.JSON
import Network.AWS.StorageGateway.Types
import qualified GHC.Exts
data ListVolumes = ListVolumes
{ _lvGatewayARN :: Text
, _lvLimit :: Maybe Nat
, _lvMarker :: Maybe Text
} deriving (Eq, Ord, Show)
listVolumes :: Text
-> ListVolumes
listVolumes p1 = ListVolumes
{ _lvGatewayARN = p1
, _lvMarker = Nothing
, _lvLimit = Nothing
}
lvGatewayARN :: Lens' ListVolumes Text
lvGatewayARN = lens _lvGatewayARN (\s a -> s { _lvGatewayARN = a })
lvLimit :: Lens' ListVolumes (Maybe Natural)
lvLimit = lens _lvLimit (\s a -> s { _lvLimit = a }) . mapping _Nat
lvMarker :: Lens' ListVolumes (Maybe Text)
lvMarker = lens _lvMarker (\s a -> s { _lvMarker = a })
data ListVolumesResponse = ListVolumesResponse
{ _lvrGatewayARN :: Maybe Text
, _lvrMarker :: Maybe Text
, _lvrVolumeInfos :: List "VolumeInfos" VolumeInfo
} deriving (Eq, Show)
listVolumesResponse :: ListVolumesResponse
listVolumesResponse = ListVolumesResponse
{ _lvrGatewayARN = Nothing
, _lvrMarker = Nothing
, _lvrVolumeInfos = mempty
}
lvrGatewayARN :: Lens' ListVolumesResponse (Maybe Text)
lvrGatewayARN = lens _lvrGatewayARN (\s a -> s { _lvrGatewayARN = a })
lvrMarker :: Lens' ListVolumesResponse (Maybe Text)
lvrMarker = lens _lvrMarker (\s a -> s { _lvrMarker = a })
lvrVolumeInfos :: Lens' ListVolumesResponse [VolumeInfo]
lvrVolumeInfos = lens _lvrVolumeInfos (\s a -> s { _lvrVolumeInfos = a }) . _List
instance ToPath ListVolumes where
toPath = const "/"
instance ToQuery ListVolumes where
toQuery = const mempty
instance ToHeaders ListVolumes
instance ToJSON ListVolumes where
toJSON ListVolumes{..} = object
[ "GatewayARN" .= _lvGatewayARN
, "Marker" .= _lvMarker
, "Limit" .= _lvLimit
]
instance AWSRequest ListVolumes where
type Sv ListVolumes = StorageGateway
type Rs ListVolumes = ListVolumesResponse
request = post "ListVolumes"
response = jsonResponse
instance FromJSON ListVolumesResponse where
parseJSON = withObject "ListVolumesResponse" $ \o -> ListVolumesResponse
<$> o .:? "GatewayARN"
<*> o .:? "Marker"
<*> o .: "VolumeInfos"
instance AWSPager ListVolumes where
page rq rs
| stop (rq ^. lvMarker) = Nothing
| otherwise = (\x -> rq & lvMarker ?~ x)
<$> (rs ^. lvrMarker)