It uses the api helper from the deploy guide, and these variables: PROJECT_ID (from the subscription) and SERVICE_ID (the service instance). The routes live under /projects/{project_id}/service-instances/{id}/units.
const base = `/projects/${projectId}/service-instances/${serviceId}/units`;const units = await api("GET", base);console.log(units.scalable, units.max_units, units.included_units, units.volume_locked);for (const u of units.data) console.log(u.ordinal, u.state, u.billing_class);
Code
base = f"/projects/{project_id}/service-instances/{service_id}/units"units = api("GET", base)print(units["scalable"], units["max_units"], units["included_units"], units["volume_locked"])for u in units["data"]: print(u["ordinal"], u["state"], u["billing_class"])
scalable must be true and volume_locked false. billing_class is included for units the plan covers and extra for the rest.
An autoscaled policy needs a CPU target, a memory target or a schedule rule. Omitted fields keep their value; send null to clear a nullable one, for example "spend_cap_cents": null.
5. Watch what it does
Decisions say what the autoscaler did and why; the count series shows how many units ran.
Units that are scaled away stop billing at once. If a change is refused, the details field starts with a reason code, for example volume_locks_to_one_unit or a limit (see Limits).