module Network.AWS.S3.GetBucketLocation
(
getBucketLocation
, GetBucketLocation
, gblBucket
, getBucketLocationResponse
, GetBucketLocationResponse
, grsLocationConstraint
, grsResponseStatus
) 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'
{ _grsLocationConstraint :: !(Maybe Region)
, _grsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getBucketLocationResponse
:: Int
-> GetBucketLocationResponse
getBucketLocationResponse pResponseStatus_ =
GetBucketLocationResponse'
{ _grsLocationConstraint = Nothing
, _grsResponseStatus = pResponseStatus_
}
grsLocationConstraint :: Lens' GetBucketLocationResponse (Maybe Region)
grsLocationConstraint = lens _grsLocationConstraint (\ s a -> s{_grsLocationConstraint = a});
grsResponseStatus :: Lens' GetBucketLocationResponse Int
grsResponseStatus = lens _grsResponseStatus (\ s a -> s{_grsResponseStatus = a});