brynq-sdk-brynq 2.0.4__tar.gz → 2.1.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.
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/PKG-INFO +1 -1
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/brynq_sdk_brynq/brynq.py +78 -1
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/brynq_sdk_brynq.egg-info/PKG-INFO +1 -1
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/setup.py +1 -1
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/brynq_sdk_brynq/__init__.py +0 -0
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/brynq_sdk_brynq.egg-info/SOURCES.txt +0 -0
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/brynq_sdk_brynq.egg-info/dependency_links.txt +0 -0
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/brynq_sdk_brynq.egg-info/not-zip-safe +0 -0
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/brynq_sdk_brynq.egg-info/requires.txt +0 -0
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/brynq_sdk_brynq.egg-info/top_level.txt +0 -0
- {brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/setup.cfg +0 -0
|
@@ -2,7 +2,7 @@ import os
|
|
|
2
2
|
import requests
|
|
3
3
|
import json
|
|
4
4
|
import pandas as pd
|
|
5
|
-
from typing import Union, Literal
|
|
5
|
+
from typing import Union, Literal, Optional, List
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class BrynQ:
|
|
@@ -146,6 +146,83 @@ class BrynQ:
|
|
|
146
146
|
|
|
147
147
|
return credentials[0]
|
|
148
148
|
|
|
149
|
+
def get_interface_credential(self, interface_id: str, system: str, system_type: Optional[str] = None,
|
|
150
|
+
test_environment: bool = False) -> Union[dict, List[dict]]:
|
|
151
|
+
"""
|
|
152
|
+
This method retrieves authentication credentials from BrynQ for a specific interface and system.
|
|
153
|
+
:param interface_id: ID of the interface to get credentials for
|
|
154
|
+
:param system: The app name to search for in credentials (e.g., 'bob', 'profit')
|
|
155
|
+
:param system_type: Optional parameter to specify 'source' or 'target'. If not provided,
|
|
156
|
+
searches in both lists
|
|
157
|
+
:param test_environment: boolean if the test environment is used (only for profit system)
|
|
158
|
+
:return: Credential dictionary or list of credential dictionaries for the specified system
|
|
159
|
+
"""
|
|
160
|
+
# Get credentials from interface configuration
|
|
161
|
+
response = requests.get(
|
|
162
|
+
url=f'{self.url}interfaces/{interface_id}/config/auth',
|
|
163
|
+
headers=self._get_headers()
|
|
164
|
+
)
|
|
165
|
+
response.raise_for_status()
|
|
166
|
+
config = response.json()
|
|
167
|
+
matching_credentials = []
|
|
168
|
+
# If system_type is provided, only search in that list
|
|
169
|
+
if system_type:
|
|
170
|
+
if system_type not in ['source', 'target']:
|
|
171
|
+
raise ValueError("system_type must be either 'source' or 'target'")
|
|
172
|
+
credentials_list = config.get(f'{system_type}s', [])
|
|
173
|
+
for cred in credentials_list:
|
|
174
|
+
if cred.get('app') == system:
|
|
175
|
+
# Check test environment for profit system
|
|
176
|
+
if system == 'profit':
|
|
177
|
+
is_test = cred.get('data', {}).get('isTestEnvironment', False)
|
|
178
|
+
if is_test == test_environment:
|
|
179
|
+
matching_credentials.append({'credential': cred, 'type': system_type})
|
|
180
|
+
else:
|
|
181
|
+
matching_credentials.append({'credential': cred, 'type': system_type})
|
|
182
|
+
# If no system_type provided, search in both lists
|
|
183
|
+
else:
|
|
184
|
+
source_credentials = []
|
|
185
|
+
target_credentials = []
|
|
186
|
+
# Check sources
|
|
187
|
+
for source in config.get('sources', []):
|
|
188
|
+
if source.get('app') == system:
|
|
189
|
+
if system == 'profit':
|
|
190
|
+
is_test = source.get('data', {}).get('isTestEnvironment', False)
|
|
191
|
+
if is_test == test_environment:
|
|
192
|
+
source_credentials.append({'credential': source, 'type': 'source'})
|
|
193
|
+
else:
|
|
194
|
+
source_credentials.append({'credential': source, 'type': 'source'})
|
|
195
|
+
# Check targets
|
|
196
|
+
for target in config.get('targets', []):
|
|
197
|
+
if target.get('app') == system:
|
|
198
|
+
if system == 'profit':
|
|
199
|
+
is_test = target.get('data', {}).get('isTestEnvironment', False)
|
|
200
|
+
if is_test == test_environment:
|
|
201
|
+
target_credentials.append({'credential': target, 'type': 'target'})
|
|
202
|
+
else:
|
|
203
|
+
target_credentials.append({'credential': target, 'type': 'target'})
|
|
204
|
+
# Combine matching credentials based on type
|
|
205
|
+
if source_credentials and target_credentials:
|
|
206
|
+
raise ValueError(
|
|
207
|
+
f'Multiple credentials found for system {system} in both source and target. '
|
|
208
|
+
f'Please specify system_type as "source" or "target"'
|
|
209
|
+
)
|
|
210
|
+
matching_credentials = source_credentials or target_credentials
|
|
211
|
+
# Handle results
|
|
212
|
+
if len(matching_credentials) == 0:
|
|
213
|
+
if system == 'profit':
|
|
214
|
+
raise ValueError(f'No credentials found for system {system} with test_environment={test_environment}')
|
|
215
|
+
else:
|
|
216
|
+
raise ValueError(f'No credentials found for system {system}')
|
|
217
|
+
if len(matching_credentials) == 1:
|
|
218
|
+
return matching_credentials[0]['credential']
|
|
219
|
+
if len(matching_credentials) > 1:
|
|
220
|
+
warning_msg = f'Multiple credentials found for system {system}'
|
|
221
|
+
if system_type:
|
|
222
|
+
warning_msg += f' in {system_type}'
|
|
223
|
+
warnings.warn(warning_msg)
|
|
224
|
+
return [cred['credential'] for cred in matching_credentials]
|
|
225
|
+
|
|
149
226
|
def refresh_system_credential(self, system: str, system_id: int) -> json:
|
|
150
227
|
"""
|
|
151
228
|
This method refreshes Oauth authentication credentials in BrynQ.
|
|
File without changes
|
|
File without changes
|
{brynq_sdk_brynq-2.0.4 → brynq_sdk_brynq-2.1.0}/brynq_sdk_brynq.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|