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

from typing import Final, Iterator, 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 (
    Report,
    ReportCreate,
    ReportCreateModel,
    ReportFilter,
    ReportFilterModel,
    ReportUpdate,
    ReportUpdateModel,
)


class ReportEndpoint(Endpoint):
    BASE_PATH: Final[str] = "dashboard/v1/onetimereport"

    def list(self, **filters: Unpack[ReportFilter]) -> Iterator[Report]:
        results = self._list(self.BASE_PATH, ReportFilterModel, filters)
        return map_sync(Report.parse_api, results)

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

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

    def create(self, **payload: Unpack[ReportCreate]) -> Report:
        result = self._create(self.BASE_PATH, ReportCreateModel, payload)
        return Report.parse_api(result)

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

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