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

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


class BackendConfigSchema(BaseModel):
    """
    Backend configuration block for dataset storage.
    """
    format: str | None = Field(None, title='Format')
    path: str | None = Field(None, title='Path')
    public_url: str | None = Field(None, title='Public Url')
    size_bytes: int | None = Field(None, title='Size Bytes')
    table: str | None = Field(None, title='Table')


class CatalogueImportResponseSchema(BaseModel):
    created: int = Field(..., title='Created')
    updated: int = Field(..., title='Updated')


class ContactPointSchema(BaseModel):
    email: str | None = Field(None, title='Email')
    fn: str | None = Field(None, title='Fn')


class DatasetQueryModelSchema(BaseModel):
    limit: int | None = Field(100, title='Limit')
    offset: int | None = Field(0, title='Offset')
    sql: str | None = Field(None, title='Sql')


class DatasetQueryResultSchema(BaseModel):
    count: int = Field(..., title='Count')
    items: list[dict[str, Any]] = Field(..., title='Items')
    limit: int = Field(..., title='Limit')
    offset: int = Field(..., title='Offset')
    total: int | None = Field(None, title='Total')


class LineageSchema(BaseModel):
    class Config:
        extra = Extra.allow
    createdAt: str | None = Field(None, title='Createdat')
    description: str | None = Field(None, title='Description')
    facets: dict[str, Any] | None = Field(None, title='Facets')
    lastLifecycleState: str | None = Field(None, title='Lastlifecyclestate')
    lastModifiedAt: str | None = Field(None, title='Lastmodifiedat')
    name: str | None = Field(None, title='Name')
    namespace: str | None = Field(None, title='Namespace')
    sourceName: str | None = Field(None, title='Sourcename')
    tags: list[str] | None = Field(None, title='Tags')
    title: str | None = Field(None, title='Title')
    updatedAt: str | None = Field(None, title='Updatedat')


class TemporalCoverageSchema(BaseModel):
    end: str | None = Field(None, title='End')
    start: str | None = Field(None, title='Start')


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


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


class TagsSchema(BaseModel):
    accessRights: str | None = Field(None, title='Accessrights')
    accrualPeriodicity: str | None = Field(None, title='Accrualperiodicity')
    conformsTo: str | None = Field(None, title='Conformsto')
    contactPoint: ContactPointSchema | None = None
    identifier: str | None = Field(None, title='Identifier')
    keywords: list[str] | None = Field(None, title='Keywords')
    temporal: TemporalCoverageSchema | None = None
    themes: list[str] | None = Field(None, title='Themes')


class DatasetEntryModelSchema(BaseModel):
    access_level: str | None = Field(None, title='Access Level')
    backend_config: BackendConfigSchema | None = None
    backend_type: str = Field(..., title='Backend Type')
    dataset_id: str = Field(..., title='Dataset Id')
    description: str | None = Field(None, title='Description')
    expose: bool | None = Field(False, title='Expose')
    landing_page: str | None = Field(None, title='Landing Page')
    language_uris: list[str] | None = Field(None, title='Language Uris')
    license_uri: str | None = Field(None, title='License Uri')
    lineage: LineageSchema | None = None
    ontology_path: str | None = Field(None, title='Ontology Path')
    publisher_uri: str | None = Field(None, title='Publisher Uri')
    rights_holder_uri: str | None = Field(None, title='Rights Holder Uri')
    schema_override_path: str | None = Field(None, title='Schema Override Path')
    spatial_uris: list[str] | None = Field(None, title='Spatial Uris')
    tags: TagsSchema | None = None
    title: str = Field(..., title='Title')


class CatalogueImportModelSchema(BaseModel):
    """
    Full catalogue import: list of datasets.
    """
    datasets: list[DatasetEntryModelSchema] = Field(..., title='Datasets')
