Opsmaru.Incus.Streams (opsmaru_incus v0.1.0)

Copy Markdown View Source

Native Incus binary stream helpers for the official v7.0.1 typed methods:

Every download delivers bounded binary chunks to an explicitly acknowledged sink/1 that returns :ok; the template-file upload reads a host enumerable of bounded binary chunks. Bodies are never JSON/base64 encoded, written to host filesystem paths, buffered by this module or replayed. Native project/target selection and required extensions are preserved; a missing extension fails before any backend contact. All failures use the shared Opsmaru.Incus.Error contract: explicit native error envelopes keep kind :native (including rejected POSTs), while ambiguous transport, deadline or disconnect failures of a POST are reported :uncertain (possibly accepted). No failure is retried. This is a bounded slice, not a complete-port claim.

Summary

Functions

CreateInstanceTemplateFile: POST the host enumerable source of bounded binary chunks to /1.0/instances/{name}/metadata/templates?path={template} with native Content-Type: application/octet-stream after checking the container_edit_metadata extension. Returns the native sync envelope on success; a failure may be :uncertain (possibly accepted) and is never retried.

GetInstanceConsoleLog: stream GET /1.0/instances/{name}/console to sink/1 after checking the native console extension.

GetInstanceDebugMemory: stream GET /1.0/instances/{name}/debug/memory?format={format}&instance-type=virtual-machine to sink/1. The instance-type=virtual-machine query value is part of the official client's native request. The native method checks no API extension.

Recorded exec output: stream GET /1.0/instances/{name}/logs/exec-output/{filename} to sink/1 after checking the native container_exec_recording extension. The pinned client keeps this private: its ExecInstance fetches each recorded file and then deletes it. This helper never deletes; call DeleteInstanceExecOutput explicitly. The file name must be one path segment (not . or ..).

GetInstanceLogfile: stream GET /1.0/instances/{name}/logs/{filename} to sink/1. The native method checks no API extension.

GetInstanceTemplateFile: stream GET /1.0/instances/{name}/metadata/templates?path={template} to sink/1 after checking the native container_edit_metadata extension. The template is form-encoded exactly like the official client's url.QueryEscape.

GetMetrics: GET /1.0/metrics with the metrics extension, streaming the text/OpenMetrics body to sink/1 under the shared transfer deadline and byte bounds. Returns {:ok, %Opsmaru.Incus.Transfer{}} or {:error, %Error{}}.

GetNetworkACLLogfile: stream GET /1.0/network-acls/{name}/log to sink/1.

Functions

create_instance_template_file(client, name, template, source)

CreateInstanceTemplateFile: POST the host enumerable source of bounded binary chunks to /1.0/instances/{name}/metadata/templates?path={template} with native Content-Type: application/octet-stream after checking the container_edit_metadata extension. Returns the native sync envelope on success; a failure may be :uncertain (possibly accepted) and is never retried.

instance_console_log(client, name, sink)

GetInstanceConsoleLog: stream GET /1.0/instances/{name}/console to sink/1 after checking the native console extension.

instance_debug_memory(client, name, format, sink)

GetInstanceDebugMemory: stream GET /1.0/instances/{name}/debug/memory?format={format}&instance-type=virtual-machine to sink/1. The instance-type=virtual-machine query value is part of the official client's native request. The native method checks no API extension.

instance_exec_output(client, name, filename, sink)

Recorded exec output: stream GET /1.0/instances/{name}/logs/exec-output/{filename} to sink/1 after checking the native container_exec_recording extension. The pinned client keeps this private: its ExecInstance fetches each recorded file and then deletes it. This helper never deletes; call DeleteInstanceExecOutput explicitly. The file name must be one path segment (not . or ..).

instance_logfile(client, name, filename, sink)

GetInstanceLogfile: stream GET /1.0/instances/{name}/logs/{filename} to sink/1. The native method checks no API extension.

instance_template_file(client, name, template, sink)

GetInstanceTemplateFile: stream GET /1.0/instances/{name}/metadata/templates?path={template} to sink/1 after checking the native container_edit_metadata extension. The template is form-encoded exactly like the official client's url.QueryEscape.

metrics(client, sink)

GetMetrics: GET /1.0/metrics with the metrics extension, streaming the text/OpenMetrics body to sink/1 under the shared transfer deadline and byte bounds. Returns {:ok, %Opsmaru.Incus.Transfer{}} or {:error, %Error{}}.

network_acl_log(client, name, sink)

GetNetworkACLLogfile: stream GET /1.0/network-acls/{name}/log to sink/1.