{-# 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.KMS.ListGrants
(
listGrants
, ListGrants
, lgMarker
, lgLimit
, lgKeyId
, listGrantsResponse
, ListGrantsResponse
, lgTruncated
, lgGrants
, lgNextMarker
) 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 ListGrants = ListGrants'
{ _lgMarker :: !(Maybe Text)
, _lgLimit :: !(Maybe Nat)
, _lgKeyId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
listGrants
:: Text
-> ListGrants
listGrants pKeyId_ =
ListGrants'
{ _lgMarker = Nothing
, _lgLimit = Nothing
, _lgKeyId = pKeyId_
}
lgMarker :: Lens' ListGrants (Maybe Text)
lgMarker = lens _lgMarker (\ s a -> s{_lgMarker = a});
lgLimit :: Lens' ListGrants (Maybe Natural)
lgLimit = lens _lgLimit (\ s a -> s{_lgLimit = a}) . mapping _Nat;
lgKeyId :: Lens' ListGrants Text
lgKeyId = lens _lgKeyId (\ s a -> s{_lgKeyId = a});
instance AWSPager ListGrants where
page rq rs
| stop (rs ^. lgTruncated) = Nothing
| isNothing (rs ^. lgNextMarker) = Nothing
| otherwise =
Just $ rq & lgMarker .~ rs ^. lgNextMarker
instance AWSRequest ListGrants where
type Rs ListGrants = ListGrantsResponse
request = postJSON kms
response = receiveJSON (\ s h x -> eitherParseJSON x)
instance Hashable ListGrants
instance NFData ListGrants
instance ToHeaders ListGrants where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("TrentService.ListGrants" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListGrants where
toJSON ListGrants'{..}
= object
(catMaybes
[("Marker" .=) <$> _lgMarker,
("Limit" .=) <$> _lgLimit,
Just ("KeyId" .= _lgKeyId)])
instance ToPath ListGrants where
toPath = const "/"
instance ToQuery ListGrants where
toQuery = const mempty