qe-api-client 1.1.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.
@@ -2,103 +2,177 @@ import json
2
2
 
3
3
 
4
4
  class EngineAppApi:
5
+ """
6
+ API class for interacting with Qlik Sense engine's app-related functionalities, such as script management,
7
+ reloading, and object creation.
8
+
9
+ Methods:
10
+ get_script(doc_handle): Retrieves the script of the app.
11
+ set_script(doc_handle, script): Sets the script of the app.
12
+ do_reload(doc_handle, param_list): Triggers a reload of the app.
13
+ do_reload_ex(doc_handle, param_list): Triggers an extended reload of the app.
14
+ get_app_layout(doc_handle): Retrieves the layout structure of the app.
15
+ get_object(doc_handle, object_id): Retrieves a specific object from the app.
16
+ get_field(doc_handle, field_name, state_name): Retrieves a specific field from the app.
17
+ create_object(doc_handle, q_id, q_type, struct_name, ob_struct): Creates a new object in the app.
18
+ """
5
19
 
6
20
  def __init__(self, socket):
21
+ """
22
+ Initializes the EngineAppApi with a given socket connection.
23
+
24
+ Parameters:
25
+ socket (object): The socket connection to the Qlik Sense engine.
26
+ """
7
27
  self.engine_socket = socket
8
28
 
9
29
  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
- )
30
+ """
31
+ Retrieves the script of the app identified by the document handle.
32
+
33
+ Parameters:
34
+ doc_handle (int): The handle identifying the app document.
35
+
36
+ Returns:
37
+ str: The script of the app (qScript). In case of an error, returns the error information.
38
+ """
39
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetScript", "params": []})
40
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
15
41
  try:
16
- return response['result']
42
+ return response['result']['qScript']
17
43
  except KeyError:
18
44
  return response['error']
19
45
 
20
46
  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
- )
47
+ """
48
+ Sets the script of the app identified by the document handle.
49
+
50
+ Parameters:
51
+ doc_handle (int): The handle identifying the app document.
52
+ script (str): The script content to be set.
53
+
54
+ Returns:
55
+ dict: The result of setting the script. In case of an error, returns the error information.
56
+ """
57
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "SetScript", "params": [script]})
58
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
26
59
  try:
27
60
  return response['result']
28
61
  except KeyError:
29
62
  return response['error']
30
63
 
31
64
  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
- )
65
+ """
66
+ Triggers a reload of the app identified by the document handle.
67
+
68
+ Parameters:
69
+ doc_handle (int): The handle identifying the app document.
70
+ param_list (list): A list of parameters for the reload operation. Default is an empty list.
71
+
72
+ Returns:
73
+ dict: The result of the reload operation. In case of an error, returns the error information.
74
+ """
75
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DoReload", "params": param_list})
76
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
37
77
  try:
38
78
  return response['result']
39
79
  except KeyError:
40
80
  return response['error']
41
81
 
42
82
  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
- )
83
+ """
84
+ Triggers an extended reload of the app identified by the document handle.
85
+
86
+ Parameters:
87
+ doc_handle (int): The handle identifying the app document.
88
+ param_list (list): A list of parameters for the extended reload operation. Default is an empty list.
89
+
90
+ Returns:
91
+ dict: The result of the extended reload operation. In case of an error, returns the error information.
92
+ """
93
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DoReloadEx",
94
+ "params": param_list})
95
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
48
96
  try:
49
97
  return response['result']
50
98
  except KeyError:
51
99
  return response['error']
52
100
 
53
101
  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
- )
102
+ """
103
+ Retrieves the layout structure of the app identified by the document handle.
104
+
105
+ Parameters:
106
+ doc_handle (int): The handle identifying the app document.
107
+
108
+ Returns:
109
+ dict: The layout structure of the app (qLayout). In case of an error, returns the error information.
110
+ """
111
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetAppLayout", "params": []})
112
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
59
113
  try:
60
- return response['result']
114
+ return response['result']['qLayout']
61
115
  except KeyError:
62
116
  return response['error']
