haive.games.api.general_api =========================== .. py:module:: haive.games.api.general_api .. autoapi-nested-parse:: General API system for all haive games. from typing import Any This module provides a general-purpose API that automatically discovers all available games and creates endpoints for each one, with OpenAPI documentation and game selection capabilities. Classes ------- .. autoapisummary:: haive.games.api.general_api.GameInfo haive.games.api.general_api.GameSelectionRequest haive.games.api.general_api.GeneralGameAPI Functions --------- .. autoapisummary:: haive.games.api.general_api.create_general_game_api Module Contents --------------- .. py:class:: GameInfo(/, **data) Bases: :py:obj:`pydantic.BaseModel` Information about an available game. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:class:: GameSelectionRequest(/, **data) Bases: :py:obj:`pydantic.BaseModel` Request for creating a new game. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:class:: GeneralGameAPI(app, games_package = 'haive.games', route_prefix = '/api/games', ws_route_prefix = '/ws/games', exclude_games = None) General API system that discovers and manages all games. Initialize the general game API. :param app: FastAPI application :param games_package: Package to scan for games :param route_prefix: Prefix for REST routes :param ws_route_prefix: Prefix for WebSocket routes :param exclude_games: List of game names to exclude .. py:function:: create_general_game_api(app = None, **kwargs) Create a general game API that discovers all games. :param app: Optional FastAPI app (creates one if not provided) :param \*\*kwargs: Additional arguments for GeneralGameAPI :returns: Tuple of (FastAPI app, GeneralGameAPI instance) .. rubric:: Examples >>> app, game_api = create_general_game_api() >>> # Now you have endpoints for all games!