Beispiel #1
0
        public static Task UpsertAsync(this IViewManager viewManager, DesignDocument designDocument, Action <UpsertViewIndexOptions> configureOptions)
        {
            var options = new UpsertViewIndexOptions();

            configureOptions(options);

            return(viewManager.UpsertAsync(designDocument, options));
        }
Beispiel #2
0
        public async Task UpsertAsync(DesignDocument designDocument, UpsertViewIndexOptions options)
        {
            var json = JsonConvert.SerializeObject(designDocument);
            var uri  = GetUri(designDocument.Name, options.IsProduction);

            Logger.LogInformation($"Attempting to upsert design document {_bucketName}/{designDocument.Name} - {uri}");
            Logger.LogDebug(json);

            try
            {
                var content = new StringContent(json, Encoding.UTF8, MediaType.Json);
                var result  = await _client.PutAsync(uri, content, options.CancellationToken).ConfigureAwait(false);

                result.EnsureSuccessStatusCode();
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to upsert design document {_bucketName}/{designDocument.Name} - {uri} - {json}");
                throw;
            }
        }