Commit Graph

8 Commits

Author SHA1 Message Date
Andy Stoneberg 22c2106367 feat(ws): add @ID swag annotation for better codegen readability
- added @ID annotations for all API routes to populate operationId Swagger attribute
- split GetWorkspacesHandler into 2 separate handlers to account for @ID needing to be unique-per-route
    - GetAllWorkspacesHandler now services GET /workspaces
    - GetWorkspacesByNamespaceHandler now services GET /workspaces/{namespace}
    - non-exported getWorkspacesHandler function contains all business logic that existed in GetWorkspacesHandler
- Adjusted test cases to align with the new handler names.

Signed-off-by: Andy Stoneberg <astonebe@redhat.com>
2025-07-26 09:33:16 -04:00
Andy Stoneberg 843e5c3c48
feat(ws): add workspace pause actions backend API (#340)
related: #298

- Added PauseActionWorkspaceHandler to handle pausing or unpausing a given workspace
- Introduced single new route for starting and pausing workspaces in the API.
    - `api/v1/workspaces/{namespace}/{name}/actions/pause`
			- pausing or unpausing operation is specified in the request payload
- Created a new WorkspaceActionPauseEnvelope type for successful responses.
- Leveraging JSONPatch / client.RawPatch to ensure Workspace in "valid state" before attempting action
    - for `start`: `spec.paused` must be `true`, and `status.state` must be `Paused`
    - for `pause`: `spec.paused` must be `false`
        - note: I would love to have a `status.state` check here of `status.state != Paused`, but that type of comparison is not supported in [JSONPatch](https://datatracker.ietf.org/doc/html/rfc6902#section-4.6)
- Added tests for the new API, including success and error cases.
- Updated README/OpenAPI documentation to include the new endpoints.

---

As an interesting "edge case" worth calling out, the following payload is currently honored by the API:
```
{
  "data": {}
}
```

Given the `WorkspaceActionPause` struct is simply `{"paused": true|false}`, the "empty" Envelope presented above deserializes the JSON using the zero value of `bool` (which is `false`).

Our validation today is always performed against the **deserialized** object, and as such impossible to distinguish the following cases:
```
{
  "data": {}
}
```

vs

```
{
  "data": {
    "paused": false
  }
}
```

The effort and (relative) complexity to prevent this and return a `422` in this scenario was not deemed "worth it" for the time being.  As a result, a test case has been added for this specific scenario to at minimum document this "strange" behavior.
- Clients, however, should **NOT** rely on this behavior and always provide a fully defined `WorkspaceActionPause` JSON object to ensure future compatibility.

Signed-off-by: Andy Stoneberg <astonebe@redhat.com>
2025-07-24 20:05:02 +00:00
Roee Afriat 0db1fd7c72
feat(ws): add ws counts to backend wsk model (#368)
Signed-off-by: rafriat <roee.afriat.ext@nokia.com>
Co-authored-by: rafriat <roee.afriat.ext@nokia.com>
2025-07-24 19:36:01 +00:00
asaadbalum d38b24c76c
feat(ws): backend api to create wsk with YAML (#434)
* feat(ws): Notebooks 2.0 // Backend // API that allows frontend to upload a YAML file containing a full new WorkspaceKind definition

Signed-off-by: Asaad Balum <asaad.balum@gmail.com>

* mathew: 1

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>

---------

Signed-off-by: Asaad Balum <asaad.balum@gmail.com>
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
Co-authored-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2025-07-06 06:57:21 +00:00
Liav Weiss fcb5fc5272
feat(ws): fix swagger warnings and only generate json output (#424)
* feat(ws): Clean and fix swagger warnings and errors

Signed-off-by: Liav Weiss (EXT-Nokia) <liav.weiss.ext@nokia.com>

* feat(ws): Clean and fix swagger warnings and errors

Signed-off-by: Liav Weiss (EXT-Nokia) <liav.weiss.ext@nokia.com>

---------

Signed-off-by: Liav Weiss (EXT-Nokia) <liav.weiss.ext@nokia.com>
Co-authored-by: Liav Weiss (EXT-Nokia) <liav.weiss.ext@nokia.com>
2025-06-26 19:02:17 +00:00
Andy Stoneberg ea93acc140
fix(ws): add secrets field to backend API schema (#331)
related: #239

This commit brings partial support for secrets to the backend API.  It enables the `frontend` component to successfully create a Workspace through the "wizard flow".

**HOWEVER**, it is important to note this secrets attribute is not supported within the `controller` component yet - as #240 is not yet merged. To unblock the `frontend` - the logic contained in this commit simply adds the necessary scaffolding to accept the `secrets` attribute defined within `volumes`.  Once umarshalled, the backend essentially ignores this data.  Code to fully enable the end to end flow is included in this PR - but simply commented out with `TODO:` comments denoting what can be uncommented once #240 is merged into `notebooks-v2`.  A test is also presently disabled with `XIt` - and can also be enabled when required code present.

Changes were initially coded against the branch provided on #240 to verify full end-to-end behavior.  Once confirmed, commit was rebased onto `notebooks-v2`, relevant code commented out as described above, and behavior retested to ensure desired outcome.

In summary, with these changes:
- `backend` API accepts `volumes.secrets` in the _Create_ payload
- secrets data is **NOT USED** when programmatically constructing the Workspace CR
- Resultant workspace has no `secrets` data - irrespective of it if was provided in the payload or not.

Signed-off-by: Andy Stoneberg <astonebe@redhat.com>
2025-05-15 17:03:23 +00:00
Mohamed 45d778a972
feat(ws): complete api swagger documentation across workspaces, namespaces, and workspacekinds (#235)
* Add Swagger Config

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* add swag command

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Updated swagger output

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Updated general annotations

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Updated swagger docs version

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* updated swagger config

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* fix confilicts

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Add GetNamespaces Swagger Docs

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Add Workspaces Swagger Docs

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Add Workspaces Swagger Docs

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Add Workspacekinds Swagger Docs

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* fix: prevent Swagger from reading TODO comment by adding a tab

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* fix: resolve double api/v1 prefix in route paths

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

---------

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>
2025-05-15 16:33:23 +00:00
Mohamed a5bf4ee76c
feat(ws): add swagger api docs to backend (#206)
* Add Swagger Config

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Removed make watch

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* add swag command

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Updated swagger output

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Serve YAML API spec alongside Swagger UI

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Updated general annotations

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* Updated swagger docs version

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* updated swagger config

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* add parseDependency to swag init

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>

* update http-swagger and factor handler out

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>

* add swagger api path to readme

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>

* regen swagger for camelCase change

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>

* fix docstrings

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>

---------

Signed-off-by: mohamed-ben-khemis <mohamedbenkhemiswork576@gmail.com>
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
Co-authored-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2025-03-03 02:28:36 +00:00