public async Task PublishAsync(string designDocName, PublishIndexOptions options) { var uri = GetUri(designDocName, true); Logger.LogInformation($"Attempting to publish design document {_bucketName}/{designDocName} - {uri}"); try { // get dev design document var designDocument = await GetAsync(designDocName, GetViewIndexOptions.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(); // drop old dev design doc await DropAsync(designDocName, DropViewIndexOptions.Default); } 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; } }
public static Task PublishAsync(this IViewManager viewManager, string designDocumentName, Action <PublishIndexOptions> configureOptions) { var options = new PublishIndexOptions(); configureOptions(options); return(viewManager.PublishAsync(designDocumentName, options)); }