63
117
 
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
- )
118
+ def get_object(self, doc_handle, object_id):
119
+ """
120
+ Retrieves a specific object from the app identified by the document handle.
121
+
122
+ Parameters:
123
+ doc_handle (int): The handle identifying the app document.
124
+ object_id (str): The ID of the object to retrieve.
125
+
126
+ Returns:
127
+ dict: The retrieved object (qReturn). In case of an error, returns the error information.
128
+ """
129
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetObject",
130
+ "params": {"qId": object_id}})
131
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
70
132
  try:
71
- return response['result']
133
+ return response['result']['qReturn']
72
134
  except KeyError:
73
135
  return response['error']
74
136
 
75
137
  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
- )
138
+ """
139
+ Retrieves a specific field from the app identified by the document handle.
140
+
141
+ Parameters:
142
+ doc_handle (int): The handle identifying the app document.
143
+ field_name (str): The name of the field to retrieve.
144
+ state_name (str): The name of the state. Default is an empty string, indicating the default state.
145
+
146
+ Returns:
147
+ dict: The retrieved field (qReturn). In case of an error, returns the error information.
148
+ """
149
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetField",
150
+ "params": {"qFieldName": field_name, "qStateName": state_name}})
151
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
84
152
  try:
85
- return response['result']
153
+ return response['result']['qReturn']
86
154
  except KeyError:
87
155
  return response['error']
88
156
 
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
- )
157
+ def create_object(self, doc_handle, q_id="LB01", q_type="ListObject", struct_name="qListObjectDef", ob_struct={}):
158
+ """
159
+ Creates a new object in the app identified by the document handle.
160
+
161
+ Parameters:
162
+ doc_handle (int): The handle identifying the app document.
163
+ q_id (str): The ID of the new object. Default is "LB01".
164
+ q_type (str): The type of the new object. Default is "ListObject".
165
+ struct_name (str): The name of the structure defining the object. Default is "qListObjectDef".
166
+ ob_struct (dict): The structure defining the object.
167
+
168
+ Returns:
169
+ dict: The created object (qReturn). In case of an error, returns the error information.
170
+ """
171
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "method": "CreateObject", "handle": doc_handle,
172
+ "params": [{"qInfo": {"qId": q_id, "qType": q_type}, struct_name: ob_struct}]})
173
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
100
174
  try:
101
- return response['result']
175
+ return response['result']['qReturn']
102
176
  except KeyError:
103
177
  return response['error']
104
178
 
@@ -107,12 +181,9 @@ class EngineAppApi:
107
181
  # Objects in a given state are not affected by user selections in the other states. # NOQA
108
182
  # Call GetAppLayout() afterwards to get the latest states
109
183
  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
- )
184
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "AddAlternateState",
185
+ "params": [state_name]})
186
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
116
187
  try:
117
188
  return response['result']
118
189
  except KeyError:
@@ -121,12 +192,9 @@ class EngineAppApi:
121
192
  # AddFieldFromExpression method: Adds a field on the fly. !! The expression of a field on the fly is persisted but # NOQA
122
193
  # not its values. !!
123
194
  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",
195
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "AddFieldFromExpression",
126
196
  "params": [field_name, expr_value]})
127
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
128
- msg)
129
- )
197
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
130
198
  try:
131
199
  return response['result']
132
200
  except KeyError:
@@ -135,12 +203,9 @@ class EngineAppApi:
135
203
  # CheckExpression method: Checks whether an expression is valid or not
136
204
  # qErrorMsg is empty if it's valid
137
205
  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
- )
206
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "CheckExpression",
207
+ "params": [expr_value]})
208
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
144
209
  try:
145
210
  return response['result']
146
211
  except KeyError:
@@ -150,24 +215,17 @@ class EngineAppApi:
150
215
  # Used AFTER doing SetScript method
151
216
  # errors are displayed in an array discussing positions of characters in script where failing # NOQA
152
217
  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
- )
218
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "CheckScriptSyntax", "params": {}})
219
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
159
220
  try:
160
221
  return response['result']
161
222
  except KeyError:
162
223
  return response['error']
163
224
 
164
225
  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",
226
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "ClearAll",
167
227
  "params": [locked_also, alt_state]})
168
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
169
- msg)
170
- )
228
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
171
229
  try:
