{-# 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.CloudHSMv2.DescribeBackups
(
describeBackups
, DescribeBackups
, dbFilters
, dbNextToken
, dbMaxResults
, describeBackupsResponse
, DescribeBackupsResponse
, dbrsBackups
, dbrsNextToken
, dbrsResponseStatus
) where
import Network.AWS.CloudHSMv2.Types
import Network.AWS.CloudHSMv2.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data DescribeBackups = DescribeBackups'
{ _dbFilters :: !(Maybe (Map Text [Text]))
, _dbNextToken :: !(Maybe Text)
, _dbMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeBackups
:: DescribeBackups
describeBackups =
DescribeBackups'
{_dbFilters = Nothing, _dbNextToken = Nothing, _dbMaxResults = Nothing}
dbFilters :: Lens' DescribeBackups (HashMap Text [Text])
dbFilters = lens _dbFilters (\ s a -> s{_dbFilters = a}) . _Default . _Map
dbNextToken :: Lens' DescribeBackups (Maybe Text)
dbNextToken = lens _dbNextToken (\ s a -> s{_dbNextToken = a})
dbMaxResults :: Lens' DescribeBackups (Maybe Natural)
dbMaxResults = lens _dbMaxResults (\ s a -> s{_dbMaxResults = a}) . mapping _Nat
instance AWSPager DescribeBackups where
page rq rs
| stop (rs ^. dbrsNextToken) = Nothing
| stop (rs ^. dbrsBackups) = Nothing
| otherwise =
Just $ rq & dbNextToken .~ rs ^. dbrsNextToken
instance AWSRequest DescribeBackups where
type Rs DescribeBackups = DescribeBackupsResponse
request = postJSON cloudHSMv2
response
= receiveJSON
(\ s h x ->
DescribeBackupsResponse' <$>
(x .?> "Backups" .!@ mempty) <*> (x .?> "NextToken")
<*> (pure (fromEnum s)))
instance Hashable DescribeBackups where
instance NFData DescribeBackups where
instance ToHeaders DescribeBackups where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("BaldrApiService.DescribeBackups" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON DescribeBackups where
toJSON DescribeBackups'{..}
= object
(catMaybes
[("Filters" .=) <$> _dbFilters,
("NextToken" .=) <$> _dbNextToken,
("MaxResults" .=) <$> _dbMaxResults])
instance ToPath DescribeBackups where
toPath = const "/"
instance ToQuery DescribeBackups where
toQuery = const mempty
data DescribeBackupsResponse = DescribeBackupsResponse'
{ _dbrsBackups :: !(Maybe [Backup])
, _dbrsNextToken :: !(Maybe Text)
, _dbrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeBackupsResponse
:: Int
-> DescribeBackupsResponse
describeBackupsResponse pResponseStatus_ =
DescribeBackupsResponse'
{ _dbrsBackups = Nothing
, _dbrsNextToken = Nothing
, _dbrsResponseStatus = pResponseStatus_
}
dbrsBackups :: Lens' DescribeBackupsResponse [Backup]
dbrsBackups = lens _dbrsBackups (\ s a -> s{_dbrsBackups = a}) . _Default . _Coerce
dbrsNextToken :: Lens' DescribeBackupsResponse (Maybe Text)
dbrsNextToken = lens _dbrsNextToken (\ s a -> s{_dbrsNextToken = a})
dbrsResponseStatus :: Lens' DescribeBackupsResponse Int
dbrsResponseStatus = lens _dbrsResponseStatus (\ s a -> s{_dbrsResponseStatus = a})
instance NFData DescribeBackupsResponse where