from datetime import datetime

class ColumnType:
    @property
    def name(self) -> str: ...

class ColumnMeta:
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def column_type(self) -> ColumnType: ...
    @property
    def order(self) -> int: ...
    @property
    def comment(self) -> str: ...

class TypeTableMeta:
    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def n_rows(self) -> int: ...
    @property
    def n_columns(self) -> int: ...
    @property
    def comment(self) -> str: ...

class Column:
    @property
    def name(self) -> str: ...
    @property
    def column_type(self) -> ColumnType: ...
    def row(self, row: int) -> object: ...
    def values(self) -> list[object]: ...

class RowView:
    @property
    def n_columns(self) -> int: ...
    @property
    def column_types(self) -> list[ColumnType]: ...
    def value(self, column: int | str) -> object | None: ...
    def columns(self) -> list[tuple[str, ColumnType, object]]: ...

class Data:
    @property
    def n_rows(self) -> int: ...
    @property
    def n_columns(self) -> int: ...
    @property
    def column_names(self) -> list[str]: ...
    @property
    def column_types(self) -> list[ColumnType]: ...
    def column(self, column: int | str) -> Column: ...
    def row(self, row: int) -> RowView: ...
    def rows(self) -> list[RowView]: ...
    def value(self, column: int | str, row: int) -> object | None: ...

class TypeTableHandle:
    @property
    def name(self) -> str: ...
    @property
    def id(self) -> int: ...
    @property
    def meta(self) -> TypeTableMeta: ...
    def full_path(self) -> str: ...
    def columns(self) -> list[ColumnMeta]: ...
    def fetch(
        self,
        *,
        runs: list[int] | None = None,
        variation: str | None = None,
        timestamp: str | datetime | None = None,
    ) -> dict[int, Data]: ...
    def fetch_run_period(
        self,
        *,
        run_period: str,
        rest_version: int | None = None,
        variation: str | None = None,
        timestamp: str | datetime | None = None,
    ) -> dict[int, Data]: ...

class DirectoryHandle:
    def full_path(self) -> str: ...
    def parent(self) -> DirectoryHandle | None: ...
    def dirs(self) -> list[DirectoryHandle]: ...
    def dir(self, path: str) -> DirectoryHandle: ...
    def tables(self) -> list[TypeTableHandle]: ...
    def table(self, name: str) -> TypeTableHandle: ...

class CCDB:
    def __init__(self, path: str) -> None: ...
    @property
    def connection_path(self) -> str: ...
    def dir(self, path: str) -> DirectoryHandle: ...
    def table(self, path: str) -> TypeTableHandle: ...
    def root(self) -> DirectoryHandle: ...
    def fetch(
        self,
        path: str,
        *,
        runs: list[int] | None = None,
        variation: str | None = None,
        timestamp: str | datetime | None = None,
    ) -> dict[int, Data]: ...
    def fetch_run_period(
        self,
        path: str,
        *,
        run_period: str,
        rest_version: int | None = None,
        variation: str | None = None,
        timestamp: str | datetime | None = None,
    ) -> dict[int, Data]: ...

__all__ = [
    "CCDB",
    "Column",
    "ColumnMeta",
    "ColumnType",
    "Data",
    "DirectoryHandle",
    "RowView",
    "TypeTableHandle",
    "TypeTableMeta",
]
