module Network.AWS.KMS.ListKeyPolicies
(
listKeyPolicies
, ListKeyPolicies
, lkpMarker
, lkpLimit
, lkpKeyId
, listKeyPoliciesResponse
, ListKeyPoliciesResponse
, lkprsPolicyNames
, lkprsTruncated
, lkprsNextMarker
, lkprsResponseStatus
) 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 ListKeyPolicies = ListKeyPolicies'
{ _lkpMarker :: !(Maybe Text)
, _lkpLimit :: !(Maybe Nat)
, _lkpKeyId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listKeyPolicies
:: Text
-> ListKeyPolicies
listKeyPolicies pKeyId_ =
ListKeyPolicies'
{ _lkpMarker = Nothing
, _lkpLimit = Nothing
, _lkpKeyId = pKeyId_
}
lkpMarker :: Lens' ListKeyPolicies (Maybe Text)
lkpMarker = lens _lkpMarker (\ s a -> s{_lkpMarker = a});
lkpLimit :: Lens' ListKeyPolicies (Maybe Natural)
lkpLimit = lens _lkpLimit (\ s a -> s{_lkpLimit = a}) . mapping _Nat;
lkpKeyId :: Lens' ListKeyPolicies Text
lkpKeyId = lens _lkpKeyId (\ s a -> s{_lkpKeyId = a});
instance AWSPager ListKeyPolicies where
page rq rs
| stop (rs ^. lkprsTruncated) = Nothing
| isNothing (rs ^. lkprsNextMarker) = Nothing
| otherwise =
Just $ rq & lkpMarker .~ rs ^. lkprsNextMarker
instance AWSRequest ListKeyPolicies where
type Rs ListKeyPolicies = ListKeyPoliciesResponse
request = postJSON kms
response
= receiveJSON
(\ s h x ->
ListKeyPoliciesResponse' <$>
(x .?> "PolicyNames" .!@ mempty) <*>
(x .?> "Truncated")
<*> (x .?> "NextMarker")
<*> (pure (fromEnum s)))
instance Hashable ListKeyPolicies
instance ToHeaders ListKeyPolicies where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("TrentService.ListKeyPolicies" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListKeyPolicies where
toJSON ListKeyPolicies'{..}
= object
(catMaybes
[("Marker" .=) <$> _lkpMarker,
("Limit" .=) <$> _lkpLimit,
Just ("KeyId" .= _lkpKeyId)])
instance ToPath ListKeyPolicies where
toPath = const "/"
instance ToQuery ListKeyPolicies where
toQuery = const mempty
data ListKeyPoliciesResponse = ListKeyPoliciesResponse'
{ _lkprsPolicyNames :: !(Maybe [Text])
, _lkprsTruncated :: !(Maybe Bool)
, _lkprsNextMarker :: !(Maybe Text)
, _lkprsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listKeyPoliciesResponse
:: Int
-> ListKeyPoliciesResponse
listKeyPoliciesResponse pResponseStatus_ =
ListKeyPoliciesResponse'
{ _lkprsPolicyNames = Nothing
, _lkprsTruncated = Nothing
, _lkprsNextMarker = Nothing
, _lkprsResponseStatus = pResponseStatus_
}
lkprsPolicyNames :: Lens' ListKeyPoliciesResponse [Text]
lkprsPolicyNames = lens _lkprsPolicyNames (\ s a -> s{_lkprsPolicyNames = a}) . _Default . _Coerce;
lkprsTruncated :: Lens' ListKeyPoliciesResponse (Maybe Bool)
lkprsTruncated = lens _lkprsTruncated (\ s a -> s{_lkprsTruncated = a});
lkprsNextMarker :: Lens' ListKeyPoliciesResponse (Maybe Text)
lkprsNextMarker = lens _lkprsNextMarker (\ s a -> s{_lkprsNextMarker = a});
lkprsResponseStatus :: Lens' ListKeyPoliciesResponse Int
lkprsResponseStatus = lens _lkprsResponseStatus (\ s a -> s{_lkprsResponseStatus = a});