Amazon.S3.AmazonS3Client.GetBucketLocationAsync C# (CSharp) Method

GetBucketLocationAsync() public method

Initiates the asynchronous execution of the GetBucketLocation operation.
public GetBucketLocationAsync ( GetBucketLocationRequest request, System cancellationToken = default(CancellationToken) ) : Task
request GetBucketLocationRequest Container for the necessary parameters to execute the GetBucketLocation operation.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
return Task
        public Task<GetBucketLocationResponse> GetBucketLocationAsync(GetBucketLocationRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetBucketLocationRequestMarshaller();
            var unmarshaller = GetBucketLocationResponseUnmarshaller.Instance;

            return InvokeAsync<GetBucketLocationRequest,GetBucketLocationResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }

Same methods

AmazonS3Client::GetBucketLocationAsync ( string bucketName, System cancellationToken = default(CancellationToken) ) : Task
AmazonS3Client::GetBucketLocationAsync ( GetBucketLocationRequest request, GetBucketLocationResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
AmazonS3Client::GetBucketLocationAsync ( string bucketName, GetBucketLocationResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void

Usage Example

        public override async Task DoAction(string RoleARN)
        {
            await base.DoAction(RoleARN);

            var logger = LogManager.GetCurrentClassLogger();


            Parallel.ForEach(SharedLibrary.Utilities.GetRegions(), (region) =>
            {
                logger.Debug($"Checking S3 buckets in region {region.DisplayName }");

                var creds = SharedLibrary.Utilities.AssumeRole(RoleARN, region);

                Amazon.S3.AmazonS3Client client = new Amazon.S3.AmazonS3Client(creds, region);

                var listBucketsResult = client.ListBucketsAsync(new ListBucketsRequest {
                }).Result;

                foreach (var bucket in listBucketsResult.Buckets)
                {
                    try
                    {
                        var bucketLocationResult = client.GetBucketLocationAsync(new GetBucketLocationRequest {
                            BucketName = bucket.BucketName
                        }).Result;

                        var bucketRegion = RegionEndpoint.GetBySystemName(bucketLocationResult.Location.Value);

                        Amazon.S3.AmazonS3Client localClient = new Amazon.S3.AmazonS3Client(creds, bucketRegion);

                        EmptyBucket(localClient, bucket.BucketName).Wait();

                        var deleteBucketResult = localClient.DeleteBucketAsync(new DeleteBucketRequest {
                            BucketName = bucket.BucketName, BucketRegion = bucketLocationResult.Location
                        }).Result;


                        logger.Debug($"Bucket {bucket.BucketName} in region {region.DisplayName} deleted.");
                    }
                    catch
                    { }
                }
            });
        }
AmazonS3Client