172
230
  return response['result']
173
231
  except KeyError:
@@ -176,22 +234,12 @@ class EngineAppApi:
176
234
  # CreateConnection method: Creates a connection. A connection indicates from which data source, the data should # NOQA
177
235
  # be taken. The connection can be: an ODBC connection, OLEDB connection, a custom connection, a folder connection # NOQA
178
236
  # (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
- )
237
+ def create_connection(self, doc_handle, connect_name, connect_string, connect_type, user_name, password,
238
+ mod_date="", meta="", sso_passthrough="LOG_ON_SERVICE_USER"):
239
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "CreateConnection",
240
+ "params": [{"qName": connect_name, "qMeta": meta, "qConnectionString": connect_string,
241
+ "qType": connect_type}]})
242
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
195
243
  try:
196
244
  return response['result']
197
245
  except KeyError:
@@ -205,8 +253,8 @@ class EngineAppApi:
205
253
  def create_master_dim(self, doc_handle, dim_id, dim_title,
206
254
  dim_grouping="N", dim_field='', dim_label='',
207
255
  meta_def=""):
208
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
209
- "method": "CreateDimension", "params": [{
256
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "CreateDimension",
257
+ "params": [{
210
258
  "qInfo": {
211
259
  "qId": dim_id,
212
260
  "qType": "Dimension"
@@ -226,9 +274,7 @@ class EngineAppApi:
226
274
  }
227
275
  }]
228
276
  })
229
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
230
- msg)
231
- )
277
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
232
278
  try:
233
279
  return response['result']
234
280
  except KeyError:
@@ -236,12 +282,9 @@ class EngineAppApi:
236
282
 
237
283
  # DestroyDimension method: Removes a dimension
238
284
  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
- )
285
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DestroyDimension",
286
+ "params": [{dim_id}]})
287
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
245
288
  try:
246
289
  return response['result']
247
290
  except KeyError:
@@ -249,12 +292,9 @@ class EngineAppApi:
249
292
 
250
293
  # DestroyMeasure method: Removes a measure
251
294
  def destroy_measure(self, doc_handle, measure_id):
252
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
253
- "method": "DestroyDimension",
295
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DestroyDimension",
254
296
  "params": [{measure_id}]})
255
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
256
- msg)
257
- )
297
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
258
298
  try:
259
299
  return response['result']
260
300
  except KeyError:
@@ -262,12 +302,9 @@ class EngineAppApi:
262
302
 
263
303
  # DestroyObject method: Removes an app object. The children of the object (if any) are removed as well. # NOQA
264
304
  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
- )
305
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DestroyObject",
306
+ "params": [{object_id}]})
307
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
271
308
  try:
272
309
  return response['result']
273
310
  except KeyError:
@@ -275,12 +312,9 @@ class EngineAppApi:
275
312
 
276
313
  # DestroySessionObject method: Removes a session object. The children of the object (if any) are removed as well. # NOQA
277
314
  def destroy_session_object(self, doc_handle, object_id):
278
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
279
- "method": "DestroySessionObject",
315
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DestroySessionObject",
280
316
  "params": [{object_id}]})
281
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
282
- msg)
283
- )
317
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
284
318
  try:
285
319
  return response['result']
286
320
  except KeyError:
@@ -288,12 +322,9 @@ class EngineAppApi:
288
322
 
289
323
  # DestroySessionVariable method: Removes an transient variable.
290
324
  def destroy_session_variable(self, doc_handle, var_id):
291
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
292
- "method": "DestroySessionVariable",
325
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DestroySessionVariable",
293
326
  "params": [{var_id}]})
294
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
295
- msg)
296
- )
327
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
297
328
  try:
298
329
  return response['result']
299
330
  except KeyError:
@@ -303,12 +334,9 @@ class EngineAppApi:
303
334
  # Script-defined variables cannot be removed using the DestroyVariableById method or the # NOQA
304
335
  # DestroyVariableByName method.
305
336
  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",
337
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DestroyVariableById",
308
338
  "params": [{var_name}]})
309
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
310
- msg)
311
- )
339
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
312
340
  try:
313
341
  return response['result']
