# generated by fastapi-codegen:
#   filename:  /Users/apuvvadi/Workspace/guardicore-SO-contracts/contracts/guardicore/connector
#   timestamp: 2026-04-01T10:27:26+00:00

from __future__ import annotations

from typing import List, Optional

from pydantic import BaseModel, ConfigDict, Field, RootModel

from centra_sdk.utils.gc_serializer import GcSerializer

from ..common.inventory import SwitchInventoryItem


class Switches(RootModel[List[SwitchInventoryItem]]):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    root: List[SwitchInventoryItem] = Field(
        ..., description='List of switches for pagination compatibility'
    )

    def __getattr__(self, attr: str):
        return getattr(self.root, attr)

    def __iter__(self):
        for item in self.root:
            yield item


class SwitchesConfig(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    items: Switches = Field(..., description='Array of switch configuration items')
    prevCursor: Optional[int] = Field(0, description='Previous cursor position')
    status: Optional[int] = Field(200, description='HTTP status code')
    total_count: Optional[int] = Field(None, description='Total count of switch items')
