{-# 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.IoT.GetPolicy
(
getPolicy
, GetPolicy
, gpPolicyName
, getPolicyResponse
, GetPolicyResponse
, gprsLastModifiedDate
, gprsPolicyName
, gprsPolicyDocument
, gprsDefaultVersionId
, gprsPolicyARN
, gprsCreationDate
, gprsGenerationId
, gprsResponseStatus
) where
import Network.AWS.IoT.Types
import Network.AWS.IoT.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
newtype GetPolicy = GetPolicy'
{ _gpPolicyName :: Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getPolicy
:: Text
-> GetPolicy
getPolicy pPolicyName_ = GetPolicy' {_gpPolicyName = pPolicyName_}
gpPolicyName :: Lens' GetPolicy Text
gpPolicyName = lens _gpPolicyName (\ s a -> s{_gpPolicyName = a})
instance AWSRequest GetPolicy where
type Rs GetPolicy = GetPolicyResponse
request = get ioT
response
= receiveJSON
(\ s h x ->
GetPolicyResponse' <$>
(x .?> "lastModifiedDate") <*> (x .?> "policyName")
<*> (x .?> "policyDocument")
<*> (x .?> "defaultVersionId")
<*> (x .?> "policyArn")
<*> (x .?> "creationDate")
<*> (x .?> "generationId")
<*> (pure (fromEnum s)))
instance Hashable GetPolicy where
instance NFData GetPolicy where
instance ToHeaders GetPolicy where
toHeaders = const mempty
instance ToPath GetPolicy where
toPath GetPolicy'{..}
= mconcat ["/policies/", toBS _gpPolicyName]
instance ToQuery GetPolicy where
toQuery = const mempty
data GetPolicyResponse = GetPolicyResponse'
{ _gprsLastModifiedDate :: !(Maybe POSIX)
, _gprsPolicyName :: !(Maybe Text)
, _gprsPolicyDocument :: !(Maybe Text)
, _gprsDefaultVersionId :: !(Maybe Text)
, _gprsPolicyARN :: !(Maybe Text)
, _gprsCreationDate :: !(Maybe POSIX)
, _gprsGenerationId :: !(Maybe Text)
, _gprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getPolicyResponse
:: Int
-> GetPolicyResponse
getPolicyResponse pResponseStatus_ =
GetPolicyResponse'
{ _gprsLastModifiedDate = Nothing
, _gprsPolicyName = Nothing
, _gprsPolicyDocument = Nothing
, _gprsDefaultVersionId = Nothing
, _gprsPolicyARN = Nothing
, _gprsCreationDate = Nothing
, _gprsGenerationId = Nothing
, _gprsResponseStatus = pResponseStatus_
}
gprsLastModifiedDate :: Lens' GetPolicyResponse (Maybe UTCTime)
gprsLastModifiedDate = lens _gprsLastModifiedDate (\ s a -> s{_gprsLastModifiedDate = a}) . mapping _Time
gprsPolicyName :: Lens' GetPolicyResponse (Maybe Text)
gprsPolicyName = lens _gprsPolicyName (\ s a -> s{_gprsPolicyName = a})
gprsPolicyDocument :: Lens' GetPolicyResponse (Maybe Text)
gprsPolicyDocument = lens _gprsPolicyDocument (\ s a -> s{_gprsPolicyDocument = a})
gprsDefaultVersionId :: Lens' GetPolicyResponse (Maybe Text)
gprsDefaultVersionId = lens _gprsDefaultVersionId (\ s a -> s{_gprsDefaultVersionId = a})
gprsPolicyARN :: Lens' GetPolicyResponse (Maybe Text)
gprsPolicyARN = lens _gprsPolicyARN (\ s a -> s{_gprsPolicyARN = a})
gprsCreationDate :: Lens' GetPolicyResponse (Maybe UTCTime)
gprsCreationDate = lens _gprsCreationDate (\ s a -> s{_gprsCreationDate = a}) . mapping _Time
gprsGenerationId :: Lens' GetPolicyResponse (Maybe Text)
gprsGenerationId = lens _gprsGenerationId (\ s a -> s{_gprsGenerationId = a})
gprsResponseStatus :: Lens' GetPolicyResponse Int
gprsResponseStatus = lens _gprsResponseStatus (\ s a -> s{_gprsResponseStatus = a})
instance NFData GetPolicyResponse where