NodeHttp

class NodeHttp(httpClient: HttpClient, trustHost: TrustHost, bearerTokenProvider: () -> String?)(source)

REST + SSE-friendly client for a Krill server.

Parameters

httpClient

Pre-configured Ktor client. The caller is responsible for installing engines, content-negotiation, plugins, and trust setup.

trustHost

Trust-store callback used to evict and re-fetch a peer cert when an outbound call fails with an SSL error.

bearerTokenProvider

Supplies the current bearer token (PIN-derived per krill.zone.shared.security.PinDerivation.deriveBearerToken) on each request. null skips the Authorization header entirely, which is what unauthenticated FTUE traffic should do.

Constructors

Link copied to clipboard
constructor(httpClient: HttpClient, trustHost: TrustHost, bearerTokenProvider: () -> String?)

Functions

Link copied to clipboard
suspend fun chart(host: Node, id: String, startTime: Long, endTime: Long): ByteArray
Link copied to clipboard
suspend fun deleteBackupFile(host: Node, filename: String): Boolean

Deletes a backup archive file.

Link copied to clipboard
suspend fun deleteNode(host: Node, node: Node)
Link copied to clipboard
suspend fun getBackupList(host: Node): List<Map<String, Any?>>

Lists backup archives from the server.

Link copied to clipboard
suspend fun getCameraSnapshot(host: Node, cameraId: String): ByteArray?

Fetches a JPEG snapshot from a camera node.

Link copied to clipboard
suspend fun getCameraThumbnailBytes(host: Node, cameraId: String, filename: String): ByteArray?

Fetches a saved camera thumbnail as bytes via the trusted httpClient.

Link copied to clipboard
suspend fun getCameraThumbnails(host: Node, cameraId: String): List<String>

Lists saved camera snapshot filenames (newest first).

Link copied to clipboard
fun getCameraThumbnailUrl(host: Node, cameraId: String, filename: String): String

Returns the URL for a saved camera thumbnail.

Link copied to clipboard
fun getDataExportUrl(host: Node, nodeId: String, startTime: Long? = null, endTime: Long? = null): String

Returns the data-export URL for a node, optionally filtered by time range. Caller composes a download request from the returned URL.

Link copied to clipboard
suspend fun getDataSeries(host: Node, sourceId: String, startTime: Long, endTime: Long): List<Snapshot>

Fetches data series (snapshots) for a data point within a time range. Used by GraphScreen to load and poll chart data.

Link copied to clipboard
suspend fun getGpioHeader(host: Node): List<PinMetaData>

Fetches available GPIO pin headers from a server.

Link copied to clipboard
suspend fun getQrCode(host: Node, nodeId: String): ByteArray?
Link copied to clipboard
suspend fun invokeNode(host: Node, target: Node, by: NodeIdentity, verb: NodeAction = NodeAction.EXECUTE)

Deliberate invocation. POSTs an InvokeRequest body to ${baseUrl(host)}/node/${target.id}/invoke — the explicit replacement for the legacy state-stamp click pattern (clients posting a node with state = NodeState.EXECUTED). Under Phase 4 the server's update() does not wake a processor; this endpoint is how clicks (and any other app-side deliberate fire) reach a node's processor.

Link copied to clipboard
suspend fun postNode(host: Node, node: Node)
Link copied to clipboard
suspend fun readHealth(host: Node): Node?
Link copied to clipboard
suspend fun readNode(host: Node, id: String): Node?
Link copied to clipboard
suspend fun readNodes(host: Node): List<Node>
Link copied to clipboard
suspend fun restoreBackup(host: Node, filename: String): String?

Initiates a restore from a backup archive.

Link copied to clipboard
suspend fun uploadDiagram(host: Node, projectId: String, fileName: String, svgBytes: ByteArray): Boolean

Uploads an SVG diagram file to a project.