guacamole-client 0.5.1

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

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

impl GuacamoleClient {
    /// Fetches a schema endpoint, resolving the data source and building the URL.
    async fn schema_request(
        &self,
        data_source: Option<&str>,
        endpoint: &str,
        description: &str,
    ) -> Result<Value> {
        let ds = self.resolve_data_source(data_source)?;
        let url = self.url(&format!("/api/session/data/{ds}/schema/{endpoint}"))?;
        let response = self.http.get(&url).send().await?;
        Self::parse_response(response, description).await
    }

    /// Lists the user attributes schema for the given data source.
    pub async fn list_user_attributes_schema(
        &self,
        data_source: Option<&str>,
    ) -> Result<Value> {
        self.schema_request(data_source, "userAttributes", "user attributes schema")
            .await
    }

    /// Lists the user group attributes schema for the given data source.
    pub async fn list_user_group_attributes_schema(
        &self,
        data_source: Option<&str>,
    ) -> Result<Value> {
        self.schema_request(data_source, "userGroupAttributes", "user group attributes schema")
            .await
    }

    /// Lists the connection attributes schema for the given data source.
    pub async fn list_connection_attributes_schema(
        &self,
        data_source: Option<&str>,
    ) -> Result<Value> {
        self.schema_request(data_source, "connectionAttributes", "connection attributes schema")
            .await
    }

    /// Lists the sharing profile attributes schema for the given data source.
    pub async fn list_sharing_profile_attributes_schema(
        &self,
        data_source: Option<&str>,
    ) -> Result<Value> {
        self.schema_request(
            data_source,
            "sharingProfileAttributes",
            "sharing profile attributes schema",
        )
        .await
    }

    /// Lists the connection group attributes schema for the given data source.
    pub async fn list_connection_group_attributes_schema(
        &self,
        data_source: Option<&str>,
    ) -> Result<Value> {
        self.schema_request(
            data_source,
            "connectionGroupAttributes",
            "connection group attributes schema",
        )
        .await
    }

    /// Lists the available protocols and their parameters for the given data source.
    pub async fn list_protocols(
        &self,
        data_source: Option<&str>,
    ) -> Result<Value> {
        self.schema_request(data_source, "protocols", "protocols")
            .await
    }
}