Skip to content

Commit 1e9e19c

Browse files
authored
feat: list sandboxes by running status (#37)
* feat: allow listing sandboxes by running status * feat: add cli command * feat: enable piping * better logging * add limit support to list
1 parent 4b27757 commit 1e9e19c

File tree

12 files changed

+1098
-85
lines changed

12 files changed

+1098
-85
lines changed

openapi.json

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,19 @@
392392
"properties": {
393393
"data": {
394394
"properties": {
395+
"pagination": {
396+
"properties": {
397+
"current_page": { "type": "integer" },
398+
"next_page": {
399+
"description": "The number of the next page, if any. If `null`, the current page is the last page of records.",
400+
"nullable": true,
401+
"type": "integer"
402+
},
403+
"total_records": { "type": "integer" }
404+
},
405+
"required": ["total_records", "current_page", "next_page"],
406+
"type": "object"
407+
},
395408
"sandboxes": {
396409
"items": {
397410
"properties": {
@@ -426,7 +439,7 @@
426439
"type": "array"
427440
}
428441
},
429-
"required": ["sandboxes"],
442+
"required": ["sandboxes", "pagination"],
430443
"type": "object"
431444
}
432445
},
@@ -610,6 +623,7 @@
610623
"session_id": {
611624
"description": "Unique identifier for the session",
612625
"example": "my-session-1",
626+
"pattern": "^[a-zA-Z0-9_-]+$",
613627
"type": "string"
614628
}
615629
},
@@ -643,16 +657,16 @@
643657
"data": {
644658
"properties": {
645659
"capabilities": {
646-
"description": "List of capabilities granted to this session",
660+
"description": "List of capabilities that Pitcher has",
647661
"items": { "type": "string" },
648662
"type": "array"
649663
},
650664
"permissions": {
651-
"description": "Detailed permissions for this session",
665+
"description": "The permissions of the current session",
652666
"type": "object"
653667
},
654668
"pitcher_token": {
655-
"description": "Token to authenticate with Pitcher",
669+
"description": "Token to authenticate with Pitcher (the agent running inside the VM)",
656670
"type": "string"
657671
},
658672
"pitcher_url": {
@@ -1162,6 +1176,13 @@
11621176
"name": "page",
11631177
"required": false,
11641178
"schema": { "default": 1, "minimum": 1, "type": "integer" }
1179+
},
1180+
{
1181+
"description": "If true, only returns VMs for which a heartbeat was received in the last 30 seconds.",
1182+
"in": "query",
1183+
"name": "status",
1184+
"required": false,
1185+
"schema": { "enum": ["running"] }
11651186
}
11661187
],
11671188
"responses": {
@@ -1363,7 +1384,7 @@
13631384
"/vm/{id}/sessions": {
13641385
"post": {
13651386
"callbacks": {},
1366-
"description": "Creates a new session on a running VM. A session represents an isolated Linux user, with their own container\nwhile their API token has specific permissions (currently, read or write).\nThe session is identified by a unique session ID, and the username is based on the session ID.\n\nThis endpoint requires the VM to be running. If the VM is not running, it will return a 404 error.\n",
1387+
"description": "Creates a new session on a running VM. A session represents an isolated Linux user, with their own container.\nA session has a single use token that the user can use to connect to the VM. This token has specific permissions (currently, read or write).\nThe session is identified by a unique session ID, and the Linux username is based on the session ID.\n\nThis endpoint requires the VM to be running. If the VM is not running, it will return a 404 error.\n",
13671388
"operationId": "vm/create_session",
13681389
"parameters": [
13691390
{
@@ -1398,7 +1419,7 @@
13981419
"description": "VM Create Session Response"
13991420
}
14001421
},
1401-
"security": [{ "authorization": ["sandbox:read", "vm:manage"] }],
1422+
"security": [{ "authorization": ["vm:manage"] }],
14021423
"summary": "Create a new session on a VM",
14031424
"tags": ["vm"]
14041425
}
@@ -1565,6 +1586,6 @@
15651586
}
15661587
},
15671588
"security": [],
1568-
"servers": [{ "url": "https://api.codesandbox.stream", "variables": {} }],
1589+
"servers": [{ "url": "https://api.codesandbox.io", "variables": {} }],
15691590
"tags": []
15701591
}

0 commit comments

Comments
 (0)