qe-api-client 1.2.0__py3-none-any.whl → 2.1.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.
@@ -0,0 +1,127 @@
1
+ import json
2
+
3
+
4
+ class EngineFieldApi:
5
+ """
6
+ A client for interacting with the Qlik Engine JSON API for field operations.
7
+
8
+ Args:
9
+ socket: An object representing the engine socket connection used to communicate with the Qlik Engine.
10
+ """
11
+
12
+ def __init__(self, socket):
13
+ """
14
+ Initializes the EngineFieldApi with the provided socket.
15
+
16
+ Args:
17
+ socket: An engine socket object used to send and receive messages from the Qlik Engine.
18
+ """
19
+ self.engine_socket = socket
20
+
21
+ def select(self, fld_handle, value):
22
+ """
23
+ Selects a specific value in a field.
24
+
25
+ Args:
26
+ fld_handle (int): The handle of the field.
27
+ value (str): The value to select.
28
+
29
+ Returns:
30
+ dict: The response from the engine, containing the result or an error message.
31
+ """
32
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": fld_handle, "method": "Select",
33
+ "params": [value, False, 0]})
34
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
35
+ try:
36
+ return response
37
+ except KeyError:
38
+ return response["error"]
39
+
40
+ def select_values(self, fld_handle, values=None):
41
+ """
42
+ Selects multiple values in a field.
43
+
44
+ Args:
45
+ fld_handle (int): The handle of the field.
46
+ values (list, optional): A list of values to select. Defaults to an empty list.
47
+
48
+ Returns:
49
+ dict: The response from the engine, containing the result or an error message.
50
+ """
51
+ if values is None:
52
+ values = []
53
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": fld_handle, "method": "SelectValues",
54
+ "params": [values, False, False]})
55
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
56
+ try:
57
+ return response
58
+ except KeyError:
59
+ return response["error"]
60
+
61
+ def select_excluded(self, fld_handle):
62
+ """
63
+ Selects all excluded values in a field.
64
+
65
+ Args:
66
+ fld_handle (int): The handle of the field.
67
+
68
+ Returns:
69
+ dict: The response from the engine, containing the result or an error message.
70
+ """
71
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": fld_handle, "method": "SelectExcluded", "params": []})
72
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
73
+ try:
74
+ return response["result"]
75
+ except KeyError:
76
+ return response["error"]
77
+
78
+ def select_possible(self, fld_handle):
79
+ """
80
+ Selects all possible values in a field.
81
+
82
+ Args:
83
+ fld_handle (int): The handle of the field.
84
+
85
+ Returns:
86
+ dict: The response from the engine, containing the result or an error message.
87
+ """
88
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": fld_handle, "method": "SelectPossible", "params": []})
89
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
90
+ try:
91
+ return response["result"]
92
+ except KeyError:
93
+ return response["error"]
94
+
95
+ def clear(self, fld_handle):
96
+ """
97
+ Clears the selection in a field.
98
+
99
+ Args:
100
+ fld_handle (int): The handle of the field.
101
+
102
+ Returns:
103
+ dict: The response from the engine, containing the result or an error message.
104
+ """
105
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": fld_handle, "method": "Clear", "params": []})
106
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
107
+ try:
108
+ return response["result"]
109
+ except KeyError:
110
+ return response["error"]
111
+
112
+ def get_cardinal(self, fld_handle):
113
+ """
114
+ Gets the number of distinct values in a field.
115
+
116
+ Args:
117
+ fld_handle (int): The handle of the field.
118
+
119
+ Returns:
120
+ int: The number of distinct values in the field, or an error message.
121
+ """
122
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": fld_handle, "method": "GetCardinal", "params": []})
123
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
124
+ try:
125
+ return response["result"]
126
+ except KeyError:
127
+ return response["error"]
@@ -0,0 +1,38 @@
1
+ import json
2
+
3
+
4
+ class EngineGenericDimensionApi:
5
+ """
6
+ API class for interacting with Qlik Sense engine's generic dimension objects.
7
+
8
+ Methods:
9
+ get_dimension(handle, dimension_id): Retrieves the definition of a specific dimension.
10
+ """
11
+
12
+ def __init__(self, socket):
13
+ """
14
+ Initializes the EngineGenericDimensionApi with a given socket connection.
15
+
16
+ Parameters:
17
+ socket (object): The socket connection to the Qlik Sense engine.
18
+ """
19
+ self.engine_socket = socket
20
+
21
+ def get_dimension(self, handle, dimension_id):
22
+ """
23
+ Retrieves the definition of a specific dimension from the Qlik Sense engine.
24
+
25
+ Parameters:
26
+ handle (int): The handle identifying the dimension object.
27
+ dimension_id (str): The unique identifier (qId) of the dimension to retrieve.
28
+
29
+ Returns:
30
+ dict: The definition of the requested dimension (qReturn). In case of an error, returns the error information.
31
+ """
32
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "GetDimension",
33
+ "params": {"qId": dimension_id}})
34
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
35
+ try:
36
+ return response["result"]["qReturn"]
37
+ except KeyError:
38
+ return response["error"]
@@ -0,0 +1,37 @@
1
+ import json
2
+
3
+
4
+ class EngineGenericMeasureApi:
5
+ """
6
+ API class for interacting with Qlik Sense engine's generic measure objects.
7
+
8
+ Methods:
9
+ get_measure(handle, measure_id): Retrieves the definition of a specific measure.
10
+ """
11
+
12
+ def __init__(self, socket):
13
+ """
14
+ Initializes the EngineGenericMeasureApi with a given socket connection.
15
+
16
+ Parameters:
17
+ socket (object): The socket connection to the Qlik Sense engine.
18
+ """
19
+ self.engine_socket = socket
20
+
21
+ def get_measure(self, handle, measure_id):
22
+ """
23
+ Retrieves the definition of a specific measure from the Qlik Sense engine.
24
+
25
+ Parameters:
26
+ handle (int): The handle identifying the measure object.
27
+ measure_id (str): The unique identifier (qId) of the measure to retrieve.
28
+
29
+ Returns:
30
+ dict: The definition of the requested measure (qReturn). In case of an error, returns the error information.
31
+ """
32
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "GetMeasure", "params": {"qId": measure_id}})
33
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
34
+ try:
35
+ return response["result"]["qReturn"]
36
+ except KeyError:
37
+ return response["error"]
@@ -0,0 +1,180 @@
1
+ import json
2
+
3
+
4
+ class EngineGenericObjectApi:
5
+ """
6
+ API class for interacting with Qlik Sense engine's generic objects, such as hypercubes, lists, and other
7
+ data visualization objects.
8
+
9
+ Methods:
10
+ create_child(handle, params): Creates a generic object that is a child of another generic object.
11
+ get_layout(handle): Retrieves the layout structure of a generic object.
12
+ get_full_property_tree(handle): Retrieves the full property tree of a generic object.
13
+ get_effective_properties(handle): Retrieves the effective properties of a generic object.
14
+ get_hypercube_data(handle, path, pages): Retrieves the data from a hypercube.
15
+ get_hypercube_pivot_data(handle, path, pages): Retrieves the pivot data from a hypercube.
16
+ get_list_object_data(handle, path, pages): Retrieves the data from a list object.
17
+ """
18
+
19
+ def __init__(self, socket):
20
+ """
21
+ Initializes the EngineGenericObjectApi with a given socket connection.
22
+
23
+ Parameters:
24
+ socket (object): The socket connection to the Qlik Sense engine.
25
+ """
26
+ self.engine_socket = socket
27
+ def create_child(self, handle, params):
28
+ """
29
+ Retrieves the layout structure of a specific generic object.
30
+
31
+ Parameters:
32
+ handle (int): The handle identifying the generic object.
33
+ params (str): The parameters of the generic object.
34
+
35
+ Returns:
36
+ dict: The layout structure of the generic object (qLayout). In case of an error, returns the error information.
37
+ """
38
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "CreateChild", "params": [params]})
39
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
40
+ try:
41
+ return response["result"]
42
+ except KeyError:
43
+ return response["error"]
44
+
45
+ def get_layout(self, handle):
46
+ """
47
+ Retrieves the layout structure of a specific generic object.
48
+
49
+ Parameters:
50
+ handle (int): The handle identifying the generic object.
51
+
52
+ Returns:
53
+ dict: The layout structure of the generic object (qLayout). In case of an error, returns the error information.
54
+ """
55
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "GetLayout", "params": []})
56
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
57
+ try:
58
+ return response["result"]["qLayout"]
59
+ except KeyError:
60
+ return response["error"]
61
+
62
+ def get_full_property_tree(self, handle):
63
+ """
64
+ Retrieves the full property tree of a specific generic object.
65
+
66
+ Parameters:
67
+ handle (int): The handle identifying the generic object.
68
+
69
+ Returns:
70
+ dict: The full property tree of the generic object (qPropEntry). In case of an error, returns the error information.
71
+ """
72
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "GetFullPropertyTree", "params": []})
73
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
74
+ try:
75
+ return response["result"]['qPropEntry']
76
+ except KeyError:
77
+ return response["error"]
78
+
79
+ def get_effective_properties(self, handle):
80
+ """
81
+ Retrieves the effective properties of a specific generic object.
82
+
83
+ Parameters:
84
+ handle (int): The handle identifying the generic object.
85
+
86
+ Returns:
87
+ dict: The effective properties of the generic object (qProp). In case of an error, returns the error information.
88
+ """
89
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "GetEffectiveProperties",
90
+ "params": {}})
91
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
92
+ try:
93
+ return response["result"]['qProp']
94
+ except KeyError:
95
+ return response["error"]
96
+
97
+ def get_hypercube_data(self, handle, path="/qHyperCubeDef", pages={}):
98
+ """
99
+ Retrieves the data from a specific hypercube in a generic object.
100
+
101
+ Parameters:
102
+ handle (int): The handle identifying the generic object containing the hypercube.
103
+ path (str): The path to the hypercube definition within the object. Default is "/qHyperCubeDef".
104
+ pages (list): A list of pages to retrieve from the hypercube data.
105
+
106
+ Returns:
107
+ dict: The data from the hypercube. In case of an error, returns the error information.
108
+ """
109
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "GetHyperCubeData",
110
+ "params": {"qPath": path, "qPages": [pages]}})
111
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
112
+ try:
113
+ return response["result"]
114
+ except KeyError:
115
+ return response["error"]
116
+
117
+ def get_hypercube_pivot_data(self, handle, path="/qHyperCubeDef", pages={}):
118
+ """
119
+ Retrieves the pivot data from a specific hypercube in a generic object.
120
+
121
+ Parameters:
122
+ handle (int): The handle identifying the generic object containing the hypercube.
123
+ path (str): The path to the hypercube definition within the object. Default is "/qHyperCubeDef".
124
+ pages (list): A list of pages to retrieve from the hypercube pivot data.
125
+
126
+ Returns:
127
+ dict: The pivot data from the hypercube. In case of an error, returns the error information.
128
+ """
129
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "GetHyperCubePivotData",
130
+ "params": {"qPath": path, "qPages": [pages]}})
131
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
132
+ try:
133
+ return response["result"]
134
+ except KeyError:
135
+ return response["error"]
136
+
137
+ def get_hypercube_stack_data(self, handle, path="/qHyperCubeDef", pages={}, max_no_cells=10000):
138
+ """
139
+ Retrieves the values of a stacked pivot table. It is possible to retrieve specific pages of data.
140
+
141
+ Parameters:
142
+ handle (int): The handle identifying the generic object containing the hypercube.
143
+ path (str): The path to the hypercube definition within the object. Default is "/qHyperCubeDef".
144
+ pages (list): A list of pages to retrieve from the hypercube pivot data.
145
+ max_no_cells (int): Maximum number of cells at outer level. The default value is 10 000.
146
+
147
+
148
+ Returns:
149
+ dict: The pivot data from the hypercube. In case of an error, returns the error information.
150
+ """
151
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "GetHyperCubeStackData",
152
+ "params": {"qPath": path, "qPages": [pages], "qMaxNbrCells": max_no_cells}})
153
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
154
+ try:
155
+ return response["result"]
156
+ except KeyError:
157
+ return response["error"]
158
+
159
+ def get_list_object_data(self, handle, path="/qListObjectDef", pages=[]):
160
+ """
161
+ Retrieves the data from a specific list object in a generic object.
162
+
163
+ Parameters:
164
+ handle (int): The handle identifying the generic object containing the list object.
165
+ path (str): The path to the list object definition within the object. Default is "/qListObjectDef".
166
+ pages (list): A list of pages to retrieve from the list object data.
167
+
168
+ Returns:
169
+ dict: The data from the list object. In case of an error, returns the error information.
170
+ """
171
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle,
172
+ "method": "GetListObjectData",
173
+ "params": [path, pages]})
174
+ response = json.loads(self.engine_socket.send_call(self.engine_socket,
175
+ msg)
176
+ )
177
+ try:
178
+ return response["result"]
179
+ except KeyError:
180
+ return response["error"]
@@ -0,0 +1,56 @@
1
+ import json
2
+
3
+
4
+ class EngineGenericVariableApi:
5
+ """
6
+ API class for interacting with Qlik Sense engine's generic variable object.
7
+
8
+ Methods:
9
+ set_string_value(handle, str_val): Sets the value of a string variable.
10
+ get_properties(handle): Retrieves the properties of a generic variable.
11
+ """
12
+
13
+ def __init__(self, socket):
14
+ """
15
+ Initializes the EngineGenericVariableApi with a given socket connection.
16
+
17
+ Parameters:
18
+ socket (object): The socket connection to the Qlik Sense engine.
19
+ """
20
+ self.engine_socket = socket
21
+
22
+ def set_string_value(self, handle, str_val):
23
+ """
24
+ Sets the value of a string variable in the Qlik Sense engine.
25
+
26
+ Parameters:
27
+ handle (int): The handle identifying the variable.
28
+ str_val (str): The string value to set for the variable.
29
+
30
+ Returns:
31
+ dict: The result of the set operation. In case of an error, returns the error information.
32
+ """
33
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "SetStringValue",
34
+ "params": {"qVal": str_val}})
35
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
36
+ try:
37
+ return response["result"]
38
+ except KeyError:
39
+ return response["error"]
40
+
41
+ def get_properties(self, handle):
42
+ """
43
+ Retrieves the properties of a generic variable from the Qlik Sense engine.
44
+
45
+ Parameters:
46
+ handle (int): The handle identifying the variable.
47
+
48
+ Returns:
49
+ dict: The properties of the generic variable. In case of an error, returns the error information.
50
+ """
51
+ msg = json.dumps({"jsonrpc": "2.0", "id": 0, "handle": handle, "method": "GetProperties", "params": {}})
52
+ response = json.loads(self.engine_socket.send_call(self.engine_socket, msg))
53
+ try:
54
+ return response["result"]
55
+ except KeyError:
56
+ return response["error"]