InvokeAI/invokeai/app/api/routers/boards.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
Python
Raw Normal View History

2023-06-13 18:51:20 +00:00
from fastapi import Body, HTTPException, Path, Query
from fastapi.routing import APIRouter
from ..dependencies import ApiDependencies
boards_router = APIRouter(prefix="/v1/boards", tags=["boards"])
@boards_router.post(
"/",
operation_id="create_board",
responses={
201: {"description": "The board was created successfully"},
},
status_code=201,
)
async def create_board(
board_name: str = Body(description="The name of the board to create"),
):
"""Creates a board"""
try:
2023-06-13 19:56:09 +00:00
result = ApiDependencies.invoker.services.boards.save(board_name=board_name)
return result
2023-06-13 18:51:20 +00:00
except Exception as e:
raise HTTPException(status_code=500, detail="Failed to create board")
@boards_router.delete("/{board_id}", operation_id="delete_board")
async def delete_board(
board_id: str = Path(description="The id of board to delete"),
) -> None:
"""Deletes a board"""
try:
ApiDependencies.invoker.services.boards.delete(board_id=board_id)
except Exception as e:
# TODO: Does this need any exception handling at all?
pass