1
0
mirror of https://github.com/docker/docs.git synced 2026-10-23 18:09:02 +03:00
Files
docs/hack/sync-sandboxes-docs.py
David Karlsson bed22bda81 docs: Cloud Sandboxes API and SDK (#26168)
## Description

Add an experimental Sandboxes API and SDK section alongside Docker
Sandboxes under AI and agents, at `/ai/sandboxes-api/`. Cover
installation of `@docker/sandboxes`, browser and PAT authentication, and
a TypeScript walkthrough that launches the shell kit, runs a command,
and deletes the sandbox. Explain kits and image choices with examples,
along with compute sizes, quotas, permissions, resource lifecycle,
errors, and retries. Link subscription setup and billing to the shared
Docker Agentic Platform guide. Preserve the previous
`/ai/sandboxes/api/` URLs with redirects.

Uses the shared Docker Agentic Platform documentation merged in #26142.
Sibling to #26158, which introduces CLI-side Cloud Sandboxes
documentation.

Include 36 SDK cookbook recipes at `/ai/sandboxes-api/cookbook/` and the
public REST API reference at `/reference/api/sandboxes/`. Import the
generated export from `docker/sbx-api` commit `60d79c1d` (source
`1a7f4026`). Overview and installation remain maintained here. The
reference uses the shared API renderer from main, with separate
operation and schema pages, streaming and WebSocket details, and a
downloadable OpenAPI spec. An API reference link appears in the API/SDK
sidebar. A pinned manifest and import script provide the basis for later
release automation.

Examples are optional in the shared renderer; supplied examples still
have to pass schema validation. Requests without body examples use a
request-body file with instructions to prepare it. The import copies all
selected recipes and the OpenAPI specification byte for byte from the
corrected upstream export, without patches or link rewrites. The broken
naming recipe remains temporarily excluded.

This remains a draft pending validation against the published npm SDK.
The imported cookbook contains the TypeScript-only guidance, five-minute
request deadlines, kit-readiness explanation, active-policy status
requirement, and snapshot-deletion and lifetime-renewal restrictions.

Validation: scoped Markdown and Vale checks, full Hugo build, rendered
navigation, redirects, and internal links, and TypeScript type-checking
against the generated public SDK from `docker/sbx-api` commit
`68f214b9`. Import validation also covers all 60 REST operations and 188
schema definitions, 1,198 imported-page links and anchors,
desktop/mobile rendering, Markdown output, spec delivery, and a repeat
import. The shared renderer tests, strict generation for all five APIs
(zero diagnostics), full Hugo build, and verification of 453
HTML/Markdown page pairs and API links pass. No live sandbox execution.
The corrected export passes strict generation for all five APIs with
zero diagnostics, scoped Markdown/Vale lint, a full Hugo build, and
verification of 453 HTML/Markdown page pairs and API links. A repeat
import produces identical files. The spec update changes examples only;
schemas and operations are unchanged.

@netlify /ai/sandboxes-api/

Generated by Codex

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-24 18:06:30 +02:00

51 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Import the pinned public cookbook export. See hack/sandboxes/README.md."""
import io
import json
from pathlib import Path
import subprocess
import tarfile
ROOT = Path(__file__).resolve().parent.parent
MANIFEST = ROOT / "hack/sandboxes/source.json"
GUIDES = ROOT / "content/manuals/ai/sandboxes-api/cookbook"
REFERENCE = ROOT / "content/reference/api/sandboxes"
def main():
source = json.loads(MANIFEST.read_text())
archive = subprocess.check_output([
"gh", "api",
f"repos/{source['repository']}/tarball/{source['generatedCommit']}",
])
with tarfile.open(fileobj=io.BytesIO(archive), mode="r:gz") as tar:
files = {}
for member in tar.getmembers():
if member.isfile():
path = member.name.split("/", 1)[1]
files[path] = tar.extractfile(member).read()
if files["SOURCE"].decode().strip() != source["sourceCommit"]:
raise SystemExit("The generated export does not match the recorded source commit")
# Prepare every output before changing the working tree. Fail if an upstream
# page disappears instead of silently dropping a published recipe.
outputs = {}
for name in source["guides"]:
if Path(name).name != name or not name.endswith(".md"):
raise SystemExit(f"Invalid guide filename: {name}")
outputs[GUIDES / name] = files[f"cookbook/outputs/guides/{name}"]
outputs[REFERENCE / "api.yaml"] = files["cookbook/outputs/api-reference/api.yaml"]
for destination, content in outputs.items():
destination.parent.mkdir(parents=True, exist_ok=True)
destination.write_bytes(content)
print(f"Imported {len(source['guides'])} recipes and the public OpenAPI specification")
if __name__ == "__main__":
main()