Interface IElementEndpoint<TEntity>
Endpoint for an individual resource.
public interface IElementEndpoint<TEntity> : IElementEndpoint, IEndpoint where TEntity : class
Type Parameters
TEntity
The type of entity the endpoint represents.
- Inherited Members
Properties
MergeAllowed
Indicates whether the server has specified MergeAsync(TEntity, CancellationToken) is currently allowed.
bool? MergeAllowed { get; }
Property Value
- bool?
true
if the method is allowed,false
if the method is not allowed,null
If no request has been sent yet or the server did not specify allowed methods.
Remarks
Uses cached data from last response.
Response
A cached copy of the entity as received from the server.
TEntity? Response { get; }
Property Value
- TEntity
SetAllowed
Indicates whether the server has specified SetAsync(TEntity, CancellationToken) is currently allowed.
bool? SetAllowed { get; }
Property Value
- bool?
true
if the method is allowed,false
if the method is not allowed,null
If no request has been sent yet or the server did not specify allowed methods.
Remarks
Uses cached data from last response.
Methods
MergeAsync(TEntity, CancellationToken)
Modifies an existing entity by merging changes on the server-side.
Task<TEntity?> MergeAsync(TEntity entity, CancellationToken cancellationToken = default)
Parameters
entity
TEntityThe entity data to merge with the existing one.
cancellationToken
CancellationTokenUsed to cancel the request.
Returns
- Task<TEntity>
The modified entity as returned by the server, possibly with additional fields set.
null
if the server does not respond with a result entity.
Exceptions
- InvalidOperationException
The entity has changed since it was last retrieved with ReadAsync(CancellationToken). Your changes were rejected to prevent a lost update.
- InvalidDataException
- AuthenticationException
- UnauthorizedAccessException
- KeyNotFoundException
- HttpRequestException
Other non-success status code.
ReadAsync(CancellationToken)
Returns the entitiy.
Task<TEntity> ReadAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenUsed to cancel the request.
Returns
- Task<TEntity>
Exceptions
- AuthenticationException
- UnauthorizedAccessException
- KeyNotFoundException
- HttpRequestException
Other non-success status code.
SetAsync(TEntity, CancellationToken)
Sets/replaces the entity.
Task<TEntity?> SetAsync(TEntity entity, CancellationToken cancellationToken = default)
Parameters
entity
TEntityThe new entities.
cancellationToken
CancellationTokenUsed to cancel the request.
Returns
- Task<TEntity>
The entity as returned by the server, possibly with additional fields set.
null
if the server does not respond with a result entity.
Exceptions
- InvalidOperationException
The entity has changed since it was last retrieved with ReadAsync(CancellationToken). Your changes were rejected to prevent a lost update.
- InvalidDataException
- AuthenticationException
- UnauthorizedAccessException
- KeyNotFoundException
- HttpRequestException
Other non-success status code.
UpdateAsync(Action<JsonPatchDocument<TEntity>>, int, CancellationToken)
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.
Task<TEntity?> UpdateAsync(Action<JsonPatchDocument<TEntity>> patchAction, int maxRetries = 3, CancellationToken cancellationToken = default)
Parameters
patchAction
Action<JsonPatchDocument<TEntity>>Callback for building a patch document describing the desired modifications.
maxRetries
intThe maximum number of retries to perform for optimistic concurrency before giving up.
cancellationToken
CancellationTokenUsed to cancel the request.
Returns
- Task<TEntity>
The entity as returned by the server, possibly with additional fields set.
null
if the server does not respond with a result entity.
Exceptions
- InvalidOperationException
The number of retries performed for optimistic concurrency exceeded
maxRetries
.- NotSupportedException
Serializers does not contain a JsonMediaTypeFormatter.
- InvalidDataException
- AuthenticationException
- UnauthorizedAccessException
- KeyNotFoundException
- HttpRequestException
Other non-success status code.
UpdateAsync(Action<TEntity>, int, CancellationToken)
Reads the current state of the entity, applies a change to it and stores the result. Applies optimistic concurrency using automatic retries.
Task<TEntity?> UpdateAsync(Action<TEntity> updateAction, int maxRetries = 3, CancellationToken cancellationToken = default)
Parameters
updateAction
Action<TEntity>A callback that takes the current state of the entity and applies the desired modifications.
maxRetries
intThe maximum number of retries to perform for optimistic concurrency before giving up.
cancellationToken
CancellationTokenUsed to cancel the request.
Returns
- Task<TEntity>
The entity as returned by the server, possibly with additional fields set.
null
if the server does not respond with a result entity.
Exceptions
- InvalidOperationException
The number of retries performed for optimistic concurrency exceeded
maxRetries
.- InvalidDataException
- AuthenticationException
- UnauthorizedAccessException
- KeyNotFoundException
- HttpRequestException
Other non-success status code.
UpdateAsync(Func<TEntity, TEntity>, int, CancellationToken)
Reads the current state of the entity, applies a change to it and stores the result. Applies optimistic concurrency using automatic retries.
Task<TEntity?> UpdateAsync(Func<TEntity, TEntity> updateAction, int maxRetries = 3, CancellationToken cancellationToken = default)
Parameters
updateAction
Func<TEntity, TEntity>A callback that takes the current state of the entity and applies the desired modifications.
maxRetries
intThe maximum number of retries to perform for optimistic concurrency before giving up.
cancellationToken
CancellationTokenUsed to cancel the request.
Returns
- Task<TEntity>
The entity as returned by the server, possibly with additional fields set.
null
if the server does not respond with a result entity.
Exceptions
- InvalidOperationException
The number of retries performed for optimistic concurrency exceeded
maxRetries
.- InvalidDataException
- AuthenticationException
- UnauthorizedAccessException
- KeyNotFoundException
- HttpRequestException
Other non-success status code.