Class GrpcPagedEnumerable<TRequest, TResponse, TResource> (4.4.0)

public sealed class GrpcPagedEnumerable<TRequest, TResponse, TResource> : PagedEnumerable<TResponse, TResource>, IEnumerable<TResource>, IEnumerable where TRequest : class, IPageRequest, IMessage<TRequest> where TResponse : class, IPageResponse<TResource>, IMessage<TResponse>

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

Inheritance

object > PagedEnumerable > GrpcPagedEnumerable<TRequest, TResponse, TResource>

Implements

IEnumerable, IEnumerable

Namespace

Google.Api.Gax.Grpc

Assembly

Google.Api.Gax.Grpc.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

GrpcPagedEnumerable(ApiCall<TRequest, TResponse>, TRequest, CallSettings)

public GrpcPagedEnumerable(ApiCall<TRequest, TResponse> apiCall, TRequest request, CallSettings callSettings)

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

Parameters
NameDescription
apiCallApiCall

The API call made each time a page is required.

requestTRequest

The initial request.

callSettingsCallSettings

The settings to apply to each API call.

Remarks

The request is cloned each time the sequence is evaluated.

Methods

AsRawResponses()

public override IEnumerable<TResponse> AsRawResponses()

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

Returns
TypeDescription
IEnumerable

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

Overrides

GetEnumerator()

public override IEnumerator<TResource> GetEnumerator()
Returns
TypeDescription
IEnumerator
Overrides

ReadPage(int)

public override Page<TResource> ReadPage(int pageSize)

Eagerly 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.

Parameter
NameDescription
pageSizeint

The page size. Must be greater than 0.

Returns
TypeDescription
Page

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

Overrides 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.)