module Network.AWS.IoT.CreatePolicyVersion
(
createPolicyVersion
, CreatePolicyVersion
, cpvSetAsDefault
, cpvPolicyName
, cpvPolicyDocument
, createPolicyVersionResponse
, CreatePolicyVersionResponse
, cpvrsPolicyDocument
, cpvrsPolicyVersionId
, cpvrsPolicyARN
, cpvrsIsDefaultVersion
, cpvrsResponseStatus
) where
import Network.AWS.IoT.Types
import Network.AWS.IoT.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreatePolicyVersion = CreatePolicyVersion'
{ _cpvSetAsDefault :: !(Maybe Bool)
, _cpvPolicyName :: !Text
, _cpvPolicyDocument :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createPolicyVersion
:: Text
-> Text
-> CreatePolicyVersion
createPolicyVersion pPolicyName_ pPolicyDocument_ =
CreatePolicyVersion'
{ _cpvSetAsDefault = Nothing
, _cpvPolicyName = pPolicyName_
, _cpvPolicyDocument = pPolicyDocument_
}
cpvSetAsDefault :: Lens' CreatePolicyVersion (Maybe Bool)
cpvSetAsDefault = lens _cpvSetAsDefault (\ s a -> s{_cpvSetAsDefault = a});
cpvPolicyName :: Lens' CreatePolicyVersion Text
cpvPolicyName = lens _cpvPolicyName (\ s a -> s{_cpvPolicyName = a});
cpvPolicyDocument :: Lens' CreatePolicyVersion Text
cpvPolicyDocument = lens _cpvPolicyDocument (\ s a -> s{_cpvPolicyDocument = a});
instance AWSRequest CreatePolicyVersion where
type Rs CreatePolicyVersion =
CreatePolicyVersionResponse
request = postJSON ioT
response
= receiveJSON
(\ s h x ->
CreatePolicyVersionResponse' <$>
(x .?> "policyDocument") <*>
(x .?> "policyVersionId")
<*> (x .?> "policyArn")
<*> (x .?> "isDefaultVersion")
<*> (pure (fromEnum s)))
instance ToHeaders CreatePolicyVersion where
toHeaders = const mempty
instance ToJSON CreatePolicyVersion where
toJSON CreatePolicyVersion'{..}
= object
(catMaybes
[Just ("policyDocument" .= _cpvPolicyDocument)])
instance ToPath CreatePolicyVersion where
toPath CreatePolicyVersion'{..}
= mconcat
["/policies/", toBS _cpvPolicyName, "/version"]
instance ToQuery CreatePolicyVersion where
toQuery CreatePolicyVersion'{..}
= mconcat ["setAsDefault" =: _cpvSetAsDefault]
data CreatePolicyVersionResponse = CreatePolicyVersionResponse'
{ _cpvrsPolicyDocument :: !(Maybe Text)
, _cpvrsPolicyVersionId :: !(Maybe Text)
, _cpvrsPolicyARN :: !(Maybe Text)
, _cpvrsIsDefaultVersion :: !(Maybe Bool)
, _cpvrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createPolicyVersionResponse
:: Int
-> CreatePolicyVersionResponse
createPolicyVersionResponse pResponseStatus_ =
CreatePolicyVersionResponse'
{ _cpvrsPolicyDocument = Nothing
, _cpvrsPolicyVersionId = Nothing
, _cpvrsPolicyARN = Nothing
, _cpvrsIsDefaultVersion = Nothing
, _cpvrsResponseStatus = pResponseStatus_
}
cpvrsPolicyDocument :: Lens' CreatePolicyVersionResponse (Maybe Text)
cpvrsPolicyDocument = lens _cpvrsPolicyDocument (\ s a -> s{_cpvrsPolicyDocument = a});
cpvrsPolicyVersionId :: Lens' CreatePolicyVersionResponse (Maybe Text)
cpvrsPolicyVersionId = lens _cpvrsPolicyVersionId (\ s a -> s{_cpvrsPolicyVersionId = a});
cpvrsPolicyARN :: Lens' CreatePolicyVersionResponse (Maybe Text)
cpvrsPolicyARN = lens _cpvrsPolicyARN (\ s a -> s{_cpvrsPolicyARN = a});
cpvrsIsDefaultVersion :: Lens' CreatePolicyVersionResponse (Maybe Bool)
cpvrsIsDefaultVersion = lens _cpvrsIsDefaultVersion (\ s a -> s{_cpvrsIsDefaultVersion = a});
cpvrsResponseStatus :: Lens' CreatePolicyVersionResponse Int
cpvrsResponseStatus = lens _cpvrsResponseStatus (\ s a -> s{_cpvrsResponseStatus = a});