ElementEndpoint

Endpoint for an individual resource.

Parameters

TEntity

The type of entity the endpoint represents.

Inheritors

Properties

Link copied to clipboard

Handles errors in responses.

Link copied to clipboard
abstract val httpClient: OkHttpClient

The HTTP client used to communicate with the remote resource.

Link copied to clipboard
abstract val isDeleteAllowed: Boolean?

Shows whether the server has indicated that delete is currently allowed.

Link copied to clipboard
abstract val isMergeAllowed: Boolean?

Shows whether the server has indicated that merge is currently allowed.

Link copied to clipboard
abstract val isSetAllowed: Boolean?

Shows whether the server has indicated that set is currently allowed.

Link copied to clipboard

Extracts links from responses.

Link copied to clipboard
abstract val response: TEntity?

A cached copy of the entity as received from the server.

Link copied to clipboard
abstract val serializers: List<Serializer>

A list of serializers used for entities received from the server, sorted from most to least preferred. Always uses first for sending to the server.

Link copied to clipboard
abstract val uri: URI

The HTTP URI of the remote resource.

Functions

Link copied to clipboard
abstract fun delete()

Deletes the element.

Link copied to clipboard
abstract fun exists(): Boolean

Determines whether the element currently exists.

Link copied to clipboard
abstract fun getLinks(rel: String): List<Pair<URI, String?>>

Resolves all links with a specific relation type. Uses cached data from last response.

Link copied to clipboard
abstract fun link(rel: String): URI

Resolves a single link with a specific relation type. Uses cached data from last response if possible.

Link copied to clipboard
abstract fun linkTemplate(rel: String, variables: Map<String, Any>): URI

Resolves a link template with a specific relation type. Uses cached data from last response if possible.

Link copied to clipboard
abstract fun merge(entity: TEntity): TEntity?

Modifies an existing entity by merging changes on the server-side.

Link copied to clipboard
abstract fun read(): TEntity

Returns the entity.

Link copied to clipboard
abstract fun set(entity: TEntity): TEntity?

Sets/replaces the entity.

Link copied to clipboard
abstract fun update(updateAction: (TEntity) -> TEntity, maxRetries: Int = 3): TEntity?

Reads the current state of the entity, applies a change to it and stores the result. Applies optimistic concurrency using automatic retries.