"""Pydantic schemas for the Permissions plugin."""

from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel, Field


class PermissionGrantRequest(BaseModel):
    user_id: str
    group_id: str | None = None
    access_level: str = Field("read", pattern="^(read|write)$")


class PermissionResponse(BaseModel):
    id: str
    file_id: str
    user_id: str
    group_id: str | None = None
    access_level: str


class ShareLinkCreateRequest(BaseModel):
    password: str | None = Field(None, min_length=4, max_length=100)
    expires_at: datetime | None = None
    access_level: str = Field("download", pattern="^(download|preview)$")


class ShareLinkResponse(BaseModel):
    id: str
    file_id: str
    token: str
    public_url: str
    expires_at: datetime | None = None
    access_level: str
    has_password: bool


class ShareLinkVerifyRequest(BaseModel):
    password: str | None = None