314
342
  except KeyError:
@@ -319,8 +347,7 @@ class EngineAppApi:
319
347
  # can contain the same dimension.
320
348
  # Parameters:
321
349
  # 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=""):
350
+ def create_master_measure(self, doc_handle, measure_id, measure_title, measure_expr, meta_def=""):
324
351
  msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
325
352
  "method": "CreateMeasure", "params": [{
326
353
  "qInfo": {
@@ -336,9 +363,7 @@ class EngineAppApi:
336
363
  }
337
364
  }]
338
365
  })
339
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
340
- msg)
341
- )
366
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
342
367
  try:
343
368
  return response['result']
344
369
  except KeyError:
@@ -368,8 +393,7 @@ class EngineAppApi:
368
393
  # ### Example: The variable x contains the text string Sum(Sales). In a chart, you define the expression $(x)/12. # NOQA
369
394
  # 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
395
  # 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=""):
396
+ def create_session_variable(self, doc_handle, var_id="", var_name="", var_comment="", var_def=""):
373
397
  msg = json.dumps(
374
398
  {"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
375
399
  "method": "CreateSessionVariable", "params": [{
@@ -382,9 +406,7 @@ class EngineAppApi:
382
406
  "qDefinition": var_def
383
407
  }]
384
408
  })
385
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
386
- msg)
387
- )
409
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
388
410
  try:
389
411
  return response['result']
390
412
  except KeyError:
@@ -400,8 +422,7 @@ class EngineAppApi:
400
422
  # The effect is exactly the same as having the chart expression Sum(Sales)/12. # NOQA
401
423
  # However, if you change the value of the variable x to Sum(Budget),
402
424
  # 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=""):
425
+ def create_variable(self, doc_handle, var_id="", var_name="", var_comment="", var_def=""):
405
426
  msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
406
427
  "method": "CreateVariable", "params": [{
407
428
  "qInfo": {
@@ -413,9 +434,7 @@ class EngineAppApi:
413
434
  "qDefinition": var_def
414
435
  }]
415
436
  })
416
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
417
- msg)
418
- )
437
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
419
438
  try:
420
439
  return response['result']
421
440
  except KeyError:
@@ -446,11 +465,8 @@ class EngineAppApi:
446
465
  # DoSave method: Saves an app - All objects and data in the data model are saved. # NOQA
447
466
  # Desktop only - server auto saves
448
467
  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
- )
468
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "DoSave", "params": []})
469
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
454
470
  try:
455
471
  return response['result']
456
472
  except KeyError:
@@ -459,12 +475,9 @@ class EngineAppApi:
459
475
  # Evaluate method: Evaluates an expression as a string. (Actually uses EvaluateEx, which is better for giving the data type back to python) # NOQA
460
476
  # Parameters: qExpression
461
477
  def expr_eval(self, doc_handle, expr):
462
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
463
- "method": "EvaluateEx",
478
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "EvaluateEx",
464
479
  "params": {"qExpression": expr}})
465
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
466
- msg)
467
- )
480
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
468
481
  try:
469
482
  return response['result']
470
483
  except KeyError:
@@ -472,124 +485,89 @@ class EngineAppApi:
472
485
 
473
486
  # GetAllInfos method: Get the identifier and the type of any generic object in an app by using the GetAllInfos method. # NOQA
474
487
  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
- )
488
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetAllInfos", "params": []})
489
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
480
490
  try:
481
- return response['result']
491
+ return response['result']['qInfos']
482
492
  except KeyError:
483
493
  return response['error']
484
494
 
485
495
  # GetAppProperties method: Gets the properties of an app.
486
496
  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
- )
497
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetAppProperties", "params": []})
498
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
493
499
  try:
494
- return response['result']
500
+ return response['result']['qProp']
495
501
  except KeyError:
496
502
  return response['error']
497
503
 
498
504
  # GetConnection method: Retrieves a connection and returns: The creation time of the connection, The identifier of # NOQA
499
505
  # the connection, The type of the connection, The name of the connection, The connection string # NOQA
500
506
  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
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetConnection",
508
+ "params": [connection_id]})
509
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
507
510
  try:
