SolidResourceClient

Reads, creates, updates and deletes resources on the authenticated user's Solid pod by communicating with the Android Solid Services app over IPC.

Obtain an instance via Solid.getResourceClient.

All public methods are suspend functions and must be called from a coroutine. Each returns its result or throws a SolidException subtype on failure — including precondition failures (SolidException.SolidAppNotFoundException, SolidException.SolidServiceConnectionException).

See also

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun copy(webId: String, sourceUri: String, destinationUri: String): String

Copies a resource, or a whole container tree, to destinationUri. Not transactional.

Link copied to clipboard
suspend fun <T : SolidResource> create(webId: String, resource: T): T

Creates a new resource on the pod at the URI specified by resource for webId.

Link copied to clipboard
suspend fun <T : SolidResource> createInContainer(webId: String, containerUri: String, resource: T): String?

Creates a member inside containerUri by POSTing, letting the server allocate the child URI — and therefore needing only Append, not Write.

Link copied to clipboard
suspend fun <T : SolidResource> delete(webId: String, resource: T): T

Deletes a resource from the pod for webId.

Link copied to clipboard
suspend fun deleteContainer(webId: String, containerUri: String)

Recursively deletes a container and all of its contents.

Link copied to clipboard
suspend fun ensureContainer(webId: String, containerUri: String)

Creates the container and any missing ancestors, bottom-up. Idempotent.

Link copied to clipboard
suspend fun exists(webId: String, uri: String): Boolean

Reports whether a resource exists: a 404 is false; anything indeterminate (403, auth, network, 5xx) throws rather than being collapsed to false.

Link copied to clipboard
suspend fun getWebId(webId: String): WebId

Fetches and parses the WebID document for webId from their pod.

Link copied to clipboard
suspend fun head(webId: String, resourceUrl: String): SolidMetadata

Fetches only the HTTP headers for the resource at resourceUrl via HTTP HEAD.

Link copied to clipboard
suspend fun headPublic(uri: String): SolidMetadata

HEADs a public resource with no Authorization header.

Link copied to clipboard
suspend fun listContainer(webId: String, containerUri: String, enrichWithHead: Boolean = false): List<SolidSourceReference>

Lists a container's direct children in a single GET.

Link copied to clipboard
suspend fun move(webId: String, sourceUri: String, destinationUri: String): String

A copy followed by a delete of the source. Not transactional.

Link copied to clipboard
suspend fun patch(webId: String, uri: String, patch: N3Patch)

Applies an N3 Patch to an RDF resource on the pod via HTTP PATCH.

Link copied to clipboard
suspend fun patchRaw(webId: String, uri: String, n3Body: String)

Applies an already-serialised N3 Patch document to an RDF resource.

Link copied to clipboard
suspend fun post(webId: String, uri: String, contentType: String, body: ByteArray, additionalHeaders: Map<String, String> = emptyMap()): String?

POSTs an opaque body to a container; returns the Location the server allocated.

Link copied to clipboard
suspend fun probeAccess(webId: String, uri: String): AccessProbe

Reports the access the user effectively holds on uri, from its WAC-Allow header.

Link copied to clipboard
suspend fun putRaw(webId: String, uri: String, contentType: String, body: ByteArray, ifMatch: String? = null, linkHeader: String? = null)

PUTs an opaque body to uri.

Link copied to clipboard
suspend fun <T : SolidResource> read(webId: String, resourceUrl: String, clazz: Class<T>): T

Reads a resource from the pod for webId.

Link copied to clipboard
suspend fun readContainer(webId: String, containerUrl: String): SolidContainer

Reads an LDP container from the pod, with each contained resource enriched by its own HTTP HEAD metadata (carried in each SolidSourceReference.headMetadata).

Link copied to clipboard
suspend fun <T : SolidResource> readPublic(uri: String, clazz: Class<T>): T

Reads a public resource with no Authorization header — most usefully a foreign WebID profile document, which a pod may reject when presented a foreign issuer's token.

Link copied to clipboard
suspend fun readStream(webId: String, uri: String): SolidStream

Opens the resource at uri as a live stream.

Link copied to clipboard
suspend fun rename(webId: String, sourceUri: String, newName: String): String

Moves a resource to a sibling name in the same container.

Link copied to clipboard

Hot Flow of the IPC service connection state. Emits true once the bound service connects and false if it disconnects.

Link copied to clipboard
suspend fun <T : SolidResource> update(webId: String, resource: T, ifMatch: String? = null): T

Replaces an existing resource on the pod via HTTP PUT.

Link copied to clipboard
suspend fun writeStream(webId: String, uri: String, contentType: String, source: InputStream, contentLength: Long = -1L, ifMatch: String? = null)

Writes the resource at uri by streaming source across, rather than buffering it.