import typing as _typing

from pydantic import Field
import dynamix_sdk.base as _base
from dynamix_sdk.utils import EmptyStr as _EmptyStr
from . import enums as _enums


class AccessAPIResultNM(_base.BaseAPIResultNestedModel):
    explicit: bool
    guid: str | None = None
    access_type: _enums.AccessType
    status: str
    type: str
    user_name: str

    can_be_deleted: None | bool = None
    user_email: str | None = None
    user_emails: list[str] | None = None


class AffinityRuleAPIResultNM(_base.BaseAPIResultNestedModel):
    guid: str
    key: str
    mode: _enums.AffinityMode
    policy: _enums.AffinityPolicy
    topology: _enums.AffinityTopology
    value: str


class QOSAPIResultNM(_base.BaseAPIResultNestedModel):
    egress_rate: int
    guid: str
    ingress_burst: int
    ingress_rate: int


class VMACLAPIResultNM(_base.BaseAPIResultNestedModel):
    account: list[AccessAPIResultNM]
    vm: list[AccessAPIResultNM]
    rg: list[AccessAPIResultNM]


class LibvirtSettingsAPIResultNM(_base.BaseAPIResultNestedModel):
    event_idx: _EmptyStr | _enums.EventIdx
    guid: str
    ioeventfd: _EmptyStr | _enums.Ioeventfd
    queues: int
    rx_queue_size: int
    tx_mode: _EmptyStr | _enums.TXMode
    tx_queue_size: int


class InterfaceForComputeListAPIResultNM(_base.BaseAPIResultNestedModel):
    bus_num: int
    conn_id: int
    conn_type: str
    default_gw: str
    enabled: bool
    flip_group_id: int
    guid: str
    ip_addr: str
    libvirt_settings: LibvirtSettingsAPIResultNM
    listen_ssh: bool
    mac: str
    mtu: int
    name: str
    net_id: int
    net_prefix: int
    net_type: _enums.NetType
    node_id: int
    pci_slot_num: int
    sdn_logical_port_id: str
    security_group_ids: list[int]
    security_group_mode: bool
    target: str
    trunk_vlan_ids: str | None = None
    type: str
    vnf_ids: list[int]


class InterfaceForComputeGetAPIResultNM(_base.BaseAPIResultNestedModel):
    bus_num: int
    conn_id: int
    conn_type: str
    default_gw: str
    security_group_mode: bool
    enabled: bool
    flip_group_id: int
    guid: str
    ip_addr: str
    libvirt_settings: LibvirtSettingsAPIResultNM
    listen_ssh: bool
    mac: str
    mtu: int
    name: str
    net_id: int
    net_prefix: int
    net_type: _enums.NetType
    node_id: int
    pci_slot_num: int
    sdn_logical_port_id: str
    qos: QOSAPIResultNM
    security_group_ids: list[int]
    target: str
    trunk_vlan_ids: str | None = None
    type: str
    vnf_ids: list[int]


class VNFDevInterfaceAPIResultNM(_base.BaseAPIResultNestedModel):
    bus_num: int
    conn_id: int
    conn_type: str
    default_gw: str
    enabled: bool
    flip_group_id: int
    guid: str
    ip_addr: str
    libvirt_settings: LibvirtSettingsAPIResultNM
    listen_ssh: bool
    mac: str
    mtu: int
    name: str
    net_id: int
    net_prefix: int
    net_type: _EmptyStr | _enums.NetType
    node_id: int
    pci_slot_num: int
    qos: QOSAPIResultNM
    sdn_logical_port_id: str
    security_group_ids: list[int]
    security_group_mode: bool
    target: str
    type: str
    vnf_ids: list[int]


class SnapshotSetAPIResultNM(_base.BaseAPIResultNestedModel):
    disk_ids: list[int]
    guid: str
    label: str
    timestamp: int

    @_base.computed_field
    def datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.timestamp)


class IOTuneAPIResultNM(_base.BaseAPIResultNestedModel):
    read_bytes_sec: None | int = None
    read_bytes_sec_max: None | int = None
    read_iops_sec: None | int = None
    read_iops_sec_max: None | int = None
    size_iops_sec: None | int = None
    total_bytes_sec: None | int = None
    total_bytes_sec_max: None | int = None
    total_iops_sec: None | int = None
    total_iops_sec_max: None | int = None
    write_bytes_sec: None | int = None
    write_bytes_sec_max: None | int = None
    write_iops_sec: None | int = None
    write_iops_sec_max: None | int = None


class SnapshotAPIResultNM(_base.BaseAPIResultNestedModel):
    guid: str
    label: str
    reference_id: str
    res_id: str
    snapshot_set_guid: str
    snapshot_set_timestamp: int
    timestamp: int

    @_base.computed_field
    def datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.timestamp)

    @_base.computed_field
    def snapshot_set_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.snapshot_set_timestamp)


class ReplicationAPIResultNM(_base.BaseAPIResultNestedModel):
    disk_id: int
    pool_id: str
    role: str
    self_volume_id: str
    storage_id: str
    volume_id: str


