# generated by datamodel-codegen:
#   filename:  openapi.json
#   timestamp: 2026-02-22T16:52:45+00:00

from __future__ import annotations
from pydantic import BaseModel, Extra, Field
from typing import Any


class AssetDetailSchema(BaseModel):
    asset_type: str = Field(..., title='Asset Type')
    created_at: str | None = Field(None, title='Created At')
    device: dict[str, Any] | None = Field(None, title='AssetDetailDevice')
    extra: dict[str, Any] | None = Field(None, title='AssetDetailExtra')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    owner_key: str = Field(..., title='Owner Key')
    owner_user_id: str = Field(..., title='Owner User Id')
    properties: dict[str, Any] | None = Field(None, title='AssetDetailProperties')
    relationships: dict[str, Any] | None = Field(None, title='AssetDetailRelationships')
    sensor_id: str | None = Field(None, title='Sensor Id')
    updated_at: str | None = Field(None, title='Updated At')


class AssetListItemSchema(BaseModel):
    asset_type: str = Field(..., title='Asset Type')
    device_type: str | None = Field(None, title='Device Type')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    owner_key: str = Field(..., title='Owner Key')
    owner_user_id: str = Field(..., title='Owner User Id')
    sensor_id: str | None = Field(None, title='Sensor Id')


class AssetRefSchema(BaseModel):
    asset_type: str = Field(..., title='Asset Type')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    sensor_id: str | None = Field(None, title='Sensor Id')


class AssetRelationshipsInSchema(BaseModel):
    """
    Relationships between assets.
    """
    class Config:
        extra = Extra.allow
    measures: list[str] | None = Field(None, title='Measures')
    paired_with: str | None = Field(None, title='Paired With')


class CommunityRefSchema(BaseModel):
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')


class ContactInSchema(BaseModel):
    """
    Contact information.
    """
    class Config:
        extra = Extra.allow
    address: str | None = Field(None, title='Address')
    email: str | None = Field(None, title='Email')
    pec: str | None = Field(None, title='Pec')
    phone: str | None = Field(None, title='Phone')


class DeliveryPointSchema(BaseModel):
    active: bool | None = Field(True, title='Active')
    address: str | None = Field(None, title='Address')
    description: str | None = Field(None, title='Description')
    id: str = Field(..., title='Id')
    tariff: str | None = Field(None, title='Tariff')
    type: str = Field(..., title='Type')


class DeliveryPointInSchema(BaseModel):
    """
    Physical delivery point (POD, CUPS, PRM, etc.).
    """
    class Config:
        extra = Extra.allow
    active: bool | None = Field(True, title='Active')
    address: str | None = Field(None, title='Address')
    description: str | None = Field(None, title='Description')
    id: str = Field(..., title='Id')
    tariff: str | None = Field(None, title='Tariff')
    type: str = Field(..., title='Type')


class DeliveryPointWithOwnerSchema(BaseModel):
    active: bool | None = Field(True, title='Active')
    address: str | None = Field(None, title='Address')
    description: str | None = Field(None, title='Description')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    member_key: str = Field(..., title='Member Key')
    member_name: str = Field(..., title='Member Name')
    tariff: str | None = Field(None, title='Tariff')
    type: str = Field(..., title='Type')


class DeliveryPointsResponseSchema(BaseModel):
    delivery_points: list[DeliveryPointSchema] | None = Field(None, title='Delivery Points')


class DeviceInSchema(BaseModel):
    """
    SAREF-inspired device specification.
    """
    class Config:
        extra = Extra.allow
    firmware_version: str | None = Field(None, title='Firmware Version')
    mac_address: str | None = Field(None, title='Mac Address')
    model: str | None = Field(None, title='Model')
    serial_number: str | None = Field(None, title='Serial Number')
    type: str | None = Field(None, title='Type')


