public async Task CreateScopeAsync(ScopeSpec spec, CreateScopeOptions options) { var uri = GetUri(); Logger.LogInformation($"Attempting create scope {spec.Name} - {uri}"); try { // check scope doesn't exists var scopeExists = await ScopeExistsAsync(spec.Name, new ScopeExistsOptions { CancellationToken = options.CancellationToken }) .ConfigureAwait(false); if (scopeExists) { throw new ScopeAlreadyExistsException(spec.Name); } // create scope var content = new FormUrlEncodedContent(new Dictionary <string, string> { { "name", spec.Name } }); var createResult = await _client.PostAsync(uri, content, options.CancellationToken).ConfigureAwait(false); createResult.EnsureSuccessStatusCode(); } catch (Exception exception) { Logger.LogError(exception, $"Failed to create scope {spec.Name} - {uri}"); throw; } }
public static Task CreateScopeAsync(this ICouchbaseCollectionManager manager, string scopeName, Action <CreateScopeOptions> configureOptions) { var options = new CreateScopeOptions(); configureOptions(options); return(manager.CreateScopeAsync(scopeName, options)); }
public static Task CreateScopeAsync(this ICollectionManager manager, ScopeSpec scopeSpec, Action <CreateScopeOptions> configureOptions) { var options = new CreateScopeOptions(); configureOptions(options); return(manager.CreateScopeAsync(scopeSpec, options)); }
public async Task CreateScopeAsync(ScopeSpec spec, CreateScopeOptions options = null) { options ??= CreateScopeOptions.Default; var uri = GetUri(); Logger.LogInformation($"Attempting create scope {spec.Name} - {uri}"); try { // create scope var content = new FormUrlEncodedContent(new Dictionary <string, string> { { "name", spec.Name } }); var createResult = await _client.PostAsync(uri, content, options.TokenValue).ConfigureAwait(false); createResult.EnsureSuccessStatusCode(); } catch (Exception exception) { Logger.LogError(exception, $"Failed to create scope {spec.Name} - {uri}"); throw; } }