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 — 401 methods across 14 services in ~430 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. The index is the scope ceiling. Every method carries its own scope list — grr api describe reports it and a 403 names it — so whatever Google publishes next is reachable the day the discovery PR lands. The login requests only a small default set (core::auth::login_scopes), not the union; a method outside the current grant answers 403 until grr auth login --service … / --all-scopes widens it.
  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.
Schema
A pruned response schema: field names, types, array/enum shapes, and required markers — deliberately without descriptions (that is the bulk of the raw size, and the shape is what an outputSchema consumer needs).
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