public static Uri AsRelativeUri(this string @this, PagingOptions paging, IEnumerable<AppIdentifier> context = null, IReadOnlyDictionary<string, string> extraParameters = null) { var parameters = new List<string>(); if (paging.From.HasValue) parameters.Add($"_from={WebUtility.UrlEncode(paging.From.ToString())}"); if (paging.To.HasValue) parameters.Add($"_to={WebUtility.UrlEncode(paging.To.ToString())}"); if (context != null) parameters.Add("context=" + string.Join("/", context)); if (extraParameters != null) parameters.AddRange(extraParameters.Select( p => $"{WebUtility.UrlEncode(p.Key)}={WebUtility.UrlEncode(p.Value)}")); return AsRelativeUri(@this, parameters); }
public async Task<PagedResponse<InstalledApp>> ListAppDependenciesAsync(string account, string workspace, AppIdentifier app, IEnumerable<AppIdentifier> context, string service, PagingOptions paging, bool recursive, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(account)) throw new ArgumentNullException(nameof(account), $"{nameof(account)} cannot be null or white space"); if (string.IsNullOrWhiteSpace(workspace)) throw new ArgumentNullException(nameof(workspace), $"{nameof(workspace)} cannot be null or white space"); if (app == null) throw new ArgumentNullException(nameof(app)); if (string.IsNullOrWhiteSpace(service)) throw new ArgumentNullException(nameof(service), $"{nameof(service)} cannot be null or white space"); paging = paging ?? new PagingOptions(1, 50); var parameters = recursive ? new Dictionary<string, string> {{"recursive", "true"}} : null; var url = Routes.AppDependencies(account, workspace, app, service).AsRelativeUri(paging, context, parameters); try { return await _connector.GetJsonAsync<PagedResponse<InstalledApp>>(url, null, cancellationToken) .ConfigureAwait(false); } catch (ResourceNotFoundException e) { throw e.WithWorkspace(account, workspace, app, service); } }