brynq-sdk-brynq 3.0.4__tar.gz → 4.0.0__tar.gz

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.

Files changed (26) hide show
  1. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/PKG-INFO +1 -1
  2. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/brynq.py +17 -12
  3. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/credentials.py +6 -6
  4. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/customers.py +3 -3
  5. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/interfaces.py +51 -80
  6. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/mappings.py +5 -9
  7. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/organization_chart.py +9 -9
  8. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/roles.py +9 -9
  9. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/source_systems.py +7 -7
  10. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/users.py +14 -14
  11. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq.egg-info/PKG-INFO +1 -1
  12. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/setup.py +1 -1
  13. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/__init__.py +0 -0
  14. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/schemas/__init__.py +0 -0
  15. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/schemas/credentials.py +0 -0
  16. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/schemas/customers.py +0 -0
  17. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/schemas/interfaces.py +0 -0
  18. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/schemas/organization_chart.py +0 -0
  19. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/schemas/roles.py +0 -0
  20. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq/schemas/users.py +0 -0
  21. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq.egg-info/SOURCES.txt +0 -0
  22. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq.egg-info/dependency_links.txt +0 -0
  23. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq.egg-info/not-zip-safe +0 -0
  24. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq.egg-info/requires.txt +0 -0
  25. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/brynq_sdk_brynq.egg-info/top_level.txt +0 -0
  26. {brynq_sdk_brynq-3.0.4 → brynq_sdk_brynq-4.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_brynq
3
- Version: 3.0.4
3
+ Version: 4.0.0
4
4
  Summary: BrynQ SDK for the BrynQ.com platform
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -19,6 +19,10 @@ class BrynQ:
19
19
  self.api_token = os.getenv("BRYNQ_API_TOKEN", api_token)
20
20
  self.environment = os.getenv("BRYNQ_ENVIRONMENT", staging)
21
21
  self.timeout = 3600
22
+ self.data_interface_id = os.getenv("DATA_INTERFACE_ID")
23
+ if self.data_interface_id is None:
24
+ raise ValueError("BRYNQ_DATA_INTERFACE_ID environment variable is not set, you should use this class via the TaskScheduler or set the variable in your code with:"
25
+ "os.environ['DATA_INTERFACE_ID'] = str(self.data_interface_id). This is better than setting it in your .env where you will have to change it when switching between interfaces.")
22
26
 
23
27
  if any([self.subdomain is None, self.api_token is None]):
24
28
  raise ValueError("Set the subdomain, api_token either in your .env file or provide the subdomain and api_token parameters")
@@ -29,17 +33,17 @@ class BrynQ:
29
33
 
30
34
  self.url = 'https://app.brynq-staging.com/api/v2/' if self.environment == 'dev' else 'https://app.brynq.com/api/v2/'
31
35
 
32
- # Initialize session with retry strategy
33
- self.session = requests.Session()
36
+ # Initialize session with retry strategy. This is called brynq_session and not session as to not conflict with other SDKs that use self.session
37
+ self.brynq_session = requests.Session()
34
38
  retry_strategy = Retry(
35
39
  total=3, # number of retries
36
40
  backoff_factor=0.5, # wait 0.5s * (2 ** (retry - 1)) between retries
37
41
  status_forcelist=[500, 502, 503, 504] # HTTP status codes to retry on
38
42
  )
39
43
  adapter = HTTPAdapter(max_retries=retry_strategy)
40
- self.session.mount("http://", adapter)
41
- self.session.mount("https://", adapter)
42
- self.session.headers.update(self._get_headers())
44
+ self.brynq_session.mount("http://", adapter)
45
+ self.brynq_session.mount("https://", adapter)
46
+ self.brynq_session.headers.update(self._get_headers())
43
47
 
44
48
  # Initialize components
45
49
  self.users = Users(self)
@@ -55,7 +59,7 @@ class BrynQ:
55
59
  'Domain': self.subdomain
56
60
  }
57
61
 
58
- def get_mapping(self, data_interface_id: int, mapping: str, return_format: Literal['input_as_key', 'columns_names_as_keys', 'nested_input_output'] = 'input_as_key') -> dict:
62
+ def get_mapping(self, mapping: str, return_format: Literal['input_as_key', 'columns_names_as_keys', 'nested_input_output'] = 'input_as_key') -> dict:
59
63
  """
60
64
  DEPRECATED: Use brynq.mappings.get_mapping() instead
61
65
  """
@@ -72,7 +76,7 @@ class BrynQ:
72
76
  :return: The json of the mapping
73
77
  """
74
78
  # Find the mapping for the given sheet name
75
- mappings = self.interfaces.mappings._get_mappings(interface_id=data_interface_id)
79
+ mappings = self.interfaces.mappings._get_mappings(interface_id=self.data_interface_id)
76
80
  mapping_data = next((item for item in mappings if item['name'] == mapping), None)
77
81
  if not mapping_data:
78
82
  raise ValueError(f"Mapping named '{mapping}' not found")
@@ -107,7 +111,7 @@ class BrynQ:
107
111
 
108
112
  return final_mapping
109
113
 
110
- def get_mapping_as_dataframe(self, data_interface_id: int, mapping: str, prefix: bool = False) -> pd.DataFrame:
114
+ def get_mapping_as_dataframe(self, mapping: str, prefix: bool = False) -> pd.DataFrame:
111
115
  """
