lce_service.dynamic_app_api.update_entities module

lce_service.dynamic_app_api.update_entities.update_code_for_dynamic_applications(dbc: silo_cursor, dynamic_apps: List[DynamicApp], user: User) → List[Dict[str, Any]]

Update multiple Dynamic Applications and their associated entities in the database.

This function processes a list of Dynamic Applications and performs comprehensive database updates for each application and all its associated entities (snippets, collection objects, presentations, thresholds). It handles both new application creation and existing application updates, manages GUID remapping for new entities, tracks component mapping relationships, and ensures data consistency across all related database tables.

The function performs the following operations for each Dynamic Application: 1. Updates or creates the main Dynamic Application record 2. Processes all child entities (snippets, collection objects, etc.) 3. Tracks GUID remapping for newly created entities 4. Maintains component mapping relationships between applications 5. Updates component alignment mappings to reflect any GUID changes

Parameters:
  • dbc – A silo_cursor instance used to execute database queries for updating Dynamic Application and entity data across multiple master database tables.

  • dynamic_apps – A list of DynamicApp model instances containing the complete application configurations to be updated or created in the database. Each instance includes the main application data plus all associated child entities (snippets, collection_objects, presentations, thresholds).

  • user – The User instance representing the user performing the update operations, used to populate audit fields in database records for tracking who made the changes across all affected tables.

Returns:

A list of dictionaries where each dictionary contains the serialized results of updating a single Dynamic Application. Each dictionary includes the update status for the main application and all its child entities, with information about which entities were created, updated, or encountered errors during processing.

Raises:
  • DatabaseExecutionError – Raised when any database operation fails during the Dynamic Application or entity update process, including core application updates, child entity updates, or component alignment mapping updates.

  • InvalidResourceError – Raised when any entity fails validation.

lce_service.dynamic_app_api.update_entities.update_code_for_event_policies(dbc: silo_cursor, event_policies: List[EventPolicy], user: User) → List[Dict[str, Any]]

Update multiple Event Policy entities in the database.

This function processes a list of Event Policy entities and performs comprehensive database updates for each policy. It handles both new event policy creation and existing policy updates, manages dependent field population from existing database values, validates event policy fields, and ensures data consistency across all related database tables.

The function performs the following operations: 1. Validates the complete resulting state of every Event Policy (the stored values merged

with the provided values, see EventPolicy.execute_strict_validation) before anything is written

  1. Sets the fields derived from the source of each Event Policy (normalize_event_policies)

  2. Updates or creates the Event Policy records in the database

  3. Increments PowerPack revision numbers for affected PowerPacks

  4. Returns serialized update results for all processed entities

Parameters:
  • dbc – A silo_cursor instance used to execute database queries for updating Event Policy data in the master.dynamic_app_event_policies table and related database tables. This cursor should be properly configured and connected to the database before calling this function.

  • event_policies – A list of EventPolicy model instances containing the event policy configurations to be updated or created in the database. Each instance includes event policy data such as name, description, source type, event configuration, and notification parameters.

  • user – The User instance representing the user performing the update operations, used to populate audit fields in database records for tracking who made the changes and for PowerPack revision number updates.

Returns:

A list of dictionaries where each dictionary contains the serialized results of updating a single Event Policy. Each dictionary includes the update status with information about which entities were created, updated, or encountered errors during processing, serialized using model_dump with None values excluded.

Raises:
  • DatabaseExecutionError – Raised when any database operation fails during the Event Policy update process, including dependent field retrieval, validation queries, bulk update operations, or PowerPack revision number updates.

  • InvalidResourceError – Raised when any Event Policy fails validation, including field validation errors, constraint violations, or when referenced entities (such as PowerPacks) do not exist in the database.