class DiskForCAComputeListAPIResultNM(_base.BaseAPIResultNestedModel):
    id: int
    sep_id: int | None = None


class DiskForCAComputeGetAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    acl: dict
    blkdiscard: bool
    block_size: _enums.DiskBlockSize
    boot_partition: int
    bus_num: int
    cache_mode: _enums.DiskCacheMode
    created_by: str
    created_timestamp: int
    deleted_by: str
    deleted_timestamp: int
    description: str
    destruction_timestamp: int
    device_name: str
    disk_path: str
    grid_id: int
    guid: int
    id: int
    id: int
    image_id: int
    image_ids: list[int]
    independent: bool
    io_tune: IOTuneAPIResultNM
    iqn: str
    login: str
    milestones: int
    name: str
    params: str
    parent_id: int
    password: str
    pci_slot_num: int
    present_to: dict[str, int]
    provision: _enums.DiskProvisionType
    purge_timestamp: int
    reality_device_number: int
    replication: ReplicationAPIResultNM | dict
    res_id: str
    role: str
    sep_id: int
    sep_pool_name: str
    shared: bool
    size_available_gb: float
    size_max_gb: int
    size_used_gb: float
    snapshots: list[SnapshotAPIResultNM]
    status: _enums.DiskStatus
    storage_policy_id: int
    tech_status: _enums.DiskTechStatus
    to_clean: bool
    updated_by: str
    updated_by: str
    updated_timestamp: int = 0

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def destruction_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.destruction_timestamp)

    @_base.computed_field
    def purge_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.purge_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class DiskForListAndListDeletedAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    account_name: str
    acl: dict
    blkdiscard: bool
    block_size: _enums.DiskBlockSize
    cache_mode: _enums.DiskCacheMode
    created_by: str
    created_timestamp: int
    deleted_by: str
    deleted_timestamp: int
    description: str
    destruction_timestamp: int
    device_name: str | None = None
    grid_id: int
    id: int
    image_id: int
    image_ids: list[int]
    independent: bool
    io_tune: IOTuneAPIResultNM
    milestones: int
    name: str
    params: str
    parent_id: int
    present_to: dict[str, int]
    provision: _enums.DiskProvisionType
    purge_timestamp: int
    replication: ReplicationAPIResultNM | dict
    res_id: str
    res_name: str
    role: str
    sep_id: int
    sep_pool_name: str
    sep_type: _enums.SEPType
    shared: bool
    size_available_gb: float
    size_max_gb: int
    size_used_gb: float
    snapshots: list[SnapshotAPIResultNM]
    status: _enums.DiskStatus
    storage_policy_id: int
    tech_status: _enums.DiskTechStatus
    to_clean: bool
    updated_by: str
    vm_id: int | None
    vm_name: str | None
    vms: dict[str, str]
    updated_timestamp: int = 0

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def destruction_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.destruction_timestamp)

    @_base.computed_field
    def purge_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.purge_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class DiskForListUnattachedAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    account_name: str
    acl: dict
    blkdiscard: bool
    boot_partition: int
    block_size: _enums.DiskBlockSize
    created_timestamp: int
    deleted_timestamp: int
    description: str
    destruction_timestamp: int
    disk_path: str
    cache_mode: _enums.DiskCacheMode
    grid_id: int
    guid: int
    independent: bool
    id: int
    image_id: int
    image_ids: list[int]
    io_tune: IOTuneAPIResultNM
    iqn: str
    login: str
    milestones: int
    name: str
    params: str
    parent_id: int
    password: str
    present_to: dict[str, int]
    provision: _enums.DiskProvisionType
    purge_attempt_count: int
    purge_timestamp: int
    reality_device_number: int
    reference_id: str
    replication: ReplicationAPIResultNM | dict
    res_id: str
    res_name: str
    role: str
    sep_id: int
    sep_pool_name: str
    shared: bool
    size_available_gb: float
    size_max_gb: int
    size_used_gb: float
    snapshots: list[SnapshotAPIResultNM]
    status: _enums.DiskStatus
    storage_policy_id: int
    tech_status: _enums.DiskTechStatus
    to_clean: bool
    updated_timestamp: int = 0

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def destruction_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.destruction_timestamp)

    @_base.computed_field
    def purge_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.purge_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class StoragePolicyQuotasAPIResultNM(_base.BaseAPIResultNestedModel):
    id: int
    storage_size_gb: int


class TenantQuotasAPIResultNM(_base.BaseAPIResultNestedModel):
    cpu_count: int
    disk_size_gb: int
    gpu_count: int
    ext_ip_count: int
    ram_size_mb: float | int
    storage_size_gb: int
    storage_policies: list[StoragePolicyQuotasAPIResultNM]


class ResourceGroupAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    account_name: str
    acl: list[AccessAPIResultNM]
    vm_features: list[_enums.VMFeature]
    cpu_allocation_parameter: str
    cpu_allocation_ratio: int
    created_by: str
    created_timestamp: int
    default_net_id: int
    default_net_type: _enums.RGDefaultNetType
    deleted_by: str
    deleted_timestamp: int
    description: str
    grid_id: int
    guid: int
    id: int
    lock_status: _enums.LockStatus
    milestones: int
    name: str
    quotas: TenantQuotasAPIResultNM
    resource_types: list[_enums.RGResourceType]
    sdn_access_group_id: str
    secret: str
    status: _enums.ResourceGroupStatus
    storage_policy_ids: list[int]
    sep_pools: list[str]
    updated_by: str
    updated_timestamp: int
    vins_ids: list[int]
    vm_ids: list[int]

    dirty: bool | None = None

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class AccountForCAAPIResultNM(_base.BaseAPIResultNestedModel):
    acl: list[AccessAPIResultNM]
    created_timestamp: int
    deleted_by: str
    deleted_timestamp: int
    description: str
    id: int
    name: str
    status: _enums.AccountStatus
    updated_by: str
    updated_timestamp: int
    vm_features: list[_enums.VMFeature]
    zone_ids: list[int]

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class GuestAgentAPIResultNM(_base.BaseAPIResultNestedModel):
    enabled: bool
    available_commands: list[str]
    guid: str | None = None
    last_update_timestamp: int
    user_name: str

    @_base.computed_field
    def last_update_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.last_update_timestamp)


class VGPUAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    bus_num: int
    created_timestamp: int
    deleted_timestamp: int
    grid_id: int
    guid: int
    id: int
    last_claimed_by: int
    last_update_timestamp: int
    pci_slot_num: int
    pgpu_id: int
    pgpu_mode: _enums.PGPUMode
    pgpu_processor_type: _enums.PGPUProcessorType
    profile_id: int | None
    ram_size_mb: int
    reference_id: str
    rg_id: int
    status: _enums.VGPUStatus
    vm_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def last_update_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.last_update_timestamp)


class VMAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    account_name: str
    acl: list[_typing.Any]  # BDX-7995
    affinity_label: str
    affinity_rules: list[AffinityRuleAPIResultNM]
    affinity_weight: int
    anti_affinity_rules: list[AffinityRuleAPIResultNM]
    arch: str
    auto_start: bool
    boot_disk_size_gb: int
    boot_image_id: int
    boot_loader_type: _enums.BootLoaderType
    boot_mode: _enums.BootMode
    boot_order: list[_enums.BootDevice]
    cdrom_image_id: int
    chipset: _enums.Chipset
    clone_ids: list[int]
    clone_reference: int
    cpu_count: int
    cpu_pin: bool
    created_by: str
    created_timestamp: int
    custom_fields: dict
    deleted_by: str
    deleted_timestamp: int
    description: str
    pci_devices: dict[str, int]
    disks: list[DiskForCAComputeListAPIResultNM]
    driver: _enums.Driver
    grid_id: int
    guid: int
    hot_resize: bool
    hp_backed: bool
    id: int
    interfaces: list[InterfaceForComputeListAPIResultNM]
    live_migration_job_id: int
    lock_status: _enums.LockStatus
    manager_id: int
    manager_type: str
    migration_job_id: int
    milestones: int
    name: str
    need_reboot: bool
    network_interface_naming: _enums.NetIfaceNamingTemplate
    numa_affinity: _enums.NumaAffinity
    numa_node_id: int
    os_version: str
    pinned_to_node: bool
    preferred_cpu_cores: list[int]
    ram_size_mb: int
    read_only: bool
    reference_id: str
    res_name: str
    reserved_cpu_cores: list[int]
    rg_id: int
    rg_name: str
    snapshot_sets: list[SnapshotSetAPIResultNM]
    stateless_sep_id: int | None = None
    stateless_sep_type: str | None = None
    status: _enums.VMStatus
    tags: dict
    tech_status: _enums.VMTechStatus
    total_disks_size_gb: int
    updated_by: str
    updated_timestamp: int
    user_managed: bool
    vgpu_ids: list[int]
    vins_count: int
    vm_ci_id: int
    guest_agent: GuestAgentAPIResultNM
    weight: int
    zone_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class VMCountsAPIResultNM(_base.BaseAPIResultNestedModel):
    started: int
    stopped: int


class ImageForListAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    boot_mode: _enums.BootMode | _EmptyStr | None
    bootable: bool
    cdrom: bool
    description: str
    drivers: list[_enums.Driver]
    hot_resize: bool
    id: int
    link_to: int
    name: str
    network_interface_naming: _enums.NetIfaceNamingTemplate
    os_user_name: str | None
    sep_id: int
    sep_pool_name: str
    size_gb: int
    status: _enums.ImageStatus
    storage_policy_id: int
    type: _enums.ImageType
    virtual: bool | None = None

    @_base.computed_field
    def boot_loader_type(self) -> _enums.BootLoaderType | None:
        if self.type in _enums.BootLoaderType._member_names_:
            return _enums.BootLoaderType[self.type]