112
116
  DEPRECATED: Use brynq.mappings.get_mapping_as_dataframe() instead
113
117
  """
@@ -123,7 +127,7 @@ class BrynQ:
123
127
  :return: The dataframe of the mapping
124
128
  """
125
129
  # Find the mapping for the given sheet name
126
- mappings = self.interfaces.mappings._get_mappings(interface_id=data_interface_id)
130
+ mappings = self.interfaces.mappings._get_mappings()
127
131
  mapping_data = next((item for item in mappings if item['name'] == mapping), None)
128
132
  if not mapping_data:
129
133
  raise ValueError(f"Mapping named '{mapping}' not found")
@@ -150,6 +154,7 @@ class BrynQ:
150
154
  df = pd.DataFrame(rows)
151
155
 
152
156
  return df
157
+
153
158
  def get_system_credential(self, system: str, label: Union[str, list], test_environment: bool = False) -> dict:
154
159
  """
155
160
  DEPRECATED: Use brynq.credentials.get() instead
@@ -161,7 +166,7 @@ class BrynQ:
161
166
  )
162
167
  return self.interfaces.credentials.get_system_credential(system, label, test_environment)
163
168
 
164
- def get_interface_credential(self, interface_id: str, system: str, system_type: Optional[str] = None,
169
+ def get_interface_credential(self, system: str, system_type: Optional[str] = None,
165
170
  test_environment: bool = False) -> Union[dict, List[dict]]:
166
171
  """
167
172
  DEPRECATED: Use brynq.credentials.get_interface_credential() instead
@@ -171,7 +176,7 @@ class BrynQ:
171
176
  DeprecationWarning,
172
177
  stacklevel=2
173
178
  )
174
- return self.interfaces.credentials.get(interface_id, system, system_type, test_environment)
179
+ return self.interfaces.credentials.get(self.data_interface_id, system, system_type, test_environment)
175
180
 
176
181
  def get_user_data(self):
177
182
  """
@@ -281,4 +286,4 @@ class BrynQ:
281
286
  def close(self):
282
287
  """Close the session and cleanup resources"""
283
288
  if hasattr(self, 'session'):
284
- self.session.close()
289
+ self.brynq_session.close()
@@ -24,7 +24,7 @@ class Credentials:
24
24
  DEPRECATED: Use brynq.interfaces.credentials.get() instead
25
25
  """
