mirror of
https://github.com/idrainformatica/PecFlow.git
synced 2026-06-16 12:45:42 +02:00
vbox funzionanti
This commit is contained in:
@@ -81,3 +81,14 @@ class MessageUpdateRequest(BaseModel):
|
||||
is_read: Optional[bool] = None
|
||||
is_starred: Optional[bool] = None
|
||||
is_archived: Optional[bool] = None
|
||||
|
||||
|
||||
class MessageBulkUpdateRequest(BaseModel):
|
||||
ids: list[uuid.UUID]
|
||||
is_starred: Optional[bool] = None
|
||||
is_archived: Optional[bool] = None
|
||||
|
||||
|
||||
class MessageBulkUpdateResponse(BaseModel):
|
||||
updated: int
|
||||
items: list[MessageResponse]
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
"""
|
||||
Schema Pydantic per i canali di notifica multi-canale.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Any, Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
# ─── NotificationChannel ─────────────────────────────────────────────────────
|
||||
|
||||
ChannelType = Literal["webhook", "email", "telegram", "whatsapp"]
|
||||
|
||||
|
||||
class NotificationChannelCreate(BaseModel):
|
||||
name: str = Field(..., min_length=1, max_length=255)
|
||||
channel_type: ChannelType
|
||||
config: dict[str, Any] | None = None # configurazione pubblica
|
||||
config_secret: dict[str, Any] | None = None # verrà cifrato in config_enc
|
||||
|
||||
|
||||
class NotificationChannelUpdate(BaseModel):
|
||||
name: str | None = None
|
||||
is_active: bool | None = None
|
||||
config: dict[str, Any] | None = None
|
||||
config_secret: dict[str, Any] | None = None
|
||||
|
||||
|
||||
class NotificationChannelResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
tenant_id: uuid.UUID
|
||||
name: str
|
||||
channel_type: str
|
||||
is_active: bool
|
||||
config: dict[str, Any] | None
|
||||
consecutive_failures: int
|
||||
circuit_open_until: datetime | None
|
||||
created_by: uuid.UUID | None
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class NotificationChannelListResponse(BaseModel):
|
||||
items: list[NotificationChannelResponse]
|
||||
total: int
|
||||
page: int
|
||||
page_size: int
|
||||
|
||||
|
||||
class ChannelTestResult(BaseModel):
|
||||
success: bool
|
||||
message: str
|
||||
http_status: int | None = None
|
||||
|
||||
|
||||
# ─── NotificationRule ─────────────────────────────────────────────────────────
|
||||
|
||||
EventType = Literal[
|
||||
"new_message",
|
||||
"state_changed",
|
||||
"anomaly",
|
||||
"send_failed",
|
||||
"send_delivered",
|
||||
"mailbox_error",
|
||||
]
|
||||
|
||||
|
||||
class NotificationRuleCreate(BaseModel):
|
||||
channel_id: uuid.UUID
|
||||
name: str = Field(..., min_length=1, max_length=255)
|
||||
event_type: EventType
|
||||
filter: dict[str, Any] | None = None
|
||||
|
||||
|
||||
class NotificationRuleUpdate(BaseModel):
|
||||
name: str | None = None
|
||||
event_type: EventType | None = None
|
||||
filter: dict[str, Any] | None = None
|
||||
is_active: bool | None = None
|
||||
|
||||
|
||||
class NotificationRuleResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
tenant_id: uuid.UUID
|
||||
channel_id: uuid.UUID
|
||||
name: str
|
||||
event_type: str
|
||||
filter: dict[str, Any] | None
|
||||
is_active: bool
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class NotificationRuleListResponse(BaseModel):
|
||||
items: list[NotificationRuleResponse]
|
||||
total: int
|
||||
|
||||
|
||||
# ─── NotificationLog ─────────────────────────────────────────────────────────
|
||||
|
||||
class NotificationLogResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
tenant_id: uuid.UUID
|
||||
channel_id: uuid.UUID
|
||||
rule_id: uuid.UUID | None
|
||||
event_type: str
|
||||
status: str
|
||||
attempt_count: int
|
||||
max_attempts: int
|
||||
next_retry_at: datetime | None
|
||||
last_error: str | None
|
||||
http_status: int | None
|
||||
sent_at: datetime | None
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class NotificationLogListResponse(BaseModel):
|
||||
items: list[NotificationLogResponse]
|
||||
total: int
|
||||
page: int
|
||||
page_size: int
|
||||
@@ -0,0 +1,127 @@
|
||||
"""
|
||||
Schema Pydantic per le Virtual Box.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
# ─── VirtualBoxRule ───────────────────────────────────────────────────────────
|
||||
|
||||
VBoxField = Literal["mailbox_id", "imap_folder", "subject", "from_address", "to_address"]
|
||||
VBoxOperator = Literal["contains", "equals", "starts_with", "ends_with", "regex"]
|
||||
|
||||
|
||||
class VirtualBoxRuleCreate(BaseModel):
|
||||
field: VBoxField
|
||||
operator: VBoxOperator = "contains"
|
||||
value: str = Field(..., min_length=1)
|
||||
date_from: str | None = None # YYYY-MM-DD
|
||||
date_to: str | None = None # YYYY-MM-DD
|
||||
|
||||
|
||||
class VirtualBoxRuleResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
virtual_box_id: uuid.UUID
|
||||
field: str
|
||||
operator: str
|
||||
value: str
|
||||
date_from: str | None
|
||||
date_to: str | None
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
# ─── Mailbox breve (usata nella risposta VirtualBox) ─────────────────────────
|
||||
|
||||
class MailboxBriefResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
email_address: str
|
||||
display_name: str | None
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
# ─── VirtualBox ───────────────────────────────────────────────────────────────
|
||||
|
||||
class VirtualBoxCreate(BaseModel):
|
||||
name: str = Field(..., min_length=1, max_length=255)
|
||||
description: str | None = None
|
||||
label: str | None = None
|
||||
rules: list[VirtualBoxRuleCreate] = []
|
||||
mailbox_ids: list[uuid.UUID] = Field(
|
||||
default=[],
|
||||
description="ID delle caselle PEC reali a cui è associata questa Virtual Box",
|
||||
)
|
||||
|
||||
|
||||
class VirtualBoxUpdate(BaseModel):
|
||||
name: str | None = None
|
||||
description: str | None = None
|
||||
label: str | None = None
|
||||
is_active: bool | None = None
|
||||
mailbox_ids: list[uuid.UUID] | None = Field(
|
||||
default=None,
|
||||
description="Se fornito, sostituisce completamente la lista di caselle associate",
|
||||
)
|
||||
|
||||
|
||||
class VirtualBoxResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
tenant_id: uuid.UUID
|
||||
name: str
|
||||
description: str | None
|
||||
label: str | None
|
||||
is_active: bool
|
||||
created_by: uuid.UUID | None
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
rules: list[VirtualBoxRuleResponse] = []
|
||||
assignment_count: int = 0
|
||||
mailboxes: list[MailboxBriefResponse] = []
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class VirtualBoxListResponse(BaseModel):
|
||||
items: list[VirtualBoxResponse]
|
||||
total: int
|
||||
page: int
|
||||
page_size: int
|
||||
|
||||
|
||||
# ─── VirtualBoxAssignment ─────────────────────────────────────────────────────
|
||||
|
||||
class VirtualBoxAssignRequest(BaseModel):
|
||||
user_ids: list[uuid.UUID] = Field(..., min_length=1)
|
||||
|
||||
|
||||
class VirtualBoxAssignmentResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
virtual_box_id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
assigned_by: uuid.UUID | None
|
||||
assigned_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class AssignedUserResponse(BaseModel):
|
||||
user_id: uuid.UUID
|
||||
user_email: str
|
||||
user_full_name: str
|
||||
assigned_at: datetime
|
||||
|
||||
|
||||
# ─── Gestione caselle associate ───────────────────────────────────────────────
|
||||
|
||||
class VirtualBoxMailboxAssignRequest(BaseModel):
|
||||
mailbox_ids: list[uuid.UUID] = Field(
|
||||
...,
|
||||
min_length=1,
|
||||
description="Lista degli ID delle caselle PEC da associare",
|
||||
)
|
||||
Reference in New Issue
Block a user