class ImageHistoryRecordAPIResultNM(_base.BaseAPIResultNestedModel):
    guid: str
    id: int
    timestamp: int

    @_base.computed_field
    def datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.timestamp)


class VINSVMAPIResultNM(_base.BaseAPIResultNestedModel):
    id: int
    name: str


class VINSForListAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    account_name: str
    created_by: str
    created_timestamp: int
    deleted_by: str
    deleted_timestamp: int
    ext_net_id: int
    ext_net_ip: str
    free_ip_count: int
    id: int
    name: str
    net_ip: str
    rg_id: int
    rg_name: str
    status: _enums.VINSStatus
    updated_by: str
    updated_timestamp: int
    vxlan_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class VINSForListDeletedAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    account_name: str
    created_by: str
    created_timestamp: int
    deleted_by: str
    deleted_timestamp: int
    ext_net_ip: str
    id: int
    name: str
    net_ip: str
    primary_vnfdev_id: int
    rg_id: int
    rg_name: str
    status: _enums.VINSStatus
    updated_by: str
    updated_timestamp: int
    vxlan_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class VNFHostDeviceAPIResultNM(_base.BaseAPIResultNestedModel):
    device_id: int
    iface01_name: str
    iface02_name: str


class VNFHostDevicesAPIResultNM(_base.BaseAPIResultNestedModel):
    primary: VNFHostDeviceAPIResultNM
    secondary: VNFHostDeviceAPIResultNM | None = None


class RouteAPIResultNM(_base.BaseAPIResultNestedModel):
    dst_net_ip: str
    dst_net_mask: str
    gateway: str
    guid: str
    id: int
    vm_ids: list[int]


class DHCPReservationAPIResultNM(_base.BaseAPIResultNestedModel):
    ip_addr: str
    mac: str
    type: _enums.DHCPReservationType
    vm_id: int

    account_id: None | int = None
    client_type: None | str = None
    description: None | str = None
    domain_name: None | str = None
    hostname: None | str = None


class DHCPVNFConfigAPIResultNM(_base.BaseAPIResultNestedModel):
    default_gw: str
    dns_servers: list[str]
    ip_pool_end: str
    ip_pool_start: str
    lease_time: int
    net_ip: str
    net_prefix: int
    reservations: list[DHCPReservationAPIResultNM]


class GWVNFConfigAPIResultNM(_base.BaseAPIResultNestedModel):
    default_gw: str
    ext_net_id: int
    ext_net_ip: str
    ext_net_prefix: int
    qos: _typing.Any


class NATRuleAPIResultNM(_base.BaseAPIResultNestedModel):
    id: int
    local_ip: str
    local_port: int
    protocol: _enums.NATRuleProtocol
    public_port_end: int
    public_port_start: int
    vm_id: int

    vm_name: None | str = None


class NATVNFConfigAPIResultNM(_base.BaseAPIResultNestedModel):
    net_ip: str
    net_prefix: int
    rules: list[NATRuleAPIResultNM]


class DHCPVNFAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    config: DHCPVNFConfigAPIResultNM
    created_timestamp: int
    devices: VNFHostDevicesAPIResultNM
    grid_id: int
    guid: int
    id: int
    lock_status: _enums.LockStatus
    milestones: int
    owner_id: int
    owner_type: _enums.NetType
    pure_virtual: bool
    routes: list[RouteAPIResultNM]
    status: _enums.VNFStatus
    tech_status: _enums.VNFTechStatus
    type: _enums.VNFType
    zone_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)


class GWVNFAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    config: GWVNFConfigAPIResultNM
    created_timestamp: int
    devices: VNFHostDevicesAPIResultNM
    grid_id: int
    guid: int
    id: int
    lock_status: _enums.LockStatus
    milestones: int
    owner_id: int
    owner_type: _enums.NetType
    pure_virtual: bool
    routes: list[RouteAPIResultNM]
    status: _enums.VNFStatus
    tech_status: _enums.VNFTechStatus
    type: _enums.VNFType
    zone_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)


class NATVNFAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    config: NATVNFConfigAPIResultNM
    created_timestamp: int
    devices: VNFHostDevicesAPIResultNM
    grid_id: int
    guid: int
    id: int
    lock_status: _enums.LockStatus
    milestones: int
    owner_id: int
    owner_type: _enums.NetType
    pure_virtual: bool
    routes: list[RouteAPIResultNM]
    status: _enums.VNFStatus
    tech_status: _enums.VNFTechStatus
    type: _enums.VNFType
    zone_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)


class VNFSAPIResultNM(_base.BaseAPIResultNestedModel):
    dhcp: None | DHCPVNFAPIResultNM = None
    gw: None | GWVNFAPIResultNM = None
    nat: None | NATVNFAPIResultNM = None


class VNFDevMGMTConfigAPIResultNM(_base.BaseAPIResultNestedModel):
    ip_addr: str
    password: str
    ssh_public_key: str
    user_name: str


