import uuid
from datetime import datetime

from sqlmodel import Field

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


class IssueCredentialBase(BaseModel):
    tenant_id: uuid.UUID = Field(nullable=False)
    wallet_id: uuid.UUID = Field(nullable=False)
    connection_id: uuid.UUID = Field(nullable=False)
    cred_type: str = Field(nullable=False)
    cred_protocol: str = Field(nullable=False)
    cred_def_id: str = Field(nullable=True, default=None)
    credential: str = Field(nullable=False)
    issue_role: str = Field(nullable=False)
    issue_state: str = Field(nullable=False)
    # workflow_id will be null until the tenant kcks it off
    workflow_id: uuid.UUID = Field(nullable=True, default=None)
    cred_exch_id: uuid.UUID = Field(nullable=True, default=None)
    rev_reg_id: str = Field(nullable=True, default=None)
    cred_rev_id: str = Field(nullable=True, default=None)


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


class IssueCredentialCreate(IssueCredentialBase):
    # 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 IssueCredentialRead(IssueCredentialBase):
    # 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 IssueCredentialUpdate(BaseModel):
    # This is our update interface
    # This does NOT inherit from IssueCredentialBase,
    # so no need to worry about accidentally updating id or other fields
    id: uuid.UUID
    issue_state: str = Field(nullable=False)
    workflow_id: uuid.UUID = Field(nullable=True, default=None)
    cred_exch_id: uuid.UUID = Field(nullable=True, default=None)
    rev_reg_id: str = Field(nullable=True, default=None)
    cred_rev_id: str = Field(nullable=True, default=None)

sqlmodel.Field
[((190, 211), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (195, 211), False, 'from sqlmodel import Field\n'), ((239, 260), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (244, 260), False, 'from sqlmodel import Field\n'), ((292, 313), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (297, 313), False, 'from sqlmodel import Field\n'), ((335, 356), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (340, 356), False, 'from sqlmodel import Field\n'), ((382, 403), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (387, 403), False, 'from sqlmodel import Field\n'), ((427, 461), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (432, 461), False, 'from sqlmodel import Field\n'), ((484, 505), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (489, 505), False, 'from sqlmodel import Field\n'), ((528, 549), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (533, 549), False, 'from sqlmodel import Field\n'), ((573, 594), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (578, 594), False, 'from sqlmodel import Field\n'), ((684, 718), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (689, 718), False, 'from sqlmodel import Field\n'), ((749, 783), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (754, 783), False, 'from sqlmodel import Field\n'), ((806, 840), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (811, 840), False, 'from sqlmodel import Field\n'), ((864, 898), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (869, 898), False, 'from sqlmodel import Field\n'), ((1761, 1782), 'sqlmodel.Field', 'Field', ([], {'nullable': '(False)'}), '(nullable=False)\n', (1766, 1782), False, 'from sqlmodel import Field\n'), ((1812, 1846), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (1817, 1846), False, 'from sqlmodel import Field\n'), ((1877, 1911), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (1882, 1911), False, 'from sqlmodel import Field\n'), ((1934, 1968), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (1939, 1968), False, 'from sqlmodel import Field\n'), ((1992, 2026), 'sqlmodel.Field', 'Field', ([], {'nullable': '(True)', 'default': 'None'}), '(nullable=True, default=None)\n', (1997, 2026), False, 'from sqlmodel import Field\n')]