TypedRest for .NET 1.3.5
build type-safe fluent-style REST API clients
TypedRest.Endpoints.Reactive.PollingEndpoint< TEntity > Class Template Reference

Endpoint for a resource that can be polled for state changes. More...

Inheritance diagram for TypedRest.Endpoints.Reactive.PollingEndpoint< TEntity >:
TypedRest.Endpoints.Generic.ElementEndpoint< TEntity > TypedRest.Endpoints.Reactive.IPollingEndpoint< TEntity > TypedRest.Endpoints.Generic.CachingEndpointBase TypedRest.Endpoints.Generic.IElementEndpoint< TEntity > TypedRest.Endpoints.EndpointBase TypedRest.Endpoints.ICachingEndpoint TypedRest.Endpoints.IEndpoint TypedRest.Endpoints.IEndpoint

Public Member Functions

 PollingEndpoint (IEndpoint referrer, Uri relativeUri, Predicate< TEntity >? endCondition=null)
 Creates a new polling endpoint. More...
 
 PollingEndpoint (IEndpoint referrer, string relativeUri, Predicate< TEntity >? endCondition=null)
 Creates a new polling endpoint. More...
 
IObservable< TEntity > GetObservable ()
 
- Public Member Functions inherited from TypedRest.Endpoints.Generic.ElementEndpoint< TEntity >
 ElementEndpoint (IEndpoint referrer, Uri relativeUri)
 Creates a new element endpoint. More...
 
 ElementEndpoint (IEndpoint referrer, string relativeUri)
 Creates a new element endpoint. More...
 
virtual async Task< TEntity > ReadAsync (CancellationToken cancellationToken=default)
 
async Task< bool > ExistsAsync (CancellationToken cancellationToken=default)
 
virtual async Task< TEntity?> SetAsync (TEntity entity, CancellationToken cancellationToken=default)
 
async Task< TEntity?> MergeAsync (TEntity entity, CancellationToken cancellationToken=default)
 
virtual async Task DeleteAsync (CancellationToken cancellationToken=default)
 
async Task< TEntity?> UpdateAsync (Action< TEntity > updateAction, int maxRetries=3, CancellationToken cancellationToken=default)
 
async Task< TEntity?> UpdateAsync (Action< JsonPatchDocument< TEntity > > patchAction, int maxRetries=3, CancellationToken cancellationToken=default)
 
- Public Member Functions inherited from TypedRest.Endpoints.EndpointBase
void SetDefaultLink (string rel, string? href)
 Registers one or more default links for a specific relation type. These links are used when no links with this relation type are provided by the server. This should only be called during initial setup of the endpoint. More...
 
void SetDefaultLinkTemplate (string rel, string? href)
 Registers a default link template for a specific relation type. This template is used when no template with this relation type is provided by the server. This should only be called during initial setup of the endpoint. More...
 
IReadOnlyList<(Uri uri, string? title)> GetLinks (string rel)
 Resolves all links with a specific relation type. Uses cached data from last response. More...
 
Uri Link (string rel)
 Resolves a single link with a specific relation type. Uses cached data from last response if possible. Tries lazy lookup with HTTP HEAD on cache miss. More...
 
UriTemplate GetLinkTemplate (string rel)
 Retrieves a link template with a specific relation type. Prefer IEndpoint.LinkTemplate(string,object) when possible. More...
 
Uri LinkTemplate (string rel, IDictionary< string, object > variables)
 Resolves a link template with a specific relation type. Uses cached data from last response if possible. Tries lazy lookup with HTTP HEAD on cache miss. More...
 
Uri LinkTemplate (string rel, object variables)
 Resolves a link template with a specific relation type. More...
 
override string ToString ()
 
- Public Member Functions inherited from TypedRest.Endpoints.Generic.IElementEndpoint< TEntity >
Task< bool > ExistsAsync (CancellationToken cancellationToken=default)
 Determines whether the element currently exists. More...
 
Task DeleteAsync (CancellationToken cancellationToken=default)
 Deletes the element. More...
 
