qe-api-client 1.2.0__py3-none-any.whl → 2.0.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.
- qe_api_client/api_classes/__init__.py +0 -0
- qe_api_client/{engine_app_api.py → api_classes/engine_app_api.py} +247 -327
- qe_api_client/api_classes/engine_field_api.py +127 -0
- qe_api_client/api_classes/engine_generic_dimension_api.py +38 -0
- qe_api_client/api_classes/engine_generic_measure_api.py +37 -0
- qe_api_client/api_classes/engine_generic_object_api.py +163 -0
- qe_api_client/api_classes/engine_generic_variable_api.py +56 -0
- qe_api_client/{engine_global_api.py → api_classes/engine_global_api.py} +286 -134
- qe_api_client/engine.py +189 -40
- qe_api_client/engine_helper.py +8 -8
- qe_api_client/structs.py +72 -98
- {qe_api_client-1.2.0.dist-info → qe_api_client-2.0.0.dist-info}/METADATA +26 -6
- qe_api_client-2.0.0.dist-info/RECORD +18 -0
- {qe_api_client-1.2.0.dist-info → qe_api_client-2.0.0.dist-info}/WHEEL +1 -1
- qe_api_client/engine_field_api.py +0 -81
- qe_api_client/engine_generic_dimension_api.py +0 -16
- qe_api_client/engine_generic_measure_api.py +0 -15
- qe_api_client/engine_generic_object_api.py +0 -101
- qe_api_client/engine_generic_variable_api.py +0 -24
- qe_api_client-1.2.0.dist-info/RECORD +0 -17
- {qe_api_client-1.2.0.dist-info → qe_api_client-2.0.0.dist-info}/LICENSE +0 -0
- {qe_api_client-1.2.0.dist-info → qe_api_client-2.0.0.dist-info}/top_level.txt +0 -0
qe_api_client/engine.py
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
import qe_api_client.engine_app_api as engine_app_api
|
1
|
+
import qe_api_client.api_classes.engine_app_api as engine_app_api
|
2
2
|
import qe_api_client.engine_communicator as engine_communicator
|
3
|
-
import qe_api_client.engine_field_api as engine_field_api
|
4
|
-
import qe_api_client.engine_generic_object_api as engine_generic_object_api
|
5
|
-
import qe_api_client.engine_global_api as engine_global_api
|
6
|
-
import qe_api_client.engine_generic_variable_api as engine_generic_variable_api
|
7
|
-
import qe_api_client.engine_generic_dimension_api as engine_generic_dimension_api
|
8
|
-
import qe_api_client.engine_generic_measure_api as engine_generic_measure_api
|
3
|
+
import qe_api_client.api_classes.engine_field_api as engine_field_api
|
4
|
+
import qe_api_client.api_classes.engine_generic_object_api as engine_generic_object_api
|
5
|
+
import qe_api_client.api_classes.engine_global_api as engine_global_api
|
6
|
+
import qe_api_client.api_classes.engine_generic_variable_api as engine_generic_variable_api
|
7
|
+
import qe_api_client.api_classes.engine_generic_dimension_api as engine_generic_dimension_api
|
8
|
+
import qe_api_client.api_classes.engine_generic_measure_api as engine_generic_measure_api
|
9
9
|
import qe_api_client.structs as structs
|
10
|
+
import math
|
11
|
+
import pandas as pd
|
10
12
|
|
11
13
|
|
12
14
|
class QixEngine:
|
@@ -28,7 +30,7 @@ class QixEngine:
|
|
28
30
|
self.egva = engine_generic_variable_api.EngineGenericVariableApi(self.conn)
|
29
31
|
self.egda = engine_generic_dimension_api.EngineGenericDimensionApi(self.conn)
|
30
32
|
self.egma = engine_generic_measure_api.EngineGenericMeasureApi(self.conn)
|
31
|
-
self.
|
33
|
+
self.structs = structs
|
32
34
|
self.app_handle = ''
|
33
35
|
|
34
36
|
def create_app(self, app_name='my_app'):
|
@@ -47,27 +49,23 @@ class QixEngine:
|
|
47
49
|
self.app_handle = self.ega.get_handle(opened_app)
|
48
50
|
return opened_app['qGenericId']
|
49
51
|
|
50
|
-
def create_hypercube(self, list_of_dimensions=[],
|
51
|
-
list_of_measures=[], rows_to_return=1000):
|
52
|
+
def create_hypercube(self, doc_handle, list_of_dimensions=[], list_of_measures=[], rows_to_return=1000):
|
52
53
|
no_of_columns = len(list_of_dimensions) + len(list_of_measures)
|
53
54
|
hc_dim = []
|
54
55
|
for d in list_of_dimensions:
|
55
|
-
hc_inline_dim = self.
|
56
|
-
hc_dim.append(self.
|
56
|
+
hc_inline_dim = self.structs.nx_inline_dimension_def([d])
|
57
|
+
hc_dim.append(self.structs.nx_hypercube_dimensions(hc_inline_dim))
|
57
58
|
hc_mes = []
|
58
59
|
for m in list_of_measures:
|
59
|
-
hc_mes_sort = self.
|
60
|
-
hc_inline_mes = self.
|
61
|
-
hc_mes.append(self.
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
self.egoa.get_layout(hc_handle)
|
69
|
-
hc_data = self.egoa.get_hypercube_data(hc_handle, "/qHyperCubeDef",
|
70
|
-
[nx_page])
|
60
|
+
hc_mes_sort = self.structs.nx_sort_by()
|
61
|
+
hc_inline_mes = self.structs.nx_inline_measure_def(m)
|
62
|
+
hc_mes.append(self.structs.nx_hypercube_measure(hc_mes_sort, hc_inline_mes))
|
63
|
+
nx_page = self.structs.nx_page(0, 0, no_of_columns, rows_to_return)
|
64
|
+
hc_def = self.structs.hypercube_def("$", hc_dim, hc_mes, [nx_page])
|
65
|
+
hc_response = self.eaa.create_object(doc_handle, "CH01", "Chart", "qHyperCubeDef", hc_def)
|
66
|
+
hc_handle = self.ega.get_handle(hc_response)
|
67
|
+
# self.egoa.get_layout(hc_handle)
|
68
|
+
hc_data = self.egoa.get_hypercube_data(hc_handle, "/qHyperCubeDef", [nx_page])
|
71
69
|
no_of_columns = len(list_of_dimensions)+len(list_of_measures)
|
72
70
|
return hc_data, no_of_columns
|
73
71
|
|
@@ -97,7 +95,7 @@ class QixEngine:
|
|
97
95
|
|
98
96
|
def select_in_dimension(self, dimension_name, list_of_values):
|
99
97
|
lb_field = self.eaa.get_field(self.app_handle, dimension_name)
|
100
|
-
fld_handle = self.ega.get_handle(lb_field
|
98
|
+
fld_handle = self.ega.get_handle(lb_field)
|
101
99
|
values_to_select = []
|
102
100
|
for val in list_of_values:
|
103
101
|
val = {'qText': val}
|
@@ -106,12 +104,12 @@ class QixEngine:
|
|
106
104
|
|
107
105
|
def select_excluded_in_dimension(self, dimension_name):
|
108
106
|
lb_field = self.eaa.get_field(self.app_handle, dimension_name)
|
109
|
-
fld_handle = self.ega.get_handle(lb_field
|
107
|
+
fld_handle = self.ega.get_handle(lb_field)
|
110
108
|
return self.efa.select_excluded(fld_handle)
|
111
109
|
|
112
110
|
def select_possible_in_dimension(self, dimension_name):
|
113
111
|
lb_field = self.eaa.get_field(self.app_handle, dimension_name)
|
114
|
-
fld_handle = self.ega.get_handle(lb_field
|
112
|
+
fld_handle = self.ega.get_handle(lb_field)
|
115
113
|
return self.efa.select_possible(fld_handle)
|
116
114
|
|
117
115
|
# return a list of tuples where first value in tuple is the actual
|
@@ -119,18 +117,12 @@ class QixEngine:
|
|
119
117
|
# values selection state
|
120
118
|
def get_list_object_data(self, dimension_name):
|
121
119
|
lb_field = self.eaa.get_field(self.app_handle, dimension_name)
|
122
|
-
fld_handle = self.ega.get_handle(lb_field
|
123
|
-
nx_page = self.
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
[dimension_name],
|
129
|
-
None, None, [nx_page]
|
130
|
-
)
|
131
|
-
lb_param = {"qInfo": {"qId": "SLB01", "qType": "ListObject"},
|
132
|
-
"qListObjectDef": lb_def}
|
133
|
-
listobj_handle = self.eaa.create_session_object(self.app_handle, lb_param)["qReturn"]["qHandle"] # NOQA
|
120
|
+
fld_handle = self.ega.get_handle(lb_field)
|
121
|
+
nx_page = self.structs.nx_page(0, 0, self.efa.get_cardinal(fld_handle)["qReturn"])
|
122
|
+
lb_def = self.structs.list_object_def("$", "",[dimension_name], None,
|
123
|
+
None, [nx_page])
|
124
|
+
lb_param = {"qInfo": {"qId": "SLB01", "qType": "ListObject"}, "qListObjectDef": lb_def}
|
125
|
+
listobj_handle = self.eaa.create_session_object(self.app_handle, lb_param)["qHandle"] # NOQA
|
134
126
|
val_list = self.egoa.get_layout(listobj_handle)["qListObject"]["qDataPages"][0]["qMatrix"] # NOQA
|
135
127
|
val_n_state_list = []
|
136
128
|
for val in val_list:
|
@@ -139,7 +131,7 @@ class QixEngine:
|
|
139
131
|
|
140
132
|
def clear_selection_in_dimension(self, dimension_name):
|
141
133
|
lb_field = self.eaa.get_field(self.app_handle, dimension_name)
|
142
|
-
fld_handle = self.ega.get_handle(lb_field
|
134
|
+
fld_handle = self.ega.get_handle(lb_field)
|
143
135
|
return self.efa.clear(fld_handle)['qReturn']
|
144
136
|
|
145
137
|
def clear_all_selections(self):
|
@@ -150,3 +142,160 @@ class QixEngine:
|
|
150
142
|
|
151
143
|
def disconnect(self):
|
152
144
|
self.conn.close_qvengine_connection(self.conn)
|
145
|
+
|
146
|
+
@staticmethod
|
147
|
+
def get_handle(obj):
|
148
|
+
"""
|
149
|
+
Retrieves the handle from a given object.
|
150
|
+
|
151
|
+
Parameters:
|
152
|
+
obj : dict
|
153
|
+
The object containing the handle.
|
154
|
+
|
155
|
+
Returns:
|
156
|
+
int: The handle value.
|
157
|
+
|
158
|
+
Raises:
|
159
|
+
ValueError: If the handle value is invalid.
|
160
|
+
"""
|
161
|
+
try:
|
162
|
+
return obj["qHandle"]
|
163
|
+
except ValueError:
|
164
|
+
return "Bad handle value in " + obj
|
165
|
+
|
166
|
+
def get_chart_data(self, doc_handle, obj_id):
|
167
|
+
"""
|
168
|
+
Retrieves the data from a given chart object.
|
169
|
+
|
170
|
+
Parameters:
|
171
|
+
doc_handle (int): The handle of the app.
|
172
|
+
obj_id (str): The ID of the chart object.
|
173
|
+
|
174
|
+
Returns:
|
175
|
+
int: The handle value.
|
176
|
+
|
177
|
+
Raises:
|
178
|
+
ValueError: If the handle value is invalid.
|
179
|
+
"""
|
180
|
+
|
181
|
+
# Get object ID
|
182
|
+
obj = self.eaa.get_object(doc_handle, obj_id)
|
183
|
+
if obj['qType'] is None:
|
184
|
+
return 'Chart ID does not exists!'
|
185
|
+
|
186
|
+
|
187
|
+
# Get object handle
|
188
|
+
obj_handle = self.get_handle(obj)
|
189
|
+
# Get object layout
|
190
|
+
obj_layout = self.egoa.get_layout(obj_handle)
|
191
|
+
|
192
|
+
# Determine the number of the columns and the rows the table has and splits in certain circumstances the table
|
193
|
+
# calls
|
194
|
+
no_of_columns = obj_layout['qHyperCube']['qSize']['qcx']
|
195
|
+
width = no_of_columns
|
196
|
+
no_of_rows = obj_layout['qHyperCube']['qSize']['qcy']
|
197
|
+
height = int(math.floor(10000 / no_of_columns))
|
198
|
+
|
199
|
+
# Extract the dimension and measure titles and concat them to column names.
|
200
|
+
dimension_titles = [dim['qFallbackTitle'] for dim in obj_layout['qHyperCube']['qDimensionInfo']]
|
201
|
+
measure_titles = [measure['qFallbackTitle'] for measure in obj_layout['qHyperCube']['qMeasureInfo']]
|
202
|
+
column_names = dimension_titles + measure_titles
|
203
|
+
|
204
|
+
# if the type of the charts has a straight data structure
|
205
|
+
if (obj_layout['qInfo']['qType'] in ['table', 'sn-table', 'piechart', 'scatterplot', 'combochart', 'barchart']
|
206
|
+
and obj_layout['qHyperCube']['qDataPages'] != []):
|
207
|
+
|
208
|
+
# Paging variables
|
209
|
+
page = 0
|
210
|
+
data_values = []
|
211
|
+
|
212
|
+
# Retrieves the hypercube data in a loop (because of limitation from 10.000 cells per call)
|
213
|
+
while no_of_rows > page * height:
|
214
|
+
nx_page = self.structs.nx_page(0, page * height, width, height)
|
215
|
+
hc_data = self.egoa.get_hypercube_data(obj_handle, '/qHyperCubeDef', [nx_page])[
|
216
|
+
'qDataPages'][0]['qMatrix']
|
217
|
+
data_values.extend(hc_data)
|
218
|
+
page += 1
|
219
|
+
|
220
|
+
# Creates Dataframe from the content of the attribute 'qText'.
|
221
|
+
df = pd.DataFrame([[d['qText'] for d in sublist] for sublist in data_values])
|
222
|
+
|
223
|
+
# Assign titles zu Dataframe columns
|
224
|
+
df.columns = column_names
|
225
|
+
|
226
|
+
# if the type of the charts has a pivot data structure
|
227
|
+
elif (obj_layout['qInfo']['qType'] in ['pivot-table', 'sn-pivot-table']
|
228
|
+
and obj_layout['qHyperCube']['qPivotDataPages'] != []):
|
229
|
+
|
230
|
+
# Supporting function to traverse all subnodes to get all dimensions
|
231
|
+
def get_all_dimensions(node):
|
232
|
+
dimensions = [node['qText']]
|
233
|
+
# if 'qSubNodes' in node and node['qSubNodes']:
|
234
|
+
if node['qSubNodes']:
|
235
|
+
sub_dimensions = []
|
236
|
+
for sub_node in node['qSubNodes']:
|
237
|
+
sub_dimensions.extend([dimensions + d for d in get_all_dimensions(sub_node)])
|
238
|
+
return sub_dimensions
|
239
|
+
else:
|
240
|
+
return [dimensions]
|
241
|
+
|
242
|
+
# Gets the column headers for the pivot table
|
243
|
+
col_headers = []
|
244
|
+
nx_page_top = self.structs.nx_page(0, 0, width, 1)
|
245
|
+
hc_top = self.egoa.get_hypercube_pivot_data(obj_handle, '/qHyperCubeDef', [nx_page_top])[
|
246
|
+
'qDataPages'][0]['qTop']
|
247
|
+
for top_node in hc_top:
|
248
|
+
col_headers.extend(get_all_dimensions(top_node))
|
249
|
+
|
250
|
+
# Paging variables
|
251
|
+
page = 0
|
252
|
+
row_headers = []
|
253
|
+
data_values = []
|
254
|
+
|
255
|
+
# Retrieves the hypercube data in a loop (bacause of limitation from 10.000 cells per call)
|
256
|
+
while no_of_rows > page * height:
|
257
|
+
nx_page = self.structs.nx_page(0, page * height, width, height)
|
258
|
+
|
259
|
+
# Retrieves the row headers for the pivot table
|
260
|
+
hc_left = self.egoa.get_hypercube_pivot_data(obj_handle, '/qHyperCubeDef', [nx_page])[
|
261
|
+
'qDataPages'][0]['qLeft']
|
262
|
+
for left_node in hc_left:
|
263
|
+
row_headers.extend(get_all_dimensions(left_node))
|
264
|
+
|
265
|
+
# Retrieves the data for the pivot table
|
266
|
+
hc_data = self.egoa.get_hypercube_pivot_data(obj_handle, '/qHyperCubeDef', [nx_page])[
|
267
|
+
'qDataPages'][0]['qData']
|
268
|
+
for row in hc_data:
|
269
|
+
data_values.append([cell['qText'] for cell in row])
|
270
|
+
|
271
|
+
page += 1
|
272
|
+
|
273
|
+
# Creates multi indes for rows and columns
|
274
|
+
row_index = pd.MultiIndex.from_tuples(row_headers)
|
275
|
+
col_index = pd.MultiIndex.from_tuples(col_headers)
|
276
|
+
|
277
|
+
# Creates the Dataframe
|
278
|
+
df = pd.DataFrame(data_values, index=row_index, columns=col_index)
|
279
|
+
|
280
|
+
# if the type of the charts has a stacked data structure
|
281
|
+
elif obj_layout['qInfo']['qType'] in ['barchart'] and obj_layout['qHyperCube']['qStackedDataPages'] != []:
|
282
|
+
max_no_cells = no_of_columns * no_of_rows
|
283
|
+
nx_page = self.structs.nx_page(0, 0, no_of_columns, no_of_rows)
|
284
|
+
hc_data = self.egoa.get_hypercube_stack_data(obj_handle, '/qHyperCubeDef', [nx_page],
|
285
|
+
max_no_cells)['qDataPages'][0]['qData'][0]['qSubNodes']
|
286
|
+
|
287
|
+
# Transform the nested structure into a flat DataFrame
|
288
|
+
data_values = []
|
289
|
+
for node in hc_data:
|
290
|
+
for sub_node in node['qSubNodes']:
|
291
|
+
value = sub_node['qSubNodes'][0]['qValue'] if sub_node['qSubNodes'] else None
|
292
|
+
data_values.append([node['qText'], sub_node['qText'], value])
|
293
|
+
|
294
|
+
# Creates the Dataframe
|
295
|
+
df = pd.DataFrame(data_values, columns=column_names)
|
296
|
+
|
297
|
+
else:
|
298
|
+
return 'Chart type not supported.'
|
299
|
+
|
300
|
+
# Returns the Dataframe
|
301
|
+
return df
|
qe_api_client/engine_helper.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import math
|
2
2
|
|
3
|
-
from qe_api_client.engine_app_api import EngineAppApi
|
4
|
-
from qe_api_client.engine_field_api import EngineFieldApi
|
5
|
-
from qe_api_client.engine_generic_object_api import EngineGenericObjectApi
|
6
|
-
from qe_api_client.engine_global_api import EngineGlobalApi
|
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
7
|
from qe_api_client.structs import Structs
|
8
8
|
|
9
9
|
import pandas as pd
|
@@ -26,12 +26,12 @@ def getDataFrame(connection, appHandle, measures, dimensions, selections={}):
|
|
26
26
|
|
27
27
|
width = len(measures) + len(dimensions)
|
28
28
|
height = int(math.floor(10000 / width))
|
29
|
-
nx_page = Structs.nx_page(0, 0,
|
30
|
-
hc_def = Structs.hypercube_def("$", hc_dim, hc_mes, [nx_page])
|
29
|
+
nx_page = Structs.nx_page(0, 0, width, height)
|
30
|
+
hc_def = Structs.hypercube_def("$", [hc_dim], [hc_mes], [nx_page])
|
31
31
|
|
32
32
|
engineAppApi = EngineAppApi(connection)
|
33
33
|
hc_response = engineAppApi.create_object(appHandle, "CH01", "Chart", "qHyperCubeDef", hc_def) # NOQA
|
34
|
-
hc_handle = engineGlobalApi.get_handle(hc_response)
|
34
|
+
hc_handle = engineGlobalApi.get_handle(hc_response['qReturn'])
|
35
35
|
|
36
36
|
engineGenericObjectApi = EngineGenericObjectApi(connection)
|
37
37
|
|
@@ -47,7 +47,7 @@ def getDataFrame(connection, appHandle, measures, dimensions, selections={}):
|
|
47
47
|
|
48
48
|
i = 0
|
49
49
|
while i % height == 0:
|
50
|
-
nx_page = Structs.nx_page(i,
|
50
|
+
nx_page = Structs.nx_page(0, i, width, height)
|
51
51
|
hc_data = engineGenericObjectApi.get_hypercube_data(hc_handle, "/qHyperCubeDef", [nx_page]) # NOQA
|
52
52
|
elems = hc_data["qDataPages"][0]['qMatrix']
|
53
53
|
|
qe_api_client/structs.py
CHANGED
@@ -1,107 +1,81 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
def list_object_def(state_name="$", library_id="", field_defs=None, field_labels=None, sort_criterias=None,
|
2
|
+
initial_data_fetch=None):
|
3
|
+
if initial_data_fetch is None:
|
4
|
+
initial_data_fetch = []
|
5
|
+
if sort_criterias is None:
|
6
|
+
sort_criterias = []
|
7
|
+
if field_labels is None:
|
8
|
+
field_labels = []
|
9
|
+
if field_defs is None:
|
10
|
+
field_defs = []
|
11
|
+
return {"qStateName": state_name, "qLibraryId": library_id,
|
12
|
+
"qDef": {"qFieldDefs": field_defs, "qFieldLabels": field_labels, "qSortCriterias": sort_criterias},
|
13
|
+
"qInitialDataFetch": initial_data_fetch}
|
4
14
|
|
5
|
-
@staticmethod
|
6
|
-
def list_object_def(state_name="$", library_id="",
|
7
|
-
field_defs=None, field_labels=None,
|
8
|
-
sort_criterias=None, initial_data_fetch=None
|
9
|
-
):
|
10
|
-
if initial_data_fetch is None:
|
11
|
-
initial_data_fetch = []
|
12
|
-
if sort_criterias is None:
|
13
|
-
sort_criterias = []
|
14
|
-
if field_labels is None:
|
15
|
-
field_labels = []
|
16
|
-
if field_defs is None:
|
17
|
-
field_defs = []
|
18
|
-
return {"qStateName": state_name,
|
19
|
-
"qLibraryId": library_id,
|
20
|
-
"qDef": {
|
21
|
-
"qFieldDefs": field_defs,
|
22
|
-
"qFieldLabels": field_labels,
|
23
|
-
"qSortCriterias": sort_criterias
|
24
|
-
},
|
25
|
-
"qInitialDataFetch": initial_data_fetch
|
26
|
-
}
|
27
15
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
"qIndentMode": False,
|
48
|
-
"qCalcCond": "",
|
49
|
-
"qSortbyYValue": 0
|
50
|
-
}
|
16
|
+
def hypercube_def(state_name="$", nx_dims=[], nx_meas=[], nx_page=[], inter_column_sort=[0, 1, 2], suppress_zero=False,
|
17
|
+
suppress_missing=False):
|
18
|
+
return {"qStateName": state_name,
|
19
|
+
"qDimensions": nx_dims, # NxDimensions
|
20
|
+
"qMeasures": nx_meas, # NxMeasure
|
21
|
+
"qInterColumnSortOrder": inter_column_sort,
|
22
|
+
"qSuppressZero": suppress_zero,
|
23
|
+
"qSuppressMissing": suppress_missing,
|
24
|
+
"qInitialDataFetch": nx_page, # NxPage
|
25
|
+
"qMode": 'S',
|
26
|
+
"qNoOfLeftDims": -1,
|
27
|
+
"qAlwaysFullyExpanded": False,
|
28
|
+
"qMaxStackedCells": 5000,
|
29
|
+
"qPopulateMissing": False,
|
30
|
+
"qShowTotalsAbove": False,
|
31
|
+
"qIndentMode": False,
|
32
|
+
"qCalcCond": "",
|
33
|
+
"qSortbyYValue": 0
|
34
|
+
}
|
51
35
|
|
52
|
-
@staticmethod
|
53
|
-
def nx_hypercube_dimensions(dim_def):
|
54
|
-
return {"qLibraryId": "",
|
55
|
-
"qNullSuppression": False,
|
56
|
-
"qDef": dim_def
|
57
|
-
}
|
58
36
|
|
59
|
-
|
60
|
-
|
61
|
-
grouping='N',
|
62
|
-
field_labels=[]
|
63
|
-
):
|
64
|
-
return {"qGrouping": grouping,
|
65
|
-
"qFieldDefs": field_definitions,
|
66
|
-
"qFieldLabels": field_labels
|
67
|
-
}
|
37
|
+
def nx_hypercube_dimensions(dim_def):
|
38
|
+
return {"qLibraryId": "", "qNullSuppression": False, "qDef": dim_def}
|
68
39
|
|
69
|
-
@staticmethod
|
70
|
-
def nx_hypercube_measure(sort_by={}, nx_inline_measures_def=""):
|
71
|
-
return {"qSortBy": sort_by,
|
72
|
-
"qDef": nx_inline_measures_def
|
73
|
-
}
|
74
40
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
"qSortByAscii": ascii,
|
81
|
-
"qSortByLoadOrder": load_order,
|
82
|
-
"qSortByExpression": 0,
|
83
|
-
"qExpression": {
|
84
|
-
"qv": ""
|
85
|
-
}
|
86
|
-
}
|
41
|
+
def nx_inline_dimension_def(field_definitions=[], grouping='N', field_labels=[]):
|
42
|
+
return {"qGrouping": grouping,
|
43
|
+
"qFieldDefs": field_definitions,
|
44
|
+
"qFieldLabels": field_labels
|
45
|
+
}
|
87
46
|
|
88
|
-
@staticmethod
|
89
|
-
def nx_inline_measure_def(definition, label="",
|
90
|
-
description="",
|
91
|
-
tags=[],
|
92
|
-
grouping="N"
|
93
|
-
):
|
94
|
-
return {"qLabel": label,
|
95
|
-
"qDescription": description,
|
96
|
-
"qTags": tags,
|
97
|
-
"qGrouping": grouping,
|
98
|
-
"qDef": definition
|
99
|
-
}
|
100
47
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
48
|
+
def nx_hypercube_measure(sort_by={}, nx_inline_measures_def=""):
|
49
|
+
return {"qSortBy": sort_by,
|
50
|
+
"qDef": nx_inline_measures_def
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
def nx_sort_by(state=0, freq=0, numeric=0, ascii=0, load_order=1):
|
55
|
+
return {"qSortByState": state,
|
56
|
+
"qSortByFrequency": freq,
|
57
|
+
"qSortByNumeric": numeric,
|
58
|
+
"qSortByAscii": ascii,
|
59
|
+
"qSortByLoadOrder": load_order,
|
60
|
+
"qSortByExpression": 0,
|
61
|
+
"qExpression": {
|
62
|
+
"qv": ""
|
107
63
|
}
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
def nx_inline_measure_def(definition, label="",
|
68
|
+
description="",
|
69
|
+
tags=[],
|
70
|
+
grouping="N"
|
71
|
+
):
|
72
|
+
return {"qLabel": label,
|
73
|
+
"qDescription": description,
|
74
|
+
"qTags": tags,
|
75
|
+
"qGrouping": grouping,
|
76
|
+
"qDef": definition
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
def nx_page(left=0, top=0, width=2, height=2):
|
81
|
+
return {"qLeft": left, "qTop": top, "qWidth": width, "qHeight": height}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: qe-api-client
|
3
|
-
Version:
|
3
|
+
Version: 2.0.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
|
@@ -13,7 +13,7 @@ Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
14
14
|
Requires-Dist: websocket-client >=0.47.0
|
15
15
|
|
16
|
-
#
|
16
|
+
# Qlik Engine API Client
|
17
17
|
|
18
18
|
Python wrapper around [Qlik Engine JSON API](https://help.qlik.com/en-US/sense-developer/February2024/Subsystems/EngineAPI/Content/Sense_EngineAPI/introducing-engine-API.htm)
|
19
19
|
|
@@ -23,10 +23,15 @@ Forked from [jhettler/pyqlikengine](https://github.com/jhettler/pyqlikengine)
|
|
23
23
|
* Python 3.6+
|
24
24
|
* websocket-client>=0.47.0
|
25
25
|
|
26
|
-
##
|
26
|
+
## Installation
|
27
27
|
```bash
|
28
28
|
pip install qe-api-client
|
29
29
|
```
|
30
|
+
|
31
|
+
## Example of usage on Qlik Sense Enterprise Server
|
32
|
+
You need to export the Qlik Sense certificates in PEM format from the Qlik Sense Enterprise server to a local folder in
|
33
|
+
order to authenticate on the server.
|
34
|
+
|
30
35
|
```python
|
31
36
|
from qe_api_client.engine import QixEngine
|
32
37
|
|
@@ -36,10 +41,25 @@ user_id = 'sense'
|
|
36
41
|
ca_certs = 'qlik_certs/qlik-1_root.pem'
|
37
42
|
certfile = 'qlik_certs/qlik-1_client.pem'
|
38
43
|
keyfile = 'qlik_certs/qlik-1_client_key.pem'
|
39
|
-
qixe = QixEngine(url=url, user_directory=user_directory,
|
40
|
-
|
41
|
-
|
44
|
+
qixe = QixEngine(url=url, user_directory=user_directory, user_id=user_id, ca_certs=ca_certs, certfile=certfile,
|
45
|
+
keyfile=keyfile)
|
46
|
+
|
47
|
+
# print all apps in Qlik Server
|
48
|
+
print(qixe.ega.get_doc_list())
|
49
|
+
```
|
50
|
+
|
51
|
+
## Example of usage on Qlik Sense Desktop
|
52
|
+
You need to start your Qlik Sense Desktop client on your local PC.
|
53
|
+
|
54
|
+
```python
|
55
|
+
from qe_api_client.engine import QixEngine
|
56
|
+
|
57
|
+
url = 'ws://localhost:4848/app'
|
58
|
+
qixe = QixEngine(url=url)
|
42
59
|
|
43
60
|
# print all apps in Qlik Server
|
44
61
|
print(qixe.ega.get_doc_list())
|
45
62
|
```
|
63
|
+
|
64
|
+
## API reference
|
65
|
+
Please click on this [link](https://lr-bicc.github.io/qe-api-client) for full API reference documentation .
|
@@ -0,0 +1,18 @@
|
|
1
|
+
qe_api_client/__init__.py,sha256=bypB4CIjpHtf5Pu_NwtJajC69zqQD7qB9jo8cCX0B54,23
|
2
|
+
qe_api_client/engine.py,sha256=jG4YYLI_CJChimp76wJamgChJ-55YDMisKzmuRbPrew,13589
|
3
|
+
qe_api_client/engine_communicator.py,sha256=Va8Kz4cN6uyKLzV3JllBw08KbU4uDn8e-5pIm5Kmsfs,1291
|
4
|
+
qe_api_client/engine_helper.py,sha256=PU29TYs3V9yF54_IWTHD4O2qSSW-bcaayqH1LCsGFOc,2400
|
5
|
+
qe_api_client/structs.py,sha256=vswDRzkH8YEG0v6GuFl6hXEnRaWkQzvnTBU1T_e1vkk,2813
|
6
|
+
qe_api_client/api_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
qe_api_client/api_classes/engine_app_api.py,sha256=UtlB_ctSDZYMMiGmpiAU9jIyUPM4f2ybyK5i3bHpRRs,38423
|
8
|
+
qe_api_client/api_classes/engine_field_api.py,sha256=KiFhs2ev3S-92JklWzIVtfTEZ1oCiHEAanm1AXtV38s,4407
|
9
|
+
qe_api_client/api_classes/engine_generic_dimension_api.py,sha256=1joTET6GWCTW-80wafrajLQuMyFwIPp0QKoILyLdP1U,1377
|
10
|
+
qe_api_client/api_classes/engine_generic_measure_api.py,sha256=zbRYRA99LQS9SY3QVgoUABqgVDRPwBQ8o2ZbESVEsHE,1321
|
11
|
+
qe_api_client/api_classes/engine_generic_object_api.py,sha256=5pKcbti1tJSKLuacw-nXKMDXH-MlCNr12BoeE40F0OE,7311
|
12
|
+
qe_api_client/api_classes/engine_generic_variable_api.py,sha256=sWXZpE-GLfcMijmfORnDNrJ6lmXX3x5TRHlkEu_i0BQ,2027
|
13
|
+
qe_api_client/api_classes/engine_global_api.py,sha256=SdzhIP6Isco83xB1Y6y3LHKv-HjBTS_iMh-QdVYAl4g,27499
|
14
|
+
qe_api_client-2.0.0.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
15
|
+
qe_api_client-2.0.0.dist-info/METADATA,sha256=OxDu8jkrUtxmLTUxYH-qBUNYdhTS46CpWPqAysK_CFM,1995
|
16
|
+
qe_api_client-2.0.0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
17
|
+
qe_api_client-2.0.0.dist-info/top_level.txt,sha256=m_43YagP8UtZgJHmZEfu0vlBNwt36M01-Qby2jByMnk,14
|
18
|
+
qe_api_client-2.0.0.dist-info/RECORD,,
|