brynq-sdk-brynq 4.2.6.dev0__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.
Potentially problematic release.
This version of brynq-sdk-brynq might be problematic. Click here for more details.
- brynq_sdk_brynq/__init__.py +1 -0
- brynq_sdk_brynq/brynq.py +289 -0
- brynq_sdk_brynq/credentials.py +157 -0
- brynq_sdk_brynq/customers.py +88 -0
- brynq_sdk_brynq/interfaces.py +234 -0
- brynq_sdk_brynq/mappings.py +107 -0
- brynq_sdk_brynq/organization_chart.py +251 -0
- brynq_sdk_brynq/roles.py +272 -0
- brynq_sdk_brynq/scenarios.py +3495 -0
- brynq_sdk_brynq/schemas/__init__.py +52 -0
- brynq_sdk_brynq/schemas/credentials.py +37 -0
- brynq_sdk_brynq/schemas/customers.py +108 -0
- brynq_sdk_brynq/schemas/interfaces.py +237 -0
- brynq_sdk_brynq/schemas/organization_chart.py +70 -0
- brynq_sdk_brynq/schemas/roles.py +95 -0
- brynq_sdk_brynq/schemas/scenarios.py +419 -0
- brynq_sdk_brynq/schemas/users.py +126 -0
- brynq_sdk_brynq/source_systems.py +175 -0
- brynq_sdk_brynq/users.py +405 -0
- brynq_sdk_brynq-4.2.6.dev0.dist-info/METADATA +17 -0
- brynq_sdk_brynq-4.2.6.dev0.dist-info/RECORD +23 -0
- brynq_sdk_brynq-4.2.6.dev0.dist-info/WHEEL +5 -0
- brynq_sdk_brynq-4.2.6.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from typing import Dict, Any, List, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class SourceSystems:
|
|
6
|
+
"""
|
|
7
|
+
Handles all source system related operations for BrynQ SDK.
|
|
8
|
+
"""
|
|
9
|
+
def __init__(self, brynq_instance):
|
|
10
|
+
"""
|
|
11
|
+
Initialize SourceSystems manager.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
brynq_instance: The parent BrynQ instance
|
|
15
|
+
"""
|
|
16
|
+
self._brynq = brynq_instance
|
|
17
|
+
|
|
18
|
+
def get(self) -> List[Dict[str, Any]]:
|
|
19
|
+
"""
|
|
20
|
+
Get all source systems.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
List[Dict[str, Any]]: List of all source systems
|
|
24
|
+
|
|
25
|
+
Raises:
|
|
26
|
+
requests.exceptions.RequestException: If the API request fails
|
|
27
|
+
"""
|
|
28
|
+
response = self._brynq.brynq_session.get(
|
|
29
|
+
url=f'{self._brynq.url}source-systems',
|
|
30
|
+
timeout=self._brynq.timeout
|
|
31
|
+
)
|
|
32
|
+
response.raise_for_status()
|
|
33
|
+
return response.json()
|
|
34
|
+
|
|
35
|
+
def create(self, name: str, entities: Optional[List[Dict[str, str]]] = None) -> Dict[str, Any]:
|
|
36
|
+
"""
|
|
37
|
+
Create new source systems.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
name: Name of the source system
|
|
41
|
+
entities: Optional list of entities to assign. Each entity should have 'name' and 'code' keys
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
Dict[str, Any]: Created source system details
|
|
45
|
+
|
|
46
|
+
Raises:
|
|
47
|
+
requests.exceptions.RequestException: If the API request fails
|
|
48
|
+
"""
|
|
49
|
+
data = {
|
|
50
|
+
'name': name,
|
|
51
|
+
'entities': entities or []
|
|
52
|
+
}
|
|
53
|
+
response = self._brynq.brynq_session.post(
|
|
54
|
+
url=f'{self._brynq.url}source-systems',
|
|
55
|
+
json=data,
|
|
56
|
+
timeout=self._brynq.timeout
|
|
57
|
+
)
|
|
58
|
+
response.raise_for_status()
|
|
59
|
+
return response.json()
|
|
60
|
+
|
|
61
|
+
def delete(self, system_id: int) -> None:
|
|
62
|
+
"""
|
|
63
|
+
Delete a source system.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
system_id: ID of the source system to delete
|
|
67
|
+
|
|
68
|
+
Raises:
|
|
69
|
+
requests.exceptions.RequestException: If the API request fails
|
|
70
|
+
"""
|
|
71
|
+
response = self._brynq.brynq_session.delete(
|
|
72
|
+
url=f'{self._brynq.url}source-systems/{system_id}',
|
|
73
|
+
timeout=self._brynq.timeout
|
|
74
|
+
)
|
|
75
|
+
response.raise_for_status()
|
|
76
|
+
|
|
77
|
+
def update(self, system_id: int, name: str, entities: Optional[List[Dict[str, str]]] = None) -> Dict[str, Any]:
|
|
78
|
+
"""
|
|
79
|
+
Update a source system by overwriting its name and entities.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
system_id: ID of the source system to update
|
|
83
|
+
name: New name for the source system
|
|
84
|
+
entities: Optional list of entities to replace existing ones. Each entity should have 'name' and 'code' keys
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
Dict[str, Any]: Updated source system details
|
|
88
|
+
|
|
89
|
+
Raises:
|
|
90
|
+
requests.exceptions.RequestException: If the API request fails
|
|
91
|
+
requests.exceptions.HTTPError: If source system is not found (404)
|
|
92
|
+
"""
|
|
93
|
+
data = {
|
|
94
|
+
'name': name,
|
|
95
|
+
'entities': entities or []
|
|
96
|
+
}
|
|
97
|
+
response = self._brynq.brynq_session.put(
|
|
98
|
+
url=f'{self._brynq.url}source-systems/{system_id}',
|
|
99
|
+
json=data,
|
|
100
|
+
timeout=self._brynq.timeout
|
|
101
|
+
)
|
|
102
|
+
response.raise_for_status()
|
|
103
|
+
return response.json()
|
|
104
|
+
|
|
105
|
+
def get_entities(self, system_id: int) -> requests.Response:
|
|
106
|
+
"""
|
|
107
|
+
Get all entities from a source system in BrynQ
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
system_id: The ID of the source system
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
List[Dict[str, Any]]: List of entities from the source system
|
|
114
|
+
|
|
115
|
+
Raises:
|
|
116
|
+
requests.exceptions.RequestException: If the API request fails
|
|
117
|
+
"""
|
|
118
|
+
response = self._brynq.brynq_session.get(
|
|
119
|
+
url=f'{self._brynq.url}source-systems/{system_id}/entities',
|
|
120
|
+
timeout=self._brynq.timeout
|
|
121
|
+
)
|
|
122
|
+
response.raise_for_status()
|
|
123
|
+
return response.json()
|
|
124
|
+
|
|
125
|
+
def create_entities(self, system_id: int, entities: List[Dict[str, str]]) -> Dict[str, Any]:
|
|
126
|
+
"""
|
|
127
|
+
Create new entities for a source system.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
system_id: ID of the source system
|
|
131
|
+
entities: List of entities to create. Each entity should have 'name' and 'code' keys
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
Dict[str, Any]: Result of the creation operation
|
|
135
|
+
|
|
136
|
+
Raises:
|
|
137
|
+
requests.exceptions.RequestException: If the API request fails
|
|
138
|
+
requests.exceptions.HTTPError: If source system is not found (404)
|
|
139
|
+
"""
|
|
140
|
+
data = {'entities': entities}
|
|
141
|
+
response = self._brynq.brynq_session.post(
|
|
142
|
+
url=f'{self._brynq.url}source-systems/{system_id}/entities',
|
|
143
|
+
json=data,
|
|
144
|
+
timeout=self._brynq.timeout
|
|
145
|
+
)
|
|
146
|
+
response.raise_for_status()
|
|
147
|
+
return response.json()
|
|
148
|
+
|
|
149
|
+
def update_entity(self, entity_id: int, name: str, code: str) -> Dict[str, Any]:
|
|
150
|
+
"""
|
|
151
|
+
Update a specific source system entity.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
entity_id: ID of the entity to update
|
|
155
|
+
name: New name for the entity
|
|
156
|
+
code: New code for the entity
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
Dict[str, Any]: Updated entity details
|
|
160
|
+
|
|
161
|
+
Raises:
|
|
162
|
+
requests.exceptions.RequestException: If the API request fails
|
|
163
|
+
requests.exceptions.HTTPError: If entity is not found (404)
|
|
164
|
+
"""
|
|
165
|
+
data = {
|
|
166
|
+
'name': name,
|
|
167
|
+
'code': code
|
|
168
|
+
}
|
|
169
|
+
response = self._brynq.brynq_session.put(
|
|
170
|
+
url=f'{self._brynq.url}source-systems/entities/{entity_id}',
|
|
171
|
+
json=data,
|
|
172
|
+
timeout=self._brynq.timeout
|
|
173
|
+
)
|
|
174
|
+
response.raise_for_status()
|
|
175
|
+
return response.json()
|
brynq_sdk_brynq/users.py
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from typing import List, Dict, Any
|
|
3
|
+
from .schemas.users import (
|
|
4
|
+
User, UserUpdate, UserInvite,
|
|
5
|
+
QlikDashboardRightsPayload, DashboardRightsPayload, QlikAppUserAuthorization, UserEntitiesPayload
|
|
6
|
+
)
|
|
7
|
+
from brynq_sdk_functions import Functions
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Users:
|
|
11
|
+
"""
|
|
12
|
+
Handles all user-related operations for BrynQ SDK.
|
|
13
|
+
"""
|
|
14
|
+
def __init__(self, brynq_instance):
|
|
15
|
+
"""
|
|
16
|
+
Initialize Users manager.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
brynq_instance: The parent BrynQ instance
|
|
20
|
+
"""
|
|
21
|
+
self._brynq = brynq_instance
|
|
22
|
+
|
|
23
|
+
def get(self) -> List[Dict[str, Any]]:
|
|
24
|
+
"""Get all users from BrynQ
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
List[Dict[str, Any]]: List of users with their details:
|
|
28
|
+
- id (int): User ID
|
|
29
|
+
- name (str): First name
|
|
30
|
+
- email (str): User email
|
|
31
|
+
- roles (List[dict]): User roles
|
|
32
|
+
- organization_chart_entities (List[dict]): Organization chart entities
|
|
33
|
+
- qlik_dashboards (List[dict]): Qlik dashboards
|
|
34
|
+
- dashboards (List[dict]): Standard dashboards
|
|
35
|
+
|
|
36
|
+
Raises:
|
|
37
|
+
requests.exceptions.RequestException: If the API request fails
|
|
38
|
+
ValueError: If the response data is invalid
|
|
39
|
+
"""
|
|
40
|
+
response = self._brynq.brynq_session.get(
|
|
41
|
+
url=f'{self._brynq.url}users',
|
|
42
|
+
timeout=self._brynq.timeout
|
|
43
|
+
)
|
|
44
|
+
response.raise_for_status()
|
|
45
|
+
|
|
46
|
+
valid_data, _ = Functions.validate_pydantic_data(response.json(), schema=User)
|
|
47
|
+
return valid_data
|
|
48
|
+
|
|
49
|
+
def get_by_id(self, user_id: int) -> Dict[str, Any]:
|
|
50
|
+
"""
|
|
51
|
+
Get a specific user by ID.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
user_id: The ID of the user to retrieve
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
Dict[str, Any]: User details
|
|
58
|
+
|
|
59
|
+
Raises:
|
|
60
|
+
requests.exceptions.RequestException: If the API request fails
|
|
61
|
+
requests.exceptions.HTTPError: If user is not found (404)
|
|
62
|
+
"""
|
|
63
|
+
response = self._brynq.brynq_session.get(
|
|
64
|
+
url=f'{self._brynq.url}users/{user_id}',
|
|
65
|
+
timeout=self._brynq.timeout
|
|
66
|
+
)
|
|
67
|
+
response.raise_for_status()
|
|
68
|
+
valid_data, _ = Functions.validate_pydantic_data(response.json(), schema=User)
|
|
69
|
+
return valid_data[0]
|
|
70
|
+
|
|
71
|
+
def invite(self, user_data: dict) -> requests.Response:
|
|
72
|
+
"""Invite a new user to BrynQ
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
user_data: Dictionary containing user details. Example:
|
|
76
|
+
{
|
|
77
|
+
"email": "user@example.com",
|
|
78
|
+
"products": {
|
|
79
|
+
"qlikSenseAnalyzer": true,
|
|
80
|
+
"qlikSenseProfessional": false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
Note: products field is optional
|
|
84
|
+
|
|
85
|
+
Raises:
|
|
86
|
+
requests.exceptions.RequestException: If the API request fails
|
|
87
|
+
ValueError: If the input data is invalid
|
|
88
|
+
"""
|
|
89
|
+
valid_data, _ = Functions.validate_pydantic_data(user_data, schema=UserInvite)
|
|
90
|
+
|
|
91
|
+
response = self._brynq.brynq_session.post(
|
|
92
|
+
url=f'{self._brynq.url}users',
|
|
93
|
+
json=valid_data[0],
|
|
94
|
+
timeout=self._brynq.timeout
|
|
95
|
+
)
|
|
96
|
+
response.raise_for_status()
|
|
97
|
+
return response
|
|
98
|
+
|
|
99
|
+
def update(self, user_id: str, user_data: dict) -> requests.Response:
|
|
100
|
+
"""Update a user in BrynQ
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
user_id: The ID of the user to update
|
|
104
|
+
user_data: Dictionary containing user details to update. Example:
|
|
105
|
+
{
|
|
106
|
+
"name": "John Doe",
|
|
107
|
+
"username": "johndoe",
|
|
108
|
+
"email": "john@example.com",
|
|
109
|
+
"language": "en",
|
|
110
|
+
"roles": [1, 2, 3],
|
|
111
|
+
"products": {
|
|
112
|
+
"qlikSenseAnalyzer": true,
|
|
113
|
+
"qlikSenseProfessional": false
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
All fields are optional.
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
Dict[str, Any]: Updated user data
|
|
120
|
+
|
|
121
|
+
Raises:
|
|
122
|
+
requests.exceptions.RequestException: If the API request fails
|
|
123
|
+
ValueError: If the input data is invalid
|
|
124
|
+
requests.exceptions.HTTPError: If user is not found (404)
|
|
125
|
+
"""
|
|
126
|
+
if not isinstance(user_id, str):
|
|
127
|
+
raise ValueError("user_id must be a string")
|
|
128
|
+
|
|
129
|
+
valid_data, _ = Functions.validate_pydantic_data(user_data, schema=UserUpdate)
|
|
130
|
+
|
|
131
|
+
response = self._brynq.brynq_session.put(
|
|
132
|
+
url=f'{self._brynq.url}users/{user_id}',
|
|
133
|
+
json=valid_data[0],
|
|
134
|
+
timeout=self._brynq.timeout
|
|
135
|
+
)
|
|
136
|
+
response.raise_for_status()
|
|
137
|
+
|
|
138
|
+
return response
|
|
139
|
+
|
|
140
|
+
def delete(self, user_id: str) -> requests.Response:
|
|
141
|
+
"""
|
|
142
|
+
Delete a user in BrynQ
|
|
143
|
+
:param user_id: The id of the user in BrynQ
|
|
144
|
+
"""
|
|
145
|
+
if not isinstance(user_id, int):
|
|
146
|
+
raise ValueError("user_id must be an integer")
|
|
147
|
+
response = self._brynq.brynq_session.delete(
|
|
148
|
+
url=f'{self._brynq.url}users/{user_id}',
|
|
149
|
+
timeout=self._brynq.timeout
|
|
150
|
+
)
|
|
151
|
+
response.raise_for_status()
|
|
152
|
+
return response
|
|
153
|
+
|
|
154
|
+
def assign_dashboard_rights(self, user_id: int, dashboard_rights: List[Dict[str, Any]]) -> None:
|
|
155
|
+
"""Assign or update dashboard rights to a user by ID
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
user_id: Numeric ID of the user
|
|
159
|
+
dashboard_rights: List of dashboard rights. Example:
|
|
160
|
+
[
|
|
161
|
+
{
|
|
162
|
+
"dashboardId": 123,
|
|
163
|
+
"editable": true,
|
|
164
|
+
"organigrams": [1, 2, 3]
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
|
|
168
|
+
Raises:
|
|
169
|
+
requests.exceptions.RequestException: If the API request fails
|
|
170
|
+
ValueError: If user_id is not an integer or input data is invalid
|
|
171
|
+
requests.exceptions.HTTPError: If user is not found (404)
|
|
172
|
+
"""
|
|
173
|
+
if not isinstance(user_id, int):
|
|
174
|
+
raise ValueError("user_id must be an integer")
|
|
175
|
+
|
|
176
|
+
payload = {
|
|
177
|
+
"dashboardRights": dashboard_rights
|
|
178
|
+
}
|
|
179
|
+
valid_data, _ = Functions.validate_pydantic_data(payload, schema=DashboardRightsPayload)
|
|
180
|
+
|
|
181
|
+
response = self._brynq.brynq_session.post(
|
|
182
|
+
url=f'{self._brynq.url}users/{user_id}/dashboards',
|
|
183
|
+
json=valid_data[0],
|
|
184
|
+
timeout=self._brynq.timeout
|
|
185
|
+
)
|
|
186
|
+
response.raise_for_status()
|
|
187
|
+
return response
|
|
188
|
+
|
|
189
|
+
def assign_roles(self, user_id: int, roles: List[int]) -> None:
|
|
190
|
+
"""Assign roles to a user by ID
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
user_id: Numeric ID of the user
|
|
194
|
+
roles: List of role IDs to assign. Example:
|
|
195
|
+
[1, 2, 3]
|
|
196
|
+
|
|
197
|
+
Raises:
|
|
198
|
+
requests.exceptions.RequestException: If the API request fails
|
|
199
|
+
ValueError: If user_id is not an integer or input data is invalid
|
|
200
|
+
requests.exceptions.HTTPError: If user is not found (404)
|
|
201
|
+
"""
|
|
202
|
+
import warnings
|
|
203
|
+
warnings.warn("This method is deprecated. Use update() instead.", DeprecationWarning)
|
|
204
|
+
response = self.update(user_id, {"roles": roles})
|
|
205
|
+
response.raise_for_status()
|
|
206
|
+
return response
|
|
207
|
+
|
|
208
|
+
def assign_organigram_entities(self, user_id: int, organigram_entities: list) -> dict:
|
|
209
|
+
"""Assign organigrams to a user by ID.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
user_id (int): Numeric ID of the user
|
|
213
|
+
organigram_entities (list): List of organigram entity objects
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
dict: Response from the API
|
|
217
|
+
|
|
218
|
+
Raises:
|
|
219
|
+
ValueError: If user_id is not an integer or input data is invalid
|
|
220
|
+
requests.exceptions.RequestException: If the API request fails
|
|
221
|
+
"""
|
|
222
|
+
if not isinstance(user_id, int):
|
|
223
|
+
raise ValueError("user_id must be an integer")
|
|
224
|
+
payload = {"organigramEntities": organigram_entities}
|
|
225
|
+
valid_data, _ = Functions.validate_pydantic_data(payload, schema=UserEntitiesPayload)
|
|
226
|
+
response = self._brynq.brynq_session.post(
|
|
227
|
+
url=f"{self._brynq.url}users/{user_id}/organigram-entities",
|
|
228
|
+
json=valid_data[0],
|
|
229
|
+
timeout=self._brynq.timeout
|
|
230
|
+
)
|
|
231
|
+
response.raise_for_status()
|
|
232
|
+
return response.json()
|
|
233
|
+
|
|
234
|
+
def assign_dashboard_qlik(self, user_id: int, qlik_dashboard_rights: list) -> dict:
|
|
235
|
+
"""Assign or update Qlik dashboard rights to a user by ID.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
user_id (int): Numeric ID of the user
|
|
239
|
+
qlik_dashboard_rights (list): List of Qlik dashboard rights objects
|
|
240
|
+
|
|
241
|
+
Returns:
|
|
242
|
+
dict: Response from the API
|
|
243
|
+
|
|
244
|
+
Raises:
|
|
245
|
+
ValueError: If user_id is not an integer or input data is invalid
|
|
246
|
+
requests.exceptions.RequestException: If the API request fails
|
|
247
|
+
"""
|
|
248
|
+
if not isinstance(user_id, int):
|
|
249
|
+
raise ValueError("user_id must be an integer")
|
|
250
|
+
payload = {"qlikDashboardRights": qlik_dashboard_rights}
|
|
251
|
+
valid_data, _ = Functions.validate_pydantic_data(payload, schema=QlikDashboardRightsPayload)
|
|
252
|
+
response = self._brynq.brynq_session.post(
|
|
253
|
+
url=f"{self._brynq.url}users/{user_id}/dashboards/qlik",
|
|
254
|
+
json=valid_data[0],
|
|
255
|
+
timeout=self._brynq.timeout
|
|
256
|
+
)
|
|
257
|
+
response.raise_for_status()
|
|
258
|
+
return response.json()
|
|
259
|
+
|
|
260
|
+
def assign_qlik_dashboard_rights(self, user_id: int, dashboard_rights: List[Dict[str, Any]]) -> None:
|
|
261
|
+
"""Assign or update Qlik dashboard rights to a user by ID
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
user_id: Numeric ID of the user
|
|
265
|
+
dashboard_rights: List of dashboard rights. Example:
|
|
266
|
+
[
|
|
267
|
+
{
|
|
268
|
+
"guid": "dashboard-guid",
|
|
269
|
+
"dataModelEdit": true,
|
|
270
|
+
"editable": true,
|
|
271
|
+
"organigrams": [1, 2, 3]
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
|
|
275
|
+
Raises:
|
|
276
|
+
requests.exceptions.RequestException: If the API request fails
|
|
277
|
+
ValueError: If user_id is not an integer or input data is invalid
|
|
278
|
+
requests.exceptions.HTTPError: If user is not found (404)
|
|
279
|
+
"""
|
|
280
|
+
if not isinstance(user_id, int):
|
|
281
|
+
raise ValueError("user_id must be an integer")
|
|
282
|
+
|
|
283
|
+
payload = {
|
|
284
|
+
"dashboardRights": dashboard_rights
|
|
285
|
+
}
|
|
286
|
+
valid_data, _ = Functions.validate_pydantic_data(payload, schema=QlikDashboardRightsPayload)
|
|
287
|
+
|
|
288
|
+
response = self._brynq.brynq_session.post(
|
|
289
|
+
url=f'{self._brynq.url}users/{user_id}/dashboards/qlik',
|
|
290
|
+
json=valid_data[0],
|
|
291
|
+
timeout=self._brynq.timeout
|
|
292
|
+
)
|
|
293
|
+
response.raise_for_status()
|
|
294
|
+
return response
|
|
295
|
+
|
|
296
|
+
def get_user_authorization_qlik_app(self, guid: str) -> List[Dict[str, Any]]:
|
|
297
|
+
"""Get all users who have access to a Qlik dashboard with their entities
|
|
298
|
+
|
|
299
|
+
Args:
|
|
300
|
+
guid: GUID of the Qlik dashboard
|
|
301
|
+
|
|
302
|
+
Returns:
|
|
303
|
+
List[Dict[str, Any]]: List of users and their entities. Example:
|
|
304
|
+
[
|
|
305
|
+
{
|
|
306
|
+
"username": null,
|
|
307
|
+
"userId": 420687,
|
|
308
|
+
"entityCodes": []
|
|
309
|
+
}
|
|
310
|
+
]
|
|
311
|
+
|
|
312
|
+
Raises:
|
|
313
|
+
requests.exceptions.RequestException: If the API request fails
|
|
314
|
+
ValueError: If the input data is invalid
|
|
315
|
+
"""
|
|
316
|
+
response = self._brynq.brynq_session.get(
|
|
317
|
+
url=f'{self._brynq.url}/qlik/{guid}/users',
|
|
318
|
+
timeout=self._brynq.timeout
|
|
319
|
+
)
|
|
320
|
+
response.raise_for_status()
|
|
321
|
+
|
|
322
|
+
# Wrap response in authorizations field to match schema
|
|
323
|
+
valid_data, _ = Functions.validate_pydantic_data(response.json(), schema=QlikAppUserAuthorization)
|
|
324
|
+
return valid_data
|
|
325
|
+
|
|
326
|
+
def assign_user_entities(self, user_id: int, entity_ids: List[int]) -> requests.Response:
|
|
327
|
+
"""Assign organization entities to a user
|
|
328
|
+
|
|
329
|
+
Args:
|
|
330
|
+
user_id: Numeric ID of the user
|
|
331
|
+
entity_ids: List of entity IDs to assign. Example:
|
|
332
|
+
[1, 2, 3]
|
|
333
|
+
|
|
334
|
+
Raises:
|
|
335
|
+
requests.exceptions.RequestException: If the API request fails
|
|
336
|
+
ValueError: If user_id is not an integer or input data is invalid
|
|
337
|
+
requests.exceptions.HTTPError: If user is not found (404)
|
|
338
|
+
"""
|
|
339
|
+
if not isinstance(user_id, int):
|
|
340
|
+
raise ValueError("user_id must be an integer")
|
|
341
|
+
|
|
342
|
+
payload = {"entities": entity_ids}
|
|
343
|
+
valid_data, _ = Functions.validate_pydantic_data(payload, schema=UserEntitiesPayload)
|
|
344
|
+
|
|
345
|
+
response = self._brynq.brynq_session.post(
|
|
346
|
+
url=f'{self._brynq.url}users/{user_id}/organigram-entities',
|
|
347
|
+
json=valid_data[0],
|
|
348
|
+
timeout=self._brynq.timeout
|
|
349
|
+
)
|
|
350
|
+
response.raise_for_status()
|
|
351
|
+
return response
|
|
352
|
+
|
|
353
|
+
def update_user_entities(self, user_id: int, entity_ids: List[int]) -> None:
|
|
354
|
+
"""Overwrite organization entities for a user
|
|
355
|
+
|
|
356
|
+
Args:
|
|
357
|
+
user_id: Numeric ID of the user
|
|
358
|
+
entity_ids: List of entity IDs to set. Example:
|
|
359
|
+
[1, 2, 3]
|
|
360
|
+
|
|
361
|
+
Raises:
|
|
362
|
+
requests.exceptions.RequestException: If the API request fails
|
|
363
|
+
ValueError: If user_id is not an integer or input data is invalid
|
|
364
|
+
requests.exceptions.HTTPError: If user is not found (404)
|
|
365
|
+
"""
|
|
366
|
+
if not isinstance(user_id, int):
|
|
367
|
+
raise ValueError("user_id must be an integer")
|
|
368
|
+
|
|
369
|
+
payload = {"entities": entity_ids}
|
|
370
|
+
valid_data, _ = Functions.validate_pydantic_data(payload, schema=UserEntitiesPayload)
|
|
371
|
+
|
|
372
|
+
response = self._brynq.brynq_session.put(
|
|
373
|
+
url=f'{self._brynq.url}users/{user_id}/organigram-entities',
|
|
374
|
+
json=valid_data[0],
|
|
375
|
+
timeout=self._brynq.timeout
|
|
376
|
+
)
|
|
377
|
+
response.raise_for_status()
|
|
378
|
+
return response
|
|
379
|
+
|
|
380
|
+
def delete_user_entities(self, user_id: int, entity_ids: List[int]) -> None:
|
|
381
|
+
"""Delete organization entities from a user
|
|
382
|
+
|
|
383
|
+
Args:
|
|
384
|
+
user_id: Numeric ID of the user
|
|
385
|
+
entity_ids: List of entity IDs to delete. Example:
|
|
386
|
+
[1, 2, 3]
|
|
387
|
+
|
|
388
|
+
Raises:
|
|
389
|
+
requests.exceptions.RequestException: If the API request fails
|
|
390
|
+
ValueError: If user_id is not an integer or input data is invalid
|
|
391
|
+
requests.exceptions.HTTPError: If user is not found (404)
|
|
392
|
+
"""
|
|
393
|
+
if not isinstance(user_id, int):
|
|
394
|
+
raise ValueError("user_id must be an integer")
|
|
395
|
+
|
|
396
|
+
payload = {"entities": entity_ids}
|
|
397
|
+
valid_data, _ = Functions.validate_pydantic_data(payload, schema=UserEntitiesPayload)
|
|
398
|
+
|
|
399
|
+
response = self._brynq.brynq_session.delete(
|
|
400
|
+
url=f'{self._brynq.url}users/{user_id}/organigram-entities',
|
|
401
|
+
json=valid_data[0],
|
|
402
|
+
timeout=self._brynq.timeout
|
|
403
|
+
)
|
|
404
|
+
response.raise_for_status()
|
|
405
|
+
return response
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: brynq_sdk_brynq
|
|
3
|
+
Version: 4.2.6.dev0
|
|
4
|
+
Summary: BrynQ SDK for the BrynQ.com platform
|
|
5
|
+
Author: BrynQ
|
|
6
|
+
Author-email: support@brynq.com
|
|
7
|
+
License: BrynQ License
|
|
8
|
+
Requires-Dist: requests<=3,>=2
|
|
9
|
+
Requires-Dist: pydantic[email]
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: author-email
|
|
12
|
+
Dynamic: description
|
|
13
|
+
Dynamic: license
|
|
14
|
+
Dynamic: requires-dist
|
|
15
|
+
Dynamic: summary
|
|
16
|
+
|
|
17
|
+
BrynQ SDK for the BrynQ.com platform
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
brynq_sdk_brynq/__init__.py,sha256=7Sz8dmyk0PMMPl-8y56eZEeP09qQ3O6Fo-Xvz-_oDH8,24
|
|
2
|
+
brynq_sdk_brynq/brynq.py,sha256=jNx_9nM-0PIYiqy2gTfDabQWB72xLQ6_Fbu8jofN7sI,12010
|
|
3
|
+
brynq_sdk_brynq/credentials.py,sha256=tDJ_tnOWTJ5yCrc39NFvMvWH-di0i8c1GknH-gE5XmI,7026
|
|
4
|
+
brynq_sdk_brynq/customers.py,sha256=l3z6MAfOmghJIu0uBcqqv9mGgSN4akwSkXv1gzvm-l0,3388
|
|
5
|
+
brynq_sdk_brynq/interfaces.py,sha256=SRT4ZbsMjIN11moCf_eHLTrwx9VlQWnLOL-asAqHRig,9526
|
|
6
|
+
brynq_sdk_brynq/mappings.py,sha256=Us9iKCW1bMMJZ8LFy3lZ4_F0DMsWaklylHHIOeFrCWA,4300
|
|
7
|
+
brynq_sdk_brynq/organization_chart.py,sha256=CqGz1T_B7UCAncikQwYp3svC3Q_kXvkxOskvttmXs4k,9003
|
|
8
|
+
brynq_sdk_brynq/roles.py,sha256=cDTmDPV3zMGbOSFJvAbXxgMV1yZg_sMK_tNTfXn-HXI,10750
|
|
9
|
+
brynq_sdk_brynq/scenarios.py,sha256=kAn8jiTE8QtKl4FtaxDOyPLj8yW9Bn7BdTeX8U1jB78,157289
|
|
10
|
+
brynq_sdk_brynq/source_systems.py,sha256=XCMXPLKz6w43n4_HPD7CiiQCJkzkNJkYhy4D-gA_d5w,5815
|
|
11
|
+
brynq_sdk_brynq/users.py,sha256=TIeCse-7epG_VpGxOFj3Qb2EZZYmdkgHeqnYDDKrYl4,14836
|
|
12
|
+
brynq_sdk_brynq/schemas/__init__.py,sha256=IrHXkOXEnkVWx3BmHm2HaaL6TOSa0OeV1gBV1AkvFc4,1917
|
|
13
|
+
brynq_sdk_brynq/schemas/credentials.py,sha256=RJe2jjsCklCWv6DOgqFqG23SfZRO-_cmFFZC1uoBQF0,1231
|
|
14
|
+
brynq_sdk_brynq/schemas/customers.py,sha256=dcQFkTlEZMC67kE-3G3qiVNkb8AsxkpwyFMebbNjhV4,4608
|
|
15
|
+
brynq_sdk_brynq/schemas/interfaces.py,sha256=0IwtPxJFBT9P7HO79mMgAgqATbjB96F5_v_s5G4wVZk,10544
|
|
16
|
+
brynq_sdk_brynq/schemas/organization_chart.py,sha256=cWmsOZI-htRzeaV_WdazBadZaYaYO8HQfcCo-rnQsv0,2332
|
|
17
|
+
brynq_sdk_brynq/schemas/roles.py,sha256=R0xUMZmvkMRpioXLlsi8TlycDDt3X9Vn1_PFYjLJJV8,3847
|
|
18
|
+
brynq_sdk_brynq/schemas/scenarios.py,sha256=GmQdfWmJd7vNbU_D1gCO36yzqQP1iI9zvc9csDG7ZCk,16747
|
|
19
|
+
brynq_sdk_brynq/schemas/users.py,sha256=dbrfzgfD_t3m6GpAMbw5X8h3Ff2epxh6-LEVEnvB_bE,4740
|
|
20
|
+
brynq_sdk_brynq-4.2.6.dev0.dist-info/METADATA,sha256=Z_E-DjmSm1H6cMHKoGD1mTQdFZLtdLZ67wBztH4hvMs,395
|
|
21
|
+
brynq_sdk_brynq-4.2.6.dev0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
22
|
+
brynq_sdk_brynq-4.2.6.dev0.dist-info/top_level.txt,sha256=CFsh8XAR_vNM0GEchao42bnpaeqYy64AVK2eARymew4,16
|
|
23
|
+
brynq_sdk_brynq-4.2.6.dev0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
brynq_sdk_brynq
|