|
| 1 | +"""Helper script to automatically generate OAS |
| 2 | +
|
| 3 | +This OAS are the source of truth |
| 4 | +""" |
| 5 | + |
| 6 | +# pylint: disable=redefined-outer-name |
| 7 | +# pylint: disable=unused-argument |
| 8 | +# pylint: disable=unused-variable |
| 9 | +# pylint: disable=too-many-arguments |
| 10 | + |
| 11 | + |
| 12 | +from typing import Annotated |
| 13 | + |
| 14 | +from fastapi import APIRouter, Depends, status |
| 15 | +from models_library.api_schemas_webserver.projects_conversations import ( |
| 16 | + ConversationMessageRestGet, |
| 17 | + ConversationRestGet, |
| 18 | +) |
| 19 | +from models_library.generics import Envelope |
| 20 | +from models_library.rest_pagination import Page |
| 21 | +from simcore_service_webserver._meta import API_VTAG |
| 22 | +from simcore_service_webserver.projects._controller._rest_schemas import ( |
| 23 | + ProjectPathParams, |
| 24 | +) |
| 25 | +from simcore_service_webserver.projects._controller.conversations_rest import ( |
| 26 | + _ListProjectConversationMessagesQueryParams, |
| 27 | + _ListProjectConversationsQueryParams, |
| 28 | + _ProjectConversationMessagesCreateBodyParams, |
| 29 | + _ProjectConversationMessagesPutBodyParams, |
| 30 | + _ProjectConversationsCreateBodyParams, |
| 31 | + _ProjectConversationsMessagesPathParams, |
| 32 | + _ProjectConversationsPathParams, |
| 33 | + _ProjectConversationsPutBodyParams, |
| 34 | +) |
| 35 | + |
| 36 | +router = APIRouter( |
| 37 | + prefix=f"/{API_VTAG}", |
| 38 | + tags=[ |
| 39 | + "projects", |
| 40 | + "conversations", |
| 41 | + ], |
| 42 | +) |
| 43 | + |
| 44 | + |
| 45 | +# |
| 46 | +# API entrypoints PROJECTS/*/CONVERSATIONS/* |
| 47 | +# |
| 48 | + |
| 49 | + |
| 50 | +@router.post( |
| 51 | + "/projects/{project_id}/conversations", |
| 52 | + response_model=Envelope[ConversationRestGet], |
| 53 | + status_code=status.HTTP_201_CREATED, |
| 54 | +) |
| 55 | +async def create_project_conversation( |
| 56 | + _params: Annotated[ProjectPathParams, Depends()], |
| 57 | + _body: _ProjectConversationsCreateBodyParams, |
| 58 | +): ... |
| 59 | + |
| 60 | + |
| 61 | +@router.get( |
| 62 | + "/projects/{project_id}/conversations", |
| 63 | + response_model=Page[ConversationRestGet], |
| 64 | +) |
| 65 | +async def list_project_conversations( |
| 66 | + _params: Annotated[ProjectPathParams, Depends()], |
| 67 | + _query: Annotated[_ListProjectConversationsQueryParams, Depends()], |
| 68 | +): ... |
| 69 | + |
| 70 | + |
| 71 | +@router.put( |
| 72 | + "/projects/{project_id}/conversations/{conversation_id}", |
| 73 | + response_model=Envelope[ConversationRestGet], |
| 74 | +) |
| 75 | +async def update_project_conversation( |
| 76 | + _params: Annotated[_ProjectConversationsPathParams, Depends()], |
| 77 | + _body: _ProjectConversationsPutBodyParams, |
| 78 | +): ... |
| 79 | + |
| 80 | + |
| 81 | +@router.delete( |
| 82 | + "/projects/{project_id}/conversations/{conversation_id}", |
| 83 | + status_code=status.HTTP_204_NO_CONTENT, |
| 84 | +) |
| 85 | +async def delete_project_conversation( |
| 86 | + _params: Annotated[_ProjectConversationsPathParams, Depends()], |
| 87 | +): ... |
| 88 | + |
| 89 | + |
| 90 | +@router.get( |
| 91 | + "/projects/{project_id}/conversations/{conversation_id}", |
| 92 | + response_model=Envelope[ConversationRestGet], |
| 93 | +) |
| 94 | +async def get_project_conversation( |
| 95 | + _params: Annotated[_ProjectConversationsPathParams, Depends()], |
| 96 | +): ... |
| 97 | + |
| 98 | + |
| 99 | +### Conversation Messages |
| 100 | + |
| 101 | + |
| 102 | +@router.post( |
| 103 | + "/projects/{project_id}/conversations/{conversation_id}/messages", |
| 104 | + response_model=Envelope[ConversationMessageRestGet], |
| 105 | + status_code=status.HTTP_201_CREATED, |
| 106 | +) |
| 107 | +async def create_project_conversation_message( |
| 108 | + _params: Annotated[_ProjectConversationsPathParams, Depends()], |
| 109 | + _body: _ProjectConversationMessagesCreateBodyParams, |
| 110 | +): ... |
| 111 | + |
| 112 | + |
| 113 | +@router.get( |
| 114 | + "/projects/{project_id}/conversations/{conversation_id}/messages", |
| 115 | + response_model=Page[ConversationMessageRestGet], |
| 116 | +) |
| 117 | +async def list_project_conversation_messages( |
| 118 | + _params: Annotated[_ProjectConversationsPathParams, Depends()], |
| 119 | + _query: Annotated[_ListProjectConversationMessagesQueryParams, Depends()], |
| 120 | +): ... |
| 121 | + |
| 122 | + |
| 123 | +@router.put( |
| 124 | + "/projects/{project_id}/conversations/{conversation_id}/messages/{message_id}", |
| 125 | + response_model=Envelope[ConversationMessageRestGet], |
| 126 | +) |
| 127 | +async def update_project_conversation_message( |
| 128 | + _params: Annotated[_ProjectConversationsMessagesPathParams, Depends()], |
| 129 | + _body: _ProjectConversationMessagesPutBodyParams, |
| 130 | +): ... |
| 131 | + |
| 132 | + |
| 133 | +@router.delete( |
| 134 | + "/projects/{project_id}/conversations/{conversation_id}/messages/{message_id}", |
| 135 | + status_code=status.HTTP_204_NO_CONTENT, |
| 136 | +) |
| 137 | +async def delete_project_conversation_message( |
| 138 | + _params: Annotated[_ProjectConversationsMessagesPathParams, Depends()], |
| 139 | +): ... |
| 140 | + |
| 141 | + |
| 142 | +@router.get( |
| 143 | + "/projects/{project_id}/conversations/{conversation_id}/messages/{message_id}", |
| 144 | + response_model=Envelope[ConversationMessageRestGet], |
| 145 | +) |
| 146 | +async def get_project_conversation_message( |
| 147 | + _params: Annotated[_ProjectConversationsMessagesPathParams, Depends()], |
| 148 | +): ... |
0 commit comments