class EVChargerAssetInSchema(BaseModel):
    """
    EV charger asset.
    """
    class Config:
        extra = Extra.allow
    bidirectional: bool | None = Field(None, title='Bidirectional')
    charger_type: str = Field(..., title='Charger Type')
    connector_types: list[str] | None = Field(None, title='Connector Types')
    device: DeviceInSchema | None = None
    installation_date: str | None = Field(None, title='Installation Date')
    max_power: float = Field(..., title='Max Power')
    name: str = Field(..., title='Name')
    num_ports: int | None = Field(None, title='Num Ports')
    relationships: AssetRelationshipsInSchema | None = None
    smart_charging: bool | None = Field(None, title='Smart Charging')


class GlobalAssetLookupSchema(BaseModel):
    asset_type: str = Field(..., title='Asset Type')
    community_key: str = Field(..., title='Community Key')
    community_name: str = Field(..., title='Community Name')
    device: dict[str, Any] | None = Field(None, title='GlobalAssetLookupDevice')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    owner_key: str = Field(..., title='Owner Key')
    owner_user_id: str = Field(..., title='Owner User Id')
    properties: dict[str, Any] | None = Field(None, title='GlobalAssetLookupProperties')
    relationships: dict[str, Any] | None = Field(None, title='GlobalAssetLookupRelationships')
    sensor_id: str | None = Field(None, title='Sensor Id')


class GlobalMemberLookupSchema(BaseModel):
    area: str = Field(..., title='Area')
    community_key: str = Field(..., title='Community Key')
    community_name: str = Field(..., title='Community Name')
    delivery_points: list[DeliveryPointSchema] | None = Field(None, title='Delivery Points')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    role: str = Field(..., title='Role')
    status: str = Field(..., title='Status')
    user_id: str = Field(..., title='User Id')


class HeatPumpAssetInSchema(BaseModel):
    """
    Heat pump asset.
    """
    class Config:
        extra = Extra.allow
    cop: float | None = Field(None, title='Cop')
    device: DeviceInSchema | None = None
    eer: float | None = Field(None, title='Eer')
    electrical_power: float | None = Field(None, title='Electrical Power')
    heat_pump_type: str | None = Field(None, title='Heat Pump Type')
    installation_date: str | None = Field(None, title='Installation Date')
    name: str = Field(..., title='Name')
    refrigerant: str | None = Field(None, title='Refrigerant')
    relationships: AssetRelationshipsInSchema | None = None
    reversible: bool | None = Field(None, title='Reversible')
    scop: float | None = Field(None, title='Scop')
    seer: float | None = Field(None, title='Seer')
    thermal_power: float = Field(..., title='Thermal Power')


class ImportReportSchema(BaseModel):
    """
    Import operation report.
    """
    community_key: str = Field(..., title='Community Key')
    deleted: dict[str, int] | None = Field(None, title='Deleted')
    inserted: dict[str, int] | None = Field(None, title='Inserted')
    warnings: list[str] | None = Field(None, title='Warnings')


class LegalInfoInSchema(BaseModel):
    """
    Legal and administrative details.
    """
    class Config:
        extra = Extra.allow
    fiscal_code: str | None = Field(None, title='Fiscal Code')
    legal_form: str | None = Field(None, title='Legal Form')
    name: str | None = Field(None, title='Name')
    registered_office: str | None = Field(None, title='Registered Office')
    registration_number: str | None = Field(None, title='Registration Number')
    vat: str | None = Field(None, title='Vat')


class LinksInSchema(BaseModel):
    """
    Public URLs for the community.
    """
    class Config:
        extra = Extra.allow
    logo: str | None = Field(None, title='Logo')
    privacy_policy: str | None = Field(None, title='Privacy Policy')
    regulations: str | None = Field(None, title='Regulations')
    statute: str | None = Field(None, title='Statute')
    terms: str | None = Field(None, title='Terms')
    website: str | None = Field(None, title='Website')


