public async Task <BucketSettings> GetBucketAsync(string bucketName, GetBucketOptions options = null) { options = options ?? new GetBucketOptions(); var uri = GetUri(bucketName); Logger.LogInformation($"Attempting to get bucket with name {bucketName} - {uri}"); try { var result = await _client.GetAsync(uri, options.CancellationToken).ConfigureAwait(false); if (result.StatusCode == HttpStatusCode.NotFound) { throw new BucketNotFoundException(bucketName); } result.EnsureSuccessStatusCode(); var content = await result.Content.ReadAsStringAsync().ConfigureAwait(false); var json = JObject.Parse(content); return(GetBucketSettings(json)); } catch (Exception exception) { Logger.LogError(exception, $"Failed to get bucket with name {bucketName} - {uri}"); throw; } }
public static Task <BucketSettings> GetBucketAsync(this IBucketManager bucketManager, string bucketName, Action <GetBucketOptions> configureOptions) { var options = new GetBucketOptions(); configureOptions(options); return(bucketManager.GetBucketAsync(bucketName, options)); }