module Network.AWS.KMS.GetKeyPolicy
(
getKeyPolicy
, GetKeyPolicy
, gkpKeyId
, gkpPolicyName
, getKeyPolicyResponse
, GetKeyPolicyResponse
, gkprsPolicy
, gkprsResponseStatus
) where
import Network.AWS.KMS.Types
import Network.AWS.KMS.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetKeyPolicy = GetKeyPolicy'
{ _gkpKeyId :: !Text
, _gkpPolicyName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getKeyPolicy
:: Text
-> Text
-> GetKeyPolicy
getKeyPolicy pKeyId_ pPolicyName_ =
GetKeyPolicy'
{ _gkpKeyId = pKeyId_
, _gkpPolicyName = pPolicyName_
}
gkpKeyId :: Lens' GetKeyPolicy Text
gkpKeyId = lens _gkpKeyId (\ s a -> s{_gkpKeyId = a});
gkpPolicyName :: Lens' GetKeyPolicy Text
gkpPolicyName = lens _gkpPolicyName (\ s a -> s{_gkpPolicyName = a});
instance AWSRequest GetKeyPolicy where
type Rs GetKeyPolicy = GetKeyPolicyResponse
request = postJSON kMS
response
= receiveJSON
(\ s h x ->
GetKeyPolicyResponse' <$>
(x .?> "Policy") <*> (pure (fromEnum s)))
instance ToHeaders GetKeyPolicy where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("TrentService.GetKeyPolicy" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetKeyPolicy where
toJSON GetKeyPolicy'{..}
= object
(catMaybes
[Just ("KeyId" .= _gkpKeyId),
Just ("PolicyName" .= _gkpPolicyName)])
instance ToPath GetKeyPolicy where
toPath = const "/"
instance ToQuery GetKeyPolicy where
toQuery = const mempty
data GetKeyPolicyResponse = GetKeyPolicyResponse'
{ _gkprsPolicy :: !(Maybe Text)
, _gkprsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getKeyPolicyResponse
:: Int
-> GetKeyPolicyResponse
getKeyPolicyResponse pResponseStatus_ =
GetKeyPolicyResponse'
{ _gkprsPolicy = Nothing
, _gkprsResponseStatus = pResponseStatus_
}
gkprsPolicy :: Lens' GetKeyPolicyResponse (Maybe Text)
gkprsPolicy = lens _gkprsPolicy (\ s a -> s{_gkprsPolicy = a});
gkprsResponseStatus :: Lens' GetKeyPolicyResponse Int
gkprsResponseStatus = lens _gkprsResponseStatus (\ s a -> s{_gkprsResponseStatus = a});