Skip to content

Commit 40ae0d1

Browse files
committed
Initial CRUD API for workspaces
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 stacklok#600 needs to merge Signed-off-by: Juan Antonio Osorio <[email protected]>
1 parent 1eef816 commit 40ae0d1

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

src/codegate/api/__init__.py

Whitespace-only changes.

src/codegate/api/v1.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from fastapi import APIRouter
2+
from fastapi.routing import APIRoute
3+
4+
v1 = APIRouter()
5+
6+
7+
def uniq_name(route: APIRoute):
8+
return f"v1_{route.name}"
9+
10+
11+
@v1.get("/workspaces", tags=["Workspaces"], generate_unique_id_function=uniq_name)
12+
async def list_workspaces():
13+
raise NotImplementedError
14+
15+
@v1.post("/workspaces", tags=["Workspaces"], generate_unique_id_function=uniq_name)
16+
async def create_workspace():
17+
raise NotImplementedError
18+
19+
@v1.get("/workspaces/{workspace_name}", tags=["Workspaces"], generate_unique_id_function=uniq_name)
20+
async def get_workspace(workspace_name: str):
21+
raise NotImplementedError
22+
23+
@v1.delete("/workspaces/{workspace_name}", tags=["Workspaces"],
24+
generate_unique_id_function=uniq_name)
25+
async def delete_workspace(workspace_name: str):
26+
raise NotImplementedError

src/codegate/pipeline/extract_snippets/extract_snippets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def extract_snippets(message: str) -> List[CodeSnippet]:
127127
lang_map = {
128128
"typescript": "javascript"
129129
}
130-
lang = lang_map.get(lang, lang)
130+
lang = lang_map.get(lang, lang)
131131
snippets.append(CodeSnippet(filepath=filename, code=content, language=lang))
132132

133133
return snippets

src/codegate/providers/ollama/completion_handler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
from typing import AsyncIterator, Optional, Union
32

43
import structlog

src/codegate/server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from starlette.middleware.errors import ServerErrorMiddleware
88

99
from codegate import __description__, __version__
10+
from codegate.api.v1 import v1
1011
from codegate.dashboard.dashboard import dashboard_router
1112
from codegate.pipeline.factory import PipelineFactory
1213
from codegate.providers.anthropic.provider import AnthropicProvider
@@ -97,4 +98,7 @@ async def health_check():
9798
app.include_router(system_router)
9899
app.include_router(dashboard_router)
99100

101+
# CodeGate API
102+
app.include_router(v1, prefix="/api/v1", tags=["CodeGate API"])
103+
100104
return app

0 commit comments

Comments
 (0)