/// <summary> /// Gets a page of resources. /// </summary> /// <typeparam name="TPage">The resource type.</typeparam> /// <param name="pageUrl">The page URL.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> public virtual async Task <TPage> GetResourcePageAsync <TPage>(Url pageUrl, CancellationToken cancellationToken) where TPage : IPageBuilder <TPage> { PreparedRequest request = PrepareRequest(pageUrl, cancellationToken); var results = await request .PrepareGet(cancellationToken) .SendAsync() .ReceiveJson <TPage>(); results.SetNextPageHandler(GetResourcePageAsync <TPage>); return(results); }
/// <summary> /// Builds a request to retrieve a list of resources. /// </summary> /// <param name="resourcePath">The resource path, e.g. "servers".</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <exception cref="ArgumentNullException">resourceId</exception> public async Task <PreparedRequest> PrepareListResourcesRequest(string resourcePath, CancellationToken cancellationToken) { PreparedRequest request = await PrepareRequest(resourcePath, cancellationToken); return(request.PrepareGet(cancellationToken)); }