qe-api-client 2.2.0__py3-none-any.whl → 2.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,7 +79,7 @@ class EngineAppApi:
79
79
  except KeyError:
80
80
  return response['error']
81
81
 
82
- def do_reload_ex(self, doc_handle, param_list=[]):
82
+ def do_reload_ex(self, doc_handle, param_list={}):
83
83
  """
84
84
  Triggers an extended reload of the app identified by the document handle.
85
85
 
@@ -91,10 +91,10 @@ class EngineAppApi:
91
91
  dict: The result of the extended reload operation. In case of an error, returns the error information.
92
92
  """
93
93
  msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DoReloadEx",
94
- "params": param_list})
94
+ "params": {"qParams": param_list}})
95
95
  response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
96
96
  try:
97
- return response['result']
97
+ return response["result"]["qResult"]
98
98
  except KeyError:
99
99
  return response['error']
100
100
 
@@ -435,8 +435,9 @@ class EngineAppApi:
435
435
 
436
436
  # DoSave method: Saves an app - All objects and data in the data model are saved. # NOQA
437
437
  # Desktop only - server auto saves
438
- def do_save(self, doc_handle):
439
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DoSave", "params": []})
438
+ def do_save(self, doc_handle, file_name=""):
439
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DoSave",
440
+ "params": {"qFileName": file_name}})
440
441
  response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
441
442
  try:
442
443
  return response['result']
@@ -666,7 +667,17 @@ class EngineAppApi:
666
667
 
667
668
  # GetAllInfos method: Get the identifier and the type of any generic object in an app by using the GetAllInfos method. # NOQA
668
669
  def get_lineage(self, doc_handle):
669
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetLineage", "params": []})
670
+ """
671
+ Gets the lineage information of the app. The lineage information includes the LOAD and STORE statements from
672
+ the data load script associated with this app.
673
+
674
+ Parameters:
675
+ doc_handle (int): The handle identifying the app document.
676
+
677
+ Returns:
678
+ list: Information about the lineage of the data in the app.
679
+ """
680
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetLineage", "params": {}})
670
681
  response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
671
682
  try:
672
683
  return response['result']['qLineage']
@@ -697,5 +708,24 @@ class EngineAppApi:
697
708
  response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
698
709
  try:
699
710
  return response['result']
711
+ except KeyError:
712
+ return response['error']
713
+
714
+ def get_variable_by_id(self, doc_handle, variable_id):
715
+ """
716
+ Gets the handle of a variable.
717
+
718
+ Parameters:
719
+ doc_handle (int): The handle identifying the document.
720
+ variable_id (str): The id of the variable.
721
+
722
+ Returns:
723
+ dict: The handle of the generic variable.
724
+ """
725
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetVariableById",
726
+ "params": {"qId": variable_id}})
727
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
728
+ try:
729
+ return response['result']['qReturn']
700
730
  except KeyError:
701
731
  return response['error']
qe_api_client/engine.py CHANGED
@@ -90,12 +90,62 @@ class QixEngine:
90
90
  return self.efa.clear(fld_handle)
91
91
 
92
92
  def create_single_master_dimension(self, app_handle, dim_title, dim_def, dim_label):
93
+ """
94
+ Creates a single master dimension.
95
+
96
+ Parameters:
97
+ app_handle (int): The handle of the app.
98
+ dim_title (str): The title of the dimension.
99
+ dim_def (str): The definition of the dimension.
100
+ dim_label (str): The label of the dimension.
101
+
102
+ Returns:
103
+ dict: The handle and Id of the dimension.
104
+ """
93
105
  nx_info = self.structs.nx_info("dimension")
94
106
  lb_dim_def = self.structs.nx_library_dimension_def("N",[dim_def],[""],dim_label)
95
107
  gen_dim_props = self.structs.generic_dimension_properties(nx_info, lb_dim_def, dim_title)
96
108
  master_dim = self.eaa.create_dimension(app_handle, gen_dim_props)
97
109
  return master_dim
98
110
 
