townos-api 0.0.3

Client for the Town OS control plane (systemcontroller) HTTP API
Documentation
//! Box-wide status: the overview counters and the core services.

use crate::{Client, Ping, Result, SystemService};

impl Client {
    /// The dashboard counters.
    ///
    /// Unauthenticated — the control plane answers this without a token so a
    /// client can tell a reachable box from an unreachable one before asking for
    /// a password. `needs_setup` says the box has no enabled administrator yet.
    ///
    /// Calls `GET /status/ping`.
    pub async fn ping(&self) -> Result<Ping> {
        self.get_json("/status/ping").await
    }

    /// Calls `GET /system-services`.
    pub async fn system_services(&self) -> Result<Vec<SystemService>> {
        self.get_json("/system-services").await
    }

    /// Starts, stops or restarts a core service.
    ///
    /// Calls `POST /system-services/status` (admin).
    pub async fn set_system_service(&self, key: &str, action: &str) -> Result<()> {
        self.post_empty(
            "/system-services/status",
            &serde_json::json!({ "key": key, "action": action }),
        )
        .await
    }
}