module Network.AWS.CloudDirectory.AttachPolicy
(
attachPolicy
, AttachPolicy
, apDirectoryARN
, apPolicyReference
, apObjectReference
, attachPolicyResponse
, AttachPolicyResponse
, aprsResponseStatus
) where
import Network.AWS.CloudDirectory.Types
import Network.AWS.CloudDirectory.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data AttachPolicy = AttachPolicy'
{ _apDirectoryARN :: !(Maybe Text)
, _apPolicyReference :: !ObjectReference
, _apObjectReference :: !ObjectReference
} deriving (Eq, Read, Show, Data, Typeable, Generic)
attachPolicy
:: ObjectReference
-> ObjectReference
-> AttachPolicy
attachPolicy pPolicyReference_ pObjectReference_ =
AttachPolicy'
{ _apDirectoryARN = Nothing
, _apPolicyReference = pPolicyReference_
, _apObjectReference = pObjectReference_
}
apDirectoryARN :: Lens' AttachPolicy (Maybe Text)
apDirectoryARN = lens _apDirectoryARN (\ s a -> s{_apDirectoryARN = a});
apPolicyReference :: Lens' AttachPolicy ObjectReference
apPolicyReference = lens _apPolicyReference (\ s a -> s{_apPolicyReference = a});
apObjectReference :: Lens' AttachPolicy ObjectReference
apObjectReference = lens _apObjectReference (\ s a -> s{_apObjectReference = a});
instance AWSRequest AttachPolicy where
type Rs AttachPolicy = AttachPolicyResponse
request = putJSON cloudDirectory
response
= receiveEmpty
(\ s h x ->
AttachPolicyResponse' <$> (pure (fromEnum s)))
instance Hashable AttachPolicy where
instance NFData AttachPolicy where
instance ToHeaders AttachPolicy where
toHeaders AttachPolicy'{..}
= mconcat ["x-amz-data-partition" =# _apDirectoryARN]
instance ToJSON AttachPolicy where
toJSON AttachPolicy'{..}
= object
(catMaybes
[Just ("PolicyReference" .= _apPolicyReference),
Just ("ObjectReference" .= _apObjectReference)])
instance ToPath AttachPolicy where
toPath
= const
"/amazonclouddirectory/2017-01-11/policy/attach"
instance ToQuery AttachPolicy where
toQuery = const mempty
newtype AttachPolicyResponse = AttachPolicyResponse'
{ _aprsResponseStatus :: Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
attachPolicyResponse
:: Int
-> AttachPolicyResponse
attachPolicyResponse pResponseStatus_ =
AttachPolicyResponse' {_aprsResponseStatus = pResponseStatus_}
aprsResponseStatus :: Lens' AttachPolicyResponse Int
aprsResponseStatus = lens _aprsResponseStatus (\ s a -> s{_aprsResponseStatus = a});
instance NFData AttachPolicyResponse where