cloud-api/src/user/schemas.py

80 lines
1.5 KiB
Python
Raw Normal View History

2026-04-06 12:41:49 +01:00
"""
2026-05-28 14:55:44 +01:00
Pydantic models for the user module
2026-04-06 12:41:49 +01:00
"""
from typing import Optional
from pydantic import EmailStr
2026-06-02 14:40:24 +01:00
2026-06-09 15:52:38 +01:00
from src.organisation.constants import Status
from src.organisation.schemas import Questionnaire
from src.schemas import CustomBaseModel, OrgIDMixin
2026-06-09 15:52:38 +01:00
class ContactModel(CustomBaseModel):
id: int
email: Optional[EmailStr] = None
class OrgSchema(OrgIDMixin):
name: str
status: Status
root_user_email: EmailStr
intake_questionnaire: Optional[Questionnaire] = None
2026-06-09 15:52:38 +01:00
billing_contact: ContactModel
owner_contact: ContactModel
security_contact: ContactModel
2026-05-20 10:42:07 +01:00
class OIDCClaims(CustomBaseModel):
exp: int
iat: int
auth_time: int
jti: str
iss: str
aud: str
sub: str
typ: str
azp: str
sid: str
acr: str
allowed_origins: list[str]
realm_access: dict[str, list[str]]
resource_access: dict[str, dict[str, list[str]]]
scope: str
email_verified: bool
name: str
preferred_username: str
given_name: str
family_name: str
email: str
db_id: int
2026-04-06 12:41:49 +01:00
class OIDCUser(CustomBaseModel):
first_name: str
last_name: str
email: str
oidc_id: str
class UserResponse(CustomBaseModel):
2026-06-09 16:33:42 +01:00
id: int
2026-04-06 12:41:49 +01:00
first_name: str
last_name: str
email: str
organisations: list[Optional[dict[str, str | int]]]
groups: Optional[dict[str, list[dict[str, str | int]]]] = None
2026-04-06 12:41:49 +01:00
class UserPostInvitationRequest(OrgIDMixin):
user_email: EmailStr
class UserPostInvitationAcceptRequest(CustomBaseModel):
jwt: str
2026-06-09 15:52:38 +01:00
class UserGetSelfOrgsResponse(CustomBaseModel):
organisations: list[OrgSchema]