{-# 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.GetKeyPolicy
(
getKeyPolicy
, GetKeyPolicy
, gkpKeyId
, gkpPolicyName
, getKeyPolicyResponse
, GetKeyPolicyResponse
, gkprsPolicy
, gkprsResponseStatus
) where
import Network.AWS.KMS.Types
import Network.AWS.KMS.Types.Product
import Network.AWS.Lens
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 Hashable GetKeyPolicy where
instance NFData GetKeyPolicy where
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})
instance NFData GetKeyPolicyResponse where