in Runtime/Core/BucketManagement/BucketStore.cs [272:322]
public GetBucketsResponse GetBuckets(GetBucketsRequest request)
{
try
{
ListBucketsResponse response = _amazonS3Wrapper.ListBuckets();
if (response.HttpStatusCode == HttpStatusCode.OK)
{
var buckets = new List<string>();
if (!string.IsNullOrEmpty(request.Region))
{
foreach (string bucketName in response.Buckets.Select(bucket => bucket.BucketName))
{
GetBucketLocationResponse locationResponse = _amazonS3Wrapper.GetBucketLocation(new GetBucketLocationRequest
{
BucketName = bucketName
});
if (locationResponse.HttpStatusCode == HttpStatusCode.OK && ToBucketRegion(locationResponse) == request.Region)
{
buckets.Add(bucketName);
}
}
}
else
{
buckets = response.Buckets.Select(bucket => bucket.BucketName).ToList();
}
return Response.Ok(new GetBucketsResponse()
{
Buckets = buckets
});
}
else
{
return Response.Fail(new GetBucketsResponse()
{
ErrorCode = ErrorCode.AwsError,
ErrorMessage = $"HTTP Status Code {response.HttpStatusCode}"
});
}
}
catch (Exception ex)
{
Logger.LogError(ex, ex.Message);
return HandleAwsException(ex, () => new GetBucketsResponse());
}
}