Commit Graph

15 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
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
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
Mathew Wicks e5d4e41dfe
feat(ws): add WorkspaceCreate model to backend (#205)
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2025-02-14 22:25:37 +00:00
Mathew Wicks bc6f311ac6
feat(ws): add auth to backend (#202)
* feat(ws): add auth to backend

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

* add `DISABLE_AUTH` for interim testing (enabled by default)

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

---------

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2025-02-11 20:21:28 +00:00
Mathew Wicks f9da864e1d
feat(ws): introduce limits on HTTP body/header size (#195)
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2025-02-05 20:54:38 +00:00
Mathew Wicks 710cbd4753
feat(ws): refactor backend models and repositories (#192)
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2025-02-04 17:20:37 +00:00
Mathew Wicks e920dd99de
chore: update go linting + update dependencies for controller (#137)
* chore: update controller kubebuilder

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

* chore: add new controller linting

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

* chore: update backend (similar to controller kubebuilder update)

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

* chore: add new backend linting

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

---------

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2024-12-02 16:56:58 +00:00
Eder Ignatowicz 2b747ac78d
feat(ws): Notebooks 2.0 // Backend // List namespaces (#124)
* feat(ws): Notebooks 2.0 // Backend // List namespaces #53

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

* adding test coverage

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

* ci: run controller and backend tests on pr

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

---------

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
Co-authored-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2024-11-28 00:06:54 +00:00
Eder Ignatowicz e46633be34
feat(ws): add CRUD operations to backend (#66)
* feat(ws): Notebooks 2.0 // Backend // List Workspaces API - II

In this PR:
- FUP for Notebooks 2.0 // Backend // List Workspaces API (#60) review
- Create /api/v1/workspaces to return all workspaces
- Review API endpoints as requested

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

* Notebooks 2.0 // Backend // CRUD Workspaces API

In this PR:
- Created handlers and repositories for create, get and delete workspace
- Improved the type of our json response

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

* feat(ws): Notebooks 2.0 // Backend // List WorkspaceKinds

This PR builds on top of: https://github.com/kubeflow/notebooks/pull/61 and https://github.com/kubeflow/notebooks/pull/65

In this PR:
- Created handlers and repositories for get workspacekinds

This PR closes https://github.com/kubeflow/notebooks/issues/51

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

* mathew: fix linting

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

---------

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
Co-authored-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2024-10-10 19:37:10 +00:00
Eder Ignatowicz f852c1683e
Notebooks 2.0 // Backend // List Workspaces API (#60)
Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>
2024-09-23 21:54:32 +00:00
Mathew Wicks b0af8ae418
feat(ws): use controller-runtime for backend (#43)
* feat(ws): use controller-runtime with backend

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

* revert healthcheck to normal results

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

---------

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2024-09-14 20:18:24 +00:00
Eder Ignatowicz a42f0a3e13
feat(ws): add kubernetes client to backend (#15)
* feat (ws): Backend Kubernetes client

- Creation of Kubernetes Client;
- Wrapping the client on application;

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

* Update workspaces/backend/cmd/main.go

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

* Adding .docker ignore

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

---------

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>
Co-authored-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
2024-06-08 19:25:05 +00:00
Eder Ignatowicz 9a945fb4bb
feat(ws): initial commit for backend (#7)
* feat(ws): initial commit for backend

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

* Fixing docker build

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

* Fixing git ignore

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>

---------

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>
2024-05-31 00:45:52 +00:00