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 async Task CreateScopeAsync(ScopeSpec spec, CreateScopeOptions?options = null) { options ??= CreateScopeOptions.Default; var uri = GetUri(); _logger.LogInformation("Attempting create scope {spec.Name} - {uri}", spec.Name, _redactor.SystemData(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}", spec.Name, _redactor.SystemData(uri)); throw; } }
public static Task CreateScopeAsync(this ICollectionManager manager, ScopeSpec scopeSpec, Action <CreateScopeOptions> configureOptions) { var options = new CreateScopeOptions(); configureOptions(options); return(manager.CreateScopeAsync(scopeSpec, options)); }
public static Task CreateScopeAsync(this ICollectionManager manager, ScopeSpec scopeSpec) { return(manager.CreateScopeAsync(scopeSpec, CreateScopeOptions.Default)); }
public Task CreateScopeAsync(ScopeSpec spec, CreateScopeOptions?options = null) { return(CreateScopeAsync(spec.Name, options)); }