class VNFDevResourcesConfigAPIResultNM(_base.BaseAPIResultNestedModel):
    cpu_count: int
    ram_size_mb: int
    node_id: int | None
    uuid: str


class VNFDevConfigAPIResultNM(_base.BaseAPIResultNestedModel):
    mgmt: VNFDevMGMTConfigAPIResultNM
    resources: VNFDevResourcesConfigAPIResultNM


class VNFDevAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    capabilities: list[_enums.VNFType]
    config: VNFDevConfigAPIResultNM
    config_saved: bool
    custom_pre_cfg: bool
    description: str
    grid_id: int
    guid: int
    id: int
    interfaces: list[VNFDevInterfaceAPIResultNM]
    live_migration_job_id: int
    lock_status: _enums.LockStatus
    milestones: int
    name: str
    status: _enums.VNFDevStatus
    tech_status: _enums.VNFDevTechStatus
    type: _enums.VNFDevType
    vins_ids: list[int]
    vnc_password: str
    zone_id: int


class BServiceGroupAPIResultNM(_base.BaseAPIResultNestedModel):
    id: int
    name: str
    status: _enums.BServiceGroupStatus
    tech_status: _enums.BServiceGroupTechStatus
    consistency: bool
    vm_count: int


class BServiceVMAPIResultNM(_base.BaseAPIResultNestedModel):
    id: int
    name: str
    bsgroup_id: int
    arch: str
    account_id: int
    rg_id: int
    status: _enums.VMStatus
    tech_status: _enums.VMTechStatus
    node_id: int | None
    bsgroup_name: str
    bsgroup_role: str


class BServiceSnapshotAPIResultNM(_base.BaseAPIResultNestedModel):
    timestamp: int
    label: str
    valid: bool
    guid: str

    @_base.computed_field
    def datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.timestamp)


class BServiceAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    account_name: str
    base_domain: str
    created_by: str
    created_timestamp: int
    deleted_by: str
    deleted_timestamp: int
    grid_id: int
    group_ids: list[int]
    guid: int
    id: int
    name: str
    parent_service_id: int
    parent_service_type: str
    rg_id: int
    rg_name: str
    ssh_user_name: str
    status: _enums.BServiceStatus
    tech_status: _enums.BServiceTechStatus
    updated_by: str
    updated_timestamp: int
    user_managed: bool
    zone_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class BServiceGroupOSUserAPIResultNM(_base.BaseAPIResultNestedModel):
    login: str
    password: str


class OSUserAPIResultNM(_base.BaseAPIResultNestedModel):
    guid: str
    login: str
    password: str
    ssh_public_key: str


class BServiceGroupVMAPIResultNM(_base.BaseAPIResultNestedModel):
    chipset: _enums.Chipset
    id: int
    name: str
    os_users: list[BServiceGroupOSUserAPIResultNM]
    ip_addresses: list[str]


class ExtNetForListAPIResultNM(_base.BaseAPIResultNestedModel):
    id: int
    ip_cidr: str
    name: str
    status: _enums.ExtNetStatus


class FlipGroupForListAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    client_ids: list[int]
    client_type: _enums.FlipGroupClientType
    conn_id: int
    conn_type: str
    default_gw: str
    description: str
    grid_id: int
    guid: int
    id: int
    ip_addr: str
    milestones: int
    name: str
    net_id: int
    net_prefix: int
    net_type: _enums.FlipGroupNetType
    status: _enums.FlipGroupStatus


class LBNodeAPIResultNM(_base.BaseAPIResultNestedModel):
    backend_ip_addr: str
    frontend_ip_addr: str
    guid: str
    mgmt_ip: str
    net_id: int
    vm_id: int


class LBServerSettingsAPIResultNM(_base.BaseAPIResultNestedModel):
    downinter: int
    fall: int
    guid: str
    inter: int
    maxconn: int
    maxqueue: int
    rise: int
    slowstart: int
    weight: int


class LBServerAPIResultNM(_base.BaseAPIResultNestedModel):
    check: _enums.LBServerCheck
    guid: str
    ip_addr: str
    name: str
    port: int
    server_settings: LBServerSettingsAPIResultNM


class LBBackendAPIResultNM(_base.BaseAPIResultNestedModel):
    algorithm: _enums.LBBackendAlgorithm
    guid: str
    name: str
    server_default_settings: LBServerSettingsAPIResultNM
    servers: list[LBServerAPIResultNM]


class LBFrontendBindingAPIResultNM(_base.BaseAPIResultNestedModel):
    name: str
    ip_addr: str
    port: int
    guid: str


class LBFrontendAPIResultNM(_base.BaseAPIResultNestedModel):
    name: str
    backend_name: str
    bindings: list[LBFrontendBindingAPIResultNM]
    guid: str