class LoadAssetInSchema(BaseModel):
    """
    Load asset.
    """
    class Config:
        extra = Extra.allow
    controllable: bool | None = Field(None, title='Controllable')
    device: DeviceInSchema | None = None
    flexibility_kw: float | None = Field(None, title='Flexibility Kw')
    load_type: str | None = Field(None, title='Load Type')
    min_power: float | None = Field(None, title='Min Power')
    name: str = Field(..., title='Name')
    priority: str | None = Field(None, title='Priority')
    rated_power: float | None = Field(None, title='Rated Power')
    relationships: AssetRelationshipsInSchema | None = None


class LocationSchema(BaseModel):
    lat: float = Field(..., title='Lat')
    lon: float = Field(..., title='Lon')


class LocationInSchema(BaseModel):
    """
    Geographic location.
    """
    class Config:
        extra = Extra.allow
    lat: float = Field(..., title='Lat')
    lon: float = Field(..., title='Lon')


class MemberDetailSchema(BaseModel):
    area: str = Field(..., title='Area')
    created_at: str | None = Field(None, title='Created At')
    delivery_points: list[DeliveryPointSchema] | None = Field(None, title='Delivery Points')
    extra: dict[str, Any] | None = Field(None, title='MemberDetailExtra')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    role: str = Field(..., title='Role')
    status: str = Field(..., title='Status')
    updated_at: str | None = Field(None, title='Updated At')
    user_id: str = Field(..., title='User Id')


class MemberInCommunitySchema(BaseModel):
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    role: str = Field(..., title='Role')
    status: str = Field(..., title='Status')
    user_id: str = Field(..., title='User Id')


class MemberListItemSchema(BaseModel):
    area: str = Field(..., title='Area')
    delivery_points_count: int | None = Field(0, title='Delivery Points Count')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    role: str = Field(..., title='Role')
    status: str = Field(..., title='Status')
    user_id: str = Field(..., title='User Id')


class MemberRefSchema(BaseModel):
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    role: str = Field(..., title='Role')
    user_id: str = Field(..., title='User Id')


class MetadataInSchema(BaseModel):
    """
    Registry metadata.
    """
    class Config:
        extra = Extra.allow
    created: str | None = Field(None, title='Created')
    description: str | None = Field(None, title='Description')
    updated: str | None = Field(None, title='Updated')
    updated_by: str | None = Field(None, title='Updated By')


class MeterAssetInSchema(BaseModel):
    """
    Meter asset.
    """
    class Config:
        extra = Extra.allow
    device: DeviceInSchema | None = None
    installation_date: str | None = Field(None, title='Installation Date')
    meter_type: str = Field(..., title='Meter Type')
    name: str = Field(..., title='Name')
    pod: str | None = Field(None, title='Pod')
    protocol: str | None = Field(None, title='Protocol')
    relationships: AssetRelationshipsInSchema | None = None
    sensor_id: str = Field(..., title='Sensor Id')


class MeterListItemSchema(BaseModel):
    device: dict[str, Any] | None = Field(None, title='MeterListItemDevice')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    meter_type: str | None = Field(None, title='Meter Type')
    name: str = Field(..., title='Name')
    owner_key: str = Field(..., title='Owner Key')
    owner_user_id: str = Field(..., title='Owner User Id')
    pod: str | None = Field(None, title='Pod')
    sensor_id: str | None = Field(None, title='Sensor Id')


class PVAssetInSchema(BaseModel):
    """
    PV system asset.
    """
    class Config:
        extra = Extra.allow
    device: DeviceInSchema | None = None
    installation_date: str | None = Field(None, title='Installation Date')
    inverter_power: float | None = Field(None, title='Inverter Power')
    name: str = Field(..., title='Name')
    orientation: float | None = Field(None, title='Orientation')
    panel_type: str | None = Field(None, title='Panel Type')
    rated_power: float | None = Field(None, title='Rated Power')
    relationships: AssetRelationshipsInSchema | None = None
    tilt_angle: float | None = Field(None, title='Tilt Angle')


