public async Task <ScopeSpec> GetScopeAsync(string scopeName, GetScopeOptions options) { var uri = GetUri(); Logger.LogInformation($"Attempting to verify if scope {scopeName} exists - {uri}"); try { // get all scopes var scopes = await GetAllScopesAsync(new GetAllScopesOptions { CancellationToken = options.CancellationToken }) .ConfigureAwait(false); // try find scope var scope = scopes.SingleOrDefault(x => x.Name == scopeName); if (scope != null) { return(scope); } // throw not found exception throw new ScopeNotFoundException(scopeName); } catch (Exception exception) { Logger.LogError(exception, $"Failed to verify if scope {scopeName} exists - {uri}"); throw; } }
public static Task <ScopeSpec> GetScopeAsync(this ICollectionManager manager, string scopeName, Action <GetScopeOptions> configureOptions) { var options = new GetScopeOptions(); configureOptions(options); return(manager.GetScopeAsync(scopeName, options)); }