quant rules
Deploy rules that run an edge function, an auth function or a filter function. The rules live in a JSON file in your repository.
Synopsis
Section titled “Synopsis”quant rules <file> [--functions <manifest>] [--dry-run] [--force]Credentials
Section titled “Credentials”quant rules calls the platform API, not the content API. It does not use the project token that other commands use.
| Setting | Value |
|---|---|
QUANT_API_TOKEN (or --api-token) |
A separate project-scoped token with projects:read, rules:read and rules:write. |
QUANT_BASE_URL (or --api-base-url) |
{dashboard}/api/v2: https://dashboard.quantcdn.io/api/v2 on QuantCDN, https://dash.quantgov.cloud/api/v2 on QuantGov. HTTPS only. |
| Customer and project | -c and -p, QUANT_CLIENT_ID and QUANT_PROJECT, or quant.json. |
The command ignores QUANT_TOKEN, -t and the token in quant.json.
Rules file
Section titled “Rules file”{ "version": 1, "namespace": "orbit", "rules": [ { "id": "api", "type": "function", "urls": ["/api/*"], "weight": 10, "function_ref": "orbit-api-v1" } ]}versionis1.namespaceis a stable name for your set of rules (^[a-z][a-z0-9-]{0,47}$). A file holds at most 100 rules and 64 KiB.- Each rule has a unique lowercase
id, atype(function,authorfilter),urls, a numericweightand eitherfunction_reforfunction_uuid. weightruns lowest first, from -100000 to 100000. A negative weight runs before any rule added in the dashboard or API. Give authentication rules a lower weight than the functions they protect.function_refis theidof an entry in the functions manifest (--functions) with the same type. Usefunction_uuidonly for a function the manifest does not define. The function needs a version 1 to 5 UUID.- Optional:
name,domains,methods,disabled.
A deploy changes only rules with the same namespace and id. It keeps all other rules. To turn a rule off, set disabled: true.
Rules deployed this way show as read-only in the dashboard and the rules API. If someone changed one outside code, the deploy writes nothing, exits non-zero and lists the changed fields. Use --force to overwrite them. --force never takes over a rule that this file did not create.
Example
Section titled “Example”export QUANT_API_TOKEN=...export QUANT_BASE_URL=https://dashboard.quantcdn.io/api/v2
quant rules quant/edge-rules.json --functions quant/edge-functions.json -c ORG -p PROJECT --dry-runquant functions quant/edge-functions.json -c ORG -p PROJECTquant rules quant/edge-rules.json --functions quant/edge-functions.json -c ORG -p PROJECT--dry-run checks permissions and previews the changes without writing. Deploy the functions first so their UUIDs exist.
