from typing import Optional
from pydantic.networks import EmailStr
from datetime import datetime
from pydantic.types import UUID4
from sqlmodel import SQLModel, Field
from sqlalchemy import  Enum
from sqlmodel.main import Relationship

from models.commom import CreatedAtModel, IDModel, Pagination, UpdateAtModel
from models.point_model import Point, PointCreate


class GenderEnum(str, Enum):
    male = "male"
    female = "female"
    other = "other"
    not_given = "not_given"


class ExampleBase(SQLModel):
    name: str = Field(..., max_length=256, description="User name",
                      alias="name")
    email: EmailStr = Field(alias="email", description="User Email"
                            )
    gender: GenderEnum = Field(...,
                               description="Enumerator Class Model", alias="gender")
    float_number: float = Field(
        ..., multiple_of=0.01, description="A float Number", alias="float_number"
    )
    optional_integer: Optional[int] = Field(
        None, description="An optional positive integer",  alias="optional_integer"
    )
    optional_float: Optional[float] = Field(
        None, description="An optional float", alias="optional_float"
    )
    point: Optional[Point] = Relationship(back_populates="Point")


class ExamplePointId(ExampleBase):
    point_id: Optional[int] = Field(default=None, foreign_key="point.id")

class Example(ExampleBase, IDModel, UpdateAtModel, CreatedAtModel, table=True):
    pass

class ExampleUpdate(ExampleBase, UpdateAtModel):
    pass


class ExampleGet(ExamplePointId, Pagination, CreatedAtModel):
    pass

class ExampleCreate(ExampleBase):
    pass

sqlmodel.main.Relationship sqlmodel.Field
[((529, 594), 'sqlmodel.Field', 'Field', (['...'], {'max_length': '(256)', 'description': '"""User name"""', 'alias': '"""name"""'}), "(..., max_length=256, description='User name', alias='name')\n", (534, 594), False, 'from sqlmodel import SQLModel, Field\n'), ((639, 685), 'sqlmodel.Field', 'Field', ([], {'alias': '"""email"""', 'description': '"""User Email"""'}), "(alias='email', description='User Email')\n", (644, 685), False, 'from sqlmodel import SQLModel, Field\n'), ((740, 804), 'sqlmodel.Field', 'Field', (['...'], {'description': '"""Enumerator Class Model"""', 'alias': '"""gender"""'}), "(..., description='Enumerator Class Model', alias='gender')\n", (745, 804), False, 'from sqlmodel import SQLModel, Field\n'), ((862, 947), 'sqlmodel.Field', 'Field', (['...'], {'multiple_of': '(0.01)', 'description': '"""A float Number"""', 'alias': '"""float_number"""'}), "(..., multiple_of=0.01, description='A float Number', alias='float_number'\n    )\n", (867, 947), False, 'from sqlmodel import SQLModel, Field\n'), ((995, 1081), 'sqlmodel.Field', 'Field', (['None'], {'description': '"""An optional positive integer"""', 'alias': '"""optional_integer"""'}), "(None, description='An optional positive integer', alias=\n    'optional_integer')\n", (1000, 1081), False, 'from sqlmodel import SQLModel, Field\n'), ((1130, 1198), 'sqlmodel.Field', 'Field', (['None'], {'description': '"""An optional float"""', 'alias': '"""optional_float"""'}), "(None, description='An optional float', alias='optional_float')\n", (1135, 1198), False, 'from sqlmodel import SQLModel, Field\n'), ((1242, 1278), 'sqlmodel.main.Relationship', 'Relationship', ([], {'back_populates': '"""Point"""'}), "(back_populates='Point')\n", (1254, 1278), False, 'from sqlmodel.main import Relationship\n'), ((1346, 1389), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'foreign_key': '"""point.id"""'}), "(default=None, foreign_key='point.id')\n", (1351, 1389), False, 'from sqlmodel import SQLModel, Field\n')]