feat(x2a): Initial API changes for devspaces#2594
feat(x2a): Initial API changes for devspaces#2594eloycoto wants to merge 1 commit intoredhat-developer:mainfrom
Conversation
Missing ChangesetsThe following package(s) are changed by this PR but do not have a changeset:
See CONTRIBUTING.md for more information about how to add changesets. Changed Packages
|
Review Summary by QodoAdd OpenShift Dev Spaces API endpoints for Ansible development workspaces
WalkthroughsDescription• Add OpenShift Dev Spaces API endpoints for workspace management
• Implement GET, POST, DELETE operations on /projects/{projectId}/devspaces
• Define DevSpacesWorkspace model with status tracking and metadata
• Generate TypeScript types and client methods for both backend and frontend
Diagramflowchart LR
A["API Specification<br/>openapi.yaml"] -->|"generates"| B["Backend Types<br/>Api.server.ts"]
A -->|"generates"| C["Frontend Client<br/>Api.client.ts"]
B -->|"imports"| D["DevSpacesWorkspace<br/>Models"]
C -->|"imports"| D
D -->|"includes"| E["Status Enum<br/>starting/running/stopped/failed"]
B -->|"defines"| F["Endpoints<br/>GET/POST/DELETE"]
C -->|"provides"| G["Client Methods<br/>projectsProjectIdDevspaces*"]
File Changes1. workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/apis/Api.server.ts
|
Code Review by Qodo
1. Devspaces endpoints unimplemented
|
| /projects/{projectId}/devspaces: | ||
| get: | ||
| summary: Returns the DevSpaces workspace for a project | ||
| description: | | ||
| Retrieves the OpenShift Dev Spaces workspace associated with the project. | ||
| Returns 404 if no workspace exists for this project. | ||
| parameters: | ||
| - in: path | ||
| name: projectId | ||
| schema: | ||
| type: string | ||
| required: true | ||
| description: UUID of the project | ||
| responses: | ||
| '200': | ||
| description: DevSpaces workspace information | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/DevSpacesWorkspace' | ||
| '404': | ||
| description: No DevSpaces workspace exists for this project | ||
|
|
||
| post: | ||
| summary: Creates a DevSpaces workspace for a project | ||
| description: | | ||
| Creates an OpenShift Dev Spaces workspace for Ansible development. | ||
| If a workspace already exists for this project, returns the existing workspace (idempotent). | ||
|
|
||
| The workspace will: | ||
| - Clone the project's target repository (where migrated Ansible code lives) | ||
| - Provide a browser-based IDE (VS Code) with Ansible tooling | ||
| - Be accessible via the URL returned in the response once status reaches 'running' | ||
| parameters: | ||
| - in: path | ||
| name: projectId | ||
| schema: | ||
| type: string | ||
| required: true | ||
| description: UUID of the project | ||
| responses: | ||
| '201': | ||
| description: DevSpaces workspace created successfully | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| id: | ||
| type: string | ||
| description: UUID of the created workspace | ||
| status: | ||
| $ref: '#/components/schemas/DevSpacesWorkspaceStatus' | ||
| message: | ||
| type: string | ||
| description: Confirmation message | ||
| required: | ||
| - id | ||
| - status | ||
| - message | ||
| '200': | ||
| description: DevSpaces workspace already exists (idempotent) | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/DevSpacesWorkspace' | ||
| '404': | ||
| description: Project not found | ||
| '409': | ||
| description: Workspace is being deleted, cannot create yet | ||
|
|
||
| delete: | ||
| summary: Deletes the DevSpaces workspace for a project | ||
| description: | | ||
| Stops and deletes the OpenShift Dev Spaces workspace associated with the project. | ||
| This removes the Kubernetes DevWorkspace resource and all associated data. | ||
| parameters: | ||
| - in: path | ||
| name: projectId | ||
| schema: | ||
| type: string | ||
| required: true | ||
| description: UUID of the project | ||
| responses: | ||
| '200': | ||
| description: DevSpaces workspace deleted successfully | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: object | ||
| properties: | ||
| message: | ||
| type: string | ||
| description: Confirmation message | ||
| deletedWorkspaceId: | ||
| type: string | ||
| description: UUID of the deleted workspace | ||
| required: | ||
| - message | ||
| '404': | ||
| description: No DevSpaces workspace exists for this project | ||
|
|
There was a problem hiding this comment.
1. Devspaces endpoints unimplemented 🐞 Bug ✓ Correctness
The PR adds /projects/{projectId}/devspaces GET/POST/DELETE to the OpenAPI spec and generates
client/server types, but the backend does not register any Express handlers for these routes, so
requests will return 404 at runtime.
Agent Prompt
### Issue description
The OpenAPI contract and generated clients expose `/projects/{projectId}/devspaces` GET/POST/DELETE, but the backend router does not implement these routes, causing runtime 404s.
### Issue Context
`createRouter` mounts an OpenAPI router and registers only projects/modules/jobs routes today.
### Fix Focus Areas
- Implement and register GET/POST/DELETE handlers for the new path (even as explicit placeholders that return 501) so the route exists and behavior is deterministic.
- Ensure handlers enforce the same auth/permission model as other project-scoped endpoints.
- workspaces/x2a/plugins/x2a-backend/src/router/index.ts[32-52]
- workspaces/x2a/plugins/x2a-backend/src/router/projects.ts[53-383]
- workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml[535-636]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| import { TranslationRef } from '@backstage/frontend-plugin-api'; | ||
| import { TranslationResource } from '@backstage/frontend-plugin-api'; |
There was a problem hiding this comment.
2. Missing runtime type dependency 🐞 Bug ⛯ Reliability
The x2a package public API now imports TranslationRef/TranslationResource from @backstage/frontend-plugin-api, but that package is only listed under devDependencies, which can break downstream TypeScript builds consuming the published types.
Agent Prompt
### Issue description
`@backstage/frontend-plugin-api` appears in the published API surface (via the API report / emitted d.ts), but it is only declared as a devDependency. This can cause downstream TypeScript resolution failures.
### Issue Context
The API report includes:
- `TranslationRef` from `@backstage/frontend-plugin-api`
- `TranslationResource` from `@backstage/frontend-plugin-api`
### Fix Focus Areas
- Move `@backstage/frontend-plugin-api` from `devDependencies` to `dependencies` (or `peerDependencies` if that matches your packaging policy), ensuring consumers can resolve the types.
- workspaces/x2a/plugins/x2a/package.json[37-74]
- workspaces/x2a/plugins/x2a/report.api.md[7-14]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
elai-shalev
left a comment
There was a problem hiding this comment.
overall looks good. assuming its a contract api pr for now
| | void | ||
| | void; |
There was a problem hiding this comment.
duplicate? adding an error response body schema to 404/409 would produce cleaner types
There was a problem hiding this comment.
We spoke here offline, the reason of not having a message here, it's because the error are self explanatory, so the frontend can take the error by itself, and apply the translation correctly.
| "required": [ | ||
| "message" |
There was a problem hiding this comment.
maybe add deletedWorkspaceId to the required?
There was a problem hiding this comment.
you might add two times the DELETE request, and there is no workspace, so cannot be required because does not exist yet.
To enable Openshift dev spaces we need a way to: Trigger: Post the devspace. URL: Get the devspace for a project Delete: Delete the devspace when the user finished. This is just the placeholder for the API, because I expect hard opinions on this topic, so just the placeholder for the API, and a followup of 6 to 10 PR step by step, from the deployment to the bussiness logic in backstage. Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
b702e17 to
c4a1128
Compare
|
mareklibra
left a comment
There was a problem hiding this comment.
It would make more sense to merge this along particular endpoint implementation to avoid orphaned code in the tree. But since there is a clear path to do it asap, it's ok.



To enable Openshift dev spaces we need a way to:
Trigger: Post the devspace.
URL: Get the devspace for a project
Delete: Delete the devspace when the user finished.
This is just the placeholder for the API, because I expect hard opinions on this topic, so just the placeholder for the API, and a followup of 6 to 10 PR step by step, from the deployment to the bussiness logic in backstage.
Second PR for FLPATH-3457
Related PR: x2ansible/x2a-convertor#156