class LBAPIResultNM(_base.BaseAPIResultNestedModel):
    acl: list[_typing.Any]
    backend_ha_ip_addr: str
    backends: list[LBBackendAPIResultNM]
    created_by: str
    created_timestamp: int
    deleted_by: str
    deleted_timestamp: int
    description: str
    dp_api_user: str
    ext_net_id: int
    frontend_ha_ip_addr: str
    frontends: list[LBFrontendAPIResultNM]
    grid_id: int
    guid: int
    ha_mode: bool
    id: int
    manager_id: int
    manager_type: str
    milestones: int
    name: str
    part_of_k8s: bool
    primary_node: LBNodeAPIResultNM
    rg_id: int
    rg_name: str
    secondary_node: LBNodeAPIResultNM
    status: _enums.LBStatus
    sysctl_params: dict[str, str]
    tech_status: _enums.LBTechStatus
    updated_by: str
    updated_timestamp: int
    user_managed: bool
    vins_id: int
    zone_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class SEPPoolAPIResultNM(_base.BaseAPIResultNestedModel):
    name: str
    types: list[_enums.PoolDiskType]
    system: str | bool


class LocationAPIResultNM(_base.BaseAPIResultNestedModel):
    auth_broker: list[_enums.AuthBroker]
    flag: str
    grid_id: int
    guid: int
    id: int
    location_code: str
    name: str
    network_modes: list[str]
    sdn_support: bool
    zero_access_enabled: bool
    bro_enabled: bool


class AffinityRelationsAPIResultNM(_base.BaseAPIResultNestedModel):
    same_node: list[int]
    same_node_soft: list[int]
    other_node: list[int]
    other_node_soft: list[int]
    other_node_indirect: list[int]
    other_node_indirect_soft: list[int]


class TaskAPIResultNM(_base.BaseAPIResultNestedModel):
    audit_guid: str
    completed: bool
    created_timestamp: int
    error: str
    log: list[str]
    result: _typing.Any
    stage: str
    status: _enums.TaskStatus
    updated_by: None | str = None
    updated_timestamp: None | int = None

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        if self.updated_timestamp is None:
            return None
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class K8CIForListAPIResultNM(_base.BaseAPIResultNestedModel):
    created_timestamp: int
    description: str
    id: int
    name: str
    network_plugins: list[_enums.K8sNetworkPlugin]
    status: _enums.K8CIStatus
    version: str

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)


class ZoneAPIResultNM(_base.BaseAPIResultNestedModel):
    id: int
    name: str


class NetworkIDsAPIResultNM(_base.BaseAPIResultNestedModel):
    primary: int
    secondary: int


class K8sVMAPIResultNM(_base.BaseAPIResultNestedModel):
    ext_ip: str | None = None
    id: int
    name: str
    status: _enums.VMStatus
    tech_status: _enums.VMTechStatus


class WorkerGroupAPIResultNM(_base.BaseAPIResultNestedModel):
    id: int
    guid: str
    labels: list[str]
    taints: list[str]
    annotations: list[str]


class K8sNodeGroupAPIResultNM(_base.BaseAPIResultNestedModel):
    vms: list[K8sVMAPIResultNM]
    id: int
    node_count: int
    node_cpu_count: int
    node_ram_size_mb: int
    node_boot_disk_size_gb: int
    name: str
    labels: list[str] | None = None
    taints: list[str] | None = None
    annotations: list[str] | None = None


class K8sNodeGroupsAPIResultNM(_base.BaseAPIResultNestedModel):
    master: K8sNodeGroupAPIResultNM | dict = Field(union_mode="left_to_right")
    worker: list[K8sNodeGroupAPIResultNM]


class K8sACLAPIResultNM(_base.BaseAPIResultNestedModel):
    account: list[AccessAPIResultNM]
    k8s: list[AccessAPIResultNM]
    rg: list[AccessAPIResultNM]


class LBHAIPsAPIResultNM(_base.BaseAPIResultNestedModel):
    backend: str
    frontend: str


class K8sServiceAccountAPIResultNM(_base.BaseAPIResultNestedModel):
    guid: str
    password: str
    user_name: str


class K8sAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    account_name: str
    acl: list[_typing.Any]
    bservice_id: int
    k8ci_id: int
    config: dict
    created_by: str
    created_timestamp: int
    deleted_by: str
    deleted_timestamp: int
    description: str
    ext_net_id: int
    grid_id: int
    guid: int
    id: int
    lb_id: int
    milestones: int
    name: str
    network_plugin: _enums.K8sNetworkPlugin
    rg_id: int
    rg_name: str
    service_account: K8sServiceAccountAPIResultNM
    status: _enums.K8sStatus
    tech_status: _enums.K8sTechStatus
    updated_by: str
    updated_timestamp: int
    vins_id: int
    worker_groups: list[WorkerGroupAPIResultNM]
    zone_id: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class DPDKNetAPIResultNM(_base.BaseAPIResultNestedModel):
    account_ids: list[int]
    created_timestamp: int
    description: str
    grid_id: int
    guid: int
    id: int
    name: str
    ovs_bridge: str
    rg_ids: list[int]
    security_group_mode: bool
    status: _enums.DPDKNetStatus
    updated_timestamp: int
    vlan_id: int
    vm_ids: list[int]

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class VirtualFunctionAPIResultNM(_base.BaseAPIResultNestedModel):
    guid: str
    id: int
    vm_id: int
    claimed: bool


