forked from retoor/devplacepy
iUUUUpdatexz
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from .._shared import endpoint, field
|
||||
|
||||
GROUP = {
|
||||
"slug": "workspaces",
|
||||
"title": "Dev Workspaces",
|
||||
"intro": """
|
||||
# Dev Workspaces
|
||||
|
||||
A workspace is a browser VS Code environment attached to one of your projects. It runs your project
|
||||
files, a terminal, and preinstalled Python, Rust, Nim and Swift toolchains. `sudo` and
|
||||
`apt install` work with no extra setup; ports below 1024 cannot bind, so use a high port and publish
|
||||
it through a tunnel.
|
||||
|
||||
A **tunnel** publishes one port from inside your container on a public HTTPS hostname of the form
|
||||
`<port>-<name>.tunnel.pravda.education`. **Tunnel URLs are public and unauthenticated** - anyone with
|
||||
the link can reach whatever you are serving.
|
||||
|
||||
Workspaces are bounded: a count limit per user, a disk quota, an egress quota, and a tunnel limit.
|
||||
An idle workspace is warned about, then stopped, then warned again, then removed. Every warning
|
||||
arrives as a `workspace` notification and states exactly what happens next and when.
|
||||
""",
|
||||
"endpoints": [
|
||||
endpoint(
|
||||
id="workspace-get",
|
||||
method="GET",
|
||||
path="/projects/{slug}/workspace",
|
||||
title="Read workspace",
|
||||
summary=(
|
||||
"State, quota usage, idle countdown, tunnels and open moderation flags "
|
||||
"for your workspace on this project."
|
||||
),
|
||||
auth="user",
|
||||
params=[
|
||||
field("slug", "path", "string", True, "my-project", "Project slug or uid."),
|
||||
],
|
||||
sample_response={
|
||||
"has_workspace": True,
|
||||
"viewer_can_workspace": True,
|
||||
"workspace_count": 1,
|
||||
"max_workspaces": 2,
|
||||
"editor_url": "/projects/my-project/containers/instances/INSTANCE_UID/code/",
|
||||
"workspace": {
|
||||
"uid": "INSTANCE_UID",
|
||||
"status": "running",
|
||||
"suspended": False,
|
||||
"tunnel_name": "brave-otter",
|
||||
"primary_url": "https://brave-otter.tunnel.pravda.education",
|
||||
"disk_bytes": 5242880,
|
||||
"disk_quota_mb": 2048,
|
||||
"disk_percent": 1,
|
||||
"egress_bytes": 10240,
|
||||
"egress_quota_mb": 10240,
|
||||
"egress_percent": 0,
|
||||
"idle_stop_minutes": 60,
|
||||
"retention_days": 14,
|
||||
"max_tunnels": 5,
|
||||
"tunnels": [],
|
||||
"flags": [],
|
||||
},
|
||||
},
|
||||
),
|
||||
endpoint(
|
||||
id="workspace-open",
|
||||
method="POST",
|
||||
path="/projects/{slug}/workspace",
|
||||
title="Open or resume workspace",
|
||||
summary=(
|
||||
"Create the workspace if you have none for this project, otherwise resume "
|
||||
"it. Idempotent. Refused when you are at your workspace limit, over disk "
|
||||
"quota, or suspended."
|
||||
),
|
||||
auth="user",
|
||||
params=[
|
||||
field("slug", "path", "string", True, "my-project", "Project slug or uid."),
|
||||
],
|
||||
sample_response={"ok": True, "redirect": "/projects/my-project/workspace"},
|
||||
),
|
||||
endpoint(
|
||||
id="workspace-stop",
|
||||
method="POST",
|
||||
path="/projects/{slug}/workspace/stop",
|
||||
title="Stop workspace",
|
||||
summary="Stop the container. Files and tunnels are kept.",
|
||||
auth="user",
|
||||
params=[
|
||||
field("slug", "path", "string", True, "my-project", "Project slug or uid."),
|
||||
],
|
||||
sample_response={"ok": True, "redirect": "/projects/my-project/workspace"},
|
||||
),
|
||||
endpoint(
|
||||
id="workspace-delete",
|
||||
method="POST",
|
||||
path="/projects/{slug}/workspace/delete",
|
||||
title="Delete workspace",
|
||||
summary="Remove the workspace and its tunnels. An administrator can restore it.",
|
||||
auth="user",
|
||||
params=[
|
||||
field("slug", "path", "string", True, "my-project", "Project slug or uid."),
|
||||
],
|
||||
sample_response={"ok": True, "redirect": "/projects/my-project/workspace"},
|
||||
),
|
||||
endpoint(
|
||||
id="workspace-tunnels-list",
|
||||
method="GET",
|
||||
path="/projects/{slug}/workspace/tunnels",
|
||||
title="List tunnels",
|
||||
summary="Every public tunnel published by this workspace.",
|
||||
auth="user",
|
||||
params=[
|
||||
field("slug", "path", "string", True, "my-project", "Project slug or uid."),
|
||||
],
|
||||
sample_response={
|
||||
"tunnels": [
|
||||
{
|
||||
"uid": "TUNNEL_UID",
|
||||
"hostname": "8080-brave-otter.tunnel.pravda.education",
|
||||
"label": "web",
|
||||
"container_port": 8080,
|
||||
"status": "active",
|
||||
"cert_status": "valid",
|
||||
"request_count": 12,
|
||||
"bytes_out": 40960,
|
||||
}
|
||||
]
|
||||
},
|
||||
),
|
||||
endpoint(
|
||||
id="workspace-tunnel-create",
|
||||
method="POST",
|
||||
path="/projects/{slug}/workspace/tunnels",
|
||||
title="Create tunnel",
|
||||
summary=(
|
||||
"Publish a container port on a public HTTPS hostname. The URL is public "
|
||||
"and unauthenticated. Refused past the tunnel limit."
|
||||
),
|
||||
auth="user",
|
||||
params=[
|
||||
field("slug", "path", "string", True, "my-project", "Project slug or uid."),
|
||||
field("container_port", "body", "integer", True, 8080, "Port inside the container."),
|
||||
field("label", "body", "string", False, "web", "Human label."),
|
||||
],
|
||||
sample_response={
|
||||
"ok": True,
|
||||
"data": {
|
||||
"uid": "TUNNEL_UID",
|
||||
"hostname": "8080-brave-otter.tunnel.pravda.education",
|
||||
"status": "pending",
|
||||
},
|
||||
},
|
||||
),
|
||||
endpoint(
|
||||
id="workspace-tunnel-delete",
|
||||
method="POST",
|
||||
path="/projects/{slug}/workspace/tunnels/{uid}/delete",
|
||||
title="Delete tunnel",
|
||||
summary="Remove a tunnel. The public URL stops serving immediately.",
|
||||
auth="user",
|
||||
params=[
|
||||
field("slug", "path", "string", True, "my-project", "Project slug or uid."),
|
||||
field("uid", "path", "string", True, "TUNNEL_UID", "Tunnel uid."),
|
||||
],
|
||||
sample_response={"ok": True, "redirect": "/projects/my-project/workspace"},
|
||||
),
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user