Files
googleworkspace__cli/crates/google-workspace/README.md
T
Justin Poehnelt 029e5def2b feat: extract google-workspace library crate (cargo workspace) (#613)
* feat: extract google-workspace library crate and restructure as cargo workspace

- Create crates/google-workspace/ with public modules: discovery, error, services, validate, client
- Move CLI binary to crates/cli/ (package: google-workspace-cli, binary: gws)
- Root Cargo.toml is now workspace-only
- Binary modules use thin re-exports from library (zero behavioral changes)
- Discovery fetch_discovery_document accepts cache_dir parameter for library consumers
- Break output.rs / error.rs circular dep by moving char detection to library validate module
- Update CI workflows for workspace (--workspace flags, path filters)
- Update dist-workspace.toml and policy.yml for new crate locations

Closes #386

* refactor: rename crates/cli to crates/google-workspace-cli

* chore: sync CLI version to 0.20.1 and regenerate skills

* chore: update labeler paths for workspace crate layout

* fix: update flake.nix to read version from CLI crate Cargo.toml

* fix: use tokio::fs for non-blocking I/O in library discovery cache

* docs: update AGENTS.md source layout for workspace structure

* docs: add crate-level READMEs for crates.io

---------

Co-authored-by: jpoehnelt-bot <jpoehnelt-bot@users.noreply.github.com>
2026-03-24 14:40:03 -06:00

1.6 KiB

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

Module Description
discovery Discovery Document types (RestDescription, RestMethod, etc.) and async fetch with optional disk caching
services Service registry mapping aliases (e.g., drive) to API name/version pairs
error Structured GwsError enum with exit codes and JSON serialization
validate Input validation: path safety, resource name checks, URL encoding
client HTTP client builder with automatic retry logic

Usage

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.