# @generated
# This file was automatically generated by the ncae-sdk code generator.
# DO NOT EDIT MANUALLY, ANY CHANGES WILL BE OVERWRITTEN.

from collections.abc import Iterator
from typing import Final, Optional

from typing_extensions import Unpack

from ncae_sdk._resource import ResourceId
from ncae_sdk._sync.endpoint import Endpoint
from ncae_sdk._util import map_sync
from ncae_sdk.resources._schema import (
    DeviceModel,
    DeviceModelFilter,
    DeviceModelFilterModel,
)


class DeviceModelEndpoint(Endpoint):
    BASE_PATH: Final[str] = "dashboard/v1/device-model"

    def list(self, **filters: Unpack[DeviceModelFilter]) -> Iterator[DeviceModel]:
        results = self._list(self.BASE_PATH, DeviceModelFilterModel, filters)
        return map_sync(DeviceModel.parse_api, results)

    def find(self, **filters: Unpack[DeviceModelFilter]) -> Optional[DeviceModel]:
        result = self._get_by_filters(self.BASE_PATH, DeviceModelFilterModel, filters)
        return DeviceModel.parse_api(result) if result else None

    def get(self, rid: ResourceId) -> Optional[DeviceModel]:
        result = self._get_by_id(self.BASE_PATH, rid)
        return DeviceModel.parse_api(result) if result else None
