Skip to content

Commit b46c6b0

Browse files
fix disk swagger (#1725)
<!-- This is an auto-generated description by cubic. --> ## Summary by cubic Adds a first-class durable Disk resource with public API (gRPC, REST, OpenAPI) and Python SDK/CLI to create, list, delete disks and view snapshots. Also hardens disk snapshot migrations and hides the default pool name in app responses. - **New Features** - New `DiskService` (`pkg/abstractions/disk/disk.proto`) with generated `proto/*` and `docs/openapi/disk.swagger.json` exposing `/disks` endpoints. - Gateway wiring for gRPC and REST proxy, plus HTTP routes (`pkg/gateway/gateway.go`, `pkg/abstractions/disk/http.go`). - Repository and types for disks (`pkg/repository/disk_postgres.go`, `pkg/types/storage.go`) and stub integration to auto-register durable disks (`pkg/gateway/services/stub.go`). - Python SDK client (`sdk/src/beta9/clients/disk`) and CLI commands `beta9 disk {create,list,delete,snapshots}` with tests; channel wiring in `sdk/src/beta9/channel.py`. - Proto generation updates in `bin/gen_proto.sh`. - **Migration** - Run DB migrations to add the `disk` table and ensure `disk_snapshot` exists (idempotent guard in `042_*`). No config changes required. <sup>Written for commit 21ac1aa. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/beam-cloud/beta9/pull/1725?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
1 parent bddcbbe commit b46c6b0

24 files changed

Lines changed: 3140 additions & 13 deletions

File tree

bin/gen_proto.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ protoc -I $PROTOC_INCLUDE_PATH -I ./googleapis -I ./pkg/abstractions/volume/ --p
127127
protoc -I $PROTOC_INCLUDE_PATH -I ./googleapis -I ./pkg/abstractions/volume/ --grpc-gateway_out=./proto --grpc-gateway_opt paths=source_relative --grpc-gateway_opt generate_unbound_methods=true ./pkg/abstractions/volume/volume.proto
128128
protoc -I $PROTOC_INCLUDE_PATH -I ./googleapis -I ./pkg/abstractions/volume/ --openapiv2_out=./docs/openapi --openapiv2_opt logtostderr=true ./pkg/abstractions/volume/volume.proto
129129

130+
protoc -I $PROTOC_INCLUDE_PATH -I ./googleapis -I ./pkg/abstractions/disk/ --go_out=./proto --go_opt=paths=source_relative --go-grpc_out=./proto --go-grpc_opt=paths=source_relative ./pkg/abstractions/disk/disk.proto
131+
protoc -I $PROTOC_INCLUDE_PATH -I ./googleapis -I ./pkg/abstractions/disk/ --python_betterproto_beta9_out=./sdk/src/beta9/clients/ ./pkg/abstractions/disk/disk.proto
132+
protoc -I $PROTOC_INCLUDE_PATH -I ./googleapis -I ./pkg/abstractions/disk/ --grpc-gateway_out=./proto --grpc-gateway_opt paths=source_relative --grpc-gateway_opt generate_unbound_methods=true ./pkg/abstractions/disk/disk.proto
133+
protoc -I $PROTOC_INCLUDE_PATH -I ./googleapis -I ./pkg/abstractions/disk/ --openapiv2_out=./docs/openapi --openapiv2_opt logtostderr=true ./pkg/abstractions/disk/disk.proto
134+
130135
protoc -I $PROTOC_INCLUDE_PATH -I ./pkg/abstractions/taskqueue/ --go_out=./proto --go_opt=paths=source_relative --go-grpc_out=./proto --go-grpc_opt=paths=source_relative ./pkg/abstractions/taskqueue/taskqueue.proto
131136
protoc -I $PROTOC_INCLUDE_PATH -I ./pkg/abstractions/taskqueue/ --python_betterproto_beta9_out=./sdk/src/beta9/clients/ ./pkg/abstractions/taskqueue/taskqueue.proto
132137

docs/openapi/disk.swagger.json

Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "disk.proto",
5+
"version": "version not set"
6+
},
7+
"tags": [
8+
{
9+
"name": "DiskService"
10+
}
11+
],
12+
"consumes": [
13+
"application/json"
14+
],
15+
"produces": [
16+
"application/json"
17+
],
18+
"paths": {
19+
"/disks": {
20+
"get": {
21+
"operationId": "DiskService_ListDisks",
22+
"responses": {
23+
"200": {
24+
"description": "A successful response.",
25+
"schema": {
26+
"$ref": "#/definitions/diskListDisksResponse"
27+
}
28+
},
29+
"default": {
30+
"description": "An unexpected error response.",
31+
"schema": {
32+
"$ref": "#/definitions/rpcStatus"
33+
}
34+
}
35+
},
36+
"tags": [
37+
"DiskService"
38+
]
39+
},
40+
"post": {
41+
"operationId": "DiskService_GetOrCreateDisk",
42+
"responses": {
43+
"200": {
44+
"description": "A successful response.",
45+
"schema": {
46+
"$ref": "#/definitions/diskGetOrCreateDiskResponse"
47+
}
48+
},
49+
"default": {
50+
"description": "An unexpected error response.",
51+
"schema": {
52+
"$ref": "#/definitions/rpcStatus"
53+
}
54+
}
55+
},
56+
"parameters": [
57+
{
58+
"name": "body",
59+
"in": "body",
60+
"required": true,
61+
"schema": {
62+
"$ref": "#/definitions/diskGetOrCreateDiskRequest"
63+
}
64+
}
65+
],
66+
"tags": [
67+
"DiskService"
68+
]
69+
}
70+
},
71+
"/disks/snapshots": {
72+
"get": {
73+
"operationId": "DiskService_ListDiskSnapshots",
74+
"responses": {
75+
"200": {
76+
"description": "A successful response.",
77+
"schema": {
78+
"$ref": "#/definitions/diskListDiskSnapshotsResponse"
79+
}
80+
},
81+
"default": {
82+
"description": "An unexpected error response.",
83+
"schema": {
84+
"$ref": "#/definitions/rpcStatus"
85+
}
86+
}
87+
},
88+
"parameters": [
89+
{
90+
"name": "diskName",
91+
"in": "query",
92+
"required": false,
93+
"type": "string"
94+
}
95+
],
96+
"tags": [
97+
"DiskService"
98+
]
99+
}
100+
},
101+
"/disks/{name}/delete": {
102+
"post": {
103+
"operationId": "DiskService_DeleteDisk",
104+
"responses": {
105+
"200": {
106+
"description": "A successful response.",
107+
"schema": {
108+
"$ref": "#/definitions/diskDeleteDiskResponse"
109+
}
110+
},
111+
"default": {
112+
"description": "An unexpected error response.",
113+
"schema": {
114+
"$ref": "#/definitions/rpcStatus"
115+
}
116+
}
117+
},
118+
"parameters": [
119+
{
120+
"name": "name",
121+
"in": "path",
122+
"required": true,
123+
"type": "string"
124+
},
125+
{
126+
"name": "body",
127+
"in": "body",
128+
"required": true,
129+
"schema": {
130+
"$ref": "#/definitions/DiskServiceDeleteDiskBody"
131+
}
132+
}
133+
],
134+
"tags": [
135+
"DiskService"
136+
]
137+
}
138+
}
139+
},
140+
"definitions": {
141+
"DiskServiceDeleteDiskBody": {
142+
"type": "object"
143+
},
144+
"diskDeleteDiskResponse": {
145+
"type": "object",
146+
"properties": {
147+
"ok": {
148+
"type": "boolean"
149+
},
150+
"errMsg": {
151+
"type": "string"
152+
}
153+
}
154+
},
155+
"diskDiskInstance": {
156+
"type": "object",
157+
"properties": {
158+
"id": {
159+
"type": "string"
160+
},
161+
"name": {
162+
"type": "string"
163+
},
164+
"size": {
165+
"type": "string"
166+
},
167+
"filesystem": {
168+
"type": "string"
169+
},
170+
"driver": {
171+
"type": "string"
172+
},
173+
"mountPath": {
174+
"type": "string"
175+
},
176+
"createdAt": {
177+
"type": "string",
178+
"format": "date-time"
179+
},
180+
"updatedAt": {
181+
"type": "string",
182+
"format": "date-time"
183+
},
184+
"workspaceId": {
185+
"type": "string"
186+
},
187+
"workspaceName": {
188+
"type": "string"
189+
}
190+
}
191+
},
192+
"diskDiskSnapshotInstance": {
193+
"type": "object",
194+
"properties": {
195+
"id": {
196+
"type": "string"
197+
},
198+
"diskName": {
199+
"type": "string"
200+
},
201+
"format": {
202+
"type": "string"
203+
},
204+
"status": {
205+
"type": "string"
206+
},
207+
"generation": {
208+
"type": "string",
209+
"format": "int64"
210+
},
211+
"sizeBytes": {
212+
"type": "string",
213+
"format": "int64"
214+
},
215+
"logicalSizeBytes": {
216+
"type": "string",
217+
"format": "int64"
218+
},
219+
"storedSizeBytes": {
220+
"type": "string",
221+
"format": "int64"
222+
},
223+
"createdAt": {
224+
"type": "string",
225+
"format": "date-time"
226+
},
227+
"completedAt": {
228+
"type": "string",
229+
"format": "date-time"
230+
}
231+
}
232+
},
233+
"diskGetOrCreateDiskRequest": {
234+
"type": "object",
235+
"properties": {
236+
"name": {
237+
"type": "string"
238+
},
239+
"size": {
240+
"type": "string"
241+
},
242+
"filesystem": {
243+
"type": "string"
244+
},
245+
"driver": {
246+
"type": "string"
247+
},
248+
"mountPath": {
249+
"type": "string"
250+
}
251+
}
252+
},
253+
"diskGetOrCreateDiskResponse": {
254+
"type": "object",
255+
"properties": {
256+
"ok": {
257+
"type": "boolean"
258+
},
259+
"errMsg": {
260+
"type": "string"
261+
},
262+
"disk": {
263+
"$ref": "#/definitions/diskDiskInstance"
264+
}
265+
}
266+
},
267+
"diskListDiskSnapshotsResponse": {
268+
"type": "object",
269+
"properties": {
270+
"ok": {
271+
"type": "boolean"
272+
},
273+
"errMsg": {
274+
"type": "string"
275+
},
276+
"snapshots": {
277+
"type": "array",
278+
"items": {
279+
"type": "object",
280+
"$ref": "#/definitions/diskDiskSnapshotInstance"
281+
}
282+
}
283+
}
284+
},
285+
"diskListDisksResponse": {
286+
"type": "object",
287+
"properties": {
288+
"ok": {
289+
"type": "boolean"
290+
},
291+
"errMsg": {
292+
"type": "string"
293+
},
294+
"disks": {
295+
"type": "array",
296+
"items": {
297+
"type": "object",
298+
"$ref": "#/definitions/diskDiskInstance"
299+
}
300+
}
301+
}
302+
},
303+
"protobufAny": {
304+
"type": "object",
305+
"properties": {
306+
"@type": {
307+
"type": "string"
308+
}
309+
},
310+
"additionalProperties": {}
311+
},
312+
"rpcStatus": {
313+
"type": "object",
314+
"properties": {
315+
"code": {
316+
"type": "integer",
317+
"format": "int32"
318+
},
319+
"message": {
320+
"type": "string"
321+
},
322+
"details": {
323+
"type": "array",
324+
"items": {
325+
"type": "object",
326+
"$ref": "#/definitions/protobufAny"
327+
}
328+
}
329+
}
330+
}
331+
}
332+
}

0 commit comments

Comments
 (0)