{-# 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.GetEffectivePolicies
(
getEffectivePolicies
, GetEffectivePolicies
, gepPrincipal
, gepCognitoIdentityPoolId
, gepThingName
, getEffectivePoliciesResponse
, GetEffectivePoliciesResponse
, geprsEffectivePolicies
, geprsResponseStatus
) 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 GetEffectivePolicies = GetEffectivePolicies'
{ _gepPrincipal :: !(Maybe Text)
, _gepCognitoIdentityPoolId :: !(Maybe Text)
, _gepThingName :: !(Maybe Text)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getEffectivePolicies
:: GetEffectivePolicies
getEffectivePolicies =
GetEffectivePolicies'
{ _gepPrincipal = Nothing
, _gepCognitoIdentityPoolId = Nothing
, _gepThingName = Nothing
}
gepPrincipal :: Lens' GetEffectivePolicies (Maybe Text)
gepPrincipal = lens _gepPrincipal (\ s a -> s{_gepPrincipal = a})
gepCognitoIdentityPoolId :: Lens' GetEffectivePolicies (Maybe Text)
gepCognitoIdentityPoolId = lens _gepCognitoIdentityPoolId (\ s a -> s{_gepCognitoIdentityPoolId = a})
gepThingName :: Lens' GetEffectivePolicies (Maybe Text)
gepThingName = lens _gepThingName (\ s a -> s{_gepThingName = a})
instance AWSRequest GetEffectivePolicies where
type Rs GetEffectivePolicies =
GetEffectivePoliciesResponse
request = postJSON ioT
response
= receiveJSON
(\ s h x ->
GetEffectivePoliciesResponse' <$>
(x .?> "effectivePolicies" .!@ mempty) <*>
(pure (fromEnum s)))
instance Hashable GetEffectivePolicies where
instance NFData GetEffectivePolicies where
instance ToHeaders GetEffectivePolicies where
toHeaders = const mempty
instance ToJSON GetEffectivePolicies where
toJSON GetEffectivePolicies'{..}
= object
(catMaybes
[("principal" .=) <$> _gepPrincipal,
("cognitoIdentityPoolId" .=) <$>
_gepCognitoIdentityPoolId])
instance ToPath GetEffectivePolicies where
toPath = const "/effective-policies"
instance ToQuery GetEffectivePolicies where
toQuery GetEffectivePolicies'{..}
= mconcat ["thingName" =: _gepThingName]
data GetEffectivePoliciesResponse = GetEffectivePoliciesResponse'
{ _geprsEffectivePolicies :: !(Maybe [EffectivePolicy])
, _geprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getEffectivePoliciesResponse
:: Int
-> GetEffectivePoliciesResponse
getEffectivePoliciesResponse pResponseStatus_ =
GetEffectivePoliciesResponse'
{_geprsEffectivePolicies = Nothing, _geprsResponseStatus = pResponseStatus_}
geprsEffectivePolicies :: Lens' GetEffectivePoliciesResponse [EffectivePolicy]
geprsEffectivePolicies = lens _geprsEffectivePolicies (\ s a -> s{_geprsEffectivePolicies = a}) . _Default . _Coerce
geprsResponseStatus :: Lens' GetEffectivePoliciesResponse Int
geprsResponseStatus = lens _geprsResponseStatus (\ s a -> s{_geprsResponseStatus = a})
instance NFData GetEffectivePoliciesResponse where