mud_server.api.models_admin
Admin and operations Pydantic models for the API layer.
Classes
Admin request to manage user accounts. |
|
Admin request to create a new user account. |
|
Admin request to provision a new character for an existing account. |
|
Superuser request to remove a character from an account. |
|
Admin request to stop the server gracefully. |
|
Admin request to prune old chat messages. |
|
Response to chat prune request. |
|
Response to admin user creation request. |
|
Response to admin character provisioning. |
|
Response to a superuser character management operation. |
|
Response containing list of user accounts. |
|
Admin response containing non-tombstoned user records for Active Users views. |
|
Metadata about a single database table. |
|
Admin response containing database table metadata. |
|
Foreign key metadata for a database table relationship. |
|
Schema metadata for a database table. |
|
Admin response containing database schema relationships. |
|
Admin response containing rows for a specific database table. |
|
Admin response containing character locations with names. |
|
Admin response containing active session connections. |
|
Active in-world character session row for world operations. |
|
World operations row for admin and superuser inspection. |
|
Admin response containing world operations rows. |
|
Request to force-disconnect a session. |
|
Request to disconnect all sessions bound to a character. |
|
Response for a kick session request. |
|
Response for a character kick operation. |
|
Admin response containing all active sessions from database. |
|
Admin response containing recent chat messages across all rooms. |
|
Axis score entry for a character. |
|
Admin response containing character axis state and snapshot payloads. |
|
Axis delta entry for an event. |
|
Axis event entry with deltas and metadata. |
|
Admin response containing axis events for a character. |
|
Response to user management action (role change, ban, unban). |
|
Response to server stop request. |
|
Request to execute an Ollama command. |
|
Response to Ollama command execution. |
|
Request to clear Ollama conversation context for the current session. |
|
Response to clear Ollama context request. |
Module Contents
- class mud_server.api.models_admin.UserManagementRequest(/, **data)[source]
Bases:
pydantic.BaseModelAdmin request to manage user accounts.
Requires admin or superuser permissions. Allows role changes, banning, unbanning, and password changes of user accounts. Superusers can manage all users, admins can only manage users with lower permissions.
- session_id
Active session ID (must have appropriate permission)
- target_username
Username of the account to manage
- action
Management action - one of: - “change_role”: Change user’s role (requires new_role parameter) - “ban” or “deactivate”: Deactivate user account (prevents login, removes active session) - “delete”: Permanently delete user and related data (superuser only) - “unban”: Reactivate previously banned account - “change_password”: Change user’s password (requires new_password parameter)
- new_role
(Optional) New role when action is “change_role” Valid roles: “player”, “worldbuilder”, “admin”, “superuser”
- new_password
(Optional) New password when action is “change_password” Must be at least 8 characters
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.
- class mud_server.api.models_admin.CreateUserRequest(/, **data)[source]
Bases:
pydantic.BaseModelAdmin request to create a new user account.
Requires admin or superuser permissions. Admins may create Player or WorldBuilder accounts. Superusers may create any role, including Admin and Superuser.
Passwords must meet the STANDARD password policy, and password_confirm must match password.
- session_id
Active session ID (must have appropriate permission)
- username
Desired username (2-20 characters, must be unique)
- password
Desired password (must meet STANDARD policy)
- password_confirm
Password confirmation (must match password)
- role
Role to assign to the new account Valid roles: “player”, “worldbuilder”, “admin”, “superuser”
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.
- class mud_server.api.models_admin.CreateCharacterRequest(/, **data)[source]
Bases:
pydantic.BaseModelAdmin request to provision a new character for an existing account.
This endpoint is intended for operational tooling in the Web Admin UI: it mints a name through the name-generation integration, creates the character row, then applies an entity-state seed event.
- session_id
Active admin/superuser session id.
- target_username
Username that will own the new character.
- world_id
Target world id for the new character.
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.
- class mud_server.api.models_admin.ManageCharacterRequest(/, **data)[source]
Bases:
pydantic.BaseModelSuperuser request to remove a character from an account.
This operation is intentionally restricted to superusers because it can either soft-remove a character (tombstone) or permanently delete it.
- session_id
Active superuser session id.
- character_id
Character id to mutate.
- action
Removal mode: - “tombstone”: Keep historical rows, detach ownership, rename. - “delete”: Hard-delete the character row and dependent records.
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.
- class mud_server.api.models_admin.ServerStopRequest(/, **data)[source]
Bases:
pydantic.BaseModelAdmin request to stop the server gracefully.
Requires STOP_SERVER permission (admin or superuser only). Server will shutdown 0.5 seconds after sending response to allow the HTTP response to be delivered.
- session_id
Active session ID (must have STOP_SERVER permission)
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.
- class mud_server.api.models_admin.ChatPruneRequest(/, **data)[source]
Bases:
pydantic.BaseModelAdmin request to prune old chat messages.
- session_id
Active admin/superuser session id.
- max_age_hours
Delete messages older than this many hours. Min: 1.
- world_id
If provided, restrict pruning to this world.
- room
If provided (requires world_id), restrict to a single room.
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.
- class mud_server.api.models_admin.ChatPruneResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse to chat prune request.
- success
True if pruning completed without error.
- message
Human-readable result.
- pruned_count
Number of rows deleted.
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.
- class mud_server.api.models_admin.CreateUserResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse to admin user creation request.
- success
True if account created, False otherwise
- message
Success confirmation or error details
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.
- class mud_server.api.models_admin.CreateCharacterResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse to admin character provisioning.
- success
True when character creation succeeded.
- message
Human-readable status message.
- character_id
Newly created character id.
- character_name
Generated character name.
- world_id
World id assigned to the character.
- seed
Deterministic seed used for name/entity generation.
- entity_state
Optional entity payload returned by the entity API.
- entity_state_error
Optional integration error when entity seeding fails.
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.
- class mud_server.api.models_admin.ManageCharacterResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse to a superuser character management operation.
- success
True when the requested operation completed.
- message
Human-readable operation result.
- character_id
Character id that was targeted.
- action
Normalized action string that was executed.
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.
- class mud_server.api.models_admin.UserListResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse containing list of user accounts.
Used for admin user management interfaces.
- users
List of user data dictionaries with account information
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.
- class mud_server.api.models_admin.DatabasePlayersResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing non-tombstoned user records for Active Users views.
Requires VIEW_LOGS permission. Includes account details and character counts for currently manageable accounts. Tombstoned/deleted (archival) accounts are intentionally excluded from this response contract.
- players
List of user data dictionaries with fields: - id: Database record ID - username: Account username - password_hash: Truncated password hash (first 20 chars + “…”) - role: User role - account_origin: Account provenance (“visitor”, “admin”, “superuser”, “system”, “legacy”) - is_guest: Guest flag - guest_expires_at: Guest expiry timestamp - character_count: Number of linked characters - is_online_account: True if any active session exists - is_online_in_world: True if any active session has a character - online_world_ids: Active world ids for character-bound sessions - created_at: Account creation timestamp - last_login: Last login timestamp - is_active: Account status (True=active, False=banned)
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.
- class mud_server.api.models_admin.DatabaseTableInfo(/, **data)[source]
Bases:
pydantic.BaseModelMetadata about a single database table.
- name
Table name.
- columns
List of column names in order.
- row_count
Number of rows in the table.
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.
- class mud_server.api.models_admin.DatabaseTablesResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing database table metadata.
Requires VIEW_LOGS permission. Used for table discovery in the admin UI.
- tables
List of DatabaseTableInfo entries.
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.
- tables: list[DatabaseTableInfo]
- class mud_server.api.models_admin.DatabaseSchemaForeignKey(/, **data)[source]
Bases:
pydantic.BaseModelForeign key metadata for a database table relationship.
- from_column
Column on the source table.
- ref_table
Referenced table name.
- ref_column
Referenced column name.
- on_update
SQLite ON UPDATE action.
- on_delete
SQLite ON DELETE action.
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.
- class mud_server.api.models_admin.DatabaseSchemaTable(/, **data)[source]
Bases:
pydantic.BaseModelSchema metadata for a database table.
- name
Table name.
- columns
Column names in order.
- foreign_keys
Foreign key relationships.
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.
- foreign_keys: list[DatabaseSchemaForeignKey]
- class mud_server.api.models_admin.DatabaseSchemaResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing database schema relationships.
Requires VIEW_LOGS permission. Used for schema map displays.
- tables
Schema metadata for all tables.
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.
- tables: list[DatabaseSchemaTable]
- class mud_server.api.models_admin.DatabaseTableRowsResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing rows for a specific database table.
Requires VIEW_LOGS permission. Includes column names and raw row values.
- table
Table name.
- columns
Column names in order.
- rows
Row values as a list of rows (each row is a list of values).
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.
- class mud_server.api.models_admin.DatabasePlayerLocationsResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing character locations with names.
Requires VIEW_LOGS permission. Useful for cross-referencing room occupancy.
- locations
List of dicts with fields: - character_id - character_name - zone_id - room_id - updated_at
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.
- class mud_server.api.models_admin.DatabaseConnectionsResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing active session connections.
Requires VIEW_LOGS permission. Includes activity age for dashboards.
- connections
List of session dictionaries with fields: - id - username - session_id - created_at - last_activity - expires_at - client_type - age_seconds
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.
- class mud_server.api.models_admin.WorldActiveCharacterSession(/, **data)[source]
Bases:
pydantic.BaseModelActive in-world character session row for world operations.
- character_id
Character identifier bound to the session.
- character_name
Character display name.
- username
Owning account username (if resolvable).
- session_id
Active session identifier for this character session.
- last_activity
Timestamp of most recent activity.
- client_type
Client source for the session (browser/tui/api/etc.).
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.
- class mud_server.api.models_admin.DatabaseWorldStatusRow(/, **data)[source]
Bases:
pydantic.BaseModelWorld operations row for admin and superuser inspection.
- world_id
World identifier.
- name
Human-readable world name.
- description
World description text.
- is_active
Catalog activation flag from worlds table.
- is_online
True when one or more in-world character sessions are active.
- active_session_count
Number of active sessions scoped to this world.
- active_character_count
Number of unique active characters in this world.
- last_activity
Most recent session activity timestamp in this world.
- active_characters
Kickable active character-session rows.
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.
- active_characters: list[WorldActiveCharacterSession]
- class mud_server.api.models_admin.DatabaseWorldStatusResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing world operations rows.
Requires VIEW_LOGS permission.
- worlds
World operations rows.
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.
- worlds: list[DatabaseWorldStatusRow]
- class mud_server.api.models_admin.KickSessionRequest(/, **data)[source]
Bases:
pydantic.BaseModelRequest to force-disconnect a session.
Requires KICK_USERS permission.
- session_id
Admin’s active session id.
- target_session_id
Session id to disconnect.
- reason
Optional reason for audit/logging.
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.
- class mud_server.api.models_admin.KickCharacterRequest(/, **data)[source]
Bases:
pydantic.BaseModelRequest to disconnect all sessions bound to a character.
Requires KICK_USERS permission.
- session_id
Admin/superuser session id.
- character_id
Target character id to disconnect.
- reason
Optional moderation reason for logging/audit.
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.
- class mud_server.api.models_admin.KickSessionResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse for a kick session request.
- success
True if session was removed.
- message
Human-readable result.
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.
- class mud_server.api.models_admin.KickCharacterResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse for a character kick operation.
- success
True if at least one session was removed.
- message
Human-readable operation result.
- removed_sessions
Number of removed sessions.
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.
- class mud_server.api.models_admin.DatabaseSessionsResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing all active sessions from database.
Requires VIEW_LOGS permission. Shows who is currently logged in.
- sessions
List of session data dictionaries with fields: - id: Database record ID - username: Logged in account - character_name: Active character for the session (if selected) - session_id: UUID session identifier - created_at: Login timestamp - last_activity: Most recent API request timestamp - expires_at: Session expiry timestamp (NULL means no expiry) - client_type: Client identifier (tui, browser, api)
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.
- class mud_server.api.models_admin.DatabaseChatResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing recent chat messages across all rooms.
Requires VIEW_LOGS permission. Useful for moderation and monitoring.
- messages
List of chat message dictionaries with fields: - id: Database record ID - username: Message sender - message: Message text (includes [WHISPER], [YELL] prefixes) - world_id: World the message was sent in - room_id: Room ID where message was sent - timestamp: Message timestamp
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.
- class mud_server.api.models_admin.CharacterAxisScore(/, **data)[source]
Bases:
pydantic.BaseModelAxis score entry for a character.
- axis_id
Axis registry id.
- axis_name
Axis name from policy.
- axis_score
Numeric score for the axis.
- axis_label
Resolved label from thresholds (if available).
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.
- class mud_server.api.models_admin.DatabaseCharacterAxisStateResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing character axis state and snapshot payloads.
- character_id
Character id.
- world_id
World identifier.
- state_seed
Snapshot seed counter.
- state_version
Policy hash associated with the snapshot.
- state_updated_at
Timestamp of the snapshot refresh.
- base_state
Parsed base snapshot JSON.
- current_state
Parsed current snapshot JSON.
- axes
Axis score entries.
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.
- axes: list[CharacterAxisScore]
- class mud_server.api.models_admin.CharacterAxisDelta(/, **data)[source]
Bases:
pydantic.BaseModelAxis delta entry for an event.
- axis_name
Axis name.
- old_score
Score before applying delta.
- new_score
Score after applying delta.
- delta
Applied delta value.
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.
- class mud_server.api.models_admin.CharacterAxisEvent(/, **data)[source]
Bases:
pydantic.BaseModelAxis event entry with deltas and metadata.
- event_id
Event identifier.
- world_id
World identifier for the event.
- event_type
Event type name.
- event_type_description
Optional event type description.
- timestamp
Event timestamp.
- metadata
Key/value metadata entries.
- deltas
Axis delta entries.
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.
- deltas: list[CharacterAxisDelta]
- class mud_server.api.models_admin.DatabaseCharacterAxisEventsResponse(/, **data)[source]
Bases:
pydantic.BaseModelAdmin response containing axis events for a character.
- character_id
Character id.
- events
Event entries.
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.
- events: list[CharacterAxisEvent]
- class mud_server.api.models_admin.UserManagementResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse to user management action (role change, ban, unban).
- success
True if action completed successfully
- message
Confirmation message or error details
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.
- class mud_server.api.models_admin.ServerStopResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse to server stop request.
Server will shutdown shortly after sending this response.
- success
True if shutdown initiated
- message
Confirmation message indicating who initiated shutdown
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.
- class mud_server.api.models_admin.OllamaCommandRequest(/, **data)[source]
Bases:
pydantic.BaseModelRequest to execute an Ollama command.
Requires VIEW_LOGS permission (admin or superuser only).
- session_id
Active session ID (must have appropriate permission)
- server_url
URL of the Ollama server (e.g., “http://localhost:11434”)
- command
Ollama command to execute (e.g., “list”, “ps”, “run llama2”)
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.
- class mud_server.api.models_admin.OllamaCommandResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse to Ollama command execution.
- success
True if command executed successfully
- output
Command output or error message
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.
- class mud_server.api.models_admin.ClearOllamaContextRequest(/, **data)[source]
Bases:
pydantic.BaseModelRequest to clear Ollama conversation context for the current session.
Requires VIEW_LOGS permission (admin or superuser only).
- session_id
Active session ID (must have appropriate permission)
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.
- class mud_server.api.models_admin.ClearOllamaContextResponse(/, **data)[source]
Bases:
pydantic.BaseModelResponse to clear Ollama context request.
- success
True if context was cleared successfully
- message
Confirmation message
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.