Task< TEntity > ReadAsync (CancellationToken cancellationToken=default)
 Returns the TEntity . More...
 
Task< TEntity?> SetAsync (TEntity entity, CancellationToken cancellationToken=default)
 Sets/replaces the TEntity . More...
 
Task< TEntity?> MergeAsync (TEntity entity, CancellationToken cancellationToken=default)
 Modifies an existing TEntity by merging changes on the server-side. More...
 
Task< TEntity?> UpdateAsync (Action< TEntity > updateAction, int maxRetries=3, CancellationToken cancellationToken=default)
 Reads the current state of the entity, applies a change to it and stores the result. Applies optimistic concurrency using automatic retries. More...
 
Task< TEntity?> UpdateAsync (Action< JsonPatchDocument< TEntity > > patchAction, int maxRetries=3, CancellationToken cancellationToken=default)
 Applies a JSON Patch to the entity. Sends the patch instructions to the server for processing; falls back to local processing with optimistic concurrency if that fails. More...
 
- Public Member Functions inherited from TypedRest.Endpoints.Reactive.IPollingEndpoint< TEntity >
IObservable< TEntity > GetObservable ()
 Provides an observable stream of entity states. Compares entities using object.Equals(object) to detect changes.
 

Protected Member Functions

override async Task< HttpResponseMessage > HandleAsync (Func< Task< HttpResponseMessage > > request, [CallerMemberName] string caller="unknown")
 Handles various cross-cutting concerns regarding a response message such as discovering links and handling errors. More...
 
- Protected Member Functions inherited from TypedRest.Endpoints.Generic.CachingEndpointBase
 CachingEndpointBase (IEndpoint referrer, Uri relativeUri)
 Creates a new endpoint with a relative URI. More...
 
 CachingEndpointBase (IEndpoint referrer, string relativeUri)
 Creates a new endpoint with a relative URI. More...
 
async Task< HttpContent > GetContentAsync (CancellationToken cancellationToken, [CallerMemberName] string caller="unknown")
 Performs an HTTP GET request on the IEndpoint.Uri and caches the response if the server sends an HttpResponseHeaders.ETag. More...
 
async Task< HttpResponseMessage > PutContentAsync (HttpContent content, CancellationToken cancellationToken, [CallerMemberName] string caller="unknown")
 Performs an HttpMethod.Put request on the IEndpoint.Uri. Sets HttpRequestHeaders.IfMatch if there is a cached HttpResponseHeader.ETag to detect lost updates. More...
 
async Task< HttpResponseMessage > DeleteContentAsync (CancellationToken cancellationToken, [CallerMemberName] string caller="unknown")
 Performs an HttpMethod.Delete request on the IEndpoint.Uri. Sets HttpRequestHeaders.IfMatch if there is a cached ETag to detect lost updates. More...
 
- Protected Member Functions inherited from TypedRest.Endpoints.EndpointBase
 EndpointBase (Uri uri, HttpClient httpClient, MediaTypeFormatter serializer, IErrorHandler errorHandler, ILinkExtractor linkExtractor)
 Creates a new endpoint with an absolute URI. More...
 
 EndpointBase (IEndpoint referrer, Uri relativeUri)
 Creates a new endpoint with a relative URI. More...
 
 EndpointBase (IEndpoint referrer, string relativeUri)
 Creates a new endpoint with a relative URI. More...
 
Activity? StartActivity ([CallerMemberName] string caller="unknown")
 Starts a new Activity if there is any listener registered (e.g. OpenTelemetry), returns null otherwise. More...
 
virtual void HandleCapabilities (HttpResponseMessage response)
 Handles allowed HTTP methods and other capabilities reported by the server. More...
 
bool? IsMethodAllowed (HttpMethod method)
 Shows whether the server has indicated that a specific HTTP method is currently allowed. More...
 

Properties

TimeSpan PollingInterval = TimeSpan.FromSeconds(3) [getset]
 
- Properties inherited from TypedRest.Endpoints.Generic.ElementEndpoint< TEntity >
TEntity? Response [get]
 
bool? SetAllowed [get]
 
bool? MergeAllowed [get]
 
