guacamole-client 0.5.0

Rust client library for the Guacamole REST API
Documentation
use serde_json::Value;

use crate::client::GuacamoleClient;
use crate::error::Result;
use crate::validation::validate_tunnel_id;

impl GuacamoleClient {
    /// Lists all active tunnels for the current session.
    pub async fn list_tunnels(&self) -> Result<Value> {
        let url = self.url("/api/session/tunnels")?;
        let response = self.http.get(&url).send().await?;
        Self::parse_response(response, "tunnels").await
    }

    /// Retrieves the active connection and sharing profiles for a tunnel.
    pub async fn get_tunnel_active_connection(
        &self,
        tunnel_id: &str,
    ) -> Result<Value> {
        validate_tunnel_id(tunnel_id)?;
        let url = self.url(&format!(
            "/api/session/tunnels/{tunnel_id}/activeConnection/connection/sharingProfiles"
        ))?;
        let response = self.http.get(&url).send().await?;
        Self::parse_response(response, &format!("tunnel {tunnel_id} active connection")).await
    }
}