module Network.AWS.KMS.ListKeys
(
listKeys
, ListKeys
, lkMarker
, lkLimit
, listKeysResponse
, ListKeysResponse
, lkrsTruncated
, lkrsKeys
, lkrsNextMarker
, lkrsResponseStatus
) where
import Network.AWS.KMS.Types
import Network.AWS.KMS.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListKeys = ListKeys'
{ _lkMarker :: !(Maybe Text)
, _lkLimit :: !(Maybe Nat)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listKeys
:: ListKeys
listKeys =
ListKeys'
{ _lkMarker = Nothing
, _lkLimit = Nothing
}
lkMarker :: Lens' ListKeys (Maybe Text)
lkMarker = lens _lkMarker (\ s a -> s{_lkMarker = a});
lkLimit :: Lens' ListKeys (Maybe Natural)
lkLimit = lens _lkLimit (\ s a -> s{_lkLimit = a}) . mapping _Nat;
instance AWSPager ListKeys where
page rq rs
| stop (rs ^. lkrsTruncated) = Nothing
| isNothing (rs ^. lkrsNextMarker) = Nothing
| otherwise =
Just $ rq & lkMarker .~ rs ^. lkrsNextMarker
instance AWSRequest ListKeys where
type Rs ListKeys = ListKeysResponse
request = postJSON kms
response
= receiveJSON
(\ s h x ->
ListKeysResponse' <$>
(x .?> "Truncated") <*> (x .?> "Keys" .!@ mempty) <*>
(x .?> "NextMarker")
<*> (pure (fromEnum s)))
instance Hashable ListKeys
instance NFData ListKeys
instance ToHeaders ListKeys where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("TrentService.ListKeys" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListKeys where
toJSON ListKeys'{..}
= object
(catMaybes
[("Marker" .=) <$> _lkMarker,
("Limit" .=) <$> _lkLimit])
instance ToPath ListKeys where
toPath = const "/"
instance ToQuery ListKeys where
toQuery = const mempty
data ListKeysResponse = ListKeysResponse'
{ _lkrsTruncated :: !(Maybe Bool)
, _lkrsKeys :: !(Maybe [KeyListEntry])
, _lkrsNextMarker :: !(Maybe Text)
, _lkrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listKeysResponse
:: Int
-> ListKeysResponse
listKeysResponse pResponseStatus_ =
ListKeysResponse'
{ _lkrsTruncated = Nothing
, _lkrsKeys = Nothing
, _lkrsNextMarker = Nothing
, _lkrsResponseStatus = pResponseStatus_
}
lkrsTruncated :: Lens' ListKeysResponse (Maybe Bool)
lkrsTruncated = lens _lkrsTruncated (\ s a -> s{_lkrsTruncated = a});
lkrsKeys :: Lens' ListKeysResponse [KeyListEntry]
lkrsKeys = lens _lkrsKeys (\ s a -> s{_lkrsKeys = a}) . _Default . _Coerce;
lkrsNextMarker :: Lens' ListKeysResponse (Maybe Text)
lkrsNextMarker = lens _lkrsNextMarker (\ s a -> s{_lkrsNextMarker = a});
lkrsResponseStatus :: Lens' ListKeysResponse Int
lkrsResponseStatus = lens _lkrsResponseStatus (\ s a -> s{_lkrsResponseStatus = a});
instance NFData ListKeysResponse