brynq-sdk-brynq 3.0.5__tar.gz → 4.0.1__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.5 → brynq_sdk_brynq-4.0.1}/PKG-INFO +1 -1
  2. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/brynq.py +13 -8
  3. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/credentials.py +4 -4
  4. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/interfaces.py +43 -72
  5. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/mappings.py +4 -8
  6. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq.egg-info/PKG-INFO +1 -1
  7. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/setup.py +1 -1
  8. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/__init__.py +0 -0
  9. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/customers.py +0 -0
  10. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/organization_chart.py +0 -0
  11. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/roles.py +0 -0
  12. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/schemas/__init__.py +0 -0
  13. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/schemas/credentials.py +0 -0
  14. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/schemas/customers.py +0 -0
  15. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/schemas/interfaces.py +0 -0
  16. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/schemas/organization_chart.py +0 -0
  17. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/schemas/roles.py +0 -0
  18. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/schemas/users.py +0 -0
  19. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/source_systems.py +0 -0
  20. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq/users.py +0 -0
  21. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq.egg-info/SOURCES.txt +0 -0
  22. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq.egg-info/dependency_links.txt +0 -0
  23. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq.egg-info/not-zip-safe +0 -0
  24. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq.egg-info/requires.txt +0 -0
  25. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/brynq_sdk_brynq.egg-info/top_level.txt +0 -0
  26. {brynq_sdk_brynq-3.0.5 → brynq_sdk_brynq-4.0.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_brynq
3
- Version: 3.0.5
3
+ Version: 4.0.1
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")
@@ -28,7 +32,7 @@ class BrynQ:
28
32
  raise ValueError(f"Environment should be in {','.join(possible_environments)}")
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
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
33
37
  self.brynq_session = requests.Session()
34
38
  retry_strategy = Retry(
@@ -40,7 +44,7 @@ class BrynQ:
40
44
  self.brynq_session.mount("http://", adapter)
41
45
  self.brynq_session.mount("https://", adapter)
42
46
  self.brynq_session.headers.update(self._get_headers())
43
-
47
+
44
48
  # Initialize components
45
49
  self.users = Users(self)
46
50
  self.organization_chart = OrganizationChart(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()
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
  """
@@ -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
 
@@ -144,7 +144,7 @@ class Credentials:
144
144
  requests.exceptions.RequestException: If the API request fails.
145
145
  """
146
146
  response = self._brynq.brynq_session.get(
147
- url=f'{self._brynq.url}interfaces/{interface_id}/config/auth',
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()
@@ -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:
@@ -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
67
  response = self._brynq.brynq_session.get(
74
- f"{self._brynq.url}interfaces/{interface_id}",
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
97
  response = self._brynq.brynq_session.get(
106
- f"{self._brynq.url}interfaces/{interface_id}/config",
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,13 +107,10 @@ 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
 
@@ -129,38 +118,15 @@ class Interfaces:
129
118
  requests.exceptions.RequestException: If the API request fails
130
119
  """
131
120
  response = self._brynq.brynq_session.get(
132
- url=f'{self._brynq.url}interfaces/{interface_id}/config/flush',
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.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
146
  response = self._brynq.brynq_session.get(
185
- f"{self._brynq.url}interfaces/{interface_id}/config/schedule",
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,13 +156,10 @@ 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
 
@@ -208,18 +167,15 @@ class Interfaces:
208
167
  requests.exceptions.RequestException: If the API request fails
209
168
  """
210
169
  response = self._brynq.brynq_session.get(
211
- url=f'{self._brynq.url}interfaces/{interface_id}/template-config',
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
188
  response = self._brynq.brynq_session.get(
237
- f"{self._brynq.url}interfaces/{interface_id}/scope",
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
217
  response = self._brynq.brynq_session.get(
271
- url=f"{self._brynq.url}interfaces/{interface_id}/config/dev-settings",
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
38
  response = self._brynq.brynq_session.get(
43
- f"{self._brynq.url}interfaces/{interface_id}/config/mapping",
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-brynq
3
- Version: 3.0.5
3
+ Version: 4.0.1
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.5',
5
+ version='4.0.1',
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',