public static Task <DesignDocument> GetDesignDocumentAsync(this IViewIndexManager viewManager, string designDocName, DesignDocumentNamespace @namespace, Action <GetDesignDocumentOptions> configureOptions) { var options = new GetDesignDocumentOptions(); configureOptions(options); return(viewManager.GetDesignDocumentAsync(designDocName, @namespace, options)); }
public async Task <DesignDocument> GetDesignDocumentAsync(string designDocName, DesignDocumentNamespace @namespace, GetDesignDocumentOptions options) { var uri = GetUri(designDocName, @namespace); Logger.LogInformation($"Attempting to get design document {_bucketName}/{designDocName} - {uri}"); try { var result = await _client.GetAsync(uri, options.CancellationToken).ConfigureAwait(false); if (result.StatusCode == HttpStatusCode.NotFound) { throw new DesignDocumentNotFoundException(_bucketName, designDocName); } result.EnsureSuccessStatusCode(); var content = await result.Content.ReadAsStringAsync().ConfigureAwait(false); var designDocument = JsonConvert.DeserializeObject <DesignDocument>(content); designDocument.Name = designDocName; return(designDocument); } catch (Exception exception) { Logger.LogError(exception, $"Failed to get design document {_bucketName}/{designDocName} - {uri}"); throw; } }