module Network.AWS.S3.GetBucketLocation
(
getBucketLocation
, GetBucketLocation
, gblBucket
, getBucketLocationResponse
, GetBucketLocationResponse
, getrsLocationConstraint
, getrsResponseStatus
) 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 GetBucketLocation = GetBucketLocation'
{ _gblBucket :: BucketName
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getBucketLocation
:: BucketName
-> GetBucketLocation
getBucketLocation pBucket_ =
GetBucketLocation'
{ _gblBucket = pBucket_
}
gblBucket :: Lens' GetBucketLocation BucketName
gblBucket = lens _gblBucket (\ s a -> s{_gblBucket = a});
instance AWSRequest GetBucketLocation where
type Rs GetBucketLocation = GetBucketLocationResponse
request = get s3
response
= receiveXML
(\ s h x ->
GetBucketLocationResponse' <$>
(x .@? "LocationConstraint") <*> (pure (fromEnum s)))
instance ToHeaders GetBucketLocation where
toHeaders = const mempty
instance ToPath GetBucketLocation where
toPath GetBucketLocation'{..}
= mconcat ["/", toBS _gblBucket]
instance ToQuery GetBucketLocation where
toQuery = const (mconcat ["location"])
data GetBucketLocationResponse = GetBucketLocationResponse'
{ _getrsLocationConstraint :: !(Maybe Region)
, _getrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getBucketLocationResponse
:: Int
-> GetBucketLocationResponse
getBucketLocationResponse pResponseStatus_ =
GetBucketLocationResponse'
{ _getrsLocationConstraint = Nothing
, _getrsResponseStatus = pResponseStatus_
}
getrsLocationConstraint :: Lens' GetBucketLocationResponse (Maybe Region)
getrsLocationConstraint = lens _getrsLocationConstraint (\ s a -> s{_getrsLocationConstraint = a});
getrsResponseStatus :: Lens' GetBucketLocationResponse Int
getrsResponseStatus = lens _getrsResponseStatus (\ s a -> s{_getrsResponseStatus = a});