module Network.AWS.S3.GetBucketACL
(
getBucketACL
, GetBucketACL
, gbaBucket
, getBucketACLResponse
, GetBucketACLResponse
, gbarsGrants
, gbarsOwner
, gbarsStatus
) where
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.S3.Types
import Network.AWS.S3.Types.Product
newtype GetBucketACL = GetBucketACL'
{ _gbaBucket :: BucketName
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getBucketACL
:: BucketName
-> GetBucketACL
getBucketACL pBucket_ =
GetBucketACL'
{ _gbaBucket = pBucket_
}
gbaBucket :: Lens' GetBucketACL BucketName
gbaBucket = lens _gbaBucket (\ s a -> s{_gbaBucket = a});
instance AWSRequest GetBucketACL where
type Rs GetBucketACL = GetBucketACLResponse
request = get s3
response
= receiveXML
(\ s h x ->
GetBucketACLResponse' <$>
(x .@? "AccessControlList" .!@ mempty >>=
may (parseXMLList "Grant"))
<*> (x .@? "Owner")
<*> (pure (fromEnum s)))
instance ToHeaders GetBucketACL where
toHeaders = const mempty
instance ToPath GetBucketACL where
toPath GetBucketACL'{..}
= mconcat ["/", toBS _gbaBucket]
instance ToQuery GetBucketACL where
toQuery = const (mconcat ["acl"])
data GetBucketACLResponse = GetBucketACLResponse'
{ _gbarsGrants :: !(Maybe [Grant])
, _gbarsOwner :: !(Maybe Owner)
, _gbarsStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getBucketACLResponse
:: Int
-> GetBucketACLResponse
getBucketACLResponse pStatus_ =
GetBucketACLResponse'
{ _gbarsGrants = Nothing
, _gbarsOwner = Nothing
, _gbarsStatus = pStatus_
}
gbarsGrants :: Lens' GetBucketACLResponse [Grant]
gbarsGrants = lens _gbarsGrants (\ s a -> s{_gbarsGrants = a}) . _Default . _Coerce;
gbarsOwner :: Lens' GetBucketACLResponse (Maybe Owner)
gbarsOwner = lens _gbarsOwner (\ s a -> s{_gbarsOwner = a});
gbarsStatus :: Lens' GetBucketACLResponse Int
gbarsStatus = lens _gbarsStatus (\ s a -> s{_gbarsStatus = a});