Class RestPagedAsyncEnumerable<TRequest, TResponse, TResource> (3.2.0)

public sealed class RestPagedAsyncEnumerable<TRequest, TResponse, TResource> : PagedAsyncEnumerable<TResponse, TResource> where TRequest : class, IClientServiceRequest<TResponse> where TResponse : class

An asynchronous sequence of resources, obtained lazily via API operations which retrieve a page at a time.

Inheritance

Object > PagedAsyncEnumerable<TResponse, TResource> > RestPagedAsyncEnumerable<TRequest, TResponse, TResource>

Namespace

Google.Api.Gax.Rest

Assembly

Google.Api.Gax.Rest.dll

Type Parameters

NameDescription
TRequest

The API request type.

TResponse

The API response type. Each response contains a page of resources.

TResource

The resource type contained within the response.

Constructors

RestPagedAsyncEnumerable(Func<TRequest>, IPageManager<TRequest, TResponse, TResource>)

public RestPagedAsyncEnumerable(Func<TRequest> requestProvider, IPageManager<TRequest, TResponse, TResource> pageManager)

Creates a new lazily-evaluated sequence from the given API call, initial request, and call settings.

Parameters
NameDescription
requestProviderFunc<TRequest>

A factory used to create an initial request each time the sequence is iterated over.

pageManagerIPageManager<TRequest, TResponse, TResource>

A manager to work with the requests and responses.

Methods

AsRawResponses()

public override IAsyncEnumerable<TResponse> AsRawResponses()

Returns the sequence of raw API responses, each of which contributes a page of resources to this sequence.

Returns
TypeDescription
IAsyncEnumerable<TResponse>

An asynchronous sequence of raw API responses, each containing a page of resources.

Overrides
Google.Api.Gax.PagedAsyncEnumerable<TResponse, TResource>.AsRawResponses()

GetAsyncEnumerator(CancellationToken)

public override IAsyncEnumerator<TResource> GetAsyncEnumerator(CancellationToken cancellationToken)
Parameter
NameDescription
cancellationTokenCancellationToken
Returns
TypeDescription
IAsyncEnumerator<TResource>
Overrides
Google.Api.Gax.PagedAsyncEnumerable<TResponse, TResource>.GetAsyncEnumerator(System.Threading.CancellationToken)

ReadPageAsync(Int32, CancellationToken)

public override Task<Page<TResource>> ReadPageAsync(int pageSize, CancellationToken cancellationToken = default(CancellationToken))

Eagerly (but asynchronously) reads a single page of results with a fixed maximum size. The returned page is guaranteed to have that many results, unless there is no more data available.

Parameters
NameDescription
pageSizeInt32

The page size. Must be greater than 0.

cancellationTokenCancellationToken

A token to cancel the operation.

Returns
TypeDescription
Task<Page<TResource>>

An asynchronous operation, the result of which is a page of resources.

Overrides
Google.Api.Gax.PagedAsyncEnumerable<TResponse, TResource>.ReadPageAsync(System.Int32, System.Threading.CancellationToken)
Remarks

"Natural" pages returned by the API may contain a smaller number of resources than requested. For example, a request for a page with 100 resources may return a page with 80 resources but a next page token for more to be retrieved. This is suitable for batch-processing, but not for user-visible paging such as in a web application, where fixed-size pages are expected. This method may make more than one API call in order to fill the page, but after the page has been returned, all the data will have been loaded. (In particular, iterating over the items in the page multiple times will not make any further requests.)