{-# 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.DynamoDB.ListBackups
(
listBackups
, ListBackups
, lbTimeRangeUpperBound
, lbTimeRangeLowerBound
, lbLimit
, lbExclusiveStartBackupARN
, lbTableName
, listBackupsResponse
, ListBackupsResponse
, lbrsBackupSummaries
, lbrsLastEvaluatedBackupARN
, lbrsResponseStatus
) where
import Network.AWS.DynamoDB.Types
import Network.AWS.DynamoDB.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListBackups = ListBackups'
{ _lbTimeRangeUpperBound :: !(Maybe POSIX)
, _lbTimeRangeLowerBound :: !(Maybe POSIX)
, _lbLimit :: !(Maybe Nat)
, _lbExclusiveStartBackupARN :: !(Maybe Text)
, _lbTableName :: !(Maybe Text)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listBackups
:: ListBackups
listBackups =
ListBackups'
{ _lbTimeRangeUpperBound = Nothing
, _lbTimeRangeLowerBound = Nothing
, _lbLimit = Nothing
, _lbExclusiveStartBackupARN = Nothing
, _lbTableName = Nothing
}
lbTimeRangeUpperBound :: Lens' ListBackups (Maybe UTCTime)
lbTimeRangeUpperBound = lens _lbTimeRangeUpperBound (\ s a -> s{_lbTimeRangeUpperBound = a}) . mapping _Time
lbTimeRangeLowerBound :: Lens' ListBackups (Maybe UTCTime)
lbTimeRangeLowerBound = lens _lbTimeRangeLowerBound (\ s a -> s{_lbTimeRangeLowerBound = a}) . mapping _Time
lbLimit :: Lens' ListBackups (Maybe Natural)
lbLimit = lens _lbLimit (\ s a -> s{_lbLimit = a}) . mapping _Nat
lbExclusiveStartBackupARN :: Lens' ListBackups (Maybe Text)
lbExclusiveStartBackupARN = lens _lbExclusiveStartBackupARN (\ s a -> s{_lbExclusiveStartBackupARN = a})
lbTableName :: Lens' ListBackups (Maybe Text)
lbTableName = lens _lbTableName (\ s a -> s{_lbTableName = a})
instance AWSPager ListBackups where
page rq rs
| stop (rs ^. lbrsLastEvaluatedBackupARN) = Nothing
| stop (rs ^. lbrsBackupSummaries) = Nothing
| otherwise =
Just $ rq &
lbExclusiveStartBackupARN .~
rs ^. lbrsLastEvaluatedBackupARN
instance AWSRequest ListBackups where
type Rs ListBackups = ListBackupsResponse
request = postJSON dynamoDB
response
= receiveJSON
(\ s h x ->
ListBackupsResponse' <$>
(x .?> "BackupSummaries" .!@ mempty) <*>
(x .?> "LastEvaluatedBackupArn")
<*> (pure (fromEnum s)))
instance Hashable ListBackups where
instance NFData ListBackups where
instance ToHeaders ListBackups where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("DynamoDB_20120810.ListBackups" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.0" :: ByteString)])
instance ToJSON ListBackups where
toJSON ListBackups'{..}
= object
(catMaybes
[("TimeRangeUpperBound" .=) <$>
_lbTimeRangeUpperBound,
("TimeRangeLowerBound" .=) <$>
_lbTimeRangeLowerBound,
("Limit" .=) <$> _lbLimit,
("ExclusiveStartBackupArn" .=) <$>
_lbExclusiveStartBackupARN,
("TableName" .=) <$> _lbTableName])
instance ToPath ListBackups where
toPath = const "/"
instance ToQuery ListBackups where
toQuery = const mempty
data ListBackupsResponse = ListBackupsResponse'
{ _lbrsBackupSummaries :: !(Maybe [BackupSummary])
, _lbrsLastEvaluatedBackupARN :: !(Maybe Text)
, _lbrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listBackupsResponse
:: Int
-> ListBackupsResponse
listBackupsResponse pResponseStatus_ =
ListBackupsResponse'
{ _lbrsBackupSummaries = Nothing
, _lbrsLastEvaluatedBackupARN = Nothing
, _lbrsResponseStatus = pResponseStatus_
}
lbrsBackupSummaries :: Lens' ListBackupsResponse [BackupSummary]
lbrsBackupSummaries = lens _lbrsBackupSummaries (\ s a -> s{_lbrsBackupSummaries = a}) . _Default . _Coerce
lbrsLastEvaluatedBackupARN :: Lens' ListBackupsResponse (Maybe Text)
lbrsLastEvaluatedBackupARN = lens _lbrsLastEvaluatedBackupARN (\ s a -> s{_lbrsLastEvaluatedBackupARN = a})
lbrsResponseStatus :: Lens' ListBackupsResponse Int
lbrsResponseStatus = lens _lbrsResponseStatus (\ s a -> s{_lbrsResponseStatus = a})
instance NFData ListBackupsResponse where