# generated by fastapi-codegen:
#   filename:  connector
#   timestamp: 2025-08-06T07:59:35+00:00

from __future__ import annotations

from abc import ABC, abstractmethod

from fastapi import APIRouter, HTTPException

from ..dependencies import *
from ..handler_registry import call_handler

router = APIRouter(tags=['Inventory'])


class InventoryHandler(ABC):
    def __init__(self):
        pass

    @abstractmethod
    def get_labels(
        self,
        cursor: Optional[conint(ge=0)] = 0,
        page_size: Optional[conint(ge=1, le=1000)] = 100,
    ) -> Labels:
        """This method should be implemented by the subclass."""
        raise HTTPException(status_code=404, detail=f"get_labels not implemented")

    @abstractmethod
    def get_inventory(
        self,
        cursor: Optional[conint(ge=0)] = 0,
        page_size: Optional[conint(ge=1, le=1000)] = 100,
    ) -> Inventory:
        """This method should be implemented by the subclass."""
        raise HTTPException(status_code=404, detail=f"get_inventory not implemented")

    @abstractmethod
    def push_inventory_of_type(
        self,
        id: str,
        asset_type: InventoryAssetType = ...,
        revision: int = ...,
        reporter: Optional[InventoryReporterType] = None,
        body: Inventory = ...,
    ) -> V1ProviderInventoryIdAssetsAssetTypePostResponse:
        """This method should be implemented by the subclass."""
        raise HTTPException(
            status_code=404, detail=f"push_inventory_of_type not implemented"
        )

    @abstractmethod
    def get_asset_id(self, body: LookupRequest) -> InventoryItem:
        """This method should be implemented by the subclass."""
        raise HTTPException(status_code=404, detail=f"get_asset_id not implemented")

    @abstractmethod
    def get_network_topology(
        self,
        cursor: Optional[conint(ge=0)] = 0,
        page_size: Optional[conint(ge=1, le=1000)] = 100,
    ) -> NetworkTopology:
        """This method should be implemented by the subclass."""
        raise HTTPException(
            status_code=404, detail=f"get_network_topology not implemented"
        )


@router.get('/v1/provider/import-labels', response_model=Labels, tags=['Inventory'])
def get_labels(
    cursor: Optional[conint(ge=0)] = 0, page_size: Optional[conint(ge=1, le=1000)] = 100
) -> Labels:
    """
    Get connector environment labels (with pagination)
    """
    return call_handler('Inventory', get_labels.__name__, cursor, page_size)


@router.get('/v1/provider/inventory', response_model=Inventory, tags=['Inventory'])
def get_inventory(
    cursor: Optional[conint(ge=0)] = 0, page_size: Optional[conint(ge=1, le=1000)] = 100
) -> Inventory:
    """
    Retrieve the entire inventory
    """
    return call_handler('Inventory', get_inventory.__name__, cursor, page_size)


@router.post(
    '/v1/provider/inventory/{id}/assets/{asset_type}',
    response_model=V1ProviderInventoryIdAssetsAssetTypePostResponse,
    responses={'412': {'model': V1ProviderInventoryIdAssetsAssetTypePostResponse1}},
    tags=['Inventory'],
)
def push_inventory_of_type(
    id: str,
    asset_type: InventoryAssetType = ...,
    revision: int = ...,
    reporter: Optional[InventoryReporterType] = None,
    body: Inventory = ...,
) -> Union[
    V1ProviderInventoryIdAssetsAssetTypePostResponse,
    V1ProviderInventoryIdAssetsAssetTypePostResponse1,
]:
    """
    Report inventory for assets of type 'aset-type'
    """
    return call_handler(
        'Inventory',
        push_inventory_of_type.__name__,
        id,
        asset_type,
        revision,
        reporter,
        body,
    )


@router.post('/v1/provider/lookup', response_model=InventoryItem, tags=['Inventory'])
def get_asset_id(body: LookupRequest) -> InventoryItem:
    """
    Retrieve the asset id of the destination side.
    """
    return call_handler('Inventory', get_asset_id.__name__, body)


@router.get('/v1/provider/topology', response_model=NetworkTopology, tags=['Inventory'])
def get_network_topology(
    cursor: Optional[conint(ge=0)] = 0, page_size: Optional[conint(ge=1, le=1000)] = 100
) -> NetworkTopology:
    """
    Retrieve network topology information
    """
    return call_handler('Inventory', get_network_topology.__name__, cursor, page_size)