508
- return response['result']
511
+ return response['result']['qConnection']
509
512
  except KeyError:
510
513
  return response['error']
511
514
 
512
515
  # GetConnections method: Lists the connections in an app
513
516
  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
- )
517
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetConnections", "params": []})
518
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
520
519
  try:
521
- return response['result']
520
+ return response['result']['qConnections']
522
521
  except KeyError:
523
522
  return response['error']
524
523
 
525
524
  # GetDatabaseInfo: Get information about an ODBC, OLEDB or CUSTOM connection # NOQA
526
525
  def get_db_info(self, doc_handle, connection_id):
527
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
528
- "method": "GetDatabaseInfo",
526
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetDatabaseInfo",
529
527
  "params": [connection_id]})
530
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
531
- msg)
532
- )
528
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
533
529
  try:
534
- return response['result']
530
+ return response['result']['qInfo']
535
531
  except KeyError:
536
532
  return response['error']
537
533
 
538
534
  # GetDatabaseOwners: List the owners of a database for a ODBC, OLEDB or CUSTOM connection # NOQA
539
535
  def get_db_owners(self, doc_handle, connection_id):
540
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
541
- "method": "GetDatabaseOwners",
536
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetDatabaseOwners",
542
537
  "params": [connection_id]})
543
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
544
- msg)
545
- )
538
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
546
539
  try:
547
- return response['result']
540
+ return response['result']['qOwners']
548
541
  except KeyError:
549
542
  return response['error']
550
543
 
551
544
  # GetDatabases: List the databases of a ODBC, OLEDB or CUSTOM connection
552
545
  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
- )
546
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetDatabases",
547
+ "params": [connection_id]})
548
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
559
549
  try:
560
- return response['result']
550
+ return response['result']['qDatabases']
561
551
  except KeyError:
562
552
  return response['error']
563
553
 
564
554
  # GetDatabaseTableFields: List the fields in a table for a ODBC, OLEDB or CUSTOM connection # NOQA
565
555
  # 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
- )
556
+ def get_db_table_fields(self, doc_handle, connection_id, db_name="", db_owner="", table_name=""):
557
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetDatabaseTableFields",
558
+ "params": [connection_id, db_name, db_owner, table_name]})
559
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
576
560
  try:
577
- return response['result']
561
+ return response['result']['qFields']
578
562
  except KeyError:
579
563
  return response['error']
580
564
 
581
565
  # GetDatabaseTablePreview: Preview the data in the fields in a table for a ODBC, OLEDB or CUSTOM connection # NOQA
582
566
  # 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
- )
567
+ def get_db_table_preview(self, doc_handle, connection_id, db_name="", db_owner="", table_name=""):
568
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetDatabaseTablePreview",
569
+ "params": [connection_id, db_name, db_owner, table_name]})
570
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
593
571
  try:
594
572
  return response['result']
595
573
  except KeyError:
@@ -597,30 +575,23 @@ class EngineAppApi:
597
575
 
598
576
  # GetDatabaseTables: List the tables in a database for a specific owner and for a ODBC, OLEDB or CUSTOM connection # NOQA
599
577
  # 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",
578
+ def get_db_tables(self, doc_handle, connection_id, db_name="", db_owner=""):
579
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetDatabaseTables",
604
580
  "params": [connection_id, db_name, db_owner]})
605
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
606
- msg)
607
- )
581
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
608
582
  try:
609
- return response['result']
583
+ return response['result']['qTables']
610
584
  except KeyError:
611
585
  return response['error']
612
586
 
613
587
  # GetDimension: Get the handle of a dimension by using the GetDimension method. # NOQA
614
588
  # 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
- )
589
+ def get_dimension(self, doc_handle, dim_id):
590
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetDimension",
591
+ "params": [dim_id]})
592
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
622
593
  try:
623
- return response['result']
594
+ return response['result']['qReturn']
624
595
  except KeyError:
625
596
  return response['error']
626
597
 
@@ -628,41 +599,21 @@ class EngineAppApi:
628
599
  # localized information from the regional settings of the computer.
629
600
  # Parameter: none
630
601
  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
- )
602
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetEmptyScript", "params": []})
603
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
637
604
  try:
