Skip to content

Commit 278ba4e

Browse files
shareable workspaces pt. 2 (#1233)
* endpoint to get full workspace config + free * add `provider_endpoint_type` to muxes table * add `provider_endpoint_name` to muxes table * allow mux CRUD without knowledge of provider IDs * tests & tidy ups * fix type nit * bug fixes and tests * update any remaining endpoints referring to providers by name * fix alembic head conflict * bug fixes & testing * lint fix * fix integration tests * fix bug where provider name not updated in muxes table after rename * address logger feedback * move `raise ProviderNotFoundError` into crud method * clean up converting API MuxRule to internal representation * flatten migrations * fix 500 error when deleting workspace w. no mux rules * fix possible inconsistent db state when muxes are deleted * linter * address feedback on DB schema changes * address unnecessary manual deletions feedback * tidy ups
1 parent cebc18a commit 278ba4e

File tree

18 files changed

+1686
-290
lines changed

18 files changed

+1686
-290
lines changed

api/openapi.json

+98-115
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
}
149149
}
150150
},
151-
"/api/v1/provider-endpoints/{provider_id}/models": {
151+
"/api/v1/provider-endpoints/{provider_name}/models": {
152152
"get": {
153153
"tags": [
154154
"CodeGate API",
@@ -159,13 +159,12 @@
159159
"operationId": "v1_list_models_by_provider",
160160
"parameters": [
161161
{
162-
"name": "provider_id",
162+
"name": "provider_name",
163163
"in": "path",
164164
"required": true,
165165
"schema": {
166166
"type": "string",
167-
"format": "uuid",
168-
"title": "Provider Id"
167+
"title": "Provider Name"
169168
}
170169
}
171170
],
@@ -197,24 +196,23 @@
197196
}
198197
}
199198
},
200-
"/api/v1/provider-endpoints/{provider_id}": {
199+
"/api/v1/provider-endpoints/{provider_name}": {
201200
"get": {
202201
"tags": [
203202
"CodeGate API",
204203
"Providers"
205204
],
206205
"summary": "Get Provider Endpoint",
207-
"description": "Get a provider endpoint by ID.",
206+
"description": "Get a provider endpoint by name.",
208207
"operationId": "v1_get_provider_endpoint",
209208
"parameters": [
210209
{
211-
"name": "provider_id",
210+
"name": "provider_name",
212211
"in": "path",
213212
"required": true,
214213
"schema": {
215214
"type": "string",
216-
"format": "uuid",
217-
"title": "Provider Id"
215+
"title": "Provider Name"
218216
}
219217
}
220218
],
@@ -247,17 +245,16 @@
247245
"Providers"
248246
],
249247
"summary": "Update Provider Endpoint",
250-
"description": "Update a provider endpoint by ID.",
248+
"description": "Update a provider endpoint by name.",
251249
"operationId": "v1_update_provider_endpoint",
252250
"parameters": [
253251
{
254-
"name": "provider_id",
252+
"name": "provider_name",
255253
"in": "path",
256254
"required": true,
257255
"schema": {
258256
"type": "string",
259-
"format": "uuid",
260-
"title": "Provider Id"
257+
"title": "Provider Name"
261258
}
262259
}
263260
],
@@ -300,17 +297,16 @@
300297
"Providers"
301298
],
302299
"summary": "Delete Provider Endpoint",
303-
"description": "Delete a provider endpoint by id.",
300+
"description": "Delete a provider endpoint by name.",
304301
"operationId": "v1_delete_provider_endpoint",
305302
"parameters": [
306303
{
307-
"name": "provider_id",
304+
"name": "provider_name",
308305
"in": "path",
309306
"required": true,
310307
"schema": {
311308
"type": "string",
312-
"format": "uuid",
313-
"title": "Provider Id"
309+
"title": "Provider Name"
314310
}
315311
}
316312
],
@@ -336,7 +332,7 @@
336332
}
337333
}
338334
},
339-
"/api/v1/provider-endpoints/{provider_id}/auth-material": {
335+
"/api/v1/provider-endpoints/{provider_name}/auth-material": {
340336
"put": {
341337
"tags": [
342338
"CodeGate API",
@@ -347,13 +343,12 @@
347343
"operationId": "v1_configure_auth_material",
348344
"parameters": [
349345
{
350-
"name": "provider_id",
346+
"name": "provider_name",
351347
"in": "path",
352348
"required": true,
353349
"schema": {
354350
"type": "string",
355-
"format": "uuid",
356-
"title": "Provider Id"
351+
"title": "Provider Name"
357352
}
358353
}
359354
],
@@ -391,8 +386,26 @@
391386
"Workspaces"
392387
],
393388
"summary": "List Workspaces",
394-
"description": "List all workspaces.",
389+
"description": "List all workspaces.\n\nArgs:\n provider_name (Optional[str]): Filter workspaces by provider name. If provided,\n will return workspaces where models from the specified provider (e.g., OpenAI,\n Anthropic) have been used in workspace muxing rules.\n\nReturns:\n ListWorkspacesResponse: A response object containing the list of workspaces.",
395390
"operationId": "v1_list_workspaces",
391+
"parameters": [
392+
{
393+
"name": "provider_name",
394+
"in": "query",
395+
"required": false,
396+
"schema": {
397+
"anyOf": [
398+
{
399+
"type": "string"
400+
},
401+
{
402+
"type": "null"
403+
}
404+
],
405+
"title": "Provider Name"
406+
}
407+
}
408+
],
396409
"responses": {
397410
"200": {
398411
"description": "Successful Response",
@@ -403,6 +416,16 @@
403416
}
404417
}
405418
}
419+
},
420+
"422": {
421+
"description": "Validation Error",
422+
"content": {
423+
"application/json": {
424+
"schema": {
425+
"$ref": "#/components/schemas/HTTPValidationError"
426+
}
427+
}
428+
}
406429
}
407430
}
408431
},
@@ -415,14 +438,14 @@
415438
"description": "Create a new workspace.",
416439
"operationId": "v1_create_workspace",
417440
"requestBody": {
441+
"required": true,
418442
"content": {
419443
"application/json": {
420444
"schema": {
421445
"$ref": "#/components/schemas/FullWorkspace-Input"
422446
}
423447
}
424-
},
425-
"required": true
448+
}
426449
},
427450
"responses": {
428451
"201": {
@@ -552,7 +575,7 @@
552575
}
553576
},
554577
"responses": {
555-
"201": {
578+
"200": {
556579
"description": "Successful Response",
557580
"content": {
558581
"application/json": {
@@ -613,6 +636,48 @@
613636
}
614637
}
615638
}
639+
},
640+
"get": {
641+
"tags": [
642+
"CodeGate API",
643+
"Workspaces"
644+
],
645+
"summary": "Get Workspace By Name",
646+
"description": "List workspaces by provider ID.",
647+
"operationId": "v1_get_workspace_by_name",
648+
"parameters": [
649+
{
650+
"name": "workspace_name",
651+
"in": "path",
652+
"required": true,
653+
"schema": {
654+
"type": "string",
655+
"title": "Workspace Name"
656+
}
657+
}
658+
],
659+
"responses": {
660+
"200": {
661+
"description": "Successful Response",
662+
"content": {
663+
"application/json": {
664+
"schema": {
665+
"$ref": "#/components/schemas/FullWorkspace-Output"
666+
}
667+
}
668+
}
669+
},
670+
"422": {
671+
"description": "Validation Error",
672+
"content": {
673+
"application/json": {
674+
"schema": {
675+
"$ref": "#/components/schemas/HTTPValidationError"
676+
}
677+
}
678+
}
679+
}
680+
}
616681
}
617682
},
618683
"/api/v1/workspaces/archive": {
@@ -1195,55 +1260,6 @@
11951260
}
11961261
}
11971262
},
1198-
"/api/v1/workspaces/{provider_id}": {
1199-
"get": {
1200-
"tags": [
1201-
"CodeGate API",
1202-
"Workspaces"
1203-
],
1204-
"summary": "List Workspaces By Provider",
1205-
"description": "List workspaces by provider ID.",
1206-
"operationId": "v1_list_workspaces_by_provider",
1207-
"parameters": [
1208-
{
1209-
"name": "provider_id",
1210-
"in": "path",
1211-
"required": true,
1212-
"schema": {
1213-
"type": "string",
1214-
"format": "uuid",
1215-
"title": "Provider Id"
1216-
}
1217-
}
1218-
],
1219-
"responses": {
1220-
"200": {
1221-
"description": "Successful Response",
1222-
"content": {
1223-
"application/json": {
1224-
"schema": {
1225-
"type": "array",
1226-
"items": {
1227-
"$ref": "#/components/schemas/WorkspaceWithModel"
1228-
},
1229-
"title": "Response V1 List Workspaces By Provider"
1230-
}
1231-
}
1232-
}
1233-
},
1234-
"422": {
1235-
"description": "Validation Error",
1236-
"content": {
1237-
"application/json": {
1238-
"schema": {
1239-
"$ref": "#/components/schemas/HTTPValidationError"
1240-
}
1241-
}
1242-
}
1243-
}
1244-
}
1245-
}
1246-
},
12471263
"/api/v1/alerts_notification": {
12481264
"get": {
12491265
"tags": [
@@ -2136,9 +2152,8 @@
21362152
"type": "string",
21372153
"title": "Name"
21382154
},
2139-
"provider_id": {
2140-
"type": "string",
2141-
"title": "Provider Id"
2155+
"provider_type": {
2156+
"$ref": "#/components/schemas/ProviderType"
21422157
},
21432158
"provider_name": {
21442159
"type": "string",
@@ -2148,7 +2163,7 @@
21482163
"type": "object",
21492164
"required": [
21502165
"name",
2151-
"provider_id",
2166+
"provider_type",
21522167
"provider_name"
21532168
],
21542169
"title": "ModelByProvider",
@@ -2168,19 +2183,11 @@
21682183
"MuxRule": {
21692184
"properties": {
21702185
"provider_name": {
2171-
"anyOf": [
2172-
{
2173-
"type": "string"
2174-
},
2175-
{
2176-
"type": "null"
2177-
}
2178-
],
2186+
"type": "string",
21792187
"title": "Provider Name"
21802188
},
2181-
"provider_id": {
2182-
"type": "string",
2183-
"title": "Provider Id"
2189+
"provider_type": {
2190+
"$ref": "#/components/schemas/ProviderType"
21842191
},
21852192
"model": {
21862193
"type": "string",
@@ -2203,7 +2210,8 @@
22032210
},
22042211
"type": "object",
22052212
"required": [
2206-
"provider_id",
2213+
"provider_name",
2214+
"provider_type",
22072215
"model",
22082216
"matcher_type"
22092217
],
@@ -2565,31 +2573,6 @@
25652573
"muxing_rules"
25662574
],
25672575
"title": "WorkspaceConfig"
2568-
},
2569-
"WorkspaceWithModel": {
2570-
"properties": {
2571-
"id": {
2572-
"type": "string",
2573-
"title": "Id"
2574-
},
2575-
"name": {
2576-
"type": "string",
2577-
"pattern": "^[a-zA-Z0-9_-]+$",
2578-
"title": "Name"
2579-
},
2580-
"provider_model_name": {
2581-
"type": "string",
2582-
"title": "Provider Model Name"
2583-
}
2584-
},
2585-
"type": "object",
2586-
"required": [
2587-
"id",
2588-
"name",
2589-
"provider_model_name"
2590-
],
2591-
"title": "WorkspaceWithModel",
2592-
"description": "Returns a workspace ID with model name"
25932576
}
25942577
}
25952578
}

0 commit comments

Comments
 (0)