1
0
mirror of https://github.com/docker/docs.git synced 2026-10-25 06:09:46 +03:00
Files
docs/layouts/_partials/api-ref/curl.html
David Karlsson 553c69e1b7 sbx: restructure governance docs and add API reference (#25162)
## Summary

Restructures the Docker AI Governance documentation under
\`/ai/sandboxes/governance/\` and adds the supporting API reference.

Preview links:

-
https://deploy-preview-25162--docsdocker.netlify.app/ai/sandboxes/governance/
-
https://deploy-preview-25162--docsdocker.netlify.app/reference/api/ai-governance/

### Information architecture

The existing \`security/governance\` and \`security/policy\` pages are
merged into a new top-level \`governance\` section so local-policy and
org-policy sit side by side instead of being split across unrelated
parents:

- \`/ai/sandboxes/governance/\` — section landing; explains local + org
as layered enforcement
- \`/ai/sandboxes/governance/concepts/\` — resource model, rule syntax,
evaluation, precedence
- \`/ai/sandboxes/governance/local/\` — \`sbx policy\` CLI for
individual machines
- \`/ai/sandboxes/governance/org/\` — Admin Console flow (was
\`security/governance.md\`)
- \`/ai/sandboxes/governance/monitoring/\` — \`sbx policy ls\` / \`sbx
policy log\`

### API reference

\`/reference/api/ai-governance/\` renders the Governance OpenAPI spec
vendored at \`content/reference/api/ai-governance/api.yaml\` from
\`docker/governor-services\`. Operations, schemas, examples, and status
codes are fully driven by the spec — future updates land via re-vendor,
not in-repo edits. Anything wrong in the rendered reference should be
fixed upstream and re-vendored here.

The spec has been re-vendored to the latest upstream version, which
updated the server URL to \`hub.docker.com/v2\` and added the
\`/governance/\` prefix to all API paths.

### Review focus

1. The \`/ai/sandboxes/governance/\` landing — does the local + org
framing match how the product is positioned?
2. \`/reference/api/ai-governance/\` — does the rendered spec match the
source of truth, and is anything important missing?

Generated by Claude Code

---------

Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 10:05:05 +02:00

140 lines
4.5 KiB
HTML

{{/* Build a curl command for an OpenAPI operation.
Input dict:
api — unmarshaled spec root
op — operation object
method — http method (lowercase string)
path — path string (e.g. "/orgs/{org_name}/policies")
sharedParams — already-resolved path-level parameters
Output: a multi-line curl command string (line-continued with " \\\n ").
Path placeholders are filled from parameter examples when available;
unresolved path params fall back to `<name>`. Query params without an
example are omitted. Bearer-auth schemes contribute an Authorization
header with the literal `$TOKEN` placeholder.
*/}}
{{- $api := .api -}}
{{- $op := .op -}}
{{- $method := .method -}}
{{- $path := .path -}}
{{- $sharedParams := .sharedParams -}}
{{/* Combine path-level + operation-level parameters, resolving $refs. */}}
{{- $params := $sharedParams -}}
{{- with index $op "parameters" -}}
{{- range . -}}
{{- $p := partial "api-ref/resolve.html" (dict "api" $api "node" .) -}}
{{- $params = $params | append $p -}}
{{- end -}}
{{- end -}}
{{/* Substitute path placeholders. */}}
{{- $url := $path -}}
{{- range $params -}}
{{- if eq .in "path" -}}
{{- $val := printf "<%s>" .name -}}
{{- with .example -}}{{- $val = . | string -}}{{- end -}}
{{- with .examples -}}
{{- $picked := false -}}
{{- with index . "default" -}}
{{- with .value -}}
{{- $val = . | string -}}{{- $picked = true -}}
{{- end -}}
{{- end -}}
{{- if not $picked -}}
{{- range . -}}
{{- if not $picked -}}
{{- with .value -}}
{{- $val = . | string -}}{{- $picked = true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $url = replace $url (printf "{%s}" .name) $val -}}
{{- end -}}
{{- end -}}
{{/* Append query string from query parameters that have examples. */}}
{{- $qs := slice -}}
{{- range $params -}}
{{- if eq .in "query" -}}
{{- $val := "" -}}
{{- with .example -}}{{- $val = . | string -}}{{- end -}}
{{- with .examples -}}
{{- $picked := false -}}
{{- with index . "default" -}}
{{- with .value -}}
{{- $val = . | string -}}{{- $picked = true -}}
{{- end -}}
{{- end -}}
{{- if not $picked -}}
{{- range . -}}
{{- if not $picked -}}
{{- with .value -}}
{{- $val = . | string -}}{{- $picked = true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $val -}}
{{- $qs = $qs | append (printf "%s=%s" .name $val) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $qs -}}{{- $url = printf "%s?%s" $url (delimit $qs "&") -}}{{- end -}}
{{/* Prepend base URL from the first server entry. */}}
{{- $base := "" -}}
{{- with index $api.servers 0 -}}{{- $base = .url -}}{{- end -}}
{{- $fullURL := printf "%s%s" $base $url -}}
{{- $lines := slice (printf "curl -X %s '%s'" (upper $method) $fullURL) -}}
{{/* Bearer auth header if the spec defines a bearer scheme. */}}
{{- $hasBearer := false -}}
{{- with $api.components -}}
{{- with .securitySchemes -}}
{{- range . -}}
{{- if and (eq .type "http") (eq .scheme "bearer") -}}
{{- $hasBearer = true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $hasBearer -}}
{{- $lines = $lines | append "-H 'Authorization: Bearer $TOKEN'" -}}
{{- end -}}
{{/* Request body example. Picks the first content type declared. */}}
{{- with $op.requestBody -}}
{{- $body := partial "api-ref/resolve.html" (dict "api" $api "node" .) -}}
{{- $ct := "" -}}
{{- $media := dict -}}
{{- range $name, $m := $body.content -}}
{{- if not $ct -}}{{- $ct = $name -}}{{- $media = $m -}}{{- end -}}
{{- end -}}
{{- if $ct -}}
{{- $lines = $lines | append (printf "-H 'Content-Type: %s'" $ct) -}}
{{- $example := "" -}}
{{- with $media.examples -}}
{{- with index . "default" -}}
{{- with .value -}}{{- $example = . | jsonify -}}{{- end -}}
{{- end -}}
{{- if not $example -}}
{{- range . -}}
{{- if not $example -}}
{{- with .value -}}{{- $example = . | jsonify -}}{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $example -}}
{{- $lines = $lines | append (printf "-d '%s'" $example) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- return (delimit $lines " \\\n ") -}}