bool? DeleteAllowed [get]
 
- Properties inherited from TypedRest.Endpoints.Generic.CachingEndpointBase
ResponseCacheResponseCache [getset]
 
- Properties inherited from TypedRest.Endpoints.EndpointBase
Uri Uri [get]
 
HttpClient HttpClient [get]
 
MediaTypeFormatter Serializer [get]
 
IErrorHandler ErrorHandler [get]
 
ILinkExtractor LinkExtractor [get]
 
- Properties inherited from TypedRest.Endpoints.IEndpoint
Uri Uri [get]
 The HTTP URI of the remote resource.
 
HttpClient HttpClient [get]
 The HTTP client used to communicate with the remote resource.
 
MediaTypeFormatter Serializer [get]
 Controls the serialization of entities sent to and received from the server.
 
IErrorHandler ErrorHandler [get]
 Handles errors in responses.
 
ILinkExtractor LinkExtractor [get]
 Extracts links from responses.
 
- Properties inherited from TypedRest.Endpoints.ICachingEndpoint
ResponseCacheResponseCache [getset]
 A cached copy of the last response.
 
- Properties inherited from TypedRest.Endpoints.Generic.IElementEndpoint< TEntity >
bool? DeleteAllowed [get]
 Shows whether the server has indicated that DeleteAsync is currently allowed. More...
 
TEntity? Response [get]
 A cached copy of the entity as received from the server.
 
bool? SetAllowed [get]
 Shows whether the server has indicated that SetAsync is currently allowed. More...
 
bool? MergeAllowed [get]
 Shows whether the server has indicated that MergeAsync is currently allowed. More...
 
- Properties inherited from TypedRest.Endpoints.Reactive.IPollingEndpoint< TEntity >
TimeSpan PollingInterval [getset]
 The interval in which to send requests to the server. The server can modify this value using the "Retry-After" header.
 

Additional Inherited Members

- Static Protected Member Functions inherited from TypedRest.Endpoints.EndpointBase
static Func< IEndpoint, Uri, TEndpoint > GetConstructor< TEndpoint > ()
 Returns a constructor for TEndpoint as a function with a referrer an a relative URI as input. More...
 

Detailed Description

Endpoint for a resource that can be polled for state changes.

Template Parameters
TEntityThe type of entity the endpoint represents.
Type Constraints
TEntity :class 

Constructor & Destructor Documentation

◆ PollingEndpoint() [1/2]

TypedRest.Endpoints.Reactive.PollingEndpoint< TEntity >.PollingEndpoint ( IEndpoint  referrer,
Uri  relativeUri,
Predicate< TEntity >?  endCondition = null 
)
inline

Creates a new polling endpoint.

Parameters
referrerThe endpoint used to navigate to this one.
relativeUriThe URI of this endpoint relative to the referrer 's.
endConditionA check to determine whether the entity has reached its final state an no further polling is required.

◆ PollingEndpoint() [2/2]

TypedRest.Endpoints.Reactive.PollingEndpoint< TEntity >.PollingEndpoint ( IEndpoint  referrer,
string  relativeUri,
Predicate< TEntity >?  endCondition = null 
)
inline

Creates a new polling endpoint.

Parameters
referrerThe endpoint used to navigate to this one.
relativeUriThe URI of this endpoint relative to the referrer 's. Add a ./ prefix here to imply a trailing slash referrer 's URI.
endConditionA check to determine whether the entity has reached its final state an no further polling is required.

Member Function Documentation

◆ HandleAsync()

override async Task< HttpResponseMessage > TypedRest.Endpoints.Reactive.PollingEndpoint< TEntity >.HandleAsync ( Func< Task< HttpResponseMessage > >  request,
[CallerMemberName] string  caller = "unknown" 
)
inlineprotectedvirtual

Handles various cross-cutting concerns regarding a response message such as discovering links and handling errors.

Parameters
requestA callback that performs the actual HTTP request.
callerThe name of the method calling this method.
Returns
The resolved request .

Reimplemented from TypedRest.Endpoints.EndpointBase.


The documentation for this class was generated from the following file: