pub struct Client { /* private fields */ }Expand description
Connection to incusd.
Implementations§
Source§impl Client
impl Client
Sourcepub fn default_socket() -> PathBuf
pub fn default_socket() -> PathBuf
Locate the socket the way the incus tools do: $INCUS_SOCKET, else
$INCUS_DIR/unix.socket, else /var/lib/incus/unix.socket. On macOS
the last fallback is the default isb machine’s forwarded socket,
~/.isb/machine/isb/incus.sock.
pub fn with_socket(socket: impl Into<PathBuf>) -> Self
Sourcepub fn project(self, project: impl Into<String>) -> Self
pub fn project(self, project: impl Into<String>) -> Self
Use an incus project other than default.
pub fn timeouts(self, timeouts: Timeouts) -> Self
pub fn socket(&self) -> &Path
pub fn project_name(&self) -> &str
pub fn get_timeouts(&self) -> &Timeouts
Sourcepub fn server_info(&self) -> Result<Value>
pub fn server_info(&self) -> Result<Value>
GET /1.0: server info. Also a cheap reachability check.
Sourcepub fn has_extension(&self, name: &str) -> Result<bool>
pub fn has_extension(&self, name: &str) -> Result<bool>
Whether the server lists the API extension name.
Sourcepub fn server_version(&self) -> Result<Option<String>>
pub fn server_version(&self) -> Result<Option<String>>
The server’s version (environment.server_version), if it says.
Sourcepub fn oci_unsupported(&self) -> Option<String>
pub fn oci_unsupported(&self) -> Option<String>
A sentence saying so when this incus cannot run OCI images
(docker:, ghcr:, registry:), else None. Also None when
incusd cannot be asked.
Sourcepub fn wait_operation(
&self,
operation: &str,
step: &str,
deadline: Duration,
) -> Result<Value>
pub fn wait_operation( &self, operation: &str, step: &str, deadline: Duration, ) -> Result<Value>
Wait for an operation to finish. Returns its metadata on success.
Sourcepub fn start_operation(
&self,
method: &str,
path: &str,
body: Option<&Value>,
) -> Result<String>
pub fn start_operation( &self, method: &str, path: &str, body: Option<&Value>, ) -> Result<String>
Start an operation without waiting for it; returns its path
(/1.0/operations/<id>). Low-level: most callers want the sandbox API.
Sourcepub fn cancel_operation(&self, operation: &str) -> Result<()>
pub fn cancel_operation(&self, operation: &str) -> Result<()>
DELETE /1.0/operations/<id>. Fails for operations incus will not cancel.
Sourcepub fn push_file(
&self,
instance: &str,
path: &str,
data: &[u8],
uid: u32,
gid: u32,
mode: u32,
) -> Result<()>
pub fn push_file( &self, instance: &str, path: &str, data: &[u8], uid: u32, gid: u32, mode: u32, ) -> Result<()>
Write a file into an instance (running or stopped), replacing it.
Parent directories must exist; see Client::make_dir.
Sourcepub fn make_dir(
&self,
instance: &str,
path: &str,
uid: u32,
gid: u32,
mode: u32,
) -> Result<()>
pub fn make_dir( &self, instance: &str, path: &str, uid: u32, gid: u32, mode: u32, ) -> Result<()>
Create a directory in an instance; an existing one is left as is.
Sourcepub fn console_log(&self, instance: &str) -> Result<Vec<u8>>
pub fn console_log(&self, instance: &str) -> Result<Vec<u8>>
An instance’s console log as incus keeps it (an OCI app’s output).
Sourcepub fn read_file(&self, instance: &str, path: &str) -> Result<Option<Vec<u8>>>
pub fn read_file(&self, instance: &str, path: &str) -> Result<Option<Vec<u8>>>
Read a file from an instance; None if it does not exist.
Sourcepub fn events_websocket(&self, query: &str) -> Result<WebSocket<UnixStream>>
pub fn events_websocket(&self, query: &str) -> Result<WebSocket<UnixStream>>
Follow /1.0/events?QUERY (all projects when the query says so) as
a websocket. Reads time out every 5 s so a follower can check
whether to stop; a timeout is not an error.