# @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 (
    InfluxSystem,
    InfluxSystemCreate,
    InfluxSystemCreateModel,
    InfluxSystemFilter,
    InfluxSystemFilterModel,
    InfluxSystemUpdate,
    InfluxSystemUpdateModel,
)


class InfluxSystemEndpoint(Endpoint):
    BASE_PATH: Final[str] = "observability/v1/influx-system"

    def list(self, **filters: Unpack[InfluxSystemFilter]) -> Iterator[InfluxSystem]:
        results = self._list(self.BASE_PATH, InfluxSystemFilterModel, filters)
        return map_sync(InfluxSystem.parse_api, results)

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

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

    def create(self, **payload: Unpack[InfluxSystemCreate]) -> InfluxSystem:
        result = self._create(self.BASE_PATH, InfluxSystemCreateModel, payload)
        return InfluxSystem.parse_api(result)

    def update(self, rid: ResourceId, /, **payload: Unpack[InfluxSystemUpdate]) -> InfluxSystem:
        result = self._update(self.BASE_PATH, rid, InfluxSystemUpdateModel, payload)
        return InfluxSystem.parse_api(result)

    def delete(self, rid: ResourceId) -> bool:
        return self._delete(self.BASE_PATH, rid)