class PaginatedResponseAssetListItemSchema(BaseModel):
    items: list[AssetListItemSchema] = Field(..., title='Items')
    next_cursor: str | None = Field(None, title='Next Cursor')


class PaginatedResponseDeliveryPointWithOwnerSchema(BaseModel):
    items: list[DeliveryPointWithOwnerSchema] = Field(..., title='Items')
    next_cursor: str | None = Field(None, title='Next Cursor')


class PaginatedResponseMemberListItemSchema(BaseModel):
    items: list[MemberListItemSchema] = Field(..., title='Items')
    next_cursor: str | None = Field(None, title='Next Cursor')


class PaginatedResponseMeterListItemSchema(BaseModel):
    items: list[MeterListItemSchema] = Field(..., title='Items')
    next_cursor: str | None = Field(None, title='Next Cursor')


class SensorIdsBatchRequestSchema(BaseModel):
    sensor_ids: list[str] = Field(..., title='Sensor Ids')


class SettingsInSchema(BaseModel):
    """
    Operational settings.
    """
    class Config:
        extra = Extra.allow
    currency: str | None = Field(None, title='Currency')
    energy_unit: str | None = Field(None, title='Energy Unit')
    power_unit: str | None = Field(None, title='Power Unit')
    timezone: str | None = Field(None, title='Timezone')


class StorageAssetInSchema(BaseModel):
    """
    Battery storage asset.
    """
    class Config:
        extra = Extra.allow
    battery_type: str | None = Field(None, title='Battery Type')
    capacity: float | None = Field(None, title='Capacity')
    device: DeviceInSchema | None = None
    installation_date: str | None = Field(None, title='Installation Date')
    max_charge_power: float | None = Field(None, title='Max Charge Power')
    max_discharge_power: float | None = Field(None, title='Max Discharge Power')
    name: str = Field(..., title='Name')
    relationships: AssetRelationshipsInSchema | None = None
    round_trip_efficiency: float | None = Field(None, title='Round Trip Efficiency')


class TopologyNodeSchema(BaseModel):
    area: dict[str, Any] | None = Field(None, title='TopologyNodeArea')
    id: str = Field(..., title='Id')
    name: str | None = Field(None, title='Name')
    operator: str | None = Field(None, title='Operator')
    parent: str | None = Field(None, title='Parent')
    type: str = Field(..., title='Type')


class TopologyNodeInSchema(BaseModel):
    """
    Grid topology node (substation, transformer, etc.).
    """
    class Config:
        extra = Extra.allow
    area: dict[str, Any] | None = Field(None, title='Area')
    id: str = Field(..., title='Id')
    name: str | None = Field(None, title='Name')
    operator: str | None = Field(None, title='Operator')
    parent: str | None = Field(None, title='Parent')
    type: str = Field(..., title='Type')


class TopologyResponseSchema(BaseModel):
    topology: list[TopologyNodeSchema] | None = Field(None, title='Topology')


class UserAssetSchema(BaseModel):
    asset_type: str = Field(..., title='Asset Type')
    device: dict[str, Any] | None = Field(None, title='UserAssetDevice')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    properties: dict[str, Any] | None = Field(None, title='UserAssetProperties')
    relationships: dict[str, Any] | None = Field(None, title='UserAssetRelationships')
    sensor_id: str | None = Field(None, title='Sensor Id')


class UserAssetDetailSchema(BaseModel):
    asset_type: str = Field(..., title='Asset Type')
    created_at: str | None = Field(None, title='Created At')
    device: dict[str, Any] | None = Field(None, title='UserAssetDetailDevice')
    extra: dict[str, Any] | None = Field(None, title='UserAssetDetailExtra')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    properties: dict[str, Any] | None = Field(None, title='UserAssetDetailProperties')
    relationships: dict[str, Any] | None = Field(None, title='UserAssetDetailRelationships')
    sensor_id: str | None = Field(None, title='Sensor Id')
    updated_at: str | None = Field(None, title='Updated At')


