import uuid
from datetime import datetime

from sqlmodel import Field

from api.db.models.base import BaseModel, BaseTable


class TenantSchemaBase(BaseModel):
    tenant_id: uuid.UUID = Field(nullable=False)
    wallet_id: uuid.UUID = Field(nullable=False)
    # workflow_id will be null until the tenant kcks it off
    workflow_id: uuid.UUID = Field(nullable=True, default=None)
    schema_id: str = Field(nullable=True, default=None)
    schema_name: str = Field(nullable=True, default=None)
    schema_version: str = Field(nullable=True, default=None)
    schema_attrs: str = Field(nullable=True, default=None)
    schema_txn_id: uuid.UUID = Field(nullable=True, default=None)
    schema_state: str = Field(nullable=True, default=None)
    cred_def_tag: str = Field(nullable=True, default=None)
    cred_def_txn_id: uuid.UUID = Field(nullable=True, default=None)
    cred_def_id: str = Field(nullable=True, default=None)
    cred_def_state: str = Field(nullable=True, default=None)
    cred_revocation: bool = Field(nullable=True, default=None)
    cred_revoc_reg_size: int = Field(nullable=True, default=None)
    revoc_reg_state: str = Field(nullable=True, default=None)


class TenantSchema(TenantSchemaBase, BaseTable, table=True):
    # This is the class that represents the table
    pass


class TenantSchemaCreate(TenantSchemaBase):
    # This is the class that represents interface for creating a tenant
    # we must set all the required fields,
    # but do not need to set optional (and shouldn't)
    pass


class TenantSchemaRead(TenantSchemaBase):
    # This is the class that represents interface for reading a tenant
    # here we indicate id, created_at and updated_at must be included
    id: uuid.UUID
    created_at: datetime
    updated_at: datetime


class TenantSchemaUpdate(BaseModel):
    # This is our update interface
    # This does NOT inherit from TenantSchemaBase,
    # so no need to worry about accidentally updating id or other fields
    id: uuid.UUID
    workflow_id: uuid.UUID = Field(nullable=True, default=None)
    schema_id: str = Field(nullable=True, default=None)
    schema_txn_id: uuid.UUID = Field(nullable=True, default=None)
    schema_state: str = Field(nullable=True, default=None)
    cred_def_txn_id: uuid.UUID = Field(nullable=True, default=None)
    cred_def_id: str = Field(nullable=True, default=None)
    cred_def_state: str = Field(nullable=True, default=None)
    revoc_reg_state: str = Field(nullable=True, default=None)

sqlmodel.Field
[((187, 208), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (192, 208), False, 'from sqlmodel import Field\n'), ((236, 257), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (241, 257), False, 'from sqlmodel import Field\n'), ((347, 381), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (352, 381), False, 'from sqlmodel import Field\n'), ((403, 437), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (408, 437), False, 'from sqlmodel import Field\n'), ((461, 495), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (466, 495), False, 'from sqlmodel import Field\n'), ((522, 556), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (527, 556), False, 'from sqlmodel import Field\n'), ((581, 615), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (586, 615), False, 'from sqlmodel import Field\n'), ((647, 681), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (652, 681), False, 'from sqlmodel import Field\n'), ((706, 740), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (711, 740), False, 'from sqlmodel import Field\n'), ((765, 799), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (770, 799), False, 'from sqlmodel import Field\n'), ((833, 867), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (838, 867), False, 'from sqlmodel import Field\n'), ((891, 925), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (896, 925), False, 'from sqlmodel import Field\n'), ((952, 986), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (957, 986), False, 'from sqlmodel import Field\n'), ((1015, 1049), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (1020, 1049), False, 'from sqlmodel import Field\n'), ((1081, 1115), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (1086, 1115), False, 'from sqlmodel import Field\n'), ((1143, 1177), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (1148, 1177), False, 'from sqlmodel import Field\n'), ((2022, 2056), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (2027, 2056), False, 'from sqlmodel import Field\n'), ((2078, 2112), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (2083, 2112), False, 'from sqlmodel import Field\n'), ((2144, 2178), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (2149, 2178), False, 'from sqlmodel import Field\n'), ((2203, 2237), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (2208, 2237), False, 'from sqlmodel import Field\n'), ((2271, 2305), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (2276, 2305), False, 'from sqlmodel import Field\n'), ((2329, 2363), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (2334, 2363), False, 'from sqlmodel import Field\n'), ((2390, 2424), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (2395, 2424), False, 'from sqlmodel import Field\n'), ((2452, 2486), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (2457, 2486), False, 'from sqlmodel import Field\n')]