public ListBucketsAsync ( ListBucketsRequest request, System cancellationToken = default(CancellationToken) ) : Task |
||
request | ListBucketsRequest | Container for the necessary parameters to execute the ListBuckets operation. |
cancellationToken | System | /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// |
Résultat | Task |
// Use this for initialization void Start () { // ResultText is a label used for displaying status information Debug.Log("hallo1"); Debug.Log("hallo2"); S3Client = new AmazonS3Client(Credentials); Debug.Log("hallo3"); ResultText.text = "Fetching all the Buckets"; S3Client.ListBucketsAsync(new ListBucketsRequest(), (responseObject) => { ResultText.text += "\n"; if (responseObject.Exception == null) { ResultText.text += "Got Response \nPrinting now \n"; responseObject.Response.Buckets.ForEach((s3b) => { ResultText.text += string.Format("bucket = {0}, created date = {1} \n", s3b.BucketName, s3b.CreationDate); }); } else { ResultText.text += "Got Exception \n"; } }); }
private static async Task TestCredentials(ProxyRefreshingAWSCredentials creds, bool expectFailure) { using (var client = new AmazonS3Client(creds)) { try { await client.ListBucketsAsync(); Assert.False(expectFailure); } catch (AmazonClientException ace) { Assert.True(expectFailure); Assert.NotNull(ace); Assert.NotNull(ace.Message); Assert.True(ace.Message.IndexOf("already") >= 0); } } }
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 { } } }); }
public async Task EnsureBucketExistsAsync() { using (var s3Client = new AmazonS3Client(credentials, s3ConfigurationProvider.RegionEndpoint)) { var getBucketLocationResponse = await s3Client.ListBucketsAsync(); if ( getBucketLocationResponse.Buckets.Any( bucket => bucket.BucketName == s3ConfigurationProvider.BucketName)) { loggerProvider.GetLogger().Debug("Bucket {bucketName} exists.", s3ConfigurationProvider.BucketName); } else { loggerProvider.GetLogger() .Debug("Bucket {bucketName} does not exist. Creating...", s3ConfigurationProvider.BucketName); await s3Client.PutBucketAsync(s3ConfigurationProvider.BucketName); } await EnsureExpirationRuleOnBucketAsync(s3Client); } }