class UserAssetsResponseSchema(BaseModel):
    items: list[UserAssetSchema] = Field(..., title='Items')
    total: int = Field(..., title='Total')


class UserCommunitySummarySchema(BaseModel):
    description: str | None = Field(None, title='Description')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')


class UserDeliveryPointsResponseSchema(BaseModel):
    items: list[DeliveryPointSchema] = Field(..., title='Items')
    total: int = Field(..., title='Total')


class UserMemberDetailSchema(BaseModel):
    area: str = Field(..., title='Area')
    created_at: str | None = Field(None, title='Created At')
    delivery_points: list[DeliveryPointSchema] | None = Field(None, title='Delivery Points')
    extra: dict[str, Any] | None = Field(None, title='UserMemberDetailExtra')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    role: str = Field(..., title='Role')
    status: str = Field(..., title='Status')
    updated_at: str | None = Field(None, title='Updated At')


class UserMemberSummarySchema(BaseModel):
    area: str = Field(..., title='Area')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')
    role: str = Field(..., title='Role')
    status: str = Field(..., title='Status')


class UserMembershipSchema(BaseModel):
    assets_count: dict[str, int] | None = Field(None, title='UserMembershipAssetsCount')
    community: UserCommunitySummarySchema
    delivery_points_count: int | None = Field(0, title='Delivery Points Count')
    member: UserMemberSummarySchema


class UserProfileSchema(BaseModel):
    email: str | None = Field(None, title='Email')
    name: str | None = Field(None, title='Name')
    preferred_username: str | None = Field(None, title='Preferred Username')
    sub: str = Field(..., title='Sub')


class ValidationErrorSchema(BaseModel):
    loc: list[str | int] = Field(..., title='Location')
    msg: str = Field(..., title='Message')
    type: str = Field(..., title='Error Type')


class AreaSchema(BaseModel):
    location: LocationSchema
    name: str = Field(..., title='Name')


class AreaInSchema(BaseModel):
    """
    Community area definition.
    """
    class Config:
        extra = Extra.allow
    location: LocationInSchema
    name: str = Field(..., title='Name')


class AssetCollectionInSchema(BaseModel):
    """
    Collection of assets organized by type.
    """
    class Config:
        extra = Extra.allow
    ev_charger: dict[str, EVChargerAssetInSchema] | None = Field(None, title='Ev Charger')
    heat_pump: dict[str, HeatPumpAssetInSchema] | None = Field(None, title='Heat Pump')
    load: dict[str, LoadAssetInSchema] | None = Field(None, title='Load')
    meter: dict[str, MeterAssetInSchema] | None = Field(None, title='Meter')
    pv: dict[str, PVAssetInSchema] | None = Field(None, title='Pv')
    storage: dict[str, StorageAssetInSchema] | None = Field(None, title='Storage')


class CommunityDetailSchema(BaseModel):
    areas: dict[str, AreaSchema] | None = Field(None, title='CommunityDetailAreas')
    contact: dict[str, Any] | None = Field(None, title='CommunityDetailContact')
    created_at: str | None = Field(None, title='Created At')
    description: str | None = Field(None, title='Description')
    extra: dict[str, Any] | None = Field(None, title='CommunityDetailExtra')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    legal: dict[str, Any] | None = Field(None, title='CommunityDetailLegal')
    links: dict[str, Any] | None = Field(None, title='CommunityDetailLinks')
    name: str = Field(..., title='Name')
    settings: dict[str, Any] | None = Field(None, title='CommunityDetailSettings')
    topology: list[TopologyNodeSchema] | None = Field(None, title='Topology')
    updated_at: str | None = Field(None, title='Updated At')