26
26
  warnings.warn("This function is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
27
- response = self._brynq.session.get(
27
+ response = self._brynq.brynq_session.get(
28
28
  url=f'{self._brynq.url}apps/{system}',
29
29
  timeout=self._brynq.timeout
30
30
  )
@@ -47,7 +47,7 @@ class Credentials:
47
47
 
48
48
  return credentials[0]
49
49
 
50
- def get(self,interface_id: str, system: str,system_type: Optional[str] = None,test_environment: bool = False) -> Union[dict, List[dict]]:
50
+ def get(self, system: str, system_type: Optional[str] = None, test_environment: bool = False) -> Union[dict, List[dict]]:
51
51
  """
52
52
  This method retrieves authentication credentials from BrynQ for a specific interface and system.
53
53
 
@@ -60,7 +60,7 @@ class Credentials:
60
60
  """
61
61
 
62
62
  # Fetch the config using a separate method
63
- config = self._fetch_config(interface_id)
63
+ config = self._fetch_config()
64
64
 
65
65
  matching_credentials = []
66
66
 
@@ -129,7 +129,7 @@ class Credentials:
129
129
  warnings.warn(warning_msg)
130
130
  return [cred['credential'] for cred in matching_credentials]
131
131
 
132
- def _fetch_config(self, interface_id: str) -> Dict[str, Any]:
132
+ def _fetch_config(self) -> Dict[str, Any]:
133
133
  """
134
134
  Fetch configuration from BrynQ for a given interface ID.
135
135
 
@@ -143,8 +143,8 @@ class Credentials:
143
143
  ValueError: If the response data is invalid.
144
144
  requests.exceptions.RequestException: If the API request fails.
145
145
  """
146
- response = self._brynq.session.get(
147
- url=f'{self._brynq.url}interfaces/{interface_id}/config/auth',
146
+ response = self._brynq.brynq_session.get(
147
+ url=f'{self._brynq.url}interfaces/{self._brynq.data_interface_id}/config/auth',
148
148
  timeout=self._brynq.timeout
149
149
  )
150
150
  response.raise_for_status()
@@ -25,7 +25,7 @@ class Customers:
25
25
  requests.exceptions.RequestException: If the API request fails
26
26
  ValueError: If the response data doesn't match the expected schema
27
27
  """
28
- response = self.brynq.session.get(
28
+ response = self.brynq.brynq_session.get(
29
29
  url=f"{self.brynq.url}customers",
30
30
  timeout=self.brynq.timeout
31
31
  )
@@ -48,7 +48,7 @@ class Customers:
48
48
  requests.exceptions.RequestException: If the API request fails
49
49
  ValueError: If the response data doesn't match the expected schema
50
50
  """
51
- response = self.brynq.session.get(
51
+ response = self.brynq.brynq_session.get(
52
52
  f"{self.brynq.url}customers/contract-details",
53
53
  timeout=self.brynq.timeout
54
54
  )
@@ -74,7 +74,7 @@ class Customers:
74
74
  ValueError: If the response data is invalid.
75
75
  requests.exceptions.RequestException: If the API request fails.
76
76
  """
77
- response = self.brynq.session.get(
77
+ response = self.brynq.brynq_session.get(
78
78
  f"{self.brynq.url}customers/{customer_id}/contract-details",
79
79
  timeout=self.brynq.timeout
80
80
  )
@@ -19,7 +19,7 @@ class Interfaces:
19
19
  self.credentials = Credentials(brynq_instance)
20
20
  self.mappings = Mappings(brynq_instance)
21
21
 
22
- def get(self) -> List[Dict[str, Any]]:
22
+ def get_all(self) -> List[Dict[str, Any]]:
23
23
  """Get all interfaces this token has access to.
24
24
 
25
25
  Returns:
@@ -35,7 +35,7 @@ class Interfaces:
35
35
  ValueError: If the response data is invalid
36
36
  requests.exceptions.RequestException: If the API request fails
37
37
  """
38
- response = self._brynq.session.get(
38
+ response = self._brynq.brynq_session.get(
39
39
  f"{self._brynq.url}interfaces",
40
40
  timeout=self._brynq.timeout
41
41
  )
@@ -48,12 +48,8 @@ class Interfaces:
48
48
  except ValueError as e:
49
49
  raise ValueError(f"Invalid interface data received from API: {str(e)}")
50
50
 
51
- def get_by_id(self, interface_id: int) -> Dict[str, Any]:
51
+ def get(self) -> Dict[str, Any]:
52
52
  """Get a specific interface by its ID.
53
-
54
- Args:
55
- interface_id (int): The ID of the interface to retrieve
56
-
57
53
  Returns:
58
54
  Dict[str, Any]: Interface details including:
59
55
  - name (str): Interface name
@@ -67,11 +63,9 @@ class Interfaces:
67
63
  requests.exceptions.RequestException: If the API request fails
68
64
  """
69
65
  # Basic validation
70
- if not isinstance(interface_id, int) or interface_id <= 0:
71
- raise ValueError("interface_id must be a positive integer")
72
66
 
73
- response = self._brynq.session.get(
74
- f"{self._brynq.url}interfaces/{interface_id}",
67
+ response = self._brynq.brynq_session.get(
68
+ f"{self._brynq.url}interfaces/{self._brynq.data_interface_id}",
75
69
  timeout=self._brynq.timeout
76
70
  )
77
71
  response.raise_for_status()
@@ -83,7 +77,7 @@ class Interfaces:
83
77
  except ValueError as e:
84
78
  raise ValueError(f"Invalid interface data received from API: {str(e)}")
85
79
 
86
- def get_config(self, interface_id: int) -> Dict[str, Any]:
80
+ def get_config(self) -> Dict[str, Any]:
87
81
  """Get the base configuration of an interface.
88
82
 
89
83
  Args:
@@ -99,11 +93,9 @@ class Interfaces:
99
93
  requests.exceptions.RequestException: If the API request fails
100
94
  """
101
95
  # Basic validation
102
- if not isinstance(interface_id, int) or interface_id <= 0:
103
- raise ValueError("interface_id must be a positive integer")
104
96
 
105
- response = self._brynq.session.get(
106
- f"{self._brynq.url}interfaces/{interface_id}/config",
97
+ response = self._brynq.brynq_session.get(
98
+ f"{self._brynq.url}interfaces/{self._brynq.data_interface_id}/config",
107
99
  timeout=self._brynq.timeout
108
100
  )
109
101
  response.raise_for_status()
@@ -115,52 +107,26 @@ class Interfaces:
115
107
  except ValueError as e:
116
108
  raise ValueError(f"Invalid interface configuration data: {str(e)}")
117
109
 
118
- def flush_config(self, interface_id: int) -> Dict[str, Any]:
110
+ def flush_config(self) -> Dict[str, Any]:
119
111
  """
120
112
  Flushes the interface config to revert to a fresh state.
121
-
122
- Args:
123
- interface_id: The ID of the interface
124
-
113
+
125
114
  Returns:
126
115
  Dict[str, Any]: Response from the flush operation
127
116
 
128
117
  Raises:
129
118
  requests.exceptions.RequestException: If the API request fails
130
119
  """
131
- response = self._brynq.session.get(
132
- url=f'{self._brynq.url}interfaces/{interface_id}/config/flush',
120
+ response = self._brynq.brynq_session.get(
121
+ url=f'{self._brynq.url}interfaces/{self._brynq.data_interface_id}/config/flush',
133
122
  timeout=self._brynq.timeout
134
123
  )
135
124
  response.raise_for_status()
136
125
  return response
137
126
 
138
- def get_dataflows(self, interface_id: int) -> Dict[str, Any]:
139
- """
140
- Get the dataflows configuration of an interface.
141
-
142
- Args:
143
- interface_id: The ID of the interface
144
-
145
- Returns:
146
- Dict[str, Any]: Dataflows configuration
147
-
148
- Raises:
149
- requests.exceptions.RequestException: If the API request fails
150
- """
151
- response = self._brynq.session.get(
152
- url=f'{self._brynq.url}interfaces/{interface_id}/config/dataflows',
153
- timeout=self._brynq.timeout
154
- )
155
- response.raise_for_status()
156
- return response.json()
157
-
158
- def get_schedule(self, interface_id: int) -> Dict[str, Any]:
127
+ def get_schedule(self) -> Dict[str, Any]:
159
128
  """Get the schedule configuration of an interface.
160
-
161
- Args:
162
- interface_id (int): The ID of the interface
163
-
129
+
164
130
  Returns:
165
131
  Dict[str, Any]: Schedule configuration including:
166
132
  - id (int): The schedule ID
@@ -177,12 +143,8 @@ class Interfaces:
177
143
  ValueError: If interface_id is not a positive integer or if the response data is invalid
178
144
  requests.exceptions.RequestException: If the API request fails
179
145
  """
180
- # Basic validation
181
- if not isinstance(interface_id, int) or interface_id <= 0:
182
- raise ValueError("interface_id must be a positive integer")
183
-
184
- response = self._brynq.session.get(
185
- f"{self._brynq.url}interfaces/{interface_id}/config/schedule",
146
+ response = self._brynq.brynq_session.get(
147
+ f"{self._brynq.url}interfaces/{self._brynq.data_interface_id}/config/schedule",
186
148
  timeout=self._brynq.timeout
187
149
  )
188
150
  response.raise_for_status()
@@ -194,32 +156,26 @@ class Interfaces:
194
156
  except ValueError as e:
195
157
  raise ValueError(f"Invalid schedule configuration data: {str(e)}")
196
158
 
197
- def get_template_config(self, interface_id: int) -> Dict[str, Any]:
159
+ def get_template_config(self) -> Dict[str, Any]:
198
160
  """
199
161
  Get the template configuration of an interface.
200
-
201
- Args:
202
- interface_id: The ID of the interface
203
-
162
+
204
163
  Returns:
205
164
  Dict[str, Any]: Template configuration
206
165
 
207
166
  Raises:
208
167
  requests.exceptions.RequestException: If the API request fails
209
168
  """
210
- response = self._brynq.session.get(
211
- url=f'{self._brynq.url}interfaces/{interface_id}/template-config',
169
+ response = self._brynq.brynq_session.get(
170
+ url=f'{self._brynq.url}interfaces/{self._brynq.data_interface_id}/template-config',
212
171
  timeout=self._brynq.timeout
213
172
  )
214
173
  response.raise_for_status()
215
174
  return response.json()
216
175
 
217
- def get_scope(self, interface_id: int) -> Dict[str, Any]:
176
+ def get_scope(self) -> Dict[str, Any]:
218
177
  """Get live and draft scopes from interface by id.
219
-
220
- Args:
221
- interface_id (int): The ID of the interface
222
-
178
+
223
179
  Returns:
224
180
  Dict[str, Any]: Scope configuration including:
225
181
  - live (Dict, optional): Live scope configuration
@@ -229,12 +185,8 @@ class Interfaces:
229
185
  ValueError: If interface_id is not a positive integer or if the response data is invalid
230
186
  requests.exceptions.RequestException: If the API request fails
231
187
  """
232
- # Basic validation
233
- if not isinstance(interface_id, int) or interface_id <= 0:
234
- raise ValueError("interface_id must be a positive integer")
235
-
236
- response = self._brynq.session.get(
237
- f"{self._brynq.url}interfaces/{interface_id}/scope",
188
+ response = self._brynq.brynq_session.get(
189
+ f"{self._brynq.url}interfaces/{self._brynq.data_interface_id}/scope",
238
190
  timeout=self._brynq.timeout
239
191
  )
240
192
  response.raise_for_status()
@@ -246,12 +198,9 @@ class Interfaces:
246
198
  except ValueError as e:
247
199
  raise ValueError(f"Invalid scope data: {str(e)}")
248
200
 
249
- def get_dev_settings(self, interface_id: int) -> List[dict[str,Any]]:
201
+ def get_dev_settings(self) -> List[dict[str,Any]]:
250
202
  """Get the dev-settings of an interface
251
203
 
252
- Args:
253
- interface_id: Numeric ID of the interface
254
-
255
204
  Returns:
256
205
  Dict[str, Any]: A dictionary containing the dev settings:
257
206
  - dockerImage (str): Docker image name
@@ -264,14 +213,36 @@ class Interfaces:
264
213
  requests.exceptions.HTTPError: If dev settings not found (404)
265
214
  ValueError: If interface_id is not a positive integer
266
215
  """
267
- if not isinstance(interface_id, int) or interface_id <= 0:
268
- raise ValueError("interface_id must be a positive integer")
269
216
 
270
- response = self._brynq.session.get(
271
- url=f"{self._brynq.url}interfaces/{interface_id}/config/dev-settings",
217
+ response = self._brynq.brynq_session.get(
218
+ url=f"{self._brynq.url}interfaces/{self._brynq.data_interface_id}/config/dev-settings",
272
219
  timeout=self._brynq.timeout
273
220
  )
274
221
  response.raise_for_status()
275
222
 
276
223
  valid_data, _ = Functions.validate_pydantic_data(response.json(), schema=DevSettings)
277
224
  return valid_data
225
+
226
+ def get_variables(self, variable_name: str = None):
227
+ """
228
+ Get a value from the task_variables table corresponding with the given name. If temp value is filled, it will
229
+ (run_instant = 1), then the temp_value will be returned. This is to give the possibility for users in the frontend to run
230
+ a task once manual with other values then normal without overwriting the normal values.
231
+ :param variable_name: the name of the variable
232
+ :return: the value of the given variable.
233
+ """
234
+
235
+ variables = self.get_config().get("variables")
236
+
237
+ if not variables:
238
+ raise Exception(f"There are no valid variables in interface '{self._brynq.data_interface_id}'")
239
+
240
+ if variable_name:
241
+ variable = variables.get(variable_name)
242
+ if not variable:
243
+ raise Exception(f"The variable '{variable_name}' does not exist in interface '{self._brynq.data_interface_id}'")
244
+ self.flush_config()
245
+ return variable
246
+ else:
247
+ self.flush_config()
248
+ return variables
@@ -22,7 +22,7 @@ class Mappings:
22
22
  """
23
23
  self._brynq = brynq_instance
24
24
 
25
- def _get_mappings(self, interface_id: int) -> List[Dict[str, Any]]:
25
+ def _get_mappings(self) -> List[Dict[str, Any]]:
26
26
  """Get all mappings for an interface.
27
27
 
28
28
  Args:
@@ -35,12 +35,8 @@ class Mappings:
35
35
  ValueError: If interface_id is not a positive integer or if the response data is invalid
36
36
  requests.exceptions.RequestException: If the API request fails
37
37
  """
38
- # Basic validation
39
- if not isinstance(interface_id, int) or interface_id <= 0:
40
- raise ValueError("interface_id must be a positive integer")
41
-
42
- response = self._brynq.session.get(
43
- f"{self._brynq.url}interfaces/{interface_id}/config/mapping",
38
+ response = self._brynq.brynq_session.get(
39
+ f"{self._brynq.url}interfaces/{self._brynq.data_interface_id}/config/mapping",
44
40
  timeout=self._brynq.timeout
45
41
  )
46
42
  response.raise_for_status()
@@ -73,7 +69,7 @@ class Mappings:
73
69
  mappings[input_key] = output_value
74
70
  return mappings
75
71
 
76
- def get(self, interface_id: int, mapping: str, as_df: bool = False, prefix: bool = False) -> dict:
72
+ def get(self, mapping: str, as_df: bool = False, prefix: bool = False) -> dict:
77
73
  """Get the mapping from BrynQ.
78
74
 
79
75
  Args:
@@ -91,7 +87,7 @@ class Mappings:
91
87
  MappingNotFoundError: If mapping is not found
92
88
  ValueError: If mapping data is invalid
93
89
  """
94
- mappings = self._get_mappings(interface_id=interface_id)
90
+ mappings = self._get_mappings()
95
91
  mapping_data = next((item for item in mappings if item['name'] == mapping), None)
96
92
 
97
93
  if not mapping_data:
@@ -45,7 +45,7 @@ class OrganizationChart:
45
45
  if layout not in ["nested", "flat"]:
46
46
  raise ValueError('layout must be either "nested" or "flat"')
47
47
 
48
- response = self._brynq.session.get(
48
+ response = self._brynq.brynq_session.get(
49
49
  f"{self._brynq.url}organization-chart",
50
50
  params={"layout": layout},
51
51
  timeout=self._brynq.timeout
@@ -72,7 +72,7 @@ class OrganizationChart:
72
72
  requests.exceptions.RequestException: If the API request fails
73
73
  ValueError: If the response data is invalid
74
74
  """
75
- response = self._brynq.session.get(
75
+ response = self._brynq.brynq_session.get(
76
76
  f"{self._brynq.url}organization-chart/layers",
77
77
  timeout=self._brynq.timeout
78
78
  )
@@ -103,7 +103,7 @@ class OrganizationChart:
103
103
  """
104
104
  valid_data, _ = Functions.validate_pydantic_data(data, schema=OrganizationLayerCreate)
105
105
 
106
- response = self._brynq.session.post(
106
+ response = self._brynq.brynq_session.post(
107
107
  f"{self._brynq.url}organization-chart/layers",
108
108
  json=valid_data[0],
109
109
  timeout=self._brynq.timeout
@@ -130,7 +130,7 @@ class OrganizationChart:
130
130
  """
131
131
  valid_data, _ = Functions.validate_pydantic_data(data, schema=OrganizationLayerUpdate)
132
132
 
133
- response = self._brynq.session.put(
133
+ response = self._brynq.brynq_session.put(
134
134
  f"{self._brynq.url}organization-chart/layers/{data['id']}",
135
135
  json=valid_data[0],
136
136
  timeout=self._brynq.timeout
@@ -151,7 +151,7 @@ class OrganizationChart:
151
151
  if not isinstance(layer_id, int):
152
152
  raise ValueError("layer_id must be an integer")
153
153
 
154
- response = self._brynq.session.delete(
154
+ response = self._brynq.brynq_session.delete(
155
155
  f"{self._brynq.url}organization-chart/layers/{layer_id}",
156
156
  timeout=self._brynq.timeout
157
157
  )
@@ -171,7 +171,7 @@ class OrganizationChart:
171
171
  requests.exceptions.RequestException: If the API request fails
172
172
  ValueError: If the response data is invalid
173
173
  """
174
- response = self._brynq.session.get(
174
+ response = self._brynq.brynq_session.get(
175
175
  url=f'{self._brynq.url}organization-chart/nodes',
176
176
  timeout=self._brynq.timeout
177
177
  )
@@ -199,7 +199,7 @@ class OrganizationChart:
199
199
 
200
200
  valid_data, _ = Functions.validate_pydantic_data(data, schema=OrganizationNodeCreate)
201
201
 
202
- response = self._brynq.session.post(
202
+ response = self._brynq.brynq_session.post(
203
203
  f"{self._brynq.url}organization-chart/nodes",
204
204
  json=valid_data[0],
205
205
  timeout=self._brynq.timeout
@@ -222,7 +222,7 @@ class OrganizationChart:
222
222
  """
223
223
  valid_data, _ = Functions.validate_pydantic_data(data, schema=OrganizationNodeUpdate)
224
224
 
225
- response = self._brynq.session.put(
225
+ response = self._brynq.brynq_session.put(
226
226
  f"{self._brynq.url}organization-chart/nodes/{data['id']}",
227
227
  json=valid_data[0],
228
228
  timeout=self._brynq.timeout
@@ -243,7 +243,7 @@ class OrganizationChart:
243
243
  if not isinstance(node_id, int):
244
244
  raise ValueError("node_id must be an integer")
245
245
 
246
- response = self._brynq.session.delete(
246
+ response = self._brynq.brynq_session.delete(
247
247
  f"{self._brynq.url}organization-chart/nodes/{node_id}",
248
248
  timeout=self._brynq.timeout
249
249
  )
@@ -25,7 +25,7 @@ class Roles:
25
25
  requests.HTTPError: If the API request fails
26
26
  ValueError: If the role data is invalid
27
27
  """
28
- response = self._brynq.session.get(
28
+ response = self._brynq.brynq_session.get(
29
29
  url=f'{self._brynq.url}roles',
30
30
  timeout=self._brynq.timeout
31
31
  )
@@ -54,7 +54,7 @@ class Roles:
54
54
  ValueError: If the response data is invalid.
55
55
  requests.exceptions.RequestException: If the API request fails.
56
56
  """
57
- response = self._brynq.session.get(
57
+ response = self._brynq.brynq_session.get(
58
58
  f"{self._brynq.url}roles/{role_id}",
59
59
  timeout=self._brynq.timeout
60
60
  )
@@ -85,7 +85,7 @@ class Roles:
85
85
  try:
86
86
  valid_data, _ = Functions.validate_pydantic_data(data, schema=CreateRoleRequest)
87
87
  if valid_data:
88
- response = self._brynq.session.post(
88
+ response = self._brynq.brynq_session.post(
89
89
  f"{self._brynq.url}roles",
90
90
  json=valid_data[0],
91
91
  timeout=self._brynq.timeout
@@ -116,7 +116,7 @@ class Roles:
116
116
  try:
117
117
  valid_data, _ = Functions.validate_pydantic_data(data, schema=RoleSchema)
118
118
  if valid_data:
119
- response = self._brynq.session.put(
119
+ response = self._brynq.brynq_session.put(
120
120
  f"{self._brynq.url}roles/{data['id']}",
121
121
  json=valid_data[0],
122
122
  timeout=self._brynq.timeout
@@ -144,7 +144,7 @@ class Roles:
144
144
  raise ValueError("role_id must be a positive integer")
145
145
 
146
146
  params = {"force": "true" if force else "false"}
147
- response = self._brynq.session.delete(
147
+ response = self._brynq.brynq_session.delete(
148
148
  f"{self._brynq.url}roles/{role_id}",
149
149
  params=params,
150
150
  timeout=self._brynq.timeout
@@ -169,7 +169,7 @@ class Roles:
169
169
  if not isinstance(role_id, int) or role_id <= 0:
170
170
  raise ValueError("role_id must be a positive integer")
171
171
 
172
- response = self._brynq.session.get(
172
+ response = self._brynq.brynq_session.get(
173
173
  f"{self._brynq.url}roles/{role_id}/users",
174
174
  timeout=self._brynq.timeout
175
175
  )
@@ -202,7 +202,7 @@ class Roles:
202
202
 
203
203
  try:
204
204
  valid_data, _ = Functions.validate_pydantic_data(dashboard_rights, schema=DashboardRight)
205
- response = self._brynq.session.post(
205
+ response = self._brynq.brynq_session.post(
206
206
  f"{self._brynq.url}roles/{role_id}/dashboards",
207
207
  json=valid_data[0],
208
208
  timeout=self._brynq.timeout
@@ -233,7 +233,7 @@ class Roles:
233
233
 
234
234
  try:
235
235
  valid_data, _ = Functions.validate_pydantic_data(qlik_dashboard_rights, schema=QlikDashboardRight)
236
- response = self._brynq.session.post(
236
+ response = self._brynq.brynq_session.post(
237
237
  f"{self._brynq.url}roles/{role_id}/dashboards/qlik",
238
238
  json=valid_data[0],
239
239
  timeout=self._brynq.timeout
@@ -263,7 +263,7 @@ class Roles:
263
263
  payload = {"qlikDashboards": qlik_dashboards}
264
264
  valid_data, _ = Functions.validate_pydantic_data(payload, schema=QlikDashboardRight)
265
265
 
266
- response = self._brynq.session.post(
266
+ response = self._brynq.brynq_session.post(
267
267
  f"{self._brynq.url}roles/{role_id}/dashboards/qlik",
268
268
  json=valid_data[0],
269
269
  timeout=self._brynq.timeout
@@ -25,7 +25,7 @@ class SourceSystems:
25
25
  Raises:
26
26
  requests.exceptions.RequestException: If the API request fails
27
27
  """
28
- response = self._brynq.session.get(
28
+ response = self._brynq.brynq_session.get(
29
29
  url=f'{self._brynq.url}source-systems',
30
30
  timeout=self._brynq.timeout
31
31
  )
@@ -50,7 +50,7 @@ class SourceSystems:
50
50
  'name': name,
51
51
  'entities': entities or []
52
52
  }
53
- response = self._brynq.session.post(
53
+ response = self._brynq.brynq_session.post(
54
54
  url=f'{self._brynq.url}source-systems',
55
55
  json=data,
56
56
  timeout=self._brynq.timeout
@@ -68,7 +68,7 @@ class SourceSystems:
68
68
  Raises:
69
69
  requests.exceptions.RequestException: If the API request fails
70
70
  """
71
- response = self._brynq.session.delete(
71
+ response = self._brynq.brynq_session.delete(
72
72
  url=f'{self._brynq.url}source-systems/{system_id}',
73
73
  timeout=self._brynq.timeout
74
74
  )
@@ -94,7 +94,7 @@ class SourceSystems:
94
94
  'name': name,
95
95
  'entities': entities or []
96
96
  }
97
- response = self._brynq.session.put(
97
+ response = self._brynq.brynq_session.put(
98
98
  url=f'{self._brynq.url}source-systems/{system_id}',
99
99
  json=data,
100
100
  timeout=self._brynq.timeout
@@ -115,7 +115,7 @@ class SourceSystems:
115
115
  Raises:
116
116
  requests.exceptions.RequestException: If the API request fails
117
117
  """
118
- response = self._brynq.session.get(
118
+ response = self._brynq.brynq_session.get(
119
119
  url=f'{self._brynq.url}source-systems/{system_id}/entities',
120
120
  timeout=self._brynq.timeout
121
121
  )
@@ -138,7 +138,7 @@ class SourceSystems:
138
138
  requests.exceptions.HTTPError: If source system is not found (404)
139
139
  """
140
140
  data = {'entities': entities}
141
- response = self._brynq.session.post(
141
+ response = self._brynq.brynq_session.post(
142
142
  url=f'{self._brynq.url}source-systems/{system_id}/entities',
143
143
  json=data,
144
144
  timeout=self._brynq.timeout
@@ -166,7 +166,7 @@ class SourceSystems:
166
166
  'name': name,
167
167
  'code': code
168
168
  }
169
- response = self._brynq.session.put(
169
+ response = self._brynq.brynq_session.put(
170
170
  url=f'{self._brynq.url}source-systems/entities/{entity_id}',
171
171
  json=data,
172
172
  timeout=self._brynq.timeout
@@ -39,7 +39,7 @@ class Users:
39
39
  requests.exceptions.RequestException: If the API request fails
40
40
  ValueError: If the response data is invalid
41
41
  """
42
- response = self._brynq.session.get(
42
+ response = self._brynq.brynq_session.get(
43
43
  url=f'{self._brynq.url}users',
44
44
  timeout=self._brynq.timeout
45
45
  )
@@ -62,7 +62,7 @@ class Users:
62
62
  requests.exceptions.RequestException: If the API request fails
63
63
  requests.exceptions.HTTPError: If user is not found (404)
64
64
  """
65
- response = self._brynq.session.get(
65
+ response = self._brynq.brynq_session.get(
66
66
  url=f'{self._brynq.url}users/{user_id}',
67
67
  timeout=self._brynq.timeout
68
68
  )
@@ -90,7 +90,7 @@ class Users:
90
90
  """
91
91
  valid_data, _ = Functions.validate_pydantic_data(user_data, schema=UserInvite)
92
92
 
93
- response = self._brynq.session.post(
93
+ response = self._brynq.brynq_session.post(
94
94
  url=f'{self._brynq.url}users',
95
95
  json=valid_data[0],
96
96
  timeout=self._brynq.timeout
@@ -129,7 +129,7 @@ class Users:
129
129
 
130
130
  valid_data, _ = Functions.validate_pydantic_data(user_data, schema=UserUpdate)
131
131
 
132
- response = self._brynq.session.put(
132
+ response = self._brynq.brynq_session.put(
133
133
  url=f'{self._brynq.url}users/{user_id}',
134
134
  json=valid_data[0],
135
135
  timeout=self._brynq.timeout
@@ -145,7 +145,7 @@ class Users:
145
145
  """
146
146
  if not isinstance(user_id, int):
147
147
  raise ValueError("user_id must be an integer")
148
- response = self._brynq.session.delete(
148
+ response = self._brynq.brynq_session.delete(
149
149
  url=f'{self._brynq.url}users/{user_id}',
150
150
  timeout=self._brynq.timeout
151
151
  )
@@ -179,7 +179,7 @@ class Users:
179
179
  }
180
180
  valid_data, _ = Functions.validate_pydantic_data(payload, schema=DashboardRightsPayload)
181
181
 
182
- response = self._brynq.session.post(
182
+ response = self._brynq.brynq_session.post(
183
183
  url=f'{self._brynq.url}users/{user_id}/dashboards',
184
184
  json=valid_data[0],
185
185
  timeout=self._brynq.timeout
@@ -206,7 +206,7 @@ class Users:
206
206
  payload = {"roles": roles}
207
207
  valid_data, _ = Functions.validate_pydantic_data(payload, schema=UserRolesPayload)
208
208
 
209
- response = self._brynq.session.post(
209
+ response = self._brynq.brynq_session.post(
210
210
  url=f'{self._brynq.url}users/{user_id}/roles',
211
211
  json=valid_data[0],
212
212
  timeout=self._brynq.timeout
@@ -232,7 +232,7 @@ class Users:
232
232
  raise ValueError("user_id must be an integer")
233
233
  payload = {"organigramEntities": organigram_entities}
234
234
  valid_data, _ = Functions.validate_pydantic_data(payload, schema=UserEntitiesPayload)
235
- response = self._brynq.session.post(
235
+ response = self._brynq.brynq_session.post(
236
236
  url=f"{self._brynq.url}users/{user_id}/organigram-entities",
237
237
  json=valid_data[0],
238
238
  timeout=self._brynq.timeout
@@ -258,7 +258,7 @@ class Users:
258
258
  raise ValueError("user_id must be an integer")
259
259
  payload = {"qlikDashboardRights": qlik_dashboard_rights}
260
260
  valid_data, _ = Functions.validate_pydantic_data(payload, schema=QlikDashboardRightsPayload)
261
- response = self._brynq.session.post(
261
+ response = self._brynq.brynq_session.post(
262
262
  url=f"{self._brynq.url}users/{user_id}/dashboards/qlik",
263
263
  json=valid_data[0],
264
264
  timeout=self._brynq.timeout
@@ -294,7 +294,7 @@ class Users:
294
294
  }
295
295
  valid_data, _ = Functions.validate_pydantic_data(payload, schema=QlikDashboardRightsPayload)
296
296
 
297
- response = self._brynq.session.post(
297
+ response = self._brynq.brynq_session.post(
298
298
  url=f'{self._brynq.url}users/{user_id}/dashboards/qlik',
299
299
  json=valid_data[0],
300
300
  timeout=self._brynq.timeout
@@ -322,7 +322,7 @@ class Users:
322
322
  requests.exceptions.RequestException: If the API request fails
323
323
  ValueError: If the input data is invalid
324
324
  """
325
- response = self._brynq.session.get(
325
+ response = self._brynq.brynq_session.get(
326
326
  url=f'{self._brynq.url}/qlik/{guid}/users',
327
327
  timeout=self._brynq.timeout
328
328
  )
@@ -351,7 +351,7 @@ class Users:
351
351
  payload = {"entities": entity_ids}
352
352
  valid_data, _ = Functions.validate_pydantic_data(payload, schema=UserEntitiesPayload)
353
353
 
354
- response = self._brynq.session.post(
354
+ response = self._brynq.brynq_session.post(
355
355
  url=f'{self._brynq.url}users/{user_id}/organigram-entities',
356
356
  json=valid_data[0],
357
357
  timeout=self._brynq.timeout
@@ -378,7 +378,7 @@ class Users:
378
378
  payload = {"entities": entity_ids}
379
379
  valid_data, _ = Functions.validate_pydantic_data(payload, schema=UserEntitiesPayload)
380
380
 
381
- response = self._brynq.session.put(
381
+ response = self._brynq.brynq_session.put(
382
382
  url=f'{self._brynq.url}users/{user_id}/organigram-entities',
383
383
  json=valid_data[0],
384
384
  timeout=self._brynq.timeout
@@ -405,7 +405,7 @@ class Users:
405
405
  payload = {"entities": entity_ids}
406
406
  valid_data, _ = Functions.validate_pydantic_data(payload, schema=UserEntitiesPayload)
407
407
 
408
- response = self._brynq.session.delete(
408
+ response = self._brynq.brynq_session.delete(
409
409
  url=f'{self._brynq.url}users/{user_id}/organigram-entities',
410
410
  json=valid_data[0],
411
411
  timeout=self._brynq.timeout
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-brynq
3
- Version: 3.0.4
3
+ Version: 4.0.0
4
4
  Summary: BrynQ SDK for the BrynQ.com platform
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_brynq',
5
- version='3.0.4',
5
+ version='4.0.0',
6
6
  description='BrynQ SDK for the BrynQ.com platform',
7
7
  long_description='BrynQ SDK for the BrynQ.com platform',
8
8
  author='BrynQ',