Skip to content

Commit 267e6cc

Browse files
chore: add slug workflow api endpoints (#1137)
1 parent 9741cad commit 267e6cc

9 files changed

Lines changed: 1151 additions & 9 deletions

File tree

‎apps/api/openapi/openapi.json‎

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3673,6 +3673,41 @@
36733673
],
36743674
"type": "object"
36753675
},
3676+
"WorkflowSlugConflictResponse": {
3677+
"properties": {
3678+
"code": {
3679+
"enum": [
3680+
"DUPLICATE_SLUG"
3681+
],
3682+
"type": "string"
3683+
},
3684+
"details": {
3685+
"properties": {
3686+
"existingWorkflowId": {
3687+
"description": "UUID of the workflow that already uses this slug, if known.",
3688+
"type": "string"
3689+
},
3690+
"slug": {
3691+
"description": "The slug that collided.",
3692+
"type": "string"
3693+
}
3694+
},
3695+
"required": [
3696+
"slug"
3697+
],
3698+
"type": "object"
3699+
},
3700+
"message": {
3701+
"type": "string"
3702+
}
3703+
},
3704+
"required": [
3705+
"message",
3706+
"code",
3707+
"details"
3708+
],
3709+
"type": "object"
3710+
},
36763711
"WorkflowStringInput": {
36773712
"properties": {
36783713
"default": {
@@ -9854,6 +9889,16 @@
98549889
}
98559890
},
98569891
"description": "Invalid request"
9892+
},
9893+
"409": {
9894+
"content": {
9895+
"application/json": {
9896+
"schema": {
9897+
"$ref": "#/components/schemas/WorkflowSlugConflictResponse"
9898+
}
9899+
}
9900+
},
9901+
"description": "Workflow slug already exists in this workspace"
98579902
}
98589903
},
98599904
"summary": "Create a workflow",
@@ -9862,6 +9907,150 @@
98629907
]
98639908
}
98649909
},
9910+
"/v1/workspaces/{workspaceId}/workflows/slug/{slug}": {
9911+
"get": {
9912+
"description": "Gets a workflow by its slug within the workspace.",
9913+
"operationId": "getWorkflowBySlug",
9914+
"parameters": [
9915+
{
9916+
"description": "ID of the workspace",
9917+
"in": "path",
9918+
"name": "workspaceId",
9919+
"required": true,
9920+
"schema": {
9921+
"type": "string"
9922+
}
9923+
},
9924+
{
9925+
"description": "Slug of the workflow",
9926+
"in": "path",
9927+
"name": "slug",
9928+
"required": true,
9929+
"schema": {
9930+
"type": "string"
9931+
}
9932+
}
9933+
],
9934+
"responses": {
9935+
"200": {
9936+
"content": {
9937+
"application/json": {
9938+
"schema": {
9939+
"$ref": "#/components/schemas/Workflow"
9940+
}
9941+
}
9942+
},
9943+
"description": "OK response"
9944+
},
9945+
"400": {
9946+
"content": {
9947+
"application/json": {
9948+
"schema": {
9949+
"$ref": "#/components/schemas/ErrorResponse"
9950+
}
9951+
}
9952+
},
9953+
"description": "Invalid request"
9954+
},
9955+
"404": {
9956+
"content": {
9957+
"application/json": {
9958+
"schema": {
9959+
"$ref": "#/components/schemas/ErrorResponse"
9960+
}
9961+
}
9962+
},
9963+
"description": "Resource not found"
9964+
}
9965+
},
9966+
"summary": "Get a workflow by slug",
9967+
"tags": [
9968+
"Workflows"
9969+
]
9970+
}
9971+
},
9972+
"/v1/workspaces/{workspaceId}/workflows/slug/{slug}/runs": {
9973+
"post": {
9974+
"description": "Creates a new run for a workflow identified by slug.",
9975+
"operationId": "createWorkflowRunBySlug",
9976+
"parameters": [
9977+
{
9978+
"description": "ID of the workspace",
9979+
"in": "path",
9980+
"name": "workspaceId",
9981+
"required": true,
9982+
"schema": {
9983+
"type": "string"
9984+
}
9985+
},
9986+
{
9987+
"description": "Slug of the workflow",
9988+
"in": "path",
9989+
"name": "slug",
9990+
"required": true,
9991+
"schema": {
9992+
"type": "string"
9993+
}
9994+
}
9995+
],
9996+
"requestBody": {
9997+
"content": {
9998+
"application/json": {
9999+
"schema": {
10000+
"properties": {
10001+
"inputs": {
10002+
"additionalProperties": true,
10003+
"description": "Input values for the workflow run.",
10004+
"type": "object"
10005+
}
10006+
},
10007+
"required": [
10008+
"inputs"
10009+
],
10010+
"type": "object"
10011+
}
10012+
}
10013+
},
10014+
"required": true
10015+
},
10016+
"responses": {
10017+
"201": {
10018+
"content": {
10019+
"application/json": {
10020+
"schema": {
10021+
"$ref": "#/components/schemas/WorkflowRun"
10022+
}
10023+
}
10024+
},
10025+
"description": "Resource created successfully"
10026+
},
10027+
"400": {
10028+
"content": {
10029+
"application/json": {
10030+
"schema": {
10031+
"$ref": "#/components/schemas/ErrorResponse"
10032+
}
10033+
}
10034+
},
10035+
"description": "Invalid request"
10036+
},
10037+
"404": {
10038+
"content": {
10039+
"application/json": {
10040+
"schema": {
10041+
"$ref": "#/components/schemas/ErrorResponse"
10042+
}
10043+
}
10044+
},
10045+
"description": "Resource not found"
10046+
}
10047+
},
10048+
"summary": "Create a workflow run by slug",
10049+
"tags": [
10050+
"Workflows"
10051+
]
10052+
}
10053+
},
986510054
"/v1/workspaces/{workspaceId}/workflows/{workflowId}": {
986610055
"delete": {
986710056
"description": "Deletes a workflow.",
@@ -10046,6 +10235,16 @@
1004610235
}
1004710236
},
1004810237
"description": "Resource not found"
10238+
},
10239+
"409": {
10240+
"content": {
10241+
"application/json": {
10242+
"schema": {
10243+
"$ref": "#/components/schemas/WorkflowSlugConflictResponse"
10244+
}
10245+
}
10246+
},
10247+
"description": "Workflow slug already exists in this workspace"
1004910248
}
1005010249
},
1005110250
"summary": "Update a workflow",

