Back to Googleworkspace

google-workspace

crates/google-workspace/README.md

0.22.51.6 KB
Original Source

google-workspace

Core Rust library for interacting with Google Workspace APIs via the Discovery Service.

This crate provides the foundational types and utilities used by the google-workspace-cli (gws) command-line tool, and can be used independently for programmatic access.

Dynamic Discovery — this library fetches Google's Discovery Documents at runtime rather than relying on generated client crates. When Google adds or updates an API endpoint, your code picks it up automatically.

Modules

ModuleDescription
discoveryDiscovery Document types (RestDescription, RestMethod, etc.) and async fetch with optional disk caching
servicesService registry mapping aliases (e.g., drive) to API name/version pairs
errorStructured GwsError enum with exit codes and JSON serialization
validateInput validation: path safety, resource name checks, URL encoding
clientHTTP client builder with automatic retry logic

Usage

rust
use google_workspace::discovery::fetch_discovery_document;
use google_workspace::services::resolve_service;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let (api, version) = resolve_service("drive").unwrap();
    let doc = fetch_discovery_document(api, version, None).await?;

    println!("{} {} — {} resources",
        doc.name, doc.version,
        doc.resources.len(),
    );
    Ok(())
}

License

Apache-2.0 — see LICENSE.