module Network.AWS.S3.GetBucketLocation
(
getBucketLocation
, GetBucketLocation
, gblBucket
, getBucketLocationResponse
, GetBucketLocationResponse
, getrsLocationConstraint
, getrsStatus
) 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 Sv GetBucketLocation = S3
type Rs GetBucketLocation = GetBucketLocationResponse
request = get
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)
, _getrsStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getBucketLocationResponse
:: Int
-> GetBucketLocationResponse
getBucketLocationResponse pStatus_ =
GetBucketLocationResponse'
{ _getrsLocationConstraint = Nothing
, _getrsStatus = pStatus_
}
getrsLocationConstraint :: Lens' GetBucketLocationResponse (Maybe Region)
getrsLocationConstraint = lens _getrsLocationConstraint (\ s a -> s{_getrsLocationConstraint = a});
getrsStatus :: Lens' GetBucketLocationResponse Int
getrsStatus = lens _getrsStatus (\ s a -> s{_getrsStatus = a});