Ejemplo n.º 1
0
        public async Task <Dictionary <string, BucketSettings> > GetAllBucketsAsync(GetAllBucketsOptions options = null)
        {
            options = options ?? new GetAllBucketsOptions();
            var uri = GetUri();

            Logger.LogInformation($"Attempting to get all buckets - {uri}");

            try
            {
                var result = await _client.GetAsync(uri, options.CancellationToken).ConfigureAwait(false);

                result.EnsureSuccessStatusCode();

                var content = await result.Content.ReadAsStringAsync().ConfigureAwait(false);

                var buckets = new Dictionary <string, BucketSettings>();
                var json    = JArray.Parse(content);

                foreach (var row in json)
                {
                    var settings = GetBucketSettings(row);
                    buckets.Add(settings.Name, settings);
                }

                return(buckets);
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to get all buckets - {uri}");
                throw;
            }
        }
Ejemplo n.º 2
0
        public static Task <Dictionary <string, BucketSettings> > GetAllBucketsAsync(this IBucketManager bucketManager, Action <GetAllBucketsOptions> configureOptions)
        {
            var options = new GetAllBucketsOptions();

            configureOptions(options);

            return(bucketManager.GetAllBucketsAsync(options));
        }