class VFPoolNodeInterfaceAPIResultNM(_base.BaseAPIResultNestedModel):
    guid: str
    name: str
    vfs: list[VirtualFunctionAPIResultNM]


class VFPoolNodeAPIResultNM(_base.BaseAPIResultNestedModel):
    guid: str
    id: int
    interfaces: list[VFPoolNodeInterfaceAPIResultNM]


class VFPoolAPIResultNM(_base.BaseAPIResultNestedModel):
    account_ids: list[int]
    created_timestamp: int
    description: str
    grid_id: int
    guid: int
    id: int
    name: str
    rg_ids: list[int]
    status: _enums.VFPoolStatus
    updated_timestamp: int
    nodes: list[VFPoolNodeAPIResultNM]

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class ZoneForListAPIResultNM(_base.BaseAPIResultNestedModel):
    created_timestamp: int
    deletable: bool
    description: str
    drs_broadcast_ip_addr: str
    drs_bvs_domain: str
    drs_dx_app_id: str
    drs_dx_ssl_skip_verify: bool
    drs_dx_sso_type: _enums.DRSDXSSOType
    drs_dx_sso_url: str
    drs_dx_url: str
    drs_name: str
    drs_uid: str
    drs: bool
    grid_id: int
    guid: int
    id: int
    name: str
    node_auto_start: bool
    node_ids: list[int]
    drs_ping_ip_addr: str
    status: _enums.ZoneStatus
    updated_timestamp: int

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class SecurityGroupRuleAPIResultNM(_base.BaseAPIResultNestedModel):
    ethertype: _enums.SGRuleEthertype
    id: int
    port_range_max: int | None
    port_range_min: int | None
    protocol: _enums.SGRuleProtocol | None
    remote_group_id: int | None = None
    remote_net_cidr: str | None
    traffic_direction: _enums.TrafficDirection


class TrunkAPIResultNM(_base.BaseAPIResultNestedModel):
    account_ids: list[int] | None
    created_by: str
    created_timestamp: int
    deleted_by: str | None
    deleted_timestamp: int | None
    description: str
    guid: int
    id: int
    mac: str
    mtu: int
    name: str
    native_vlan_id: int | None
    ovs_bridge: str
    status: _enums.TrunkStatus
    updated_by: str | None
    updated_timestamp: int | None
    vlan_ids: str

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        if self.deleted_timestamp is None:
            return None
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        if self.updated_timestamp is None:
            return None
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class SEPPoolsAPIResultNM(_base.BaseAPIResultNestedModel):
    pool_names: list[str]
    sep_id: int
    sep_name: str | None = None
    sep_tech_status: _enums.SEPTechStatus


class TenantIDsAPIResultNM(_base.BaseAPIResultNestedModel):
    account_ids: list[int]
    rg_ids: list[int]


class StoragePolicyAPIResultNM(_base.BaseAPIResultNestedModel):
    sep_pools: list[SEPPoolsAPIResultNM]
    description: str
    guid: int
    id: int
    iops_limit: int
    name: str
    status: _enums.StoragePolicyStatus
    usage: TenantIDsAPIResultNM


class VINSExtNetAPIResultNM(_base.BaseAPIResultNestedModel):
    default_gw: str
    id: int
    ip_addr: str
    net_prefix: int
    status: _enums.ExtNetStatus
    tech_status: _enums.VNFDevTechStatus


class SecurityGroupAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int
    created_by: str
    created_timestamp: int
    description: str
    id: int
    name: str
    rules: list[SecurityGroupRuleAPIResultNM]
    updated_by: str | None
    updated_timestamp: int | None

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        if self.updated_timestamp is None:
            return None
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class BootLoaderMetaisoAPIResultNM(_base.BaseAPIResultNestedModel):
    device_name: str
    path: str


class MigrateStorageJobAPIResultNM(_base.BaseAPIResultNestedModel):
    completed: bool
    domain_name: str
    id: int
    log: list[str]
    source_node_id: int
    status: _enums.JobStatus
    target_node_id: int


class AuditAPIResultNM(_base.BaseAPIResultNestedModel):
    account_id: int | None = None
    api_url_path: str
    async_request_task_id: str | None = None
    args: str
    bservice_id: int | None = None
    client_ip_addr: str
    correlation_id: str
    execution_time_sec: float | None
    flip_group_id: int | None = None
    guid: str
    k8s_id: int | None = None
    kwargs: str
    lb_id: int | None = None
    node_ids: list[int] | None = None
    request_datetime_iso8601: str
    request_timestamp: float
    response_timestamp: float | None
    result: str | None
    rg_id: int | None = None
    sep_id: int | None = None
    status_code: int | None
    user_name: str
    vins_id: int | None = None
    vm_id: int | None = None

    @_base.computed_field
    def request_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.request_timestamp)

    @_base.computed_field
    def response_datetime(self) -> _base.datetime | None:
        if self.response_timestamp is None:
            return None
        return self._get_datetime_from_timestamp(self.response_timestamp)


