# generated by datamodel-codegen:
#   filename:  all.schemas.json

from __future__ import annotations

from datetime import datetime
from enum import Enum
from typing import Any

from pydantic import EmailStr, Field, RootModel
from triton_shared.base import BaseSchema


class Model(RootModel[Any]):
    root: Any


class OemAssetReport(BaseSchema):
    asset_id: str = Field(..., alias='assetId')
    asset_name: str = Field(..., alias='assetName')
    make: str
    model: str | None = None
    year: int | None = None
    engine_hours: float | None = Field(None, alias='engineHours')
    nautical_miles: float | None = Field(None, alias='nauticalMiles')
    last_heartbeat_utc: datetime | None = Field(None, alias='lastHeartbeatUtc')
    days_used: int | None = Field(None, alias='daysUsed')
    days_idle: int | None = Field(None, alias='daysIdle')
    alerts_bilge: int | None = Field(0, alias='alertsBilge')
    alerts_battery_low: int | None = Field(0, alias='alertsBatteryLow')
    alerts_battery_high: int | None = Field(0, alias='alertsBatteryHigh')
    alerts_disconnect: int | None = Field(0, alias='alertsDisconnect')
    alerts_geofence: int | None = Field(0, alias='alertsGeofence')


class LoginErrorCode(Enum):
    USER_NOT_FOUND = 'user_not_found'
    INCORRECT_PASSWORD = 'incorrect_password'


class TokenErrorCode(Enum):
    TOKEN_INVALID = 'token_invalid'
    TOKEN_EXPIRED = 'token_expired'
    TOKEN_NOT_YET_VALID = 'token_not_yet_valid'
    TOKEN_REVOKED = 'token_revoked'
    TOKEN_AUDIENCE_MISMATCH = 'token_audience_mismatch'
    TOKEN_ISSUER_MISMATCH = 'token_issuer_mismatch'
    TOKEN_ROLE_MISMATCH = 'token_role_mismatch'
    TOKEN_INVALID_SUBJECT = 'token_invalid_subject'
    TOKEN_TENANT_MISMATCH = 'token_tenant_mismatch'
    TOKEN_MISSING = 'token_missing'


class LoginRequest(BaseSchema):
    email: EmailStr
    password: str = Field(..., min_length=8)
    remember_me: bool | None = Field(False, alias='rememberMe')


class Role(Enum):
    ADMIN = 'admin'
    INSURER = 'insurer'
    BUILDER = 'builder'


class OemFleetReport(BaseSchema):
    make: str
    total_assets: int = Field(..., alias='totalAssets')
    total_alerts: int | None = Field(None, alias='totalAlerts')
    page: int = Field(..., ge=1)
    page_size: int = Field(..., alias='pageSize', ge=1)
    total_pages: int = Field(..., alias='totalPages', ge=1)
    total_items: int = Field(..., alias='totalItems', ge=0)
    assets: list[OemAssetReport]


class Membership(BaseSchema):
    tenant_id: str = Field(..., alias='tenantId', min_length=1)
    role: Role


class UserPublic(BaseSchema):
    id: str = Field(..., min_length=1)
    email: EmailStr
    first_name: str | None = Field(None, alias='firstName')
    last_name: str | None = Field(None, alias='lastName')
    tenants: list[Membership] = Field(..., min_length=0)


class LoginResponse(BaseSchema):
    user: UserPublic
