public async Task PublishDesignDocumentAsync(string designDocName, PublishDesignDocumentOptions options)
        {
            var uri = GetUri(designDocName, DesignDocumentNamespace.Production);

            Logger.LogInformation($"Attempting to publish design document {_bucketName}/{designDocName} - {uri}");

            try
            {
                // get dev design document
                var designDocument = await GetDesignDocumentAsync(designDocName, DesignDocumentNamespace.Development, GetDesignDocumentOptions.Default).ConfigureAwait(false);

                var json = JsonConvert.SerializeObject(designDocument);

                // publish design doc to production
                var content       = new StringContent(json, Encoding.UTF8, MediaType.Json);
                var publishResult = await _client.PutAsync(uri, content, options.CancellationToken).ConfigureAwait(false);

                publishResult.EnsureSuccessStatusCode();
            }
            catch (DesignDocumentNotFoundException)
            {
                Logger.LogError($"Failed to publish design document {_bucketName}/{designDocName} because it does not exist");
                throw;
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to put design document {_bucketName}/{designDocName} - {uri}");
                throw;
            }
        }
예제 #2
0
        public static Task PublishDesignDocumentAsync(this IViewIndexManager viewManager, string designDocumentName, Action <PublishDesignDocumentOptions> configureOptions)
        {
            var options = new PublishDesignDocumentOptions();

            configureOptions(options);

            return(viewManager.PublishDesignDocumentAsync(designDocumentName, options));
        }