class UserAPIResultNM(_base.BaseAPIResultNestedModel):
    active: bool
    api_access_groups: dict[str, str]
    auth_key: str
    auth_keys: list[_typing.Any]
    blocked: bool | None = None
    data: str
    description: str
    domain_name: str | None
    emails: list[str]
    grid_id: int
    groups: list[str]
    guid: str
    id: str
    last_check_timestamp: int
    mobile: list[_typing.Any]
    password: str
    protected: bool | None = None
    roles: list[_typing.Any]
    service_account: bool
    xmpp: list[_typing.Any]

    @_base.computed_field
    def last_check_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.last_check_timestamp)


class StorageCountersAPIResultNM(_base.BaseAPIResultNestedModel):
    storage_size_gb_by_real_usage: float
    storage_size_gb_by_disk_max: float


class StoragePolicyCountersAPIResultNM(_base.BaseAPIResultNestedModel):
    storage_size_gb_by_real_usage: float
    storage_size_gb_by_disk_max: float
    sep_pools: dict[str, dict[str, StorageCountersAPIResultNM]]
    storage_size_quota_gb: int | None = None


class ResourceCountersAPIResultNM(_base.BaseAPIResultNestedModel):
    cpu_count: int
    ram_size_mb: int
    storage_size_gb_by_real_usage: int | float
    storage_size_gb_by_disk_max: int
    ext_ip_count: int
    gpu_count: int
    sep_pools: dict[str, dict[str, StorageCountersAPIResultNM]]
    storage_policies: dict[str, StoragePolicyCountersAPIResultNM]


class TenantQuotasForResourceConsumptionAPIResultNM(
    _base.BaseAPIResultNestedModel,
):
    cpu_count: int
    disk_size_gb: int
    gpu_count: int
    ext_ip_count: int
    ram_size_mb: float | int
    storage_size_gb: int


class PCIDeviceAPIResultNM(_base.BaseAPIResultNestedModel):
    vm_id: int
    description: str
    guid: int
    hw_path: str
    id: int
    name: str
    rg_id: int
    node_id: int
    status: _enums.PCIDeviceStatus
    system_name: str


class AvailableSEPPoolsAPIResultNM(_base.BaseAPIResultNestedModel):
    sep_id: int
    sep_name: str
    sep_type: _enums.SEPType
    pools: list[SEPPoolAPIResultNM]


class ResourceGroupForListDeletedAPIResultNM(_base.BaseAPIResultNestedModel):
    account_acl: AccessAPIResultNM
    account_id: int
    account_name: str
    acl: list[AccessAPIResultNM]
    vm_features: list[_enums.VMFeature]
    cpu_allocation_parameter: str
    cpu_allocation_ratio: int
    created_by: str
    created_timestamp: int
    default_net_id: int
    default_net_type: _enums.RGDefaultNetType
    deleted_by: str
    deleted_timestamp: int
    description: str
    grid_id: int
    guid: int
    id: int
    lock_status: _enums.LockStatus
    milestones: int
    name: str
    quotas: TenantQuotasAPIResultNM
    resource_types: list[_enums.RGResourceType]
    sdn_access_group_id: str
    secret: str
    status: _enums.ResourceGroupStatus
    storage_policy_ids: list[int]
    sep_pools: list[str]
    updated_by: str
    updated_timestamp: int
    vins_ids: list[int]
    vm_ids: list[int]

    dirty: bool | None = None

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)


class TenantStatusCountersAPIResultNM(_base.BaseAPIResultNestedModel):
    disabled: int
    enabled: int


class VMStatusCountersAPIResultNM(_base.BaseAPIResultNestedModel):
    started: int
    stopped: int


class AccountForCBAPIResultNM(_base.BaseAPIResultNestedModel):
    acc_lvl_vins_ids: list[int]
    acl: list[AccessAPIResultNM]
    company_url: str
    company: str
    cpu_allocation_parameter: str
    cpu_allocation_ratio: int
    created_by: str
    created_timestamp: int
    dc_location: str
    deactivation_timestamp: int
    default_zone_id: int
    deleted_by: str
    deleted_timestamp: int
    description: str
    display_name: str
    guid: int
    id: int
    name: str
    quotas: TenantQuotasAPIResultNM
    resource_types: list[_enums.AccountResourceType]
    send_access_emails: bool
    status: _enums.AccountStatus
    storage_policy_ids: list[int]
    sep_pools: list[str]
    updated_by: str
    updated_timestamp: int
    version: int
    vm_features: list[_enums.VMFeature]
    zone_ids: list[int]
    zones: list[int]

    @_base.computed_field
    def created_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.created_timestamp)

    @_base.computed_field
    def deleted_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.deleted_timestamp)

    @_base.computed_field
    def updated_datetime(self) -> _base.datetime | None:
        return self._get_datetime_from_timestamp(self.updated_timestamp)
