module Network.AWS.IoT.CreatePolicy
(
createPolicy
, CreatePolicy
, cpPolicyName
, cpPolicyDocument
, createPolicyResponse
, CreatePolicyResponse
, cprsPolicyName
, cprsPolicyDocument
, cprsPolicyVersionId
, cprsPolicyARN
, cprsResponseStatus
) 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
data CreatePolicy = CreatePolicy'
{ _cpPolicyName :: !Text
, _cpPolicyDocument :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createPolicy
:: Text
-> Text
-> CreatePolicy
createPolicy pPolicyName_ pPolicyDocument_ =
CreatePolicy'
{ _cpPolicyName = pPolicyName_
, _cpPolicyDocument = pPolicyDocument_
}
cpPolicyName :: Lens' CreatePolicy Text
cpPolicyName = lens _cpPolicyName (\ s a -> s{_cpPolicyName = a});
cpPolicyDocument :: Lens' CreatePolicy Text
cpPolicyDocument = lens _cpPolicyDocument (\ s a -> s{_cpPolicyDocument = a});
instance AWSRequest CreatePolicy where
type Rs CreatePolicy = CreatePolicyResponse
request = postJSON ioT
response
= receiveJSON
(\ s h x ->
CreatePolicyResponse' <$>
(x .?> "policyName") <*> (x .?> "policyDocument") <*>
(x .?> "policyVersionId")
<*> (x .?> "policyArn")
<*> (pure (fromEnum s)))
instance Hashable CreatePolicy
instance NFData CreatePolicy
instance ToHeaders CreatePolicy where
toHeaders = const mempty
instance ToJSON CreatePolicy where
toJSON CreatePolicy'{..}
= object
(catMaybes
[Just ("policyDocument" .= _cpPolicyDocument)])
instance ToPath CreatePolicy where
toPath CreatePolicy'{..}
= mconcat ["/policies/", toBS _cpPolicyName]
instance ToQuery CreatePolicy where
toQuery = const mempty
data CreatePolicyResponse = CreatePolicyResponse'
{ _cprsPolicyName :: !(Maybe Text)
, _cprsPolicyDocument :: !(Maybe Text)
, _cprsPolicyVersionId :: !(Maybe Text)
, _cprsPolicyARN :: !(Maybe Text)
, _cprsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createPolicyResponse
:: Int
-> CreatePolicyResponse
createPolicyResponse pResponseStatus_ =
CreatePolicyResponse'
{ _cprsPolicyName = Nothing
, _cprsPolicyDocument = Nothing
, _cprsPolicyVersionId = Nothing
, _cprsPolicyARN = Nothing
, _cprsResponseStatus = pResponseStatus_
}
cprsPolicyName :: Lens' CreatePolicyResponse (Maybe Text)
cprsPolicyName = lens _cprsPolicyName (\ s a -> s{_cprsPolicyName = a});
cprsPolicyDocument :: Lens' CreatePolicyResponse (Maybe Text)
cprsPolicyDocument = lens _cprsPolicyDocument (\ s a -> s{_cprsPolicyDocument = a});
cprsPolicyVersionId :: Lens' CreatePolicyResponse (Maybe Text)
cprsPolicyVersionId = lens _cprsPolicyVersionId (\ s a -> s{_cprsPolicyVersionId = a});
cprsPolicyARN :: Lens' CreatePolicyResponse (Maybe Text)
cprsPolicyARN = lens _cprsPolicyARN (\ s a -> s{_cprsPolicyARN = a});
cprsResponseStatus :: Lens' CreatePolicyResponse Int
cprsResponseStatus = lens _cprsResponseStatus (\ s a -> s{_cprsResponseStatus = a});
instance NFData CreatePolicyResponse