‎apps/api/openapi/paths/workflows.jsonnet‎

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,66 @@ local openapi = import '../lib/openapi.libsonnet';
3131
},
3232
},
3333
},
34-
responses: openapi.createdResponse(openapi.schemaRef('Workflow')) +
35-
openapi.badRequestResponse(),
34+
responses: openapi.createdResponse(openapi.schemaRef('Workflow'))
35+
+ openapi.badRequestResponse()
36+
+ {
37+
'409': {
38+
description: 'Workflow slug already exists in this workspace',
39+
content: {
40+
'application/json': {
41+
schema: openapi.schemaRef('WorkflowSlugConflictResponse'),
42+
},
43+
},
44+
},
45+
},
46+
},
47+
},
48+
'/v1/workspaces/{workspaceId}/workflows/slug/{slug}': {
49+
get: {
50+
tags: ['Workflows'],
51+
summary: 'Get a workflow by slug',
52+
operationId: 'getWorkflowBySlug',
53+
description: 'Gets a workflow by its slug within the workspace.',
54+
parameters: [
55+
openapi.workspaceIdParam(),
56+
openapi.stringParam('slug', 'Slug of the workflow'),
57+
],
58+
responses: openapi.okResponse(openapi.schemaRef('Workflow'))
59+
+ openapi.notFoundResponse()
60+
+ openapi.badRequestResponse(),
61+
},
62+
},
63+
'/v1/workspaces/{workspaceId}/workflows/slug/{slug}/runs': {
64+
post: {
65+
tags: ['Workflows'],
66+
summary: 'Create a workflow run by slug',
67+
operationId: 'createWorkflowRunBySlug',
68+
description: 'Creates a new run for a workflow identified by slug.',
69+
parameters: [
70+
openapi.workspaceIdParam(),
71+
openapi.stringParam('slug', 'Slug of the workflow'),
72+
],
73+
requestBody: {
74+
required: true,
75+
content: {
76+
'application/json': {
77+
schema: {
78+
type: 'object',
79+
required: ['inputs'],
80+
properties: {
81+
inputs: {
82+
type: 'object',
83+
additionalProperties: true,
84+
description: 'Input values for the workflow run.',
85+
},
86+
},
87+
},
88+
},
89+
},
90+
},
91+
responses: openapi.createdResponse(openapi.schemaRef('WorkflowRun'))
92+
+ openapi.notFoundResponse()
93+
+ openapi.badRequestResponse(),
3694
},
3795
},
3896
'/v1/workspaces/{workspaceId}/workflows/{workflowId}': {
@@ -68,7 +126,17 @@ local openapi = import '../lib/openapi.libsonnet';
68126
},
69127
responses: openapi.acceptedResponse(openapi.schemaRef('Workflow'))
70128
+ openapi.notFoundResponse()
71-
+ openapi.badRequestResponse(),
129+
+ openapi.badRequestResponse()
130+
+ {
131+
'409': {
132+
description: 'Workflow slug already exists in this workspace',
133+
content: {
134+
'application/json': {
135+
schema: openapi.schemaRef('WorkflowSlugConflictResponse'),
136+
},
137+
},
138+
},
139+
},
72140
},
73141
delete: {
74142
tags: ['Workflows'],

‎apps/api/openapi/schemas/workflows.jsonnet‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ local openapi = import '../lib/openapi.libsonnet';
175175
},
176176
},
177177

178+
WorkflowSlugConflictResponse: {
179+
type: 'object',
180+
required: ['message', 'code', 'details'],
181+
properties: {
182+
message: { type: 'string' },
183+
code: { type: 'string', enum: ['DUPLICATE_SLUG'] },
184+
details: {
185+
type: 'object',
186+
required: ['slug'],
187+
properties: {
188+
slug: { type: 'string', description: 'The slug that collided.' },
189+
existingWorkflowId: {
190+
type: 'string',
191+
description: 'UUID of the workflow that already uses this slug, if known.',
192+
},
193+
},
194+
},
195+
},
196+
},
197+
178198
WorkflowJob: {
179199
type: 'object',
180200
required: ['id', 'workflowId', 'index', 'ref', 'config'],

0 commit comments

Comments
 (0)