mud_server.admin_gradio.api.settings
Settings API client for MUD Server.
This module handles user settings and server management operations: - Password changes - Server control (stop server)
- All functions follow a consistent pattern:
Validate session state and permissions
Validate input
Make API request using BaseAPIClient
Return standardized response dictionaries
- Response Format:
All functions return dictionaries with: {
“success”: bool, # Whether operation succeeded “message”: str, # User-facing message “data”: None, “error”: str | None, # Error details if failed
}
Classes
API client for settings and server management operations. |
Module Contents
- class mud_server.admin_gradio.api.settings.SettingsAPIClient(server_url=None)[source]
Bases:
mud_server.admin_gradio.api.base.BaseAPIClientAPI client for settings and server management operations.
This client handles password changes and server control operations.
Example
>>> client = SettingsAPIClient() >>> result = client.change_password( ... session_id="abc123", ... old_password="old123", ... new_password="new456", ... confirm_password="new456" ... ) >>> if result["success"]: ... print("Password changed successfully")
Initialize the base API client.
- Parameters:
server_url (str | None) – Optional server URL override. If not provided, uses MUD_SERVER_URL environment variable or defaults to http://localhost:8000
- change_password(session_id, old_password, new_password, confirm_password)[source]
Change the current user’s password.
Validates passwords, sends change request to backend, and returns confirmation or error message.
- Parameters:
- Returns:
- {
“success”: bool, “message”: str, “data”: None, “error”: str | None,
}
- Return type:
Dictionary with structure
Examples
>>> client = SettingsAPIClient() >>> result = client.change_password( ... session_id="abc123", ... old_password="old123", ... new_password="new456789", ... confirm_password="new456789" ... ) >>> result["success"] True
- stop_server(session_id, role)[source]
Stop the backend server (Admin/Superuser only).
This operation requires admin or superuser permissions. The server will shut down gracefully after responding to this request.
- Parameters:
- Returns:
- {
“success”: bool, “message”: str, “data”: None, “error”: str | None,
}
- Return type:
Dictionary with structure
Examples
>>> client = SettingsAPIClient() >>> result = client.stop_server(session_id="abc123", role="admin") >>> if result["success"]: ... print("Server shutting down")