示例#1
0
        public async Task DropAsync(string bucketName, DropBucketOptions options)
        {
            var uri = GetUri(bucketName);

            Logger.LogInformation($"Attempting to drop bucket with name {bucketName} - {uri}");

            try
            {
                // try get bucket, throws BucketNotFoundException if it doesn't exist
                await GetAsync(bucketName, GetBucketOptions.Default).ConfigureAwait(false);

                // perform drop
                var result = await _client.DeleteAsync(uri, options.CancellationToken).ConfigureAwait(false);

                result.EnsureSuccessStatusCode();
            }
            catch (BucketNotFoundException)
            {
                Logger.LogError($"Unable to drop bucket with name {bucketName} because it does not exist");
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to drop bucket with name {bucketName}");
                throw;
            }
        }
示例#2
0
        public static Task DropAsync(this IBucketManager bucketManager, string bucketName, Action <DropBucketOptions> configureOptions)
        {
            var options = new DropBucketOptions();

            configureOptions(options);

            return(bucketManager.DropAsync(bucketName, options));
        }