# DO NOT EDIT — generated by _sdk_gen/ from the OpenAPI spec.
# Regenerate with: ./generate.sh
from __future__ import annotations

from typing import Any

import httpx

from goodmem._generated.models.system_info_response import SystemInfoResponse
from goodmem._generated.models.system_init_response import SystemInitResponse
from goodmem.errors import raise_for_status


class SystemAPIBase:
    """System API — auto-generated structural base.

    Auto-generated structural base. Do not edit.
    Override in goodmem/api/system.py to add domain-specific logic.
    """

    _rest_metadata: dict = {'info': {'http_method': 'GET', 'path': '/v1/system/info', 'response': 'SystemInfoResponse'}, 'init': {'http_method': 'POST', 'path': '/v1/system/init', 'response': 'SystemInitResponse', 'body_model': 'SystemInitRequest', 'body_expr': 'SystemInitRequest(**kwargs)', 'body_kind': 'json', 'body_kinds': ['application/json']}}

    def __init__(self, http: httpx.Client, headers: dict[str, str]) -> None:
        self._http = http
        self._headers = headers

    def info(self) -> SystemInfoResponse:
        """Retrieve server build metadata

        Returns the server's advertised semantic version, git metadata, build timestamp, and optional capability flags. The endpoint is intentionally unauthenticated so bootstrap tooling can call it before API keys exist.

        Returns:
            SystemInfoResponse
        """
        resp = self._http.get("/v1/system/info", headers=self._headers)
        raise_for_status(resp)
        return SystemInfoResponse.model_validate(resp.json())

    def init(self, **kwargs: Any) -> SystemInitResponse:
        """Initialize the system

        Initializes the system by creating a root user and API key. This endpoint should only be called once during first-time setup. If the system is already initialized, the endpoint will return a success response without creating new credentials.

        Returns:
            SystemInitResponse
        """
        resp = self._http.post(
            "/v1/system/init",
            json=kwargs if kwargs else None,
            headers=self._headers,
        )
        raise_for_status(resp)
        return SystemInitResponse.model_validate(resp.json())


class AsyncSystemAPIBase:
    """Async System API — auto-generated structural base.

    Auto-generated structural base. Do not edit.
    Override in goodmem/api/system.py to add domain-specific logic.
    """

    _rest_metadata: dict = {'info': {'http_method': 'GET', 'path': '/v1/system/info', 'response': 'SystemInfoResponse'}, 'init': {'http_method': 'POST', 'path': '/v1/system/init', 'response': 'SystemInitResponse', 'body_model': 'SystemInitRequest', 'body_expr': 'SystemInitRequest(**kwargs)', 'body_kind': 'json', 'body_kinds': ['application/json']}}

    def __init__(self, http: httpx.AsyncClient, headers: dict[str, str]) -> None:
        self._http = http
        self._headers = headers

    async def info(self) -> SystemInfoResponse:
        """Retrieve server build metadata

        Returns the server's advertised semantic version, git metadata, build timestamp, and optional capability flags. The endpoint is intentionally unauthenticated so bootstrap tooling can call it before API keys exist.

        Returns:
            SystemInfoResponse
        """
        resp = await self._http.get("/v1/system/info", headers=self._headers)
        raise_for_status(resp)
        return SystemInfoResponse.model_validate(resp.json())

    async def init(self, **kwargs: Any) -> SystemInitResponse:
        """Initialize the system

        Initializes the system by creating a root user and API key. This endpoint should only be called once during first-time setup. If the system is already initialized, the endpoint will return a success response without creating new credentials.

        Returns:
            SystemInitResponse
        """
        resp = await self._http.post(
            "/v1/system/init",
            json=kwargs if kwargs else None,
            headers=self._headers,
        )
        raise_for_status(resp)
        return SystemInitResponse.model_validate(resp.json())

