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

from typing import Any

from urllib.parse import quote
import httpx

from goodmem.errors import raise_for_status
from goodmem.models.user_response import UserResponse


class UsersAPIBase:
    """Users API — auto-generated structural base.

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

    _rest_metadata: dict = {'get': {'http_method': 'GET', 'path': '/v1/users/{id}', 'input_shape': 'path_query', 'summary': 'Get a user by ID', 'description': 'Retrieves a specific user by their unique identifier. This endpoint only accepts user IDs - for email-based lookup, use GET /v1/users/email/{email}. For getting your own profile, use GET /v1/users/me.', 'response': 'UserResponse', 'query_params': ['id'], 'params': [{'name': 'id', 'type': 'str', 'source': 'path', 'required': False, 'description': 'The unique identifier of the user to retrieve'}, {'name': 'email', 'type': 'str', 'source': 'path', 'required': False, 'description': 'The email address of the user to retrieve'}]}, 'me': {'http_method': 'GET', 'path': '/v1/users/me', 'input_shape': 'no_params', 'summary': 'Get current user profile', 'description': "Retrieves the authenticated user's profile information including email, display name, and creation time. This endpoint does not require any parameters as it automatically returns the caller's information.", 'response': 'UserResponse'}}

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

    def get(self, *, id: str | None = None, email: str | None = None) -> UserResponse:
        """Get a user by ID

        Retrieves a specific user by their unique identifier. This endpoint only accepts user IDs - for email-based lookup, use GET /v1/users/email/{email}. For getting your own profile, use GET /v1/users/me.

        Exactly one of ``id``, ``email`` must be provided.

        Args:
            id (str, optional): The unique identifier of the user to retrieve
            email (str, optional): The email address of the user to retrieve

        Returns:
            UserResponse
        """
        if (id is not None) + (email is not None) != 1:
            raise ValueError("Exactly one of 'id', 'email' must be provided")
        if email is not None:
            resp = self._http.get(f"/v1/users/email/{quote(email, safe='')}", headers=self._headers)
        elif id is not None:
            resp = self._http.get(f"/v1/users/{quote(id, safe='')}", headers=self._headers)
        raise_for_status(resp)
        return UserResponse.model_validate(resp.json())

    def me(self) -> UserResponse:
        """Get current user profile

        Retrieves the authenticated user's profile information including email, display name, and creation time. This endpoint does not require any parameters as it automatically returns the caller's information.

        Returns:
            UserResponse
        """
        resp = self._http.get("/v1/users/me", headers=self._headers)
        raise_for_status(resp)
        return UserResponse.model_validate(resp.json())


class AsyncUsersAPIBase:
    """Async Users API — auto-generated structural base.

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

    _rest_metadata: dict = {'get': {'http_method': 'GET', 'path': '/v1/users/{id}', 'input_shape': 'path_query', 'summary': 'Get a user by ID', 'description': 'Retrieves a specific user by their unique identifier. This endpoint only accepts user IDs - for email-based lookup, use GET /v1/users/email/{email}. For getting your own profile, use GET /v1/users/me.', 'response': 'UserResponse', 'query_params': ['id'], 'params': [{'name': 'id', 'type': 'str', 'source': 'path', 'required': False, 'description': 'The unique identifier of the user to retrieve'}, {'name': 'email', 'type': 'str', 'source': 'path', 'required': False, 'description': 'The email address of the user to retrieve'}]}, 'me': {'http_method': 'GET', 'path': '/v1/users/me', 'input_shape': 'no_params', 'summary': 'Get current user profile', 'description': "Retrieves the authenticated user's profile information including email, display name, and creation time. This endpoint does not require any parameters as it automatically returns the caller's information.", 'response': 'UserResponse'}}

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

    async def get(self, *, id: str | None = None, email: str | None = None) -> UserResponse:
        """Get a user by ID

        Retrieves a specific user by their unique identifier. This endpoint only accepts user IDs - for email-based lookup, use GET /v1/users/email/{email}. For getting your own profile, use GET /v1/users/me.

        Exactly one of ``id``, ``email`` must be provided.

        Args:
            id (str, optional): The unique identifier of the user to retrieve
            email (str, optional): The email address of the user to retrieve

        Returns:
            UserResponse
        """
        if (id is not None) + (email is not None) != 1:
            raise ValueError("Exactly one of 'id', 'email' must be provided")
        if email is not None:
            resp = await self._http.get(f"/v1/users/email/{quote(email, safe='')}", headers=self._headers)
        elif id is not None:
            resp = await self._http.get(f"/v1/users/{quote(id, safe='')}", headers=self._headers)
        raise_for_status(resp)
        return UserResponse.model_validate(resp.json())

    async def me(self) -> UserResponse:
        """Get current user profile

        Retrieves the authenticated user's profile information including email, display name, and creation time. This endpoint does not require any parameters as it automatically returns the caller's information.

        Returns:
            UserResponse
        """
        resp = await self._http.get("/v1/users/me", headers=self._headers)
        raise_for_status(resp)
        return UserResponse.model_validate(resp.json())

