rusticai-api 0.0.6__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/PKG-INFO +8 -6
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/README.md +2 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/pyproject.toml +14 -17
- rusticai_api-1.0.0/src/rustic_ai/api_server/addons/__init__.py +4 -0
- rusticai_api-1.0.0/src/rustic_ai/api_server/addons/boards/__init__.py +5 -0
- rusticai_api-1.0.0/src/rustic_ai/api_server/addons/boards/board_store.py +124 -0
- rusticai_api-1.0.0/src/rustic_ai/api_server/addons/boards/models.py +23 -0
- rusticai_api-1.0.0/src/rustic_ai/api_server/addons/boards/router.py +156 -0
- rusticai_api-1.0.0/src/rustic_ai/api_server/addons/boards/schema.py +34 -0
- rusticai_api-1.0.0/src/rustic_ai/api_server/addons/router.py +7 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/catalog/catalog_store.py +95 -69
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/catalog/models.py +15 -8
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/catalog/router.py +138 -43
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/guilds/comms_manager.py +48 -18
- rusticai_api-1.0.0/src/rustic_ai/api_server/guilds/models.py +12 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/guilds/router.py +47 -16
- rusticai_api-1.0.0/src/rustic_ai/api_server/guilds/schema.py +25 -0
- rusticai_api-1.0.0/src/rustic_ai/api_server/guilds/service.py +96 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/guilds/system_comms_manager.py +36 -16
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/logging/config.py +20 -2
- rusticai_api-1.0.0/src/rustic_ai/api_server/logging/format.py +97 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/main.py +2 -1
- rusticai_api-0.0.6/src/rustic_ai/api_server/guilds/schema.py +0 -5
- rusticai_api-0.0.6/src/rustic_ai/api_server/guilds/service.py +0 -39
- rusticai_api-0.0.6/src/rustic_ai/api_server/logging/format.py +0 -24
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/__init__.py +0 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/api_dependency_manager.py +0 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/catalog/__init__.py +0 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/guilds/__init__.py +0 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/guilds/socket.py +0 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/logging/__init__.py +0 -0
- {rusticai_api-0.0.6 → rusticai_api-1.0.0}/src/rustic_ai/api_server/main_debug.py +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: rusticai-api
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: API Server for Rustic AI
|
|
5
|
-
License: Apache-2.0
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
6
|
Author: Dragonscale Industries Inc.
|
|
7
7
|
Author-email: dev@dragonscale.ai
|
|
8
8
|
Requires-Python: >=3.12,<3.13
|
|
9
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
9
|
Classifier: Programming Language :: Python :: 3
|
|
11
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
11
|
Provides-Extra: test
|
|
@@ -15,9 +14,10 @@ Requires-Dist: griffe (>=1.7.2,<2.0.0)
|
|
|
15
14
|
Requires-Dist: opentelemetry-distro (>=0.52b1,<0.53)
|
|
16
15
|
Requires-Dist: psycopg (>=3.2.6,<4.0.0)
|
|
17
16
|
Requires-Dist: ptvsd (>=4.3.2,<5.0.0)
|
|
17
|
+
Requires-Dist: python-json-logger (>=3.3.0,<4.0.0)
|
|
18
18
|
Requires-Dist: python-multipart (>=0.0.20,<0.0.21)
|
|
19
|
-
Requires-Dist: rusticai-core (>=0.0
|
|
20
|
-
Requires-Dist: rusticai-ray (>=0.0
|
|
19
|
+
Requires-Dist: rusticai-core (>=1.0.0,<1.1.0)
|
|
20
|
+
Requires-Dist: rusticai-ray (>=1.0.0,<1.1.0)
|
|
21
21
|
Requires-Dist: starlette (>=0.45.3,<0.46.0)
|
|
22
22
|
Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
|
|
23
23
|
Requires-Dist: websockets (>=15.0.1,<16.0.0)
|
|
@@ -85,3 +85,5 @@ Traces will be visible in Zipkin UI at http://localhost:9411/zipkin/
|
|
|
85
85
|
|
|
86
86
|
Note: To stop the Zipkin server, use `./scripts/zipkin/zipkin_down.sh`
|
|
87
87
|
|
|
88
|
+
**To run with all the available `rusticai` packages, use the poetry environment from the root directory, and prefix commands with `api/` — for example, use `./api/scripts/dev_server_with_otel.sh` instead of `./scripts/dev_server_with_otel.sh`.**
|
|
89
|
+
|
|
@@ -56,3 +56,5 @@ for details.
|
|
|
56
56
|
Traces will be visible in Zipkin UI at http://localhost:9411/zipkin/
|
|
57
57
|
|
|
58
58
|
Note: To stop the Zipkin server, use `./scripts/zipkin/zipkin_down.sh`
|
|
59
|
+
|
|
60
|
+
**To run with all the available `rusticai` packages, use the poetry environment from the root directory, and prefix commands with `api/` — for example, use `./api/scripts/dev_server_with_otel.sh` instead of `./scripts/dev_server_with_otel.sh`.**
|
|
@@ -2,24 +2,25 @@
|
|
|
2
2
|
requires = ["poetry-core"]
|
|
3
3
|
build-backend = "poetry.core.masonry.api"
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
[project]
|
|
6
7
|
name = "rusticai-api"
|
|
7
|
-
version = "0.0
|
|
8
|
+
version = "1.0.0"
|
|
8
9
|
description = "API Server for Rustic AI"
|
|
9
|
-
authors = ["Dragonscale Industries Inc.
|
|
10
|
+
authors = [{name = "Dragonscale Industries Inc.", email = "dev@dragonscale.ai"}]
|
|
10
11
|
license = "Apache-2.0"
|
|
11
12
|
readme = "README.md"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
requires-python = ">=3.12,<3.13"
|
|
14
|
+
dynamic = ["dependencies"]
|
|
15
|
+
urls = { Homepage = "https://www.rustic.ai/", Repository = "https://github.com/rustic-ai/rustic-ai", "Rustic AI Core" = "https://pypi.org/project/rusticai-core/" }
|
|
16
|
+
|
|
15
17
|
|
|
16
|
-
[tool.poetry
|
|
17
|
-
|
|
18
|
+
[tool.poetry]
|
|
19
|
+
packages = [{ include = "rustic_ai", from = "src" }]
|
|
18
20
|
|
|
19
21
|
[tool.poetry.dependencies]
|
|
20
|
-
|
|
21
|
-
rusticai-
|
|
22
|
-
rusticai-ray = { version = "0.0.7"}
|
|
22
|
+
rusticai-core = { version = "1.0.0"}
|
|
23
|
+
rusticai-ray = { version = "1.0.0"}
|
|
23
24
|
fastapi = "^0.115.8"
|
|
24
25
|
starlette = "^0.45.3"
|
|
25
26
|
uvicorn = "^0.34.0"
|
|
@@ -29,6 +30,7 @@ opentelemetry-distro = "^0.52b1"
|
|
|
29
30
|
websockets = "^15.0.1"
|
|
30
31
|
griffe = "^1.7.2"
|
|
31
32
|
psycopg = "^3.2.6"
|
|
33
|
+
python-json-logger = "^3.3.0"
|
|
32
34
|
|
|
33
35
|
[tool.poetry-monorepo.deps]
|
|
34
36
|
|
|
@@ -45,7 +47,7 @@ isort = "^6.0.0"
|
|
|
45
47
|
mypy = "^1.15.0"
|
|
46
48
|
pytest-asyncio = "^0.25.3"
|
|
47
49
|
httpx = "^0.28.1"
|
|
48
|
-
rusticai-testing = { version = "0.0
|
|
50
|
+
rusticai-testing = { version = "1.0.0"}
|
|
49
51
|
|
|
50
52
|
[tool.poetry.extras]
|
|
51
53
|
test = ["pytest", "pytest-asyncio", "httpx", "rusticai-testing"]
|
|
@@ -82,8 +84,3 @@ lines_between_sections = 1 # For the newline issue
|
|
|
82
84
|
known_third_party = ["pydantic"]
|
|
83
85
|
known_first_party = ["rustic_ai.core", "rustic_ai.ray"]
|
|
84
86
|
known_local_folder = ["rustic_ai.testing"]
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
[tool.pytest.ini_options]
|
|
88
|
-
asyncio_mode = "auto"
|
|
89
|
-
asyncio_default_fixture_loop_scope="function"
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from fastapi import HTTPException
|
|
4
|
+
from sqlalchemy import Engine
|
|
5
|
+
from sqlmodel import Session, select
|
|
6
|
+
|
|
7
|
+
from rustic_ai.api_server.addons.boards.models import Board, BoardMessage
|
|
8
|
+
from rustic_ai.api_server.addons.boards.schema import CreateBoardRequest
|
|
9
|
+
from rustic_ai.core.guild.metastore import GuildModel
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class BoardStore:
|
|
13
|
+
def __init__(self, engine: Engine):
|
|
14
|
+
self.engine = engine
|
|
15
|
+
|
|
16
|
+
def create_board(self, guild_id: str, board: CreateBoardRequest) -> str:
|
|
17
|
+
"""
|
|
18
|
+
Creates a new board for a guild.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
guild_id (str): The ID of the guild to create the board for.
|
|
22
|
+
board (CreateBoardRequest): The board creation request.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
str: The ID of the created board.
|
|
26
|
+
"""
|
|
27
|
+
with Session(self.engine) as session:
|
|
28
|
+
guild_model = GuildModel.get_by_id(session, guild_id)
|
|
29
|
+
if guild_model is None:
|
|
30
|
+
raise HTTPException(status_code=404, detail="Guild not found")
|
|
31
|
+
|
|
32
|
+
board_model = Board(
|
|
33
|
+
name=board.name,
|
|
34
|
+
guild_id=guild_id,
|
|
35
|
+
created_by=board.created_by,
|
|
36
|
+
is_default=board.is_default,
|
|
37
|
+
is_private=board.is_private,
|
|
38
|
+
)
|
|
39
|
+
session.add(board_model)
|
|
40
|
+
session.commit()
|
|
41
|
+
session.refresh(board_model)
|
|
42
|
+
|
|
43
|
+
return board_model.id
|
|
44
|
+
|
|
45
|
+
def get_boards(self, guild_id: str) -> List[Board]:
|
|
46
|
+
"""
|
|
47
|
+
Retrieves all boards for a guild.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
guild_id (str): The ID of the guild to get boards for.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
List[Board]: List of boards for the guild.
|
|
54
|
+
"""
|
|
55
|
+
with Session(self.engine) as session:
|
|
56
|
+
guild_model = GuildModel.get_by_id(session, guild_id)
|
|
57
|
+
if guild_model is None:
|
|
58
|
+
raise HTTPException(status_code=404, detail="Guild not found")
|
|
59
|
+
|
|
60
|
+
statement = select(Board).where(Board.guild_id == guild_id)
|
|
61
|
+
boards = session.exec(statement).all()
|
|
62
|
+
|
|
63
|
+
return list(boards)
|
|
64
|
+
|
|
65
|
+
def add_message_to_board(self, board_id: str, message_id: str) -> None:
|
|
66
|
+
"""
|
|
67
|
+
Adds a message to a board.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
board_id (str): The ID of the board to add the message to.
|
|
71
|
+
message_id (str): The ID of the message to add.
|
|
72
|
+
"""
|
|
73
|
+
with Session(self.engine) as session:
|
|
74
|
+
board = session.get(Board, board_id)
|
|
75
|
+
if board is None:
|
|
76
|
+
raise HTTPException(status_code=404, detail="Board not found")
|
|
77
|
+
|
|
78
|
+
existing_entry = session.get(BoardMessage, (board_id, message_id))
|
|
79
|
+
if existing_entry is not None:
|
|
80
|
+
raise HTTPException(status_code=409, detail="Message already added to board")
|
|
81
|
+
|
|
82
|
+
board_message = BoardMessage(board_id=board_id, message_id=message_id)
|
|
83
|
+
session.add(board_message)
|
|
84
|
+
session.commit()
|
|
85
|
+
|
|
86
|
+
def get_board_message_ids(self, board_id: str) -> List[str]:
|
|
87
|
+
"""
|
|
88
|
+
Retrieves all message IDs for a board.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
board_id (str): The ID of the board to get messages for.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
List[str]: List of message IDs in the board.
|
|
95
|
+
"""
|
|
96
|
+
with Session(self.engine) as session:
|
|
97
|
+
board = session.get(Board, board_id)
|
|
98
|
+
if board is None:
|
|
99
|
+
raise HTTPException(status_code=404, detail="Board not found")
|
|
100
|
+
|
|
101
|
+
statement = select(BoardMessage.message_id).where(BoardMessage.board_id == board_id)
|
|
102
|
+
message_ids = session.exec(statement).all()
|
|
103
|
+
|
|
104
|
+
return list(message_ids)
|
|
105
|
+
|
|
106
|
+
def remove_message_from_board(self, board_id: str, message_id: str) -> None:
|
|
107
|
+
"""
|
|
108
|
+
Removes a message from a board.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
board_id (str): The ID of the board to remove the message from.
|
|
112
|
+
message_id (str): The ID of the message to remove.
|
|
113
|
+
"""
|
|
114
|
+
with Session(self.engine) as session:
|
|
115
|
+
board = session.get(Board, board_id)
|
|
116
|
+
if board is None:
|
|
117
|
+
raise HTTPException(status_code=404, detail="Board not found")
|
|
118
|
+
|
|
119
|
+
board_message = session.get(BoardMessage, (board_id, message_id))
|
|
120
|
+
if board_message is None:
|
|
121
|
+
raise HTTPException(status_code=404, detail="Message not found on board")
|
|
122
|
+
|
|
123
|
+
session.delete(board_message)
|
|
124
|
+
session.commit()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from datetime import datetime, timezone
|
|
2
|
+
|
|
3
|
+
import shortuuid
|
|
4
|
+
from sqlmodel import Field, SQLModel
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Board(SQLModel, table=True):
|
|
8
|
+
__tablename__ = "board"
|
|
9
|
+
|
|
10
|
+
id: str = Field(primary_key=True, index=True, default_factory=shortuuid.uuid)
|
|
11
|
+
name: str = Field(index=True)
|
|
12
|
+
guild_id: str = Field(index=True, foreign_key="guilds.id")
|
|
13
|
+
created_by: str = Field(index=True)
|
|
14
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
|
15
|
+
is_default: bool = Field(default=False)
|
|
16
|
+
is_private: bool = Field(default=False)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BoardMessage(SQLModel, table=True):
|
|
20
|
+
__tablename__ = "board_message"
|
|
21
|
+
|
|
22
|
+
board_id: str = Field(primary_key=True, foreign_key="board.id")
|
|
23
|
+
message_id: str = Field(primary_key=True)
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from fastapi import APIRouter, Depends, HTTPException
|
|
4
|
+
from sqlalchemy import Engine
|
|
5
|
+
from starlette import status
|
|
6
|
+
|
|
7
|
+
from rustic_ai.api_server.addons.boards.board_store import BoardStore
|
|
8
|
+
from rustic_ai.api_server.addons.boards.schema import (
|
|
9
|
+
AddMessageToBoardRequest,
|
|
10
|
+
BoardMessagesResponse,
|
|
11
|
+
BoardResponse,
|
|
12
|
+
BoardsResponse,
|
|
13
|
+
CreateBoardRequest,
|
|
14
|
+
)
|
|
15
|
+
from rustic_ai.api_server.guilds.schema import IdInfo
|
|
16
|
+
from rustic_ai.core.guild.metastore import Metastore
|
|
17
|
+
|
|
18
|
+
boards_router = APIRouter()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@boards_router.post(
|
|
22
|
+
"/",
|
|
23
|
+
response_model=IdInfo,
|
|
24
|
+
status_code=status.HTTP_201_CREATED,
|
|
25
|
+
operation_id="createBoard",
|
|
26
|
+
)
|
|
27
|
+
def create_board(board: CreateBoardRequest, engine: Engine = Depends(Metastore.get_engine)):
|
|
28
|
+
"""
|
|
29
|
+
Creates a new board for a guild.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
guild_id (str): The ID of the guild to create the board for.
|
|
33
|
+
board (CreateBoardRequest): The board creation request.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
IdInfo: The id of the newly created board.
|
|
37
|
+
"""
|
|
38
|
+
try:
|
|
39
|
+
board_store = BoardStore(engine)
|
|
40
|
+
board_id = board_store.create_board(board.guild_id, board)
|
|
41
|
+
logging.debug(f"New board created: {board_id}")
|
|
42
|
+
return IdInfo(id=board_id)
|
|
43
|
+
except HTTPException:
|
|
44
|
+
raise
|
|
45
|
+
except Exception as e:
|
|
46
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@boards_router.get("/", response_model=BoardsResponse, operation_id="getBoards")
|
|
50
|
+
def get_boards(guild_id: str, engine: Engine = Depends(Metastore.get_engine)):
|
|
51
|
+
"""
|
|
52
|
+
Retrieves all boards for a guild.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
guild_id (str): The ID of the guild to get boards for.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
BoardsResponse: The boards for the guild.
|
|
59
|
+
"""
|
|
60
|
+
try:
|
|
61
|
+
board_store = BoardStore(engine)
|
|
62
|
+
boards = board_store.get_boards(guild_id)
|
|
63
|
+
board_responses = [
|
|
64
|
+
BoardResponse(
|
|
65
|
+
id=board.id,
|
|
66
|
+
name=board.name,
|
|
67
|
+
guild_id=board.guild_id,
|
|
68
|
+
created_by=board.created_by,
|
|
69
|
+
created_at=board.created_at,
|
|
70
|
+
is_default=board.is_default,
|
|
71
|
+
is_private=board.is_private,
|
|
72
|
+
)
|
|
73
|
+
for board in boards
|
|
74
|
+
]
|
|
75
|
+
return BoardsResponse(boards=board_responses)
|
|
76
|
+
except HTTPException:
|
|
77
|
+
raise
|
|
78
|
+
except Exception as e:
|
|
79
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@boards_router.post("/{board_id}/messages", status_code=status.HTTP_200_OK, operation_id="addMessageToBoard")
|
|
83
|
+
def add_message_to_board(
|
|
84
|
+
board_id: str,
|
|
85
|
+
request: AddMessageToBoardRequest,
|
|
86
|
+
engine: Engine = Depends(Metastore.get_engine),
|
|
87
|
+
):
|
|
88
|
+
"""
|
|
89
|
+
Adds a message to a board.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
board_id (str): The ID of the board to add the message to.
|
|
93
|
+
request (AddMessageToBoardRequest): The request containing the message_id.
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
dict: Success message.
|
|
97
|
+
"""
|
|
98
|
+
try:
|
|
99
|
+
board_store = BoardStore(engine)
|
|
100
|
+
board_store.add_message_to_board(board_id, request.message_id)
|
|
101
|
+
return {"message": "Message added to the board successfully"}
|
|
102
|
+
except HTTPException:
|
|
103
|
+
raise
|
|
104
|
+
except Exception as e:
|
|
105
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@boards_router.get(
|
|
109
|
+
"/{board_id}/messages",
|
|
110
|
+
response_model=BoardMessagesResponse,
|
|
111
|
+
operation_id="getBoardMessageIds",
|
|
112
|
+
)
|
|
113
|
+
def get_board_messages(board_id: str, engine: Engine = Depends(Metastore.get_engine)):
|
|
114
|
+
"""
|
|
115
|
+
Retrieves all message IDs for a board.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
board_id (str): The ID of the board to get messages for.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
BoardMessagesResponse: The message IDs in the board.
|
|
122
|
+
"""
|
|
123
|
+
try:
|
|
124
|
+
board_store = BoardStore(engine)
|
|
125
|
+
message_ids = board_store.get_board_message_ids(board_id)
|
|
126
|
+
return BoardMessagesResponse(ids=message_ids)
|
|
127
|
+
except HTTPException:
|
|
128
|
+
raise
|
|
129
|
+
except Exception as e:
|
|
130
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@boards_router.delete(
|
|
134
|
+
"/{board_id}/messages/{message_id}",
|
|
135
|
+
status_code=status.HTTP_200_OK,
|
|
136
|
+
operation_id="removeMessageFromBoard",
|
|
137
|
+
)
|
|
138
|
+
def remove_message_from_board(board_id: str, message_id: str, engine: Engine = Depends(Metastore.get_engine)):
|
|
139
|
+
"""
|
|
140
|
+
Removes a message from a board.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
board_id (str): The ID of the board to remove the message from.
|
|
144
|
+
message_id (str): The ID of the message to remove.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
dict: Success message.
|
|
148
|
+
"""
|
|
149
|
+
try:
|
|
150
|
+
board_store = BoardStore(engine)
|
|
151
|
+
board_store.remove_message_from_board(board_id, message_id)
|
|
152
|
+
return {"message": "Message removed from the board successfully"}
|
|
153
|
+
except HTTPException:
|
|
154
|
+
raise
|
|
155
|
+
except Exception as e:
|
|
156
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CreateBoardRequest(BaseModel):
|
|
8
|
+
guild_id: str
|
|
9
|
+
name: str
|
|
10
|
+
created_by: str
|
|
11
|
+
is_default: Optional[bool] = False
|
|
12
|
+
is_private: Optional[bool] = False
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class BoardResponse(BaseModel):
|
|
16
|
+
id: str
|
|
17
|
+
name: str
|
|
18
|
+
guild_id: str
|
|
19
|
+
created_by: str
|
|
20
|
+
created_at: datetime
|
|
21
|
+
is_default: bool
|
|
22
|
+
is_private: bool
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class BoardsResponse(BaseModel):
|
|
26
|
+
boards: List[BoardResponse]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class AddMessageToBoardRequest(BaseModel):
|
|
30
|
+
message_id: str
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class BoardMessagesResponse(BaseModel):
|
|
34
|
+
ids: List[str]
|