class CommunityInSchema(BaseModel):
    """
    Community definition.
    """
    class Config:
        extra = Extra.allow
    areas: dict[str, AreaInSchema] | None = Field(None, title='Areas')
    contact: ContactInSchema | None = None
    description: str | None = Field(None, title='Description')
    id: str = Field(..., title='Id')
    legal: LegalInfoInSchema | None = None
    links: LinksInSchema | None = None
    name: str = Field(..., title='Name')
    settings: SettingsInSchema | None = None
    topology: list[TopologyNodeInSchema] | None = Field(None, title='Topology')


class CommunityListItemSchema(BaseModel):
    areas: dict[str, AreaSchema] | None = Field(None, title='CommunityListItemAreas')
    description: str | None = Field(None, title='Description')
    id: str = Field(..., title='Id')
    key: str = Field(..., title='Key')
    name: str = Field(..., title='Name')


class DeliveryPointLookupSchema(BaseModel):
    delivery_point: DeliveryPointSchema
    member: MemberRefSchema


class HTTPValidationErrorSchema(BaseModel):
    detail: list[ValidationErrorSchema] | None = Field(None, title='Detail')


class LookupByDeliveryPointResponseSchema(BaseModel):
    community: CommunityRefSchema
    delivery_point: DeliveryPointSchema
    member: MemberRefSchema


class LookupBySensorIdResponseSchema(BaseModel):
    asset: AssetRefSchema
    community: CommunityRefSchema
    member: MemberInCommunitySchema


class LookupByUserIdResponseSchema(BaseModel):
    community: CommunityRefSchema
    member: MemberInCommunitySchema


class MemberInSchema(BaseModel):
    """
    Community member.
    """
    class Config:
        extra = Extra.allow
    area: str = Field(..., title='Area')
    assets: AssetCollectionInSchema | None = None
    delivery_points: list[DeliveryPointInSchema] | None = Field(None, title='Delivery Points')
    name: str = Field(..., title='Name')
    role: str = Field(..., title='Role')
    status: str = Field(..., title='Status')
    user_id: str = Field(..., title='User Id')


class PaginatedResponseCommunityListItemSchema(BaseModel):
    items: list[CommunityListItemSchema] = Field(..., title='Items')
    next_cursor: str | None = Field(None, title='Next Cursor')


class RegistryBundleInSchema(BaseModel):
    """
    Complete registry bundle for import.

    Matches v0.4 structure.
    """
    class Config:
        extra = Extra.allow
    community: CommunityInSchema
    members: dict[str, MemberInSchema] | None = Field(None, title='Members')
    metadata: MetadataInSchema | None = None
    schema_version: str | None = Field('1.0', title='Schema Version')
    version: str | None = Field('1.0', title='Version')


class UserCommunityDetailSchema(BaseModel):
    areas: dict[str, AreaSchema] | None = Field(None, title='UserCommunityDetailAreas')
    contact: dict[str, Any] | None = Field(None, title='UserCommunityDetailContact')
    description: str | None = Field(None, title='Description')
    key: str = Field(..., title='Key')
    legal: dict[str, Any] | None = Field(None, title='UserCommunityDetailLegal')
    links: dict[str, Any] | None = Field(None, title='UserCommunityDetailLinks')
    name: str = Field(..., title='Name')
    settings: dict[str, Any] | None = Field(None, title='UserCommunityDetailSettings')
    topology: list[TopologyNodeSchema] | None = Field(None, title='Topology')
    your_area: str = Field(..., title='Your Area')
    your_role: str = Field(..., title='Your Role')


class UserMeResponseSchema(BaseModel):
    membership: UserMembershipSchema | None = None
    profile: UserProfileSchema


class ImportRequestSchema(BaseModel):
    """
    Import request payload.
    """
    bundle: RegistryBundleInSchema
    dry_run: bool | None = Field(False, title='Dry Run')
