# `Opsmaru.Incus.Streams`
[🔗](https://github.com/upmaru/opsmaru-incus/blob/v0.1.0/lib/opsmaru/incus/streams.ex#L1)

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

- `metrics/2` (GetMetrics)
- `network_acl_log/3` (GetNetworkACLLogfile)
- `instance_logfile/4` (GetInstanceLogfile)
- `instance_console_log/3` (GetInstanceConsoleLog)
- `instance_template_file/4` (GetInstanceTemplateFile)
- `create_instance_template_file/4` (CreateInstanceTemplateFile)
- `instance_debug_memory/4` (GetInstanceDebugMemory)
- `instance_exec_output/4` (recorded exec output; private in the pinned client)

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.

# `create_instance_template_file`

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`

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

# `instance_debug_memory`

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`

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`

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

# `instance_template_file`

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`

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`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
