-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agents-api): Refactor routers.py files
Signed-off-by: Diwank Tomer <[email protected]>
- Loading branch information
Diwank Tomer
committed
Jul 1, 2024
1 parent
c36b94c
commit 31e6814
Showing
25 changed files
with
227 additions
and
175 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
from fastapi import APIRouter | ||
from .router import router # noqa: F401 | ||
|
||
router = APIRouter() | ||
from .create_agent import create_agent # noqa: F401 | ||
from .delete_agent import delete_agent # noqa: F401 | ||
from .get_agent_details import get_agent_details # noqa: F401 | ||
from .list_agents import list_agents # noqa: F401 | ||
from .update_agent import update_agent # noqa: F401 | ||
from .patch_agent import patch_agent # noqa: F401 |
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
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
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
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
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
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,3 @@ | ||
from fastapi import APIRouter | ||
|
||
router = APIRouter() |
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
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
from fastapi import APIRouter | ||
from .router import router # noqa: F401 | ||
|
||
router = APIRouter() | ||
from .create_session import create_session # noqa: F401 | ||
from .delete_session import delete_session # noqa: F401 | ||
from .get_session import get_session # noqa: F401 | ||
from .list_sessions import list_sessions # noqa: F401 | ||
from .update_session import update_session # noqa: F401 | ||
from .patch_session import patch_session # noqa: F401 |
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
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 |
---|---|---|
@@ -1,25 +1,27 @@ | ||
from fastapi import APIRouter, Depends, HTTPException | ||
from typing import Annotated | ||
|
||
from fastapi import Depends, HTTPException | ||
from pydantic import UUID4 | ||
from starlette.status import HTTP_202_ACCEPTED | ||
from starlette.status import HTTP_202_ACCEPTED, HTTP_404_NOT_FOUND | ||
|
||
from ...autogen.openapi_model import ResourceDeletedResponse | ||
from ...common.exceptions.sessions import SessionNotFoundError | ||
from ...common.utils.datetime import utcnow | ||
from ...dependencies.developer_id import get_developer_id | ||
from ...models.session.delete_session import delete_session_query | ||
|
||
from agents_api.dependencies.developer_id import get_developer_id | ||
from agents_api.models.session.delete_session import delete_session_query | ||
from agents_api.common.exceptions.sessions import SessionNotFoundError | ||
from agents_api.autogen.openapi_model import ResourceDeletedResponse | ||
from agents_api.common.utils.datetime import utcnow | ||
from .router import router | ||
|
||
router = APIRouter() | ||
|
||
@router.delete("/sessions/{session_id}", status_code=HTTP_202_ACCEPTED, tags=["sessions"]) | ||
@router.delete( | ||
"/sessions/{session_id}", status_code=HTTP_202_ACCEPTED, tags=["sessions"] | ||
) | ||
async def delete_session( | ||
session_id: UUID4, x_developer_id: Annotated[UUID4, Depends(get_developer_id)] | ||
) -> ResourceDeletedResponse: | ||
try: | ||
delete_session_query(x_developer_id, session_id) | ||
except SessionNotFoundError as e: | ||
raise HTTPException( | ||
status_code=HTTP_404_NOT_FOUND, | ||
detail=str(e) | ||
) | ||
raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail=str(e)) | ||
|
||
return ResourceDeletedResponse(id=session_id, deleted_at=utcnow()) |
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
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
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
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,3 @@ | ||
from fastapi import APIRouter | ||
|
||
router = APIRouter() |
Oops, something went wrong.