import datetime
from typing import Any

import msgspec


class GraphQLInput(msgspec.Struct):
    query: str
    variables: dict[str, Any]
    operation_name: str = msgspec.field(name="operationName")


class NetboxStruct(msgspec.Struct):
    id: int | str
    created: datetime.datetime | None
    last_updated: datetime.datetime | None
    description: str
    comments: str
    url: str


class NamedNetboxAsset(msgspec.Struct):
    name: str


class NetboxIPAddress(NetboxStruct, tag="NetboxIPSearchResult", tag_field="kind"):
    address: str
    tenant: NamedNetboxAsset | None
    dns_name: str


class NetboxPrefix(NetboxStruct, tag="NetboxPrefixSearchResult", tag_field="kind"):
    prefix: str
    tenant: NamedNetboxAsset | None


class NetboxTenant(NetboxStruct, tag="NetboxTenantSearchResult", tag_field="kind"):
    name: str
    group: NamedNetboxAsset | None
