Skip to main content

Module discovery

Module discovery 

Source
Expand description

Discovery-driven API surface.

Google’s Discovery Service publishes a machine-readable description of every Workspace method: HTTP verb, path template, parameters and OAuth scopes. scripts/fetch-discovery.mjs distils those documents into a compact index (method id, verb, path, scopes, parameters) which this module embeds — 308 methods across ten services in ~350 KiB, versus several megabytes for the raw documents.

This is the escape hatch that makes the curated commands unnecessary for coverage: grr api call <service>.<resource>.<method> reaches every method Google publishes, including ones that did not exist when grr was written, with no code change and no release.

Two properties matter more than the coverage:

  1. One consent, everything works. Every method carries its own scope list — grr api describe reports it and a 403 names it — but the login requests the union of all of them (all_scopes below), so a method that exists is a method you can call without a second consent round-trip. The index is the ceiling: whatever Google publishes next is reachable, scope included, the day the discovery PR lands.
  2. Offline. The index is compiled in, so grr api list and describe work with no network and no cache directory.

Structs§

Method
Parameter
RefreshReport
One service’s refresh outcome, for the grr api refresh report.
Service

Functions§

all_scopes
Every distinct scope the index names, sorted and deduped. The consent set is built from this (core::auth::scopes) instead of from a hand-typed list, so a scope Google adds arrives with the daily discovery PR rather than waiting for someone to notice a 403. Sorted, because the consent string must be byte-stable across runs.
build_path
Expand a discovery path template into a URL path, substituting {...} placeholders from the supplied parameters.
build_query
Render a parameter map as a query string, skipping path parameters (already substituted) and honouring repeated: true for multi-valued params such as Gmail’s labelIds.
cache_dir
Where grr api refresh stores fetched indexes, and where services() looks for a copy fresher than the embedded baseline.
refresh
Fetch fresh Discovery documents and write them to the cache directory.
resolve
Resolve service.resource.method (or service..method for the few top-level methods that have no resource).
services
Every service, keyed by name: the embedded baseline overlaid with any fresher on-disk cache. Parsed once, on first use.
value_to_string