module Network.AWS.ElastiCache.DescribeSnapshots
(
describeSnapshots
, DescribeSnapshots
, dsCacheClusterId
, dsMarker
, dsMaxRecords
, dsSnapshotName
, dsSnapshotSource
, describeSnapshotsResponse
, DescribeSnapshotsResponse
, dssrsSnapshots
, dssrsMarker
, dssrsResponseStatus
) where
import Network.AWS.ElastiCache.Types
import Network.AWS.ElastiCache.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data DescribeSnapshots = DescribeSnapshots'
{ _dsCacheClusterId :: !(Maybe Text)
, _dsMarker :: !(Maybe Text)
, _dsMaxRecords :: !(Maybe Int)
, _dsSnapshotName :: !(Maybe Text)
, _dsSnapshotSource :: !(Maybe Text)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeSnapshots
:: DescribeSnapshots
describeSnapshots =
DescribeSnapshots'
{ _dsCacheClusterId = Nothing
, _dsMarker = Nothing
, _dsMaxRecords = Nothing
, _dsSnapshotName = Nothing
, _dsSnapshotSource = Nothing
}
dsCacheClusterId :: Lens' DescribeSnapshots (Maybe Text)
dsCacheClusterId = lens _dsCacheClusterId (\ s a -> s{_dsCacheClusterId = a});
dsMarker :: Lens' DescribeSnapshots (Maybe Text)
dsMarker = lens _dsMarker (\ s a -> s{_dsMarker = a});
dsMaxRecords :: Lens' DescribeSnapshots (Maybe Int)
dsMaxRecords = lens _dsMaxRecords (\ s a -> s{_dsMaxRecords = a});
dsSnapshotName :: Lens' DescribeSnapshots (Maybe Text)
dsSnapshotName = lens _dsSnapshotName (\ s a -> s{_dsSnapshotName = a});
dsSnapshotSource :: Lens' DescribeSnapshots (Maybe Text)
dsSnapshotSource = lens _dsSnapshotSource (\ s a -> s{_dsSnapshotSource = a});
instance AWSPager DescribeSnapshots where
page rq rs
| stop (rs ^. dssrsMarker) = Nothing
| stop (rs ^. dssrsSnapshots) = Nothing
| otherwise =
Just $ rq & dsMarker .~ rs ^. dssrsMarker
instance AWSRequest DescribeSnapshots where
type Rs DescribeSnapshots = DescribeSnapshotsResponse
request = postQuery elastiCache
response
= receiveXMLWrapper "DescribeSnapshotsResult"
(\ s h x ->
DescribeSnapshotsResponse' <$>
(x .@? "Snapshots" .!@ mempty >>=
may (parseXMLList "Snapshot"))
<*> (x .@? "Marker")
<*> (pure (fromEnum s)))
instance Hashable DescribeSnapshots
instance NFData DescribeSnapshots
instance ToHeaders DescribeSnapshots where
toHeaders = const mempty
instance ToPath DescribeSnapshots where
toPath = const "/"
instance ToQuery DescribeSnapshots where
toQuery DescribeSnapshots'{..}
= mconcat
["Action" =: ("DescribeSnapshots" :: ByteString),
"Version" =: ("2015-02-02" :: ByteString),
"CacheClusterId" =: _dsCacheClusterId,
"Marker" =: _dsMarker, "MaxRecords" =: _dsMaxRecords,
"SnapshotName" =: _dsSnapshotName,
"SnapshotSource" =: _dsSnapshotSource]
data DescribeSnapshotsResponse = DescribeSnapshotsResponse'
{ _dssrsSnapshots :: !(Maybe [Snapshot])
, _dssrsMarker :: !(Maybe Text)
, _dssrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeSnapshotsResponse
:: Int
-> DescribeSnapshotsResponse
describeSnapshotsResponse pResponseStatus_ =
DescribeSnapshotsResponse'
{ _dssrsSnapshots = Nothing
, _dssrsMarker = Nothing
, _dssrsResponseStatus = pResponseStatus_
}
dssrsSnapshots :: Lens' DescribeSnapshotsResponse [Snapshot]
dssrsSnapshots = lens _dssrsSnapshots (\ s a -> s{_dssrsSnapshots = a}) . _Default . _Coerce;
dssrsMarker :: Lens' DescribeSnapshotsResponse (Maybe Text)
dssrsMarker = lens _dssrsMarker (\ s a -> s{_dssrsMarker = a});
dssrsResponseStatus :: Lens' DescribeSnapshotsResponse Int
dssrsResponseStatus = lens _dssrsResponseStatus (\ s a -> s{_dssrsResponseStatus = a});
instance NFData DescribeSnapshotsResponse