{-# 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.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 :: !Text
, _apPolicyReference :: !ObjectReference
, _apObjectReference :: !ObjectReference
} deriving (Eq, Read, Show, Data, Typeable, Generic)
attachPolicy
:: Text
-> ObjectReference
-> ObjectReference
-> AttachPolicy
attachPolicy pDirectoryARN_ pPolicyReference_ pObjectReference_ =
AttachPolicy'
{ _apDirectoryARN = pDirectoryARN_
, _apPolicyReference = pPolicyReference_
, _apObjectReference = pObjectReference_
}
apDirectoryARN :: Lens' AttachPolicy 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