lce_service.dynamic_app_api package
Dynamic Application API Module.
This module provides the functionality needed for the Dynamic Application API.
- exception lce_service.dynamic_app_api.DatabaseExecutionError(message: str)
Bases:
ExceptionException raised when a database operation fails to execute successfully.
This error is raised when attempting to execute a database operation (such as INSERT, UPDATE, DELETE, or SELECT queries) that encounters execution failures due to database connectivity issues, constraint violations, syntax errors, or other database-level problems.
- Parameters:
message – A descriptive error message explaining what database operation failed and any relevant details about the execution error.
- exception lce_service.dynamic_app_api.InvalidCharacterError(message: str)
Bases:
InvalidResourceError,DatabaseExecutionErrorException raised when a value contains characters that cannot be stored in the database.
The database stores text as latin1, so values containing characters outside of latin1 are rejected. This is a user input error, so it is an InvalidResourceError, while remaining a DatabaseExecutionError for callers that handle failed database operations.
- Parameters:
message – A descriptive error message identifying the invalid character and value.
- exception lce_service.dynamic_app_api.InvalidResourceError(message: str)
Bases:
AttributeErrorException raised when a resource is found but contains invalid or malformed data.
This error is raised when attempting to validate a resource (such as a Dynamic Application) that exists in the database but fails validation due to invalid data, incorrect format, or constraint violations.
- Parameters:
message – A descriptive error message explaining what validation failed and any relevant details about the invalid data.
- exception lce_service.dynamic_app_api.MissingResourceError(message: str, matches: List[str] = None)
Bases:
LookupErrorException raised when a requested resource cannot be found.
This error is raised when attempting to retrieve a resource (such as a Dynamic Application) that does not exist in the database or is otherwise unavailable.
- Parameters:
message – A descriptive error message explaining which resource is missing and any relevant identifying information.
matches – An optional list of entity names that matched the search criteria, allowing the caller to see all potential matches and potentially refine their search to be more specific.
- lce_service.dynamic_app_api.get_app_id_from_dynamic_app_guid(dbc: silo_cursor, app_guid: str) int
Retrieves the application ID for a Dynamic Application using its GUID.
This function queries the database to find the numeric application ID (aid) that corresponds to a given Dynamic Application GUID. It uses the database manager context to execute the query and handles cases where no matching application is found.
- Parameters:
dbc – A silo_cursor instance used to execute the database query and fetch application data from the master database.
app_guid – The GUID (Globally Unique Identifier) of the Dynamic Application to look up in the database.
- Returns:
The numeric application ID (aid) associated with the provided GUID
- Raises:
MissingResourceError – If no Dynamic Application is found with the specified GUID in the database
DatabaseExecutionError – Raised when the database query execution fails for any reason
- lce_service.dynamic_app_api.get_app_id_from_dynamic_app_name(dbc: silo_cursor, name: str | None) int | None
Retrieves the application ID for a Dynamic Application using its name with fuzzy matching.
This function queries the database to find the numeric application ID (aid) that corresponds to a given Dynamic Application name. It uses fuzzy string matching to handle minor variations in application names and provides intelligent disambiguation when multiple similar matches are found. The function delegates to get_id_from_entity_name for the actual fuzzy matching logic and database operations.
- Parameters:
dbc – A silo_cursor instance used to execute the database query and fetch application data from the master database. Must be properly configured and connected to the database before calling this function.
name – The name of the Dynamic Application to look up. Can be None, which will raise a ValueError. Must be a non-empty string between 1 and 64 characters if provided. Leading and trailing whitespace will be stripped during processing.
- Returns:
The numeric application ID (aid) associated with the best matching Dynamic Application name if a confident match is found. Returns None if no confident match can be determined (though in practice, exceptions are raised for all failure cases).
- Raises:
ValueError – When the name parameter is None, empty, not a string, longer than 64 characters, or when multiple Dynamic Applications have similar scores making the match ambiguous (score difference less than FUZZY_MATCHING_CONFIDENT_SCORE_DIFFERENCE points).
MissingResourceError – When no Dynamic Applications in the database match the provided name above the minimum score threshold (FUZZY_MATCHING_MIN_SCORE), or when the closest match falls below the acceptable similarity threshold. Also when multiple Dynamic Applications have similar scores making the match ambiguous (score difference less than FUZZY_MATCHING_CONFIDENT_SCORE_DIFFERENCE points).
DatabaseExecutionError – Raised when the database query execution fails for any reason (connection issues, invalid table/column names, syntax errors, etc.).
- lce_service.dynamic_app_api.get_code_for_dynamic_application(dbc: silo_cursor, app_id: int, pretty: bool, include: str | None = None, exclude: str | None = None) Dict[str, Any]
Retrieve and serialize a complete Dynamic Application configuration as a dictionary.
This function acts as a wrapper around get_dynamic_application_model, fetching a complete Dynamic Application with all its associated components and converting it to a dictionary representation suitable for serialization or API responses. The include and exclude parameters allow for selective field inclusion/exclusion in the returned dictionary representation.
- Parameters:
dbc – A silo_cursor instance used to execute database queries and fetch Dynamic Application data from the master database.
app_id – The unique integer identifier (aid) of the Dynamic Application to retrieve from the database.
pretty – A boolean flag controlling the output format of the returned dictionary. When True, the model dump includes additional formatting for readability. When False, returns a compact dictionary representation.
include – An optional string specifying which fields to include in the output. When provided, only the specified fields will be included in the returned dictionary. If None, all fields are included by default.
exclude – An optional string specifying which fields to exclude from the output. When provided, the specified fields will be omitted from the returned dictionary. If None, no fields are excluded by default.
- Returns:
A dictionary containing the complete Dynamic Application configuration, including all nested components (collection_objects, snippets, presentations, and thresholds), formatted according to the pretty parameter and filtered according to the include/exclude parameters.
- Raises:
MissingResourceError – When no Dynamic Application exists with the specified app_id.
InvalidResourceError – Raised when the stored data fails a rule of its model that is not about a single field, such as the supported application types. Stored values that fail the validation of their field are kept and reported in validation_errors (see EnumLabelMixin.model_validate_stored).
DatabaseExecutionError – Raised when any database query execution fails for any reason.
- lce_service.dynamic_app_api.get_code_for_event_policy(dbc: silo_cursor, event_id: int, pretty: bool, include: str | None = None, exclude: str | None = None) Dict[str, Any]
Retrieve and serialize a complete Event Policy configuration as a dictionary.
This function acts as a wrapper around get_event_policy_model, fetching a complete Event Policy with all its associated components and converting it to a dictionary representation suitable for serialization or API responses. The include and exclude parameters allow for selective field inclusion/exclusion in the returned dictionary representation.
- Parameters:
dbc – A silo_cursor instance used to execute database queries and fetch Event Policy data from the master database.
event_id – The unique integer identifier (id) of the Event Policy to retrieve from the database.
pretty – A boolean flag controlling the output format of the returned dictionary. When True, the model dump includes additional formatting for readability. When False, returns a compact dictionary representation.
include – An optional string specifying which fields to include in the output. When provided, only the specified fields will be included in the returned dictionary. If None, all fields are included by default.
exclude – An optional string specifying which fields to exclude from the output. When provided, the specified fields will be omitted from the returned dictionary. If None, no fields are excluded by default.
- Returns:
A dictionary containing the Event Policy configuration with all associated components (auto_clear_events) and detailed information. The dictionary content is filtered according to the include/exclude parameters and formatted according to the pretty parameter.
- Raises:
MissingResourceError – When no Event Policy exists with the specified event_id.
InvalidResourceError – Raised when the stored data fails a rule of its model that is not about a single field, such as the supported application types. Stored values that fail the validation of their field are kept and reported in validation_errors (see EnumLabelMixin.model_validate_stored).
DatabaseExecutionError – Raised when any database query execution fails for any reason.
- lce_service.dynamic_app_api.get_code_for_powerpack(dbc: silo_cursor, powerpack_id: int, pretty: bool, include: str | None = None, exclude: str | None = None) Dict[str, Any]
Retrieve and serialize a complete PowerPack configuration as a dictionary.
This function acts as a wrapper around get_powerpack_model, fetching a complete PowerPack with all its associated components and converting it to a dictionary representation suitable for serialization or API responses. The include and exclude parameters allow for selective field inclusion/exclusion in the returned dictionary representation.
- Parameters:
dbc – A silo_cursor instance used to execute database queries and fetch PowerPack data from the master database.
powerpack_id – The unique integer identifier (ppid) of the PowerPack to retrieve from the database.
pretty – A boolean flag controlling the output format of the returned dictionary. When True, the model dump includes additional formatting for readability. When False, returns a compact dictionary representation.
include – An optional string specifying which fields to include in the output. When provided, only the specified fields will be included in the returned dictionary. If None, all fields are included by default.
exclude – An optional string specifying which fields to exclude from the output. When provided, the specified fields will be omitted from the returned dictionary. If None, no fields are excluded by default.
- Returns:
A dictionary containing the PowerPack configuration with all nested components (dynamic_applications) and detailed information. The dictionary content is filtered according to the include/exclude parameters and formatted according to the pretty parameter.
- Raises:
MissingResourceError – When no PowerPack exists with the specified powerpack_id.
InvalidResourceError – Raised when the stored data fails a rule of its model that is not about a single field, such as the supported application types. Stored values that fail the validation of their field are kept and reported in validation_errors (see EnumLabelMixin.model_validate_stored).
DatabaseExecutionError – Raised when any database query execution fails for any reason.
- lce_service.dynamic_app_api.get_dynamic_applications_from_filters(dbc: silo_cursor, args: Dict[str, str], pretty: bool, include: str | None, exclude: str | None, require_all: bool) Dict[str, List[Dict[str, Any]] | List[str]]
Retrieve and serialize Dynamic Applications matching specified filter criteria.
Queries the database to find Dynamic Applications that match the provided filter criteria, then retrieves and validates the complete Dynamic Application configurations for each matching application. The function constructs SQL WHERE clauses from the filter arguments and allows for both ‘AND’ and ‘OR’ logic when multiple filters are specified.
- Parameters:
dbc – A silo_cursor instance used to execute database queries and fetch Dynamic Application data from the master database.
args – A dictionary of query parameters, typically from request.args, where keys are parameter names and values are parameter values.
pretty – A boolean flag controlling the output format of the returned dictionaries. When True, the model dump includes additional formatting for readability. When False, returns compact dictionary representations.
include – An optional string specifying which fields to include in the output dictionaries. When provided, only the specified fields will be included in the returned Dynamic Application dictionaries. If None, all fields are included by default.
exclude – An optional string specifying which fields to exclude from the output dictionaries. When provided, the specified fields will be omitted from the returned Dynamic Application dictionaries. If None, no fields are excluded by default.
require_all – A boolean flag controlling how multiple filter criteria are combined. When True, all filter criteria must match (AND logic). When False, any filter criteria can match (OR logic).
- Returns:
A dictionary containing two keys: - “dynamic_applications”: A list of dictionaries representing the Dynamic
Applications that matched the filter criteria, with each dictionary containing the complete application configuration formatted according to the pretty parameter and filtered according to include/exclude parameters.
”errors”: A list of error message strings for any Dynamic Applications that were found but failed to be retrieved or validated during processing.
- Raises:
DatabaseExecutionError – Raised when any database query execution fails for any reason during the filtering or retrieval process.
MissingResourceError – Raised when no Dynamic Applications were found matching the provided filter criteria
ValueError – If any filter parameters are malformed, reference invalid field names, or use unsupported operators. Also, if either no valid filters were provided.
- lce_service.dynamic_app_api.get_dynamic_apps_from_payload(dbc: silo_cursor, payload: List[Dict[str, Any]] | Dict[str, Any]) List[DynamicApp]
Convert payload data into a list of validated DynamicApp model instances.
Takes either a single dictionary or a list of dictionaries representing Dynamic Application data and converts them into validated DynamicApp Pydantic model instances. Existing entities (the Dynamic Applications and their child entities identified by GUID) are built from their complete state: the stored values updated with the values provided in the payload. The fields provided in the payload are recorded on each model (see provided_fields). This function serves as a normalization layer that accepts flexible input formats and ensures consistent output as a list of validated models.
- Parameters:
dbc – A silo_cursor instance used to execute database queries for validating Dynamic Application GUIDs against existing records in the master database.
payload – The input data to convert, which can be either: - A single dictionary containing Dynamic Application data - A list of dictionaries, each containing Dynamic Application data When a single dictionary is provided, it is automatically wrapped in a list.
- Returns:
A list of validated DynamicApp model instances. Returns an empty list if an empty list is provided as input. Each instance in the list has been validated against the DynamicApp model schema.
- Raises:
InvalidResourceError – Raised when any dictionary in the payload fails validation against the DynamicApp model schema, containing formatted error messages describing all validation failures, or when a Dynamic Application GUID is provided more than once.
MissingResourceError – Raised when any specified Dynamic Application GUID does not exist in the database.
DatabaseExecutionError – Raised when the database query execution fails during GUID validation for any reason.
ValueError –
- Raised when the payload format is invalid, including:
Payload is neither a dictionary nor a list
The ‘dynamic_applications’ property exists but is not a list
Any item in the Dynamic Applications list is not a dictionary
Contains formatted error messages describing the specific validation failure encountered.
- lce_service.dynamic_app_api.get_event_id_from_event_policy_guid(dbc: silo_cursor, event_guid: str) int
Retrieves the event policy ID for an Event Policy using its GUID.
This function queries the database to find the numeric event policy ID that corresponds to a given Event Policy GUID. It uses the database manager context to execute the query and handles cases where no matching event policy is found.
- Parameters:
dbc – A silo_cursor instance used to execute the database query and fetch event policy data from the master database.
event_guid – The GUID (Globally Unique Identifier) of the Event Policy to look up in the database.
- Returns:
The numeric event policy ID associated with the provided GUID
- Raises:
MissingResourceError – If no Event Policy is found with the specified GUID in the database
DatabaseExecutionError – Raised when the database query execution fails for any reason
- lce_service.dynamic_app_api.get_event_id_from_event_policy_name(dbc: silo_cursor, name: str | None) int | None
Retrieves the event policy ID for an Event Policy using its name with fuzzy matching.
This function queries the database to find the numeric event policy ID that corresponds to a given Event Policy name. It uses fuzzy string matching to handle minor variations in event policy names and provides intelligent disambiguation when multiple similar matches are found. The function delegates to get_id_from_entity_name for the actual fuzzy matching logic and database operations.
- Parameters:
dbc – A silo_cursor instance used to execute the database query and fetch event policy data from the master database. Must be properly configured and connected to the database before calling this function.
name – The name of the Event Policy to look up. Can be None, which will raise a ValueError. Must be a non-empty string between 1 and 64 characters if provided. Leading and trailing whitespace will be stripped during processing.
- Returns:
The numeric event policy ID associated with the best matching Event Policy name if a confident match is found. Returns None if no confident match can be determined (though in practice, exceptions are raised for all failure cases).
- Raises:
ValueError – When the name parameter is None, empty, not a string, longer than 64 characters, or when multiple Event Policies have similar scores making the match ambiguous (score difference less than FUZZY_MATCHING_CONFIDENT_SCORE_DIFFERENCE points).
MissingResourceError – When no Event Policies in the database match the provided name above the minimum score threshold (FUZZY_MATCHING_MIN_SCORE), or when the closest match falls below the acceptable similarity threshold. Also when multiple Event Policies have similar scores making the match ambiguous (score difference less than FUZZY_MATCHING_CONFIDENT_SCORE_DIFFERENCE points).
DatabaseExecutionError – Raised when the database query execution fails for any reason (connection issues, invalid table/column names, syntax errors, etc.).
- lce_service.dynamic_app_api.get_event_policies_from_filters(dbc: silo_cursor, args: Dict[str, str], pretty: bool, include: str | None, exclude: str | None, require_all: bool) Dict[str, List[Dict[str, Any]] | List[str]]
Retrieve and serialize Event Policies matching specified filter criteria.
Queries the database to find Event Policies that match the provided filter criteria, then retrieves and validates the complete Event Policy configurations for each matching policy. The function constructs SQL WHERE clauses from the filter arguments and allows for both ‘AND’ and ‘OR’ logic when multiple filters are specified.
- Parameters:
dbc – A silo_cursor instance used to execute database queries and fetch Event Policy data from the master database.
args – A dictionary of query parameters, typically from request.args, where keys are parameter names and values are parameter values. Used to construct filter criteria for the database query.
pretty – A boolean flag controlling the output format of the returned dictionaries. When True, the model dump includes additional formatting for readability. When False, returns compact dictionary representations.
include – An optional string specifying which fields to include in the output dictionaries. When provided, only the specified fields will be included in the returned Event Policy dictionaries. If None, all fields are included by default.
exclude – An optional string specifying which fields to exclude from the output dictionaries. When provided, the specified fields will be omitted from the returned Event Policy dictionaries. If None, no fields are excluded by default.
require_all – A boolean flag controlling how multiple filter criteria are combined. When True, all filter criteria must match (AND logic). When False, any filter criteria can match (OR logic).
- Returns:
A dictionary containing two keys: - “event_policies”: A list of dictionaries representing the Event
Policies that matched the filter criteria, with each dictionary containing the complete policy configuration formatted according to the pretty parameter and filtered according to include/exclude parameters.
”errors”: A list of error message strings for any Event Policies that were found but failed to be retrieved or validated during processing.
- Raises:
DatabaseExecutionError – Raised when any database query execution fails for any reason during the filtering or retrieval process.
MissingResourceError – Raised when no Event Policies were found matching the provided filter criteria.
ValueError – If any filter parameters are malformed, reference invalid field names, or use unsupported operators. Also raised if no valid filters were provided.
- lce_service.dynamic_app_api.get_event_policies_from_payload(dbc: silo_cursor, payload: List[Dict[str, Any]] | Dict[str, Any]) List[EventPolicy]
Convert payload data into a list of validated EventPolicy model instances.
Takes either a single dictionary or a list of dictionaries representing Event Policy data and converts them into validated EventPolicy Pydantic model instances. This function serves as a normalization layer that accepts flexible input formats and ensures consistent output as a list of validated models.
- Parameters:
dbc – A silo_cursor instance used to retrieve the stored values of the existing Event Policies, which are merged with the provided values (see merge_entity_data).
payload –
The input data to convert, which can be either: - A single dictionary containing Event Policy data - A list of dictionaries, each containing Event Policy data - A dictionary with an ‘event_policies’ key containing a list of
Event Policy dictionaries
When a single dictionary is provided without the ‘event_policies’ key, it is treated as a single Event Policy.
- Returns:
A list of validated EventPolicy model instances. Each instance in the list has been validated against the EventPolicy model schema and contains the complete Event Policy configuration data from the payload.
- Raises:
InvalidResourceError – Raised when any dictionary in the payload fails validation against the EventPolicy model schema, containing formatted error messages describing all validation failures. Also raised when the same GUID is provided more than once.
ValueError –
- Raised when the payload format is invalid, including:
Payload is neither a dictionary nor a list
The ‘event_policies’ property exists but is not a list
Any item in the Event Policies list is not a dictionary
No Event Policies are provided in the payload
Contains formatted error messages describing the specific validation failure encountered.
- lce_service.dynamic_app_api.get_identifier_for_entity(dbc: silo_cursor, entity_identifier: int | str, id_from_guid_retriever: Callable, id_from_name_retriever: Callable) int
Resolve an entity identifier to its integer ID, handling ID, GUID, and name inputs.
This function normalizes entity identification by accepting either a direct integer ID, a GUID string, or an entity name string. When an integer is provided, it’s returned directly. When a GUID string is provided, it’s validated and then resolved to its corresponding integer ID using the provided GUID retriever function. When a name string is provided (after GUID validation fails), it’s resolved using the provided name retriever function with fuzzy matching capabilities.
- Parameters:
dbc – A silo_cursor instance used to execute database queries when resolving a GUID or name to its integer ID.
entity_identifier – The identifier for the entity, which can be either: - An integer representing the direct entity ID - A string representing the entity’s GUID - A string representing the entity’s name (for fuzzy matching)
id_from_guid_retriever – A callable function that takes a silo_cursor and a GUID string as parameters and returns the corresponding integer ID for the entity. This function is only called when entity_identifier is a valid GUID string. The retriever function must accept 2 arguments: a dbc instance and a GUID string. It must return the integer ID for the corresponding entity or raise a MissingResourceError if it cannot be found.
id_from_name_retriever – A callable function that takes a silo_cursor and a name string as parameters and returns the corresponding integer ID for the entity using fuzzy matching. This function is only called when entity_identifier fails GUID validation. The retriever function must accept 2 arguments: a dbc instance and a name string. It must return the integer ID for the best matching entity or raise appropriate exceptions if no match is found.
- Returns:
The integer ID of the entity corresponding to the provided identifier.
- Raises:
MissingResourceError – When either retriever function is called and determines that no entity exists with the specified identifier in the database.
ValueError – When an entity identifier is provided that is not a valid GUID (raised by validate_guid during GUID validation) or when name-based matching fails due to ambiguous or invalid names.
DatabaseExecutionError – Raised when the database query execution fails for any reason during the retrieval process.
- lce_service.dynamic_app_api.get_library_version_in_collection_env_from_db(dbc: silo_cursor, collection_env: str, underscore_name: str, hyphen_name: str) Dict[str, int | str]
Retrieve library version information from the database for a specific execution environment.
This function queries the database to find a library that is aligned to a specific execution environment (collection environment). It searches for the library using both underscore and hyphen naming conventions to handle different package naming formats. The function joins the content_libraries and content_libraries_ppack tables to find libraries that are associated with the specified execution environment.
- Parameters:
dbc – A silo_cursor instance used to execute the database query and fetch library data from the master database.
collection_env – The GUID of the execution environment to search for aligned libraries.
underscore_name – The library name using underscore naming convention (e.g., ‘my_library’). This represents one possible naming format for the library.
hyphen_name – The library name using hyphen naming convention (e.g., ‘my-library’). This represents an alternative naming format for the same library.
- Returns:
A dictionary containing the library information if found, with keys: - ‘name’: The library name as stored in the database - ‘version’: The version string of the library - ‘lib_id’: The unique library identifier Returns an empty dictionary if no matching library is found.
- Raises:
DatabaseExecutionError – Raised when any database operation fails for any reason
- lce_service.dynamic_app_api.get_pip_config_options(dbc: silo_cursor) Dict[str, List[str]]
Retrieve and validate pip configuration options from the system settings table.
This function queries the database to fetch the wheel downloader pip options configuration setting from the master.system_settings_core table. These options are used to configure pip behavior for package installation and wheel downloading operations within the system. The function validates that the retrieved options are in valid JSON format and represent a dictionary object before returning them.
- Parameters:
dbc – A silo_cursor instance used to execute the database query and fetch the pip configuration options from the master database. Must be properly configured and connected to the database before calling this function.
- Returns:
A dictionary containing the pip configuration options as parsed from the wheel_downloader_pip_options column. The structure and content depend on the stored configuration but must be a valid JSON object.
- Raises:
DatabaseExecutionError – Raised when the database query execution fails for any reason (connection issues, invalid table or column names, etc.).
ValueError – Raised when the retrieved pip options are not in valid JSON format or when the parsed JSON is not a dictionary object. This ensures that only properly formatted configuration data is returned.
- lce_service.dynamic_app_api.get_powerpack_id_from_guid(dbc: silo_cursor, powerpack_guid: str) int
Retrieves the numeric ID for a PowerPack using its GUID.
This function queries the database to find the numeric PowerPack ID (ppid) that corresponds to a given PowerPack GUID. It uses the database manager context to execute the query and handles cases where no matching PowerPack is found.
- Parameters:
dbc – A silo_cursor instance used to execute the database query and fetch application data from the master database.
powerpack_guid – The GUID (Globally Unique Identifier) of the PowerPack to look up in the database.
- Returns:
The numeric PowerPack ID (ppid) associated with the provided GUID
- Raises:
MissingResourceError – If no PowerPack is found with the specified GUID in the database
DatabaseExecutionError – Raised when the database query execution fails for any reason
- lce_service.dynamic_app_api.get_powerpack_id_from_name(dbc: silo_cursor, name: str | None) int | None
Retrieves the numeric ID for a PowerPack using its name with fuzzy matching.
This function queries the database to find the numeric PowerPack ID (ppid) that corresponds to a given PowerPack name. It uses fuzzy string matching to handle minor variations in PowerPack names and provides intelligent disambiguation when multiple similar matches are found. The function delegates to get_id_from_entity_name for the actual fuzzy matching logic and database operations.
- Parameters:
dbc – A silo_cursor instance used to execute the database query and fetch PowerPack data from the master database. Must be properly configured and connected to the database before calling this function.
name – The name of the PowerPack to look up. Must be a non-empty string between 1 and 64 characters. Leading and trailing whitespace will be stripped during processing.
- Returns:
The numeric PowerPack ID (ppid) associated with the best matching PowerPack name if a confident match is found.
- Raises:
ValueError – When the name parameter is None, empty, not a string, longer than 64 characters, or when multiple PowerPacks have similar scores making the match ambiguous (score difference less than FUZZY_MATCHING_CONFIDENT_SCORE_DIFFERENCE points).
MissingResourceError – When no PowerPacks in the database match the provided name above the minimum score threshold (FUZZY_MATCHING_MIN_SCORE). Also when multiple PowerPacks have similar scores making the match ambiguous (score difference less than FUZZY_MATCHING_CONFIDENT_SCORE_DIFFERENCE points).
DatabaseExecutionError – Raised when the database query execution fails for any reason (connection issues, invalid table/column names, syntax errors, etc.).
- lce_service.dynamic_app_api.insert_audit_log(dbc: silo_cursor, message: str, user: User, source: str = 'Snippet Framework API', organization_id: int | None = None) None
Writes an audit log entry for user actions.
This function creates a standardized audit log entry that includes the username and a descriptive message about the action performed. The log entry is written to the master_biz.organizations_log database table with a fixed source identifier and acknowledgment flag.
- Parameters:
dbc – A silo_cursor instance used to execute the database insert query for writing the audit log entry to the master_biz.organizations_log table.
message – A descriptive message about the action being audited. This message will be prefixed with the user’s username to create the full audit log entry.
user – The User instance representing the user performing the action being audited. The username and organization_id from this user object are used to populate the audit log entry.
source – The source the entry is filed under. Defaults to this service’s own source; an action the platform audits under a source of its own, such as running a device tool, is filed under that source instead so both read alike.
organization_id – The organization the entry is filed under, when it belongs to the organization of what was acted on rather than to the user’s own.
- Raises:
DatabaseExecutionError – Raised when the database insert operation fails for any reason during the audit log creation process.
- lce_service.dynamic_app_api.remove_library_from_execution_environment(dbc: silo_cursor, collection_env: str, content_library_id: int) None
Removes the alignment between a library and an execution environment.
This function removes the association between a specific library and an execution environment by deleting the corresponding record from the content_libraries_ppack table. This effectively un-aligns the library from the execution environment, making it unavailable for use in that environment.
- Parameters:
dbc – The database cursor object used to execute the SQL query
collection_env – The GUID of the execution environment to un-align the library from
content_library_id – The unique identifier of the library to un-align
- Raises:
DatabaseExecutionError – Raised when the database delete operation fails for any reason
- lce_service.dynamic_app_api.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_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
Sets the fields derived from the source of each Event Policy (normalize_event_policies)
Updates or creates the Event Policy records in the database
Increments PowerPack revision numbers for affected PowerPacks
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.
Submodules
- lce_service.dynamic_app_api.core module
BulkSQLOperationComponentsDatabaseExecutionErrorDynamicAppEntityRelationshipExistingAndNewRecordsInvalidCharacterErrorInvalidResourceErrorMissingResourceErrorcreate_reference_map_to_entities()execute_query()generate_guid()get_app_id_from_dynamic_app_guid()get_app_id_from_dynamic_app_name()get_column_from_table()get_components_for_bulk_update()get_dynamic_application_header()get_entities_from_db()get_event_id_from_event_policy_guid()get_event_id_from_event_policy_name()get_existing_and_new_records()get_fields_from_table()get_identifier_for_entity()get_library_version_in_collection_env_from_db()get_models_from_entities()get_models_from_stored_data()get_pip_config_options()get_powerpack_id_from_guid()get_powerpack_id_from_name()get_row_from_table()get_sql_select_statements()get_total_entity_count()get_value_from_table()handle_validation_error()increment_powerpack_revision_number()insert_audit_log()remove_library_from_execution_environment()replace_reference_identifiers()reset_collection_object_usage_type()set_entity_fields()update_dynamic_app_keys_table()validate_model()
- lce_service.dynamic_app_api.model_filtering module
- lce_service.dynamic_app_api.retrieve_entities module
get_alerts_for_dynamic_application()get_code_for_dynamic_application()get_code_for_event_policy()get_code_for_powerpack()get_collection_objects_for_dynamic_application()get_complete_dynamic_app()get_dynamic_application_object()get_dynamic_applications_from_filters()get_dynamic_apps_from_payload()get_event_ids_from_guids()get_event_policies_from_filters()get_event_policies_from_payload()get_execution_environment()get_existing_cleared_event_ids()get_powerpack_linkage_for_event_policies()get_presentations_for_dynamic_application()get_snippets_for_dynamic_application()get_specified_fields_for_entities()get_thresholds_for_dynamic_application()
- lce_service.dynamic_app_api.update_entities module