-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a simple and unimplemented REST API for workspaces. Workspaces will be the base for all other resources in terms of REST resource mapping, so these go first. These are initially left entirely unimplemented as #600 needs to merge Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
- Loading branch information
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from fastapi import APIRouter | ||
from fastapi.routing import APIRoute | ||
|
||
from codegate.api import v1_models | ||
|
||
v1 = APIRouter() | ||
|
||
|
||
def uniq_name(route: APIRoute): | ||
return f"v1_{route.name}" | ||
|
||
|
||
@v1.get("/workspaces", tags=["Workspaces"], generate_unique_id_function=uniq_name) | ||
async def list_workspaces() -> v1_models.ListWorkspacesResponse: | ||
"""List all workspaces.""" | ||
raise NotImplementedError | ||
|
||
@v1.get("/workspaces/active", tags=["Workspaces"], generate_unique_id_function=uniq_name) | ||
async def list_active_workspaces() -> v1_models.ListActiveWorkspacesResponse: | ||
"""List all active workspaces. | ||
In it's current form, this function will only return one workspace. That is, | ||
the globally active workspace.""" | ||
raise NotImplementedError | ||
|
||
@v1.post("/workspaces", tags=["Workspaces"], generate_unique_id_function=uniq_name, status_code=201) | ||
async def create_workspace(request: v1_models.CreateWorkspaceRequest): | ||
"""Create a new workspace.""" | ||
raise NotImplementedError | ||
|
||
@v1.get("/workspaces/{workspace_name}", tags=["Workspaces"], generate_unique_id_function=uniq_name) | ||
async def get_workspace(workspace_name: str) -> v1_models.Workspace: | ||
"""Get a workspace by name.""" | ||
raise NotImplementedError | ||
|
||
@v1.delete("/workspaces/{workspace_name}", tags=["Workspaces"], | ||
generate_unique_id_function=uniq_name, status_code=204) | ||
async def delete_workspace(workspace_name: str): | ||
"""Delete a workspace by name.""" | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Any | ||
|
||
import pydantic | ||
|
||
|
||
class Workspace(pydantic.BaseModel): | ||
name: str | ||
|
||
class ActiveWorkspace(Workspace): | ||
# TODO: use a more specific type for last_updated | ||
last_updated: Any | ||
|
||
class ListWorkspacesResponse(pydantic.BaseModel): | ||
workspaces: list[Workspace] | ||
|
||
class ListActiveWorkspacesResponse(pydantic.BaseModel): | ||
workspaces: list[ActiveWorkspace] | ||
|
||
class CreateWorkspaceRequest(pydantic.BaseModel): | ||
name: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters