QRS API Client
QRS API Client for Qlik Sense Enterprise.
- class qrs_api_client.client.QRSClient(server_name: str, server_port: int, auth_method: str, auth_manager: AuthManager = None, verify_ssl=True)[source]
Bases:
objectClient for interacting with the Qlik Repository Service (QRS) API.
Provides methods for establishing a session and performing CRUD operations on QRS entities.
- app_change_owner(app_id: UUID, user_directory: str, user_id: str) dict[source]
Changes the owner of certain app.
- Parameters:
app_id (UUID) – The ID of the app.
user_directory (str) – The user directory of the new owner.
user_id (str) – The user id of the new owner.
- Returns:
JSON response as a dict.
- Return type:
list
- app_export(app_id: UUID, file_path: str, file_name: str = None, skip_data: bool = False)[source]
Exports an app in a two-step process using POST and GET methods.
- Step 1: POST to /qrs/app/{id}/export/{token} to trigger the export.
The API returns JSON with a ‘downloadPath’ field.
Step 2: GET the downloadPath to download the binary .qvf file.
- Parameters:
app_id (UUID) – The ID of the app to be exported.
file_path (str) – The directory path where the exported app should be stored.
file_name (str, optional) – File name for the exported app (e.g., “MyApp.qvf”). Falls kein Wert übergeben
wurde
genommen. (wird der ursprüngliche Name der Datei)
skip_data
- Returns:
Success message with file name and path, or None if an error occurs.
- Return type:
str
- app_get_custom_properties(app_id: UUID) list[source]
Exports the custom properties of certain app as JSON.
- Parameters:
app_id (UUID) – The ID of the app.
- Returns:
JSON response as a list.
- Return type:
list
- app_get_owner(app_id: UUID) dict[source]
Exports the owner of certain app as JSON.
- Parameters:
app_id (UUID) – The ID of the app.
- Returns:
JSON response as a dict.
- Return type:
list
- app_get_tags(app_id: UUID, tags: list)[source]
Exports the tags of certain app as JSON.
- Parameters:
app_id (UUID) – The ID of the app.
tags (list) – List with tags to be imported.
- Returns:
JSON response as a list.
- Return type:
list
- app_reload(id: UUID, poll_interval: float = 5.0) dict[source]
Triggers a reload, identified by either a reload task ID or an app ID, and waits for it to complete. Mimics the QMC’s “Reload now” functionality.
- The given ID is resolved in two steps:
The method first checks whether a reload task with that ID exists. If so, the task is reused as-is (the method does not create or modify anything). Only reload tasks (taskType 0) are accepted; tasks of other types are rejected.
If no reload task with that ID exists, the ID is treated as an app ID. The method then looks for an existing reload task named “Manually triggered reload of <app_name>” for that app, creating one via reloadtask_create() if needed (with no schema events, only manually triggerable).
Once a reload task has been resolved, the task is started via POST /qrs/task/{id}/start/synchronous. The server returns an execution session GUID. An empty GUID (00000000-…) means the task could not be started (disabled, no scheduler available, app not available).
The execution session is then polled via GET /qrs/executionsession/{id} until it returns 404 Not Found - per Qlik’s documentation this indicates the task has finished and the execution session entity has been deleted from the database.
Finally, the execution result is fetched via GET /qrs/executionresult?filter=executionID eq <session_id> to determine the final status, duration and details.
- Parameters:
id (UUID) – Either the ID of a reload task to start, or the ID of an app to reload (resolved in that order).
poll_interval (float, optional) – Interval in seconds between status checks. Default value is 5.0.
- Returns:
- A result dictionary with the following keys:
”success” (bool): True if the reload completed successfully (status FinishedSuccess), False otherwise.
”task” (dict): The reload task object that was used.
Returns None if the ID could not be resolved to either a reload task or an app, the task could not be created or started, or no execution result was found afterwards.
- Return type:
dict
- app_set_custom_properties(app_id: UUID, custom_properties: dict)[source]
Inserts custom properties into an app.
- Parameters:
app_id (UUID) – The ID of the app.
custom_properties (dict) – Custom property with name and values to be inserted. The values have a ‘list’ as data type.
- Returns:
JSON response as a list.
- Return type:
list
- app_set_tags(app_id: UUID, tags: list)[source]
Inserts tags into an app.
- Parameters:
app_id (UUID) – The ID of the app.
tags (list) – The tags of the app.
- Returns:
JSON response as a list.
- Return type:
list
- app_upload(app_name: str, file_name: str, keep_data: bool = True, exclude_connections: bool = False)[source]
Executes a POST request to the QRS API.
- Parameters:
app_name (str) – The name of the app after upload.
file_name (str) – The path to the file.
exclude_connections (bool, optional) – If set to true and the uploaded .qvf file contains any data connections, they will not be imported to the system. The default value is false.
keep_data (bool, optional) – If set to false and the uploaded .qvf file contains app data, the data will be silently discarded. The default value is true.
- Returns:
JSON response as a dictionary.
- Return type:
dict
- app_upload_replace(target_app_id: UUID, file_name: str, keep_data: bool = True)[source]
Executes a POST request to the QRS API.
- Parameters:
target_app_id (UUID) – The ID of the app to be replaced.
file_name (str) – The path to the file.
keep_data (bool, optional) – If set to false and the uploaded .qvf file contains app data, the data will be silently discarded. The default value is true.
- Returns:
JSON response as a dictionary.
- Return type:
dict
- create_custom_properties(properties: list[dict])[source]
Creates multiple custom property definitions in a single API call.
Uses the bulk endpoint POST /qrs/custompropertydefinition/many to create several custom property definitions at once. Each entry in the input list is expected to be a custom property definition dict as produced by models.custom_property_definition(). Already existing definitions and duplicates within the input list are filtered out (case-insensitive, by name). If no definitions remain after filtering, no request is sent.
- Parameters:
properties (list[dict]) – List of custom property definition dicts (e.g. produced by models.custom_property_definition()) to be created. Already existing names and duplicates within the list are skipped and logged as errors.
- Returns:
- JSON response from the API containing the created
custom property definitions, or None if no new definitions remain to be created after filtering.
- Return type:
list[dict]
- create_custom_property(name: str, value_type: str = 'Text', choice_values: list[str] = None, object_types: list[str] = None, description: str = None)[source]
Creates a single custom property definition via the Qlik Repository Service.
Retrieves all existing custom property definitions first and checks case-insensitively whether a definition with the given name already exists. If not, a new custom property definition is created via the POST /qrs/custompropertydefinition endpoint.
- Parameters:
name (str) – The name of the custom property definition to create. Comparison with existing definitions is case-insensitive.
value_type (str, optional) – The type of value the property accepts (e.g. “Text”). Default value is “Text”.
choice_values (list[str], optional) – Predefined choice values for the property. Only relevant when the property should be restricted to a fixed set of values.
object_types (list[str], optional) – List of object types the property can be applied to (e.g. [“App”, “Stream”]).
description (str, optional) – A description of the custom property definition.
- Returns:
- JSON response from the API containing the created custom
property definition, or None if a definition with the given name already exists.
- Return type:
dict
- create_tag(name: str)[source]
Creates a single tag via the Qlik Repository Service.
Retrieves all existing tags first and checks case-insensitively whether a tag with the given name already exists. If not, a new tag is created via the POST /qrs/tag endpoint.
- Parameters:
name (str) – The name of the tag to create. Comparison with existing tags is case-insensitive.
- Returns:
- JSON response from the API containing the created tag, or
None if a tag with the given name already exists.
- Return type:
dict
- create_tags(names: list[str])[source]
Creates multiple tags in a single API call.
Uses the bulk endpoint POST /qrs/tag/many to create several tags at once. Before sending the request, both already existing tags and duplicates within the input list are filtered out (case-insensitive). If no tags remain after filtering, no request is sent.
- Parameters:
names (list[str]) – List of tag names to create. Already existing names and duplicates within the list are skipped and logged as errors.
- Returns:
- JSON response from the API containing the created tags,
or None if no new tags remain to be created after filtering.
- Return type:
list[dict]
- delete(endpoint: str, params: dict = None, silent_status_codes: set = None)[source]
Executes a DELETE request to the QRS API.
- Parameters:
endpoint (str) – The API endpoint to call.
params (dict, optional) – Query parameters as key-value pairs.
silent_status_codes (set, optional) – HTTP status codes that are expected for this call and should be logged at DEBUG instead of ERROR when they occur (see _request for details).
- Returns:
JSON response as a dictionary or None if an error occurs.
- Return type:
dict
- get(endpoint: str, params: dict = None, headers: dict = None, silent_status_codes: set = None)[source]
Executes a GET request to the QRS API.
- Parameters:
endpoint (str) – The API endpoint to call.
params (dict, optional) – Query parameters as key-value pairs.
headers (dict, optional) – Additional header parameters.
silent_status_codes (set, optional) – HTTP status codes that are expected for this call and should be logged at DEBUG instead of ERROR when they occur (see _request for details).
- Returns:
JSON response as a dictionary or None if an error occurs.
- Return type:
dict
- get_enum(schema_path: str) list[str] | None[source]
Retrieves the list of values for the enum that is used at a given Qlik Sense schema path.
Each Qlik object property whose type is an enum (e.g. ExecutionResult.Status, ReloadTask.TaskType, App.AvailabilityStatus) is associated with exactly one enum definition. This method fetches the full enum table from /qrs/about/api/enums and looks up the values for the property identified by the given schema path.
The returned list mirrors the raw server format - each entry is a string of the form “<int>: <name>” (e.g. “7: FinishedSuccess”).
- Parameters:
schema_path (str) – The schema path of the property whose enum values should be returned (e.g. “ExecutionResult.Status”, “ReloadTask.TaskType”, “App.AvailabilityStatus”).
- Returns:
- The list of enum value strings (e.g.
[“0: NeverStarted”, “1: Triggered”, …]), or None if the schema path is not associated with any enum on the server.
- Return type:
list[str]
Examples
>>> client.get_enum("ExecutionResult.Status") ['0: NeverStarted', '1: Triggered', ..., '14: DistributionRunning']
>>> client.get_enum("ReloadTask.TaskType") ['0: Reload', '1: ExternalProgram', '2: UserSync', '3: Distribute', '4: Preload']
- post(endpoint: str, params: dict = None, headers: dict = None, data=None, silent_status_codes: set = None)[source]
Executes a POST request to the QRS API.
- Parameters:
endpoint (str) – The API endpoint to call.
params (dict, optional) – Query parameters as key-value pairs.
headers (dict, optional) – Additional header parameters.
data (dict or str, optional) – The JSON payload to include in the request body.
silent_status_codes (set, optional) – HTTP status codes that are expected for this call and should be logged at DEBUG instead of ERROR when they occur (see _request for details).
- Returns:
JSON response as a dictionary or None if an error occurs.
- Return type:
dict
- put(endpoint: str, params: dict = None, headers: dict = None, data=None, silent_status_codes: set = None)[source]
Executes a PUT request to the QRS API.
- Parameters:
endpoint (str) – The API endpoint to call.
params (dict, optional) – Query parameters as key-value pairs.
headers (dict, optional)
data
payload
silent_status_codes (set, optional) – HTTP status codes that are expected for this call and should be logged at DEBUG instead of ERROR when they occur (see _request for details).
- Returns:
JSON response as a dictionary or None if an error occurs.
- Return type:
dict
- reloadtask_create(app_id, task_name, custom_properties=None, tags: list = None, created_date: datetime = None, modified_date: datetime = None, modified_by_user_name: str = None, schema_events: list = None, composite_events: list = None, schema_path: str = None, privileges: list = None, task_type: int = None, enabled: bool = None, task_session_timeout: int = None, max_retries: int = None, is_manually_triggered: bool = None, operational=None, is_partial_reload: bool = None, time_to_live: int = None, preload_nodes=None)[source]
Creates a reload task for a specified app.
- Parameters:
app_id (str) – The ID of the app for which the task is created.
task_name (str) – The name of the reload task to create.
custom_properties (dict, optional) – Dictionary of custom property IDs and their values.
tags (list, optional) – List of tag IDs to associate with the task.
schema_events (list, optional) – List of schema events to schedule the task.
composite_events (list, optional) – List of composite events to schedule the task.
schema_path (str, optional) – Schema path.
privileges (list, optional) – Privileges.
task_type (int, optional) – Task type. Default value is 0.
enabled (bool, optional) – True, if the task is active. Default value is True.
- Returns:
JSON response from the API or None if an error occurs.
- Return type:
dict