pub struct RestClient { /* private fields */ }Expand description
A blocking REST client for the agent HTTP API. Cheap to clone; clones share
one Auth.
Implementations§
Source§impl RestClient
impl RestClient
Sourcepub fn new(base: impl Into<String>) -> Self
pub fn new(base: impl Into<String>) -> Self
Build a client for the given base URL (no trailing slash).
Sourcepub fn with_api_key(self, key: impl Into<String>) -> Self
pub fn with_api_key(self, key: impl Into<String>) -> Self
Attach the pairing key sent as X-ADOS-Key on every request.
Sourcepub fn set_api_key(&self, key: Option<String>)
pub fn set_api_key(&self, key: Option<String>)
Set or clear the pairing key on this client and every clone of it.
Sourcepub fn set_session(&self, session: Option<String>)
pub fn set_session(&self, session: Option<String>)
Set or clear the dashboard PIN session on this client and every clone.
Sourcepub fn get_json(&self, path: &str) -> Result<Value, RestError>
pub fn get_json(&self, path: &str) -> Result<Value, RestError>
GET path (e.g. /api/status) and parse the JSON body.
Sourcepub fn get_json_timeout(
&self,
path: &str,
timeout: Duration,
) -> Result<Value, RestError>
pub fn get_json_timeout( &self, path: &str, timeout: Duration, ) -> Result<Value, RestError>
GET path with its own request timeout (a slow route such as a Wi-Fi
scan).
Sourcepub fn send_json(
&self,
method: &str,
path: &str,
body: Option<&Value>,
timeout: Duration,
) -> Result<Value, RestError>
pub fn send_json( &self, method: &str, path: &str, body: Option<&Value>, timeout: Duration, ) -> Result<Value, RestError>
Send method path with an optional JSON body and parse the JSON reply.
An empty 2xx body is Value::Null.
Sourcepub fn open_stream(&self, path: &str) -> Result<Box<dyn Read + Send>, RestError>
pub fn open_stream(&self, path: &str) -> Result<Box<dyn Read + Send>, RestError>
Open a server-sent-events stream on path. Only the connect is
time-bounded; the returned reader blocks until the server writes or
closes.
Sourcepub fn status(&self) -> Result<Value, RestError>
pub fn status(&self) -> Result<Value, RestError>
GET /api/status — the agent status snapshot the dashboard renders.
Sourcepub fn setup_status(&self) -> Result<Value, RestError>
pub fn setup_status(&self) -> Result<Value, RestError>
GET /api/v1/setup/status — the setup wizard state (read-only).