Skip to content

Commit b9b64cd

Browse files
feat: add skeletons and schemas
1 parent c91bda1 commit b9b64cd

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from fastapi import FastAPI
2+
from servicelib.rabbitmq import RPCRouter
3+
4+
from ...models.schemas import NotificationMessage
5+
from ...services import notifications_service
6+
7+
router = RPCRouter()
8+
9+
10+
@router.expose(reraise_if_error_type=())
11+
async def send_notification_message(
12+
app: FastAPI,
13+
*,
14+
message: NotificationMessage,
15+
) -> None:
16+
await notifications_service.send_notification_message(message=message)

services/notifications/src/simcore_service_notifications/api/rpc/routes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
from servicelib.rabbitmq import RPCRouter
77

88
from ...clients.rabbitmq import get_rabbitmq_rpc_server
9+
from . import _notifications
910

10-
ROUTERS: list[RPCRouter] = [
11-
# import and use all routers here
12-
]
11+
ROUTERS: list[RPCRouter] = [_notifications.router]
1312

1413

1514
async def rpc_api_routes_lifespan(app: FastAPI) -> AsyncIterator[State]:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import Any, TypeAlias
2+
3+
from pydantic import BaseModel
4+
5+
6+
class SMSRecipient(BaseModel):
7+
phone_number: str
8+
9+
10+
class EmailRecipient(BaseModel):
11+
email: str
12+
13+
14+
Recipient: TypeAlias = SMSRecipient | EmailRecipient
15+
16+
17+
class NotificationMessage(BaseModel):
18+
recipients: list[Recipient]
19+
event: str
20+
context: dict[str, Any] | None = None
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from ..models.schemas import NotificationMessage
2+
3+
4+
async def send_notification_message(message: NotificationMessage) -> None: ...

0 commit comments

Comments
 (0)