class AwsObjectStorageConnector implements ObjectStorageConnector {

    @Override
    public ObjectStorageMetadataResponse getObjectStorageMetadata(ObjectStorageMetadataRequest request) {
        AwsCredentialView awsCredentialView = new AwsCredentialView(request.getCredential());
        try {
            AmazonS3 s3Client = awsClient.createS3Client(awsCredentialView);
            String bucketLocation = fixBucketLocation(s3Client.getBucketLocation(request.getObjectStoragePath()));
            return ObjectStorageMetadataResponse.builder()
                    .withRegion(bucketLocation)
                    .withStatus(ResponseStatus.OK)
                    .build();
        } catch (AmazonS3Exception e) {
            // HACK let's assume that if the user gets back 403 Access Denied it is because s/he does not have the s3:GetBucketLocation permission.
            // It is also true though that if the bucket indeed exists but it is in another account or otherwise denied from the requesting user,
            // the same error code will be returned. However, this hack is mainly for QAAS.
            if (e.getStatusCode() != ACCESS_DENIED_ERROR_CODE) {
                throw new CloudConnectorException(String.format("Cannot get object storage location for %s. "
                        + "Provider error message: %s", request.getObjectStoragePath(), e.getErrorMessage()), e);
            }
            return ObjectStorageMetadataResponse.builder()
                    .withStatus(ResponseStatus.ACCESS_DENIED)
                    .build();
        }
    }

}