module Network.AWS.KMS.DescribeKey
(
describeKey
, DescribeKey
, dGrantTokens
, dKeyId
, describeKeyResponse
, DescribeKeyResponse
, dkrsKeyMetadata
, dkrsResponseStatus
) 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 DescribeKey = DescribeKey'
{ _dGrantTokens :: !(Maybe [Text])
, _dKeyId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeKey
:: Text
-> DescribeKey
describeKey pKeyId_ =
DescribeKey'
{ _dGrantTokens = Nothing
, _dKeyId = pKeyId_
}
dGrantTokens :: Lens' DescribeKey [Text]
dGrantTokens = lens _dGrantTokens (\ s a -> s{_dGrantTokens = a}) . _Default . _Coerce;
dKeyId :: Lens' DescribeKey Text
dKeyId = lens _dKeyId (\ s a -> s{_dKeyId = a});
instance AWSRequest DescribeKey where
type Rs DescribeKey = DescribeKeyResponse
request = postJSON kms
response
= receiveJSON
(\ s h x ->
DescribeKeyResponse' <$>
(x .?> "KeyMetadata") <*> (pure (fromEnum s)))
instance Hashable DescribeKey
instance NFData DescribeKey
instance ToHeaders DescribeKey where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("TrentService.DescribeKey" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON DescribeKey where
toJSON DescribeKey'{..}
= object
(catMaybes
[("GrantTokens" .=) <$> _dGrantTokens,
Just ("KeyId" .= _dKeyId)])
instance ToPath DescribeKey where
toPath = const "/"
instance ToQuery DescribeKey where
toQuery = const mempty
data DescribeKeyResponse = DescribeKeyResponse'
{ _dkrsKeyMetadata :: !(Maybe KeyMetadata)
, _dkrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeKeyResponse
:: Int
-> DescribeKeyResponse
describeKeyResponse pResponseStatus_ =
DescribeKeyResponse'
{ _dkrsKeyMetadata = Nothing
, _dkrsResponseStatus = pResponseStatus_
}
dkrsKeyMetadata :: Lens' DescribeKeyResponse (Maybe KeyMetadata)
dkrsKeyMetadata = lens _dkrsKeyMetadata (\ s a -> s{_dkrsKeyMetadata = a});
dkrsResponseStatus :: Lens' DescribeKeyResponse Int
dkrsResponseStatus = lens _dkrsResponseStatus (\ s a -> s{_dkrsResponseStatus = a});
instance NFData DescribeKeyResponse