30 lines
1007 B
Python
30 lines
1007 B
Python
"""Schemas for permission templates."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class PermissionTemplateCreate(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=200)
|
|
entity_type: str = Field(..., min_length=1, max_length=50)
|
|
level: str = Field("read", pattern="^(read|write|admin|delete)$")
|
|
trigger_condition: dict[str, Any] | None = None
|
|
auto_share_with: list[dict[str, Any]] | None = None
|
|
|
|
|
|
class PermissionTemplateUpdate(BaseModel):
|
|
name: str | None = Field(None, min_length=1, max_length=200)
|
|
entity_type: str | None = Field(None, min_length=1, max_length=50)
|
|
level: str | None = Field(None, pattern="^(read|write|admin|delete)$")
|
|
trigger_condition: dict[str, Any] | None = None
|
|
auto_share_with: list[dict[str, Any]] | None = None
|
|
|
|
|
|
class PermissionTemplateApply(BaseModel):
|
|
entity_type: str = Field(..., min_length=1, max_length=50)
|
|
entity_id: str
|
|
template_id: str | None = None
|