# @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 (
    GrafanaSystem,
    GrafanaSystemCreate,
    GrafanaSystemCreateModel,
    GrafanaSystemFilter,
    GrafanaSystemFilterModel,
    GrafanaSystemUpdate,
    GrafanaSystemUpdateModel,
)


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

    def list(self, **filters: Unpack[GrafanaSystemFilter]) -> Iterator[GrafanaSystem]:
        results = self._list(self.BASE_PATH, GrafanaSystemFilterModel, filters)
        return map_sync(GrafanaSystem.parse_api, results)

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

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

    def create(self, **payload: Unpack[GrafanaSystemCreate]) -> GrafanaSystem:
        result = self._create(self.BASE_PATH, GrafanaSystemCreateModel, payload)
        return GrafanaSystem.parse_api(result)

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

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