638
- return response['result']
605
+ return response['result']['qReturn']
639
606
  except KeyError:
640
607
  return response['error']
641
608
 
642
609
  # GetFieldDescription: Get the description of a field
643
610
  # Parameter: field name
644
611
  def get_field_descr(self, doc_handle, field_name):
645
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
646
- "method": "GetFieldDescription",
612
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetFieldDescription",
647
613
  "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
- )
614
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
664
615
  try:
665
- return response['result']
616
+ return response['result']['qReturn']
666
617
  except KeyError:
667
618
  return response['error']
668
619
 
@@ -692,16 +643,10 @@ class EngineAppApi:
692
643
  # qRelativePath: Path of the connection file
693
644
  # qDataFormat: Type of the file
694
645
  # 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
- )
646
+ def get_file_table_preview(self, doc_handle, connection_id, rel_path="", data_fmt="", table_name=""):
647
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetFileTablePreview",
648
+ "params": [connection_id, rel_path, {"qType": data_fmt}, table_name]})
649
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
705
650
  try:
706
651
  return response['result']
707
652
  except KeyError:
@@ -715,13 +660,9 @@ class EngineAppApi:
715
660
  # qTable (MOSTLY MANDATORY): Name of the table ***This parameter must be set for XLS, XLSX, HTML and XML files.*** # NOQA
716
661
  def get_file_table_ex(self, doc_handle, connection_id,
717
662
  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
- )
663
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetFileTablesEx",
664
+ "params": [connection_id, rel_path, {"qType": data_fmt}]})
665
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
725
666
  try:
726
667
  return response['result']
727
668
  except KeyError:
@@ -732,15 +673,10 @@ class EngineAppApi:
732
673
  # qConnectionId (MANDATORY): Identifier of the connection.
733
674
  # qRelativePath: Path of the connection file
734
675
  # 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
- )
676
+ def get_file_tables(self, doc_handle, connection_id, rel_path="", data_fmt=""):
677
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetFileTables",
678
+ "params": [connection_id, rel_path, {"qType": data_fmt}]})
679
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
744
680
  try:
745
681
  return response['result']
746
682
  except KeyError:
@@ -749,12 +685,9 @@ class EngineAppApi:
749
685
  # GetFolderItemsForConnection method: List the items for a folder connection # NOQA
750
686
  # Parameter: connection_id
751
687
  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",
688
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetFolderItemsForConnection",
754
689
  "params": [connection_id]})
755
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
756
- msg)
757
- )
690
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
758
691
  try:
759
692
  return response['result']
760
693
  except KeyError:
@@ -762,48 +695,35 @@ class EngineAppApi:
762
695
 
763
696
  # GetAllInfos method: Get the identifier and the type of any generic object in an app by using the GetAllInfos method. # NOQA
764
697
  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
- )
698
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "GetLineage", "params": []})
699
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
770
700
  try:
771
- return response['result']
701
+ return response['result']['qLineage']
772
702
  except KeyError:
773
703
  return response['error']
774
704
 
775
705
  def create_session_object(self, doc_handle, param):
776
- msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle,
777
- "method": "CreateSessionObject",
706
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "CreateSessionObject",
778
707
  "params": [param]})
779
- response = json.loads(self.engine_socket.send_call(self.engine_socket,
780
- msg)
781
- )
708
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
782
709
  try:
783
- return response['result']
710
+ return response['result']['qReturn']
784
711
  except KeyError:
785
712
  return response['error']
786
713
 
787
714
  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
- )
715
+ msg = json.dumps({"jsonrpc": "2.0", "id": 3, "handle": doc_handle, "method": "GetSetAnalysis",
716
+ "params": {"qStateName": state_name, "qBookmarkId": bookmark_id}})
717
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
796
718
  try:
797
- return response['result']
719
+ return response['result']['qSetExpression']
798
720
  except KeyError:
799
721
  return response['error']
800
722
 
801
723
  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
- )
724
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": doc_handle, "method": "ApplyBookmark",
725
+ "params": [bookmark_id]})
726
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
807
727
  try:
808
728
  return response['result']
809
729
  except KeyError: