qe-api-client 1.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/__init__.py +1 -0
- qe_api_client/engine.py +145 -0
- qe_api_client/engine_app_api.py +810 -0
- qe_api_client/engine_communicator.py +42 -0
- qe_api_client/engine_field_api.py +81 -0
- qe_api_client/engine_generic_object_api.py +101 -0
- qe_api_client/engine_global_api.py +376 -0
- qe_api_client/engine_helper.py +67 -0
- qe_api_client/structs.py +107 -0
- qe_api_client-1.0.0.dist-info/LICENSE +19 -0
- qe_api_client-1.0.0.dist-info/METADATA +45 -0
- qe_api_client-1.0.0.dist-info/RECORD +14 -0
- qe_api_client-1.0.0.dist-info/WHEEL +5 -0
- qe_api_client-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,810 @@
|
|
1
|
+
import json
|
2
|
+
|
3
|
+
|
4
|
+
class EngineAppApi:
|
5
|
+
|
6
|
+
def __init__(self, socket):
|
7
|
+
self.engine_socket = socket
|
8
|
+
|
9
|
+
def get_script(self, doc_handle):
|
10
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
11
|
+
"method": "GetScript", "params": []})
|
12
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
13
|
+
msg)
|
14
|
+
)
|
15
|
+
try:
|
16
|
+
return response['result']
|
17
|
+
except KeyError:
|
18
|
+
return response['error']
|
19
|
+
|
20
|
+
def set_script(self, doc_handle, script):
|
21
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
22
|
+
"method": "SetScript", "params": [script]})
|
23
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
24
|
+
msg)
|
25
|
+
)
|
26
|
+
try:
|
27
|
+
return response['result']
|
28
|
+
except KeyError:
|
29
|
+
return response['error']
|
30
|
+
|
31
|
+
def do_reload(self, doc_handle, param_list=[]):
|
32
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
33
|
+
"method": "DoReload", "params": param_list})
|
34
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
35
|
+
msg)
|
36
|
+
)
|
37
|
+
try:
|
38
|
+
return response['result']
|
39
|
+
except KeyError:
|
40
|
+
return response['error']
|
41
|
+
|
42
|
+
def do_reload_ex(self, doc_handle, param_list=[]):
|
43
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
44
|
+
"method": "DoReloadEx", "params": param_list})
|
45
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
46
|
+
msg)
|
47
|
+
)
|
48
|
+
try:
|
49
|
+
return response['result']
|
50
|
+
except KeyError:
|
51
|
+
return response['error']
|
52
|
+
|
53
|
+
def get_app_layout(self, doc_handle):
|
54
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
55
|
+
"method": "GetAppLayout", "params": []})
|
56
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
57
|
+
msg)
|
58
|
+
)
|
59
|
+
try:
|
60
|
+
return response['result']
|
61
|
+
except KeyError:
|
62
|
+
return response['error']
|
63
|
+
|
64
|
+
def get_object(self, doc_handle, param_list=[]):
|
65
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
66
|
+
"method": "GetObject", "params": param_list})
|
67
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
68
|
+
msg)
|
69
|
+
)
|
70
|
+
try:
|
71
|
+
return response['result']
|
72
|
+
except KeyError:
|
73
|
+
return response['error']
|
74
|
+
|
75
|
+
def get_field(self, doc_handle, field_name, state_name=""):
|
76
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
77
|
+
"method": "GetField", "params":
|
78
|
+
{"qFieldName": field_name,
|
79
|
+
"qStateName": state_name}
|
80
|
+
})
|
81
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
82
|
+
msg)
|
83
|
+
)
|
84
|
+
try:
|
85
|
+
return response['result']
|
86
|
+
except KeyError:
|
87
|
+
return response['error']
|
88
|
+
|
89
|
+
def create_object(self, doc_handle, q_id="LB01",
|
90
|
+
q_type="ListObject", struct_name="qListObjectDef",
|
91
|
+
ob_struct={}):
|
92
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0,
|
93
|
+
"method": "CreateObject", "handle": doc_handle,
|
94
|
+
"params": [{"qInfo": {"qId": q_id, "qType": q_type},
|
95
|
+
struct_name: ob_struct}]
|
96
|
+
})
|
97
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
98
|
+
msg)
|
99
|
+
)
|
100
|
+
try:
|
101
|
+
return response['result']
|
102
|
+
except KeyError:
|
103
|
+
return response['error']
|
104
|
+
|
105
|
+
# AddAlternateState method: Create an alternate state in app # NOQA
|
106
|
+
# You can create multiple states within a Qlik Sense app and apply these states to specific objects within the app. # NOQA
|
107
|
+
# Objects in a given state are not affected by user selections in the other states. # NOQA
|
108
|
+
# Call GetAppLayout() afterwards to get the latest states
|
109
|
+
def add_alternate_state(self, doc_handle, state_name):
|
110
|
+
msg = json.dumps(
|
111
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
112
|
+
"method": "AddAlternateState", "params": [state_name]})
|
113
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
114
|
+
msg)
|
115
|
+
)
|
116
|
+
try:
|
117
|
+
return response['result']
|
118
|
+
except KeyError:
|
119
|
+
return response['error']
|
120
|
+
|
121
|
+
# AddFieldFromExpression method: Adds a field on the fly. !! The expression of a field on the fly is persisted but # NOQA
|
122
|
+
# not its values. !!
|
123
|
+
def add_field_from_expression(self, doc_handle, field_name, expr_value):
|
124
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
125
|
+
"method": "AddFieldFromExpression",
|
126
|
+
"params": [field_name, expr_value]})
|
127
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
128
|
+
msg)
|
129
|
+
)
|
130
|
+
try:
|
131
|
+
return response['result']
|
132
|
+
except KeyError:
|
133
|
+
return response['error']
|
134
|
+
|
135
|
+
# CheckExpression method: Checks whether an expression is valid or not
|
136
|
+
# qErrorMsg is empty if it's valid
|
137
|
+
def check_expression(self, doc_handle, expr_value):
|
138
|
+
msg = json.dumps(
|
139
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
140
|
+
"method": "CheckExpression", "params": [expr_value]})
|
141
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
142
|
+
msg)
|
143
|
+
)
|
144
|
+
try:
|
145
|
+
return response['result']
|
146
|
+
except KeyError:
|
147
|
+
return response['error']
|
148
|
+
|
149
|
+
# CheckScriptSyntax method: Checks whether a load script is valid or not
|
150
|
+
# Used AFTER doing SetScript method
|
151
|
+
# errors are displayed in an array discussing positions of characters in script where failing # NOQA
|
152
|
+
def check_script(self, doc_handle):
|
153
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
154
|
+
"method": "CheckScriptSyntax",
|
155
|
+
"params": {}})
|
156
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
157
|
+
msg)
|
158
|
+
)
|
159
|
+
try:
|
160
|
+
return response['result']
|
161
|
+
except KeyError:
|
162
|
+
return response['error']
|
163
|
+
|
164
|
+
def clear_all(self, doc_handle, locked_also=False, alt_state=""):
|
165
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
166
|
+
"method": "ClearAll",
|
167
|
+
"params": [locked_also, alt_state]})
|
168
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
169
|
+
msg)
|
170
|
+
)
|
171
|
+
try:
|
172
|
+
return response['result']
|
173
|
+
except KeyError:
|
174
|
+
return response['error']
|
175
|
+
|
176
|
+
# CreateConnection method: Creates a connection. A connection indicates from which data source, the data should # NOQA
|
177
|
+
# be taken. The connection can be: an ODBC connection, OLEDB connection, a custom connection, a folder connection # NOQA
|
178
|
+
# (lib connection), an internet connection, Single Sign-On
|
179
|
+
def create_connection(self, doc_handle, connect_name,
|
180
|
+
connect_string, connect_type, user_name, password,
|
181
|
+
mod_date="", meta="",
|
182
|
+
sso_passthrough="LOG_ON_SERVICE_USER"):
|
183
|
+
msg = json.dumps(
|
184
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
185
|
+
"method": "CreateConnection", "params": [{
|
186
|
+
"qName": connect_name,
|
187
|
+
"qMeta": meta,
|
188
|
+
"qConnectionString": connect_string,
|
189
|
+
"qType": connect_type
|
190
|
+
}]
|
191
|
+
})
|
192
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
193
|
+
msg)
|
194
|
+
)
|
195
|
+
try:
|
196
|
+
return response['result']
|
197
|
+
except KeyError:
|
198
|
+
return response['error']
|
199
|
+
|
200
|
+
# CreateDimension method: Creates a master dimension.
|
201
|
+
# A Master Dimension is stored in the library of an app and can be used in many objects. Several generic objects # NOQA
|
202
|
+
# can contain the same dimension.
|
203
|
+
# Parameters:
|
204
|
+
# qProp (MANDATORY: send dim_id, dim_title, dim_grouping, dim_field, dim_label, meta_def (optional) # NOQA
|
205
|
+
def create_master_dim(self, doc_handle, dim_id, dim_title,
|
206
|
+
dim_grouping="N", dim_field='', dim_label='',
|
207
|
+
meta_def=""):
|
208
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
209
|
+
"method": "CreateDimension", "params": [{
|
210
|
+
"qInfo": {
|
211
|
+
"qId": dim_id,
|
212
|
+
"qType": "Dimension"
|
213
|
+
},
|
214
|
+
"qDim": {
|
215
|
+
"title": dim_title,
|
216
|
+
"qGrouping": dim_grouping,
|
217
|
+
"qFieldDefs": [
|
218
|
+
dim_field
|
219
|
+
],
|
220
|
+
"qFieldLabels": [
|
221
|
+
dim_label
|
222
|
+
]
|
223
|
+
},
|
224
|
+
"qMetaDef": {
|
225
|
+
"title": meta_def
|
226
|
+
}
|
227
|
+
}]
|
228
|
+
})
|
229
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
230
|
+
msg)
|
231
|
+
)
|
232
|
+
try:
|
233
|
+
return response['result']
|
234
|
+
except KeyError:
|
235
|
+
return response['error']
|
236
|
+
|
237
|
+
# DestroyDimension method: Removes a dimension
|
238
|
+
def destroy_dim(self, doc_handle, dim_id):
|
239
|
+
msg = json.dumps(
|
240
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
241
|
+
"method": "DestroyDimension", "params": [{dim_id}]})
|
242
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
243
|
+
msg)
|
244
|
+
)
|
245
|
+
try:
|
246
|
+
return response['result']
|
247
|
+
except KeyError:
|
248
|
+
return response['error']
|
249
|
+
|
250
|
+
# DestroyMeasure method: Removes a measure
|
251
|
+
def destroy_measure(self, doc_handle, measure_id):
|
252
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
253
|
+
"method": "DestroyDimension",
|
254
|
+
"params": [{measure_id}]})
|
255
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
256
|
+
msg)
|
257
|
+
)
|
258
|
+
try:
|
259
|
+
return response['result']
|
260
|
+
except KeyError:
|
261
|
+
return response['error']
|
262
|
+
|
263
|
+
# DestroyObject method: Removes an app object. The children of the object (if any) are removed as well. # NOQA
|
264
|
+
def destroy_object(self, doc_handle, object_id):
|
265
|
+
msg = json.dumps(
|
266
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
267
|
+
"method": "DestroyObject", "params": [{object_id}]})
|
268
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
269
|
+
msg)
|
270
|
+
)
|
271
|
+
try:
|
272
|
+
return response['result']
|
273
|
+
except KeyError:
|
274
|
+
return response['error']
|
275
|
+
|
276
|
+
# DestroySessionObject method: Removes a session object. The children of the object (if any) are removed as well. # NOQA
|
277
|
+
def destroy_session_object(self, doc_handle, object_id):
|
278
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
279
|
+
"method": "DestroySessionObject",
|
280
|
+
"params": [{object_id}]})
|
281
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
282
|
+
msg)
|
283
|
+
)
|
284
|
+
try:
|
285
|
+
return response['result']
|
286
|
+
except KeyError:
|
287
|
+
return response['error']
|
288
|
+
|
289
|
+
# DestroySessionVariable method: Removes an transient variable.
|
290
|
+
def destroy_session_variable(self, doc_handle, var_id):
|
291
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
292
|
+
"method": "DestroySessionVariable",
|
293
|
+
"params": [{var_id}]})
|
294
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
295
|
+
msg)
|
296
|
+
)
|
297
|
+
try:
|
298
|
+
return response['result']
|
299
|
+
except KeyError:
|
300
|
+
return response['error']
|
301
|
+
|
302
|
+
# DestroyVariableById method: Removes a varable..
|
303
|
+
# Script-defined variables cannot be removed using the DestroyVariableById method or the # NOQA
|
304
|
+
# DestroyVariableByName method.
|
305
|
+
def destroy_variable_by_id(self, doc_handle, var_name):
|
306
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
307
|
+
"method": "DestroyVariableById",
|
308
|
+
"params": [{var_name}]})
|
309
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
310
|
+
msg)
|
311
|
+
)
|
312
|
+
try:
|
313
|
+
return response['result']
|
314
|
+
except KeyError:
|
315
|
+
return response['error']
|
316
|
+
|
317
|
+
# CreateMeasure method: Creates a master dimension.
|
318
|
+
# A Master Dimension is stored in the library of an app and can be used in many objects. Several generic objects # NOQA
|
319
|
+
# can contain the same dimension.
|
320
|
+
# Parameters:
|
321
|
+
# qProp (MANDATORY: send dim_id, dim_title, dim_grouping, dim_field, dim_label, meta_def (optional) # NOQA
|
322
|
+
def create_master_measure(self, doc_handle, measure_id,
|
323
|
+
measure_title, measure_expr, meta_def=""):
|
324
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
325
|
+
"method": "CreateMeasure", "params": [{
|
326
|
+
"qInfo": {
|
327
|
+
"qId": measure_id,
|
328
|
+
"qType": "Measure"
|
329
|
+
},
|
330
|
+
"qMeasure": {
|
331
|
+
"qLabel": measure_title,
|
332
|
+
"qDef": measure_expr
|
333
|
+
},
|
334
|
+
"qMetaDef": {
|
335
|
+
"title": measure_title
|
336
|
+
}
|
337
|
+
}]
|
338
|
+
})
|
339
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
340
|
+
msg)
|
341
|
+
)
|
342
|
+
try:
|
343
|
+
return response['result']
|
344
|
+
except KeyError:
|
345
|
+
return response['error']
|
346
|
+
|
347
|
+
# CreateObject method: Creates a generic object at app level. It is possible to create a generic object that is # NOQA
|
348
|
+
# linked to another object. A linked object is an object that points to a linking object. The linking object is # NOQA
|
349
|
+
# defined in the properties of the linked object (in qExtendsId). The linked object has the same properties as the # NOQA
|
350
|
+
# linking object.
|
351
|
+
# TODO: Come back to this - Very important that it is well understood how we want to create objects / datasets from # NOQA
|
352
|
+
# python in app
|
353
|
+
# Convert hypercube to dict or some other data set
|
354
|
+
|
355
|
+
# CreateSession Object method: Creates a generic object at app level. It is possible to create a generic object that is linked to another object. # NOQA
|
356
|
+
# A linked object is an object that points to a linking object. The linking object is defined in the properties of the linked object (in qExtendsId). # NOQA
|
357
|
+
# The linked object has the same properties as the linking object.
|
358
|
+
# TODO: Come back to this - Very important that it is well understood how we want to create objects / datasets from # NOQA
|
359
|
+
# python in app
|
360
|
+
# Convert hypercube to dict or some other data set
|
361
|
+
|
362
|
+
# CreateSessionVariable method:
|
363
|
+
# A variable in Qlik Sense is a named entity, containing a data value. This value can be static or be the result of a calculation. # NOQA
|
364
|
+
# A variable acquires its value at the same time that the variable is created or after when updating the properties of the variable. # NOQA
|
365
|
+
# Variables can be used in bookmarks and can contain numeric or alphanumeric data. # NOQA
|
366
|
+
# Any change made to the variable is applied everywhere the variable is used. # NOQA
|
367
|
+
# When a variable is used in an expression, it is substituted by its value or the variable's definition. # NOQA
|
368
|
+
# ### Example: The variable x contains the text string Sum(Sales). In a chart, you define the expression $(x)/12. # NOQA
|
369
|
+
# The effect is exactly the same as having the chart expression Sum(Sales)/12. However, if you change the value of the variable x to Sum(Budget), # NOQA
|
370
|
+
# the data in the chart are immediately recalculated with the expression interpreted as Sum(Budget)/12. # NOQA
|
371
|
+
def create_session_variable(self, doc_handle, var_id="",
|
372
|
+
var_name="", var_comment="", var_def=""):
|
373
|
+
msg = json.dumps(
|
374
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
375
|
+
"method": "CreateSessionVariable", "params": [{
|
376
|
+
"qInfo": {
|
377
|
+
"qId": var_id,
|
378
|
+
"qType": "Variable"
|
379
|
+
},
|
380
|
+
"qName": var_name,
|
381
|
+
"qComment": var_comment,
|
382
|
+
"qDefinition": var_def
|
383
|
+
}]
|
384
|
+
})
|
385
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
386
|
+
msg)
|
387
|
+
)
|
388
|
+
try:
|
389
|
+
return response['result']
|
390
|
+
except KeyError:
|
391
|
+
return response['error']
|
392
|
+
|
393
|
+
# CreateVariable method:
|
394
|
+
# A variable in Qlik Sense is a named entity, containing a data value. This value can be static or be the result of a calculation. # NOQA
|
395
|
+
# A variable acquires its value at the same time that the variable is created or after when updating the properties of the variable. # NOQA
|
396
|
+
# Variables can be used in bookmarks and can contain numeric or alphanumeric data. # NOQA
|
397
|
+
# Any change made to the variable is applied everywhere the variable is used. # NOQA
|
398
|
+
# When a variable is used in an expression, it is substituted by its value or the variable's definition. # NOQA
|
399
|
+
# ### Example: The variable x contains the text string Sum(Sales). In a chart, you define the expression $(x)/12. # NOQA
|
400
|
+
# The effect is exactly the same as having the chart expression Sum(Sales)/12. # NOQA
|
401
|
+
# However, if you change the value of the variable x to Sum(Budget),
|
402
|
+
# the data in the chart are immediately recalculated with the expression interpreted as Sum(Budget)/12. # NOQA
|
403
|
+
def create_variable(self, doc_handle, var_id="",
|
404
|
+
var_name="", var_comment="", var_def=""):
|
405
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
406
|
+
"method": "CreateVariable", "params": [{
|
407
|
+
"qInfo": {
|
408
|
+
"qId": var_id,
|
409
|
+
"qType": "Variable"
|
410
|
+
},
|
411
|
+
"qName": var_name,
|
412
|
+
"qComment": var_comment,
|
413
|
+
"qDefinition": var_def
|
414
|
+
}]
|
415
|
+
})
|
416
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
417
|
+
msg)
|
418
|
+
)
|
419
|
+
try:
|
420
|
+
return response['result']
|
421
|
+
except KeyError:
|
422
|
+
return response['error']
|
423
|
+
|
424
|
+
# DoReload method: Reloads the script that is set in an app.
|
425
|
+
# Parameters:
|
426
|
+
# qMode (optional): Error handling mode (Integer).. 0: for default mode, # NOQA
|
427
|
+
# 1: for ABEND; the reload of the script ends if an error occurs.,
|
428
|
+
# 2: for ignore; the reload of the script continues even if an error is detected in the script. # NOQA
|
429
|
+
# qPartial (optional): Set to true for partial reload, The default value is false. # NOQA
|
430
|
+
# qDebug (optional): Set to true if debug breakpoints are to be honored. The execution of the script will be in debug mode. The default value is false. # NOQA
|
431
|
+
|
432
|
+
# Original do_reload function
|
433
|
+
# def do_reload(self, doc_handle, reload_mode=0,
|
434
|
+
# partial_mode=False, debug_mode=False):
|
435
|
+
# msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
436
|
+
# "method": "DoReload",
|
437
|
+
# "params": [reload_mode, partial_mode, debug_mode]})
|
438
|
+
# response = json.loads(self.engine_socket.send_call(self.engine_socket, # NOQA
|
439
|
+
# msg)
|
440
|
+
# )
|
441
|
+
# try:
|
442
|
+
# return response['result']
|
443
|
+
# except KeyError:
|
444
|
+
# return response['error']
|
445
|
+
|
446
|
+
# DoSave method: Saves an app - All objects and data in the data model are saved. # NOQA
|
447
|
+
# Desktop only - server auto saves
|
448
|
+
def do_save(self, doc_handle):
|
449
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
450
|
+
"method": "DoSave", "params": []})
|
451
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
452
|
+
msg)
|
453
|
+
)
|
454
|
+
try:
|
455
|
+
return response['result']
|
456
|
+
except KeyError:
|
457
|
+
return response['error']
|
458
|
+
|
459
|
+
# Evaluate method: Evaluates an expression as a string. (Actually uses EvaluateEx, which is better for giving the data type back to python) # NOQA
|
460
|
+
# Parameters: qExpression
|
461
|
+
def expr_eval(self, doc_handle, expr):
|
462
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
463
|
+
"method": "EvaluateEx",
|
464
|
+
"params": {"qExpression": expr}})
|
465
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
466
|
+
msg)
|
467
|
+
)
|
468
|
+
try:
|
469
|
+
return response['result']
|
470
|
+
except KeyError:
|
471
|
+
return response['error']
|
472
|
+
|
473
|
+
# GetAllInfos method: Get the identifier and the type of any generic object in an app by using the GetAllInfos method. # NOQA
|
474
|
+
def get_all_infos(self, doc_handle):
|
475
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
476
|
+
"method": "GetAllInfos", "params": []})
|
477
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
478
|
+
msg)
|
479
|
+
)
|
480
|
+
try:
|
481
|
+
return response['result']
|
482
|
+
except KeyError:
|
483
|
+
return response['error']
|
484
|
+
|
485
|
+
# GetAppProperties method: Gets the properties of an app.
|
486
|
+
def get_app_properties(self, doc_handle):
|
487
|
+
msg = json.dumps(
|
488
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
489
|
+
"method": "GetAppProperties", "params": []})
|
490
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
491
|
+
msg)
|
492
|
+
)
|
493
|
+
try:
|
494
|
+
return response['result']
|
495
|
+
except KeyError:
|
496
|
+
return response['error']
|
497
|
+
|
498
|
+
# GetConnection method: Retrieves a connection and returns: The creation time of the connection, The identifier of # NOQA
|
499
|
+
# the connection, The type of the connection, The name of the connection, The connection string # NOQA
|
500
|
+
def get_connection(self, doc_handle, connection_id):
|
501
|
+
msg = json.dumps(
|
502
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
503
|
+
"method": "GetConnection", "params": [connection_id]})
|
504
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
505
|
+
msg)
|
506
|
+
)
|
507
|
+
try:
|
508
|
+
return response['result']
|
509
|
+
except KeyError:
|
510
|
+
return response['error']
|
511
|
+
|
512
|
+
# GetConnections method: Lists the connections in an app
|
513
|
+
def get_connections(self, doc_handle):
|
514
|
+
msg = json.dumps(
|
515
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
516
|
+
"method": "GetConnections", "params": []})
|
517
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
518
|
+
msg)
|
519
|
+
)
|
520
|
+
try:
|
521
|
+
return response['result']
|
522
|
+
except KeyError:
|
523
|
+
return response['error']
|
524
|
+
|
525
|
+
# GetDatabaseInfo: Get information about an ODBC, OLEDB or CUSTOM connection # NOQA
|
526
|
+
def get_db_info(self, doc_handle, connection_id):
|
527
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
528
|
+
"method": "GetDatabaseInfo",
|
529
|
+
"params": [connection_id]})
|
530
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
531
|
+
msg)
|
532
|
+
)
|
533
|
+
try:
|
534
|
+
return response['result']
|
535
|
+
except KeyError:
|
536
|
+
return response['error']
|
537
|
+
|
538
|
+
# GetDatabaseOwners: List the owners of a database for a ODBC, OLEDB or CUSTOM connection # NOQA
|
539
|
+
def get_db_owners(self, doc_handle, connection_id):
|
540
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
541
|
+
"method": "GetDatabaseOwners",
|
542
|
+
"params": [connection_id]})
|
543
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
544
|
+
msg)
|
545
|
+
)
|
546
|
+
try:
|
547
|
+
return response['result']
|
548
|
+
except KeyError:
|
549
|
+
return response['error']
|
550
|
+
|
551
|
+
# GetDatabases: List the databases of a ODBC, OLEDB or CUSTOM connection
|
552
|
+
def get_databases(self, doc_handle, connection_id):
|
553
|
+
msg = json.dumps(
|
554
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
555
|
+
"method": "GetDatabases", "params": [connection_id]})
|
556
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
557
|
+
msg)
|
558
|
+
)
|
559
|
+
try:
|
560
|
+
return response['result']
|
561
|
+
except KeyError:
|
562
|
+
return response['error']
|
563
|
+
|
564
|
+
# GetDatabaseTableFields: List the fields in a table for a ODBC, OLEDB or CUSTOM connection # NOQA
|
565
|
+
# Parameters taken are: connection_id (mandatory), db_name, db_owner, table_name (mandatory) # NOQA
|
566
|
+
def get_db_table_fields(self, doc_handle, connection_id,
|
567
|
+
db_name="", db_owner="", table_name=""):
|
568
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
569
|
+
"method": "GetDatabaseTableFields",
|
570
|
+
"params": [connection_id, db_name,
|
571
|
+
db_owner, table_name]
|
572
|
+
})
|
573
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
574
|
+
msg)
|
575
|
+
)
|
576
|
+
try:
|
577
|
+
return response['result']
|
578
|
+
except KeyError:
|
579
|
+
return response['error']
|
580
|
+
|
581
|
+
# GetDatabaseTablePreview: Preview the data in the fields in a table for a ODBC, OLEDB or CUSTOM connection # NOQA
|
582
|
+
# Parameters taken are: connection_id (mandatory), db_name, db_owner, table_name (mandatory) # NOQA
|
583
|
+
def get_db_table_preview(self, doc_handle, connection_id,
|
584
|
+
db_name="", db_owner="", table_name=""):
|
585
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
586
|
+
"method": "GetDatabaseTablePreview",
|
587
|
+
"params": [connection_id, db_name,
|
588
|
+
db_owner, table_name]
|
589
|
+
})
|
590
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
591
|
+
msg)
|
592
|
+
)
|
593
|
+
try:
|
594
|
+
return response['result']
|
595
|
+
except KeyError:
|
596
|
+
return response['error']
|
597
|
+
|
598
|
+
# GetDatabaseTables: List the tables in a database for a specific owner and for a ODBC, OLEDB or CUSTOM connection # NOQA
|
599
|
+
# Parameters taken are: connection_id (mandatory), db_name, db_owner
|
600
|
+
def get_db_tables(self, doc_handle,
|
601
|
+
connection_id, db_name="", db_owner=""):
|
602
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
603
|
+
"method": "GetDatabaseTables",
|
604
|
+
"params": [connection_id, db_name, db_owner]})
|
605
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
606
|
+
msg)
|
607
|
+
)
|
608
|
+
try:
|
609
|
+
return response['result']
|
610
|
+
except KeyError:
|
611
|
+
return response['error']
|
612
|
+
|
613
|
+
# GetDimension: Get the handle of a dimension by using the GetDimension method. # NOQA
|
614
|
+
# Parameter: dimension id
|
615
|
+
def get_dim_handle(self, doc_handle, dim_id):
|
616
|
+
msg = json.dumps(
|
617
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
618
|
+
"method": "GetDimension", "params": [dim_id]})
|
619
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
620
|
+
msg)
|
621
|
+
)
|
622
|
+
try:
|
623
|
+
return response['result']
|
624
|
+
except KeyError:
|
625
|
+
return response['error']
|
626
|
+
|
627
|
+
# GetEmptyScript: Creates a script that contains one section. This section contains Set statements that give # NOQA
|
628
|
+
# localized information from the regional settings of the computer.
|
629
|
+
# Parameter: none
|
630
|
+
def get_empty_script(self, doc_handle):
|
631
|
+
msg = json.dumps(
|
632
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
633
|
+
"method": "GetEmptyScript", "params": []})
|
634
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
635
|
+
msg)
|
636
|
+
)
|
637
|
+
try:
|
638
|
+
return response['result']
|
639
|
+
except KeyError:
|
640
|
+
return response['error']
|
641
|
+
|
642
|
+
# GetFieldDescription: Get the description of a field
|
643
|
+
# Parameter: field name
|
644
|
+
def get_field_descr(self, doc_handle, field_name):
|
645
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
646
|
+
"method": "GetFieldDescription",
|
647
|
+
"params": {"qFieldName": field_name}})
|
648
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
649
|
+
msg)
|
650
|
+
)
|
651
|
+
try:
|
652
|
+
return response['result']
|
653
|
+
except KeyError:
|
654
|
+
return response['error']
|
655
|
+
|
656
|
+
# GetField method: Retrieves the handle of a field.
|
657
|
+
# Parameter: field name
|
658
|
+
def get_field_handle(self, doc_handle, field_name):
|
659
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
660
|
+
"method": "GetField", "params": [field_name]})
|
661
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
662
|
+
msg)
|
663
|
+
)
|
664
|
+
try:
|
665
|
+
return response['result']
|
666
|
+
except KeyError:
|
667
|
+
return response['error']
|
668
|
+
|
669
|
+
# GetFileTableFields method: Lists the fields of a table for a folder connection. # NOQA
|
670
|
+
# Parameters:
|
671
|
+
# qConnectionId (MANDATORY): Identifier of the connection.
|
672
|
+
# qRelativePath: Path of the connection file
|
673
|
+
# qDataFormat: Type of the file
|
674
|
+
# qTable (MOSTLY MANDATORY): Name of the table ***This parameter must be set for XLS, XLSX, HTML and XML files.*** # NOQA
|
675
|
+
def get_file_table_fields(self, doc_handle, connection_id,
|
676
|
+
rel_path="", data_fmt="", table_name=""):
|
677
|
+
msg = json.dumps(
|
678
|
+
{"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
679
|
+
"method": "GetFileTableFields", "params": [
|
680
|
+
connection_id, rel_path, {"qType": data_fmt}, table_name]})
|
681
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
682
|
+
msg)
|
683
|
+
)
|
684
|
+
try:
|
685
|
+
return response['result']
|
686
|
+
except KeyError:
|
687
|
+
return response['error']
|
688
|
+
|
689
|
+
# GetFileTablePreview method: Preview the data in the fields of a table for a folder connection. # NOQA
|
690
|
+
# Parameters:
|
691
|
+
# qConnectionId (MANDATORY): Identifier of the connection.
|
692
|
+
# qRelativePath: Path of the connection file
|
693
|
+
# qDataFormat: Type of the file
|
694
|
+
# qTable (MOSTLY MANDATORY): Name of the table ***This parameter must be set for XLS, XLSX, HTML and XML files.*** # NOQA
|
695
|
+
def get_file_table_preview(self, doc_handle, connection_id,
|
696
|
+
rel_path="", data_fmt="", table_name=""):
|
697
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
698
|
+
"method": "GetFileTablePreview", "params": [
|
699
|
+
connection_id, rel_path,
|
700
|
+
{"qType": data_fmt}, table_name]
|
701
|
+
})
|
702
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
703
|
+
msg)
|
704
|
+
)
|
705
|
+
try:
|
706
|
+
return response['result']
|
707
|
+
except KeyError:
|
708
|
+
return response['error']
|
709
|
+
|
710
|
+
# GetFileTablesEx method: List the tables and fields of a XML file or from a JSON file, for a folder connection # NOQA
|
711
|
+
# Parameters:
|
712
|
+
# qConnectionId (MANDATORY): Identifier of the connection.
|
713
|
+
# qRelativePath: Path of the connection file
|
714
|
+
# qDataFormat: Type of the file (XML, JSON)
|
715
|
+
# qTable (MOSTLY MANDATORY): Name of the table ***This parameter must be set for XLS, XLSX, HTML and XML files.*** # NOQA
|
716
|
+
def get_file_table_ex(self, doc_handle, connection_id,
|
717
|
+
rel_path="", data_fmt=""):
|
718
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
719
|
+
"method": "GetFileTablesEx", "params": [
|
720
|
+
connection_id, rel_path, {"qType": data_fmt}]
|
721
|
+
})
|
722
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
723
|
+
msg)
|
724
|
+
)
|
725
|
+
try:
|
726
|
+
return response['result']
|
727
|
+
except KeyError:
|
728
|
+
return response['error']
|
729
|
+
|
730
|
+
# GetFileTables method: Lists the tables for a folder connection.
|
731
|
+
# Parameters:
|
732
|
+
# qConnectionId (MANDATORY): Identifier of the connection.
|
733
|
+
# qRelativePath: Path of the connection file
|
734
|
+
# qDataFormat: Type of the file (XML, JSON)
|
735
|
+
def get_file_tables(self, doc_handle, connection_id,
|
736
|
+
rel_path="", data_fmt=""):
|
737
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
738
|
+
"method": "GetFileTables", "params": [
|
739
|
+
connection_id, rel_path, {"qType": data_fmt}]
|
740
|
+
})
|
741
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
742
|
+
msg)
|
743
|
+
)
|
744
|
+
try:
|
745
|
+
return response['result']
|
746
|
+
except KeyError:
|
747
|
+
return response['error']
|
748
|
+
|
749
|
+
# GetFolderItemsForConnection method: List the items for a folder connection # NOQA
|
750
|
+
# Parameter: connection_id
|
751
|
+
def get_folder_items_for_connection(self, doc_handle, connection_id):
|
752
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
753
|
+
"method": "GetFolderItemsForConnection",
|
754
|
+
"params": [connection_id]})
|
755
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
756
|
+
msg)
|
757
|
+
)
|
758
|
+
try:
|
759
|
+
return response['result']
|
760
|
+
except KeyError:
|
761
|
+
return response['error']
|
762
|
+
|
763
|
+
# GetAllInfos method: Get the identifier and the type of any generic object in an app by using the GetAllInfos method. # NOQA
|
764
|
+
def get_lineage(self, doc_handle):
|
765
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
766
|
+
"method": "GetLineage", "params": []})
|
767
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
768
|
+
msg)
|
769
|
+
)
|
770
|
+
try:
|
771
|
+
return response['result']
|
772
|
+
except KeyError:
|
773
|
+
return response['error']
|
774
|
+
|
775
|
+
def create_session_object(self, doc_handle, param):
|
776
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
777
|
+
"method": "CreateSessionObject",
|
778
|
+
"params": [param]})
|
779
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
780
|
+
msg)
|
781
|
+
)
|
782
|
+
try:
|
783
|
+
return response['result']
|
784
|
+
except KeyError:
|
785
|
+
return response['error']
|
786
|
+
|
787
|
+
def get_set_analysis(self, doc_handle, state_name="", bookmark_id=""):
|
788
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 3, "handle": doc_handle,
|
789
|
+
"method": "GetSetAnalysis", "params":
|
790
|
+
{"qStateName": state_name,
|
791
|
+
"qBookmarkId": bookmark_id}
|
792
|
+
})
|
793
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
794
|
+
msg)
|
795
|
+
)
|
796
|
+
try:
|
797
|
+
return response['result']
|
798
|
+
except KeyError:
|
799
|
+
return response['error']
|
800
|
+
|
801
|
+
def apply_bookmark(self, doc_handle, bookmark_id):
|
802
|
+
msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
|
803
|
+
"method": "ApplyBookmark", "params": [bookmark_id]})
|
804
|
+
response = json.loads(self.engine_socket.send_call(self.engine_socket,
|
805
|
+
msg)
|
806
|
+
)
|
807
|
+
try:
|
808
|
+
return response['result']
|
809
|
+
except KeyError:
|
810
|
+
return response['error']
|