111
+ def create_master_measure(self, app_handle, mes_title, mes_def, mes_label):
112
+ """
113
+ Creates a master measure.
114
+
115
+ Parameters:
116
+ app_handle (int): The handle of the app.
117
+ mes_title (str): The title of the measure.
118
+ mes_def (str): The definition of the measure.
119
+ mes_label (str): The label of the measure.
120
+
121
+ Returns:
122
+ dict: The handle and Id of the measure.
123
+ """
124
+ nx_info = self.structs.nx_info("measure")
125
+ lb_mes_def = self.structs.nx_inline_measure_def(mes_def,mes_label)
126
+ gen_mes_props = self.structs.generic_measure_properties(nx_info, lb_mes_def, mes_title)
127
+ master_mes = self.eaa.create_measure(app_handle, gen_mes_props)
128
+ return master_mes
129
+
130
+ def get_app_lineage_info(self, app_handle):
131
+ """
132
+ Gets the lineage information of the app. The lineage information includes the LOAD and STORE statements from
133
+ the data load script associated with this app.
134
+
135
+ Parameters:
136
+ app_handle (int): The handle of the app.
137
+
138
+ Returns:
139
+ DataFrame: Information about the lineage of the data in the app.
140
+ """
141
+ # Lineage-Daten aus der API holen
142
+ lineage_info = self.eaa.get_lineage(app_handle)
143
+
144
+ # Erstelle den DataFrame und fülle fehlende Werte mit ""
145
+ df_lineage_info = pd.DataFrame(lineage_info)
146
+ df_lineage_info = df_lineage_info[(df_lineage_info["qDiscriminator"].notna()) | (df_lineage_info["qStatement"].notna())].fillna("")
147
+ return df_lineage_info
148
+
99
149
  def disconnect(self):
100
150
  self.conn.close_qvengine_connection(self.conn)
101
151
 
@@ -22,21 +22,12 @@ class EngineCommunicator:
22
22
 
23
23
  class SecureEngineCommunicator(EngineCommunicator):
24
24
 
25
- def __init__(self, url, user_directory,
26
- user_id, ca_certs, certfile,
27
- keyfile, app_id=None
28
- ):
25
+ def __init__(self, url, user_directory, user_id, ca_certs, certfile, keyfile, app_id=None):
29
26
  self.url = "wss://" + url + ":4747/app/" + str(app_id)
30
- certs = ({"ca_certs": ca_certs,
31
- "certfile": certfile,
32
- "keyfile": keyfile,
33
- "cert_reqs": ssl.CERT_NONE,
34
- "server_side": False
35
- })
27
+ certs = ({"ca_certs": ca_certs, "certfile": certfile, "keyfile": keyfile, "cert_reqs": ssl.CERT_NONE,
28
+ "server_side": False})
36
29
 
37
30
  ssl.match_hostname = lambda cert, hostname: True
38
31
  header = f'X-Qlik-User: UserDirectory={user_directory}; UserId={user_id}' # NOQA
39
- self.ws = create_connection(
40
- self.url, sslopt=certs,
41
- cookie=None, header={header})
32
+ self.ws = create_connection(self.url, sslopt=certs, cookie=None, header={header})
42
33
  self.session = self.ws.recv()
qe_api_client/structs.py CHANGED
@@ -66,4 +66,13 @@ def num_format(type="U", n_dec=10, use_thou=0, fmt="", dec="", thou=""):
66
66
  return {"qType": type, "qnDec": n_dec, "qUseThou": use_thou, "qFmt": fmt, "qDec": dec, "qThou": thou}
67
67
 
68
68
  def generic_measure_properties(info, lb_meas_def, meas_title):
69
- return {"qInfo": info, "qMeasure": lb_meas_def, "qMetaDef": {"title": meas_title}}
69
+ return {"qInfo": info, "qMeasure": lb_meas_def, "qMetaDef": {"title": meas_title}}
70
+
71
+ def do_reload_ex_params(mode=0, partial=False, debug=False, reload_id="", skip_store=False, row_limit=0):
72
+ return {"qMode": mode, "qPartial": partial, "qDebug": debug, "qReloadId": reload_id, "qSkipStore": skip_store,
73
+ "qRowLimit": row_limit}
74
+
75
+ def dimension_list_def():
76
+ return {"qInfo": {"qType": "DimensionList"},
77
+ "qDimensionListDef": {"qType": "dimension",
78
+ "qData": {"title": "/title", "tags": "/tags", "grouping": "/qDim/qGrouping", "info": "/qDimInfos"}}}
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: qe-api-client
3
- Version: 2.2.0
3
+ Version: 2.4.0
4
4
  Summary: Python wrapper around Qlik Engine JSON API
5
5
  Home-page: https://github.com/lr-bicc/qe-api-client
6
6
  Author: Rumen Vasilev
@@ -11,7 +11,17 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.6
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: websocket-client >=0.47.0
14
+ Requires-Dist: websocket-client>=0.47.0
15
+ Requires-Dist: pandas>=2.2.0
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
15
25
 
16
26
  # Qlik Engine API Client
17
27
 
@@ -28,7 +38,7 @@ Forked from [jhettler/pyqlikengine](https://github.com/jhettler/pyqlikengine)
28
38
  pip install qe-api-client
29
39
  ```
30
40
 
31
- ## Example of usage on Qlik Sense Enterprise Server
41
+ ## Connecting to Qlik Sense Enterprise Server
32
42
  You need to export the Qlik Sense certificates in PEM format from the Qlik Sense Enterprise server to a local folder in
33
43
  order to authenticate on the server.
34
44
 
@@ -48,7 +58,7 @@ qixe = QixEngine(url=url, user_directory=user_directory, user_id=user_id, ca_cer
48
58
  print(qixe.ega.get_doc_list())
49
59
  ```
50
60
 
51
- ## Example of usage on Qlik Sense Desktop
61
+ ## Connecting to Qlik Sense Desktop
52
62
  You need to start your Qlik Sense Desktop client on your local PC.
53
63
 
54
64
  ```python
@@ -61,5 +71,8 @@ qixe = QixEngine(url=url)
61
71
  print(qixe.ega.get_doc_list())
62
72
  ```
63
73
 
74
+ ## Examples of usage
75
+ Please click on this [link](https://github.com/lr-bicc/qe-api-client/tree/master/examples) to find examples of usage of this client.
76
+
64
77
  ## API reference
65
78
  Please click on this [link](https://lr-bicc.github.io/qe-api-client) for full API reference documentation .
@@ -1,18 +1,17 @@
1
1
  qe_api_client/__init__.py,sha256=bypB4CIjpHtf5Pu_NwtJajC69zqQD7qB9jo8cCX0B54,23
2
- qe_api_client/engine.py,sha256=zK6FxdsxiFy3-IpZ664gcsoJU9dpTdVm4NWn6zgXa6E,14944
3
- qe_api_client/engine_communicator.py,sha256=Va8Kz4cN6uyKLzV3JllBw08KbU4uDn8e-5pIm5Kmsfs,1291
4
- qe_api_client/engine_helper.py,sha256=DSZR92-pGqklzki53QufgGr9tUTKKXZyF_fHEfXokTs,2382
5
- qe_api_client/structs.py,sha256=9oB8-APCIkt1nNtwRpqGGMvzF42SX2ep5r4zSrLkjL4,3999
2
+ qe_api_client/engine.py,sha256=SCTjKlhtir2kOMNDnfwd1Cz-Su6xxDk79GBUtAMgSpU,16900
3
+ qe_api_client/engine_communicator.py,sha256=q6x7ix2Ev8yGmTTm7cf1vHcidOihKM0HjDXeJ-dZYjk,1133
4
+ qe_api_client/structs.py,sha256=eZw-M9QBhZe_lHxjMcWU5TJVi18G43FhCMMGzjdJxAk,4502
6
5
  qe_api_client/api_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- qe_api_client/api_classes/engine_app_api.py,sha256=3bQHufiKvWHOOKjX50WK7pbH-fM0Rz6WMblEgEjAn2I,36847
6
+ qe_api_client/api_classes/engine_app_api.py,sha256=H0CF-BwSUi1ZpZo7pyQg736jsdKm5biShVcELun9jwY,38021
8
7
  qe_api_client/api_classes/engine_field_api.py,sha256=zCLIR7rmxqwIrJYK_-uHVEhMvBcEP2qofuX8ZPygqCA,5479
9
8
  qe_api_client/api_classes/engine_generic_dimension_api.py,sha256=1joTET6GWCTW-80wafrajLQuMyFwIPp0QKoILyLdP1U,1377
10
9
  qe_api_client/api_classes/engine_generic_measure_api.py,sha256=zbRYRA99LQS9SY3QVgoUABqgVDRPwBQ8o2ZbESVEsHE,1321
11
10
  qe_api_client/api_classes/engine_generic_object_api.py,sha256=nqsEtvKkt5XkUEIVUoBtNVXtmUvuifxrgTcw2fDuaOE,8218
12
11
  qe_api_client/api_classes/engine_generic_variable_api.py,sha256=sWXZpE-GLfcMijmfORnDNrJ6lmXX3x5TRHlkEu_i0BQ,2027
13
12
  qe_api_client/api_classes/engine_global_api.py,sha256=G6QQHI36WOo7W25zg4Uz__gMSLC2ptNTvbBdElPzgZI,27535
14
- qe_api_client-2.2.0.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
15
- qe_api_client-2.2.0.dist-info/METADATA,sha256=ZvtVqTUoNFA_a70UPxJWIjUptydO1Ij42w5Yy_hF8B0,1995
16
- qe_api_client-2.2.0.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
17
- qe_api_client-2.2.0.dist-info/top_level.txt,sha256=m_43YagP8UtZgJHmZEfu0vlBNwt36M01-Qby2jByMnk,14
18
- qe_api_client-2.2.0.dist-info/RECORD,,
13
+ qe_api_client-2.4.0.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
14
+ qe_api_client-2.4.0.dist-info/METADATA,sha256=uXwa8Jwcq9-w4r0o0CbET_lwWPM87WLY1PwxUkJYBNo,2363
15
+ qe_api_client-2.4.0.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
16
+ qe_api_client-2.4.0.dist-info/top_level.txt,sha256=m_43YagP8UtZgJHmZEfu0vlBNwt36M01-Qby2jByMnk,14
17
+ qe_api_client-2.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (75.8.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,67 +0,0 @@
1
- import math
2
-
3
- from qe_api_client.api_classes.engine_app_api import EngineAppApi
4
- from qe_api_client.api_classes.engine_field_api import EngineFieldApi
5
- from qe_api_client.api_classes.engine_generic_object_api import EngineGenericObjectApi
6
- from qe_api_client.api_classes.engine_global_api import EngineGlobalApi
7
- import qe_api_client.structs as structs
8
-
9
- import pandas as pd
10
-
11
-
12
- def getDataFrame(connection, appHandle, measures, dimensions, selections={}):
13
- engineGlobalApi = EngineGlobalApi(connection)
14
- # Define Dimensions of hypercube
15
- hc_inline_dim = structs.nx_inline_dimension_def(dimensions)
16
-
17
- # Set sorting of Dimension by Measure
18
- hc_mes_sort = structs.sort_criteria()
19
-
20
- # Define Measure of hypercube
21
- hc_inline_mes = structs.nx_inline_measure_def(measures)
22
-
23
- # Build hypercube from above definition
24
- hc_dim = structs.nx_dimension(hc_inline_dim)
25
- hc_mes = structs.nx_measure("", hc_inline_mes, hc_mes_sort)
26
-
27
- width = len(measures) + len(dimensions)
28
- height = int(math.floor(10000 / width))
29
- nx_page = structs.nx_page(0, 0, width, height)
30
- hc_def = structs.hypercube_def("$", [hc_dim], [hc_mes], [nx_page])
31
-
32
- engineAppApi = EngineAppApi(connection)
33
- hc_response = engineAppApi.create_object(appHandle, "CH01", "Chart", "qHyperCubeDef", hc_def) # NOQA
34
- hc_handle = engineGlobalApi.get_handle(hc_response['qReturn'])
35
-
36
- engineGenericObjectApi = EngineGenericObjectApi(connection)
37
-
38
- engineFieldApi = EngineFieldApi(connection)
39
-
40
- for field in selections.keys():
41
- fieldHandle = engineGlobalApi.get_handle(engineAppApi.get_field(appHandle, field)) # NOQA
42
- values = []
43
- for selectedValue in selections[field]:
44
- values.append({'qText': selectedValue})
45
-
46
- engineFieldApi.select_values(fieldHandle, values)
47
-
48
- i = 0
49
- while i % height == 0:
50
- nx_page = structs.nx_page(0, i, width, height)
51
- hc_data = engineGenericObjectApi.get_hypercube_data(hc_handle, "/qHyperCubeDef", nx_page) # NOQA
52
- elems = hc_data["qDataPages"][0]['qMatrix']
53
-
54
- df = pd.DataFrame()
55
-
56
- for elem in elems:
57
- j = 0
58
- for dim in dimensions:
59
- df.set_value(i, dim, elem[j]["qText"])
60
- j += 1
61
- for meas in measures:
62
- df.set_value(i, meas, elem[j]["qNum"])
63
- j += 1
64
-
65
- i += 1
66
-
67
- return df