aas-http-client 0.4.4__tar.gz → 0.4.6__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 aas-http-client might be problematic. Click here for more details.
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/PKG-INFO +1 -1
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/client.py +20 -19
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client.egg-info/PKG-INFO +1 -1
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/pyproject.toml +1 -1
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/LICENSE +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/README.md +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/__init__.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/classes/auth_classes.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/core/encoder.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/core/version_check.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/demo/demo_process.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/demo/logging_handler.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/utilities/__init__.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/utilities/model_builder.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/utilities/sdk_tools.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client/wrapper/sdk_wrapper.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client.egg-info/SOURCES.txt +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client.egg-info/dependency_links.txt +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client.egg-info/requires.txt +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client.egg-info/top_level.txt +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/setup.cfg +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/tests/test_client.py +0 -0
- {aas_http_client-0.4.4 → aas_http_client-0.4.6}/tests/test_wrapper.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aas-http-client
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.6
|
|
4
4
|
Summary: Generic python HTTP client for communication with various types of AAS servers
|
|
5
5
|
Author-email: Daniel Klein <daniel.klein@em.ag>
|
|
6
6
|
License: # :em engineering methods AG Software License
|
|
@@ -62,7 +62,8 @@ def log_response_errors(response: Response): # noqa: C901
|
|
|
62
62
|
result_error_messages.append(response.text)
|
|
63
63
|
|
|
64
64
|
except json.JSONDecodeError:
|
|
65
|
-
|
|
65
|
+
if response.content and response.content != "b''":
|
|
66
|
+
result_error_messages.append(response.content)
|
|
66
67
|
|
|
67
68
|
logger.error(f"Status code: {response.status_code}")
|
|
68
69
|
for result_error_message in result_error_messages:
|
|
@@ -159,7 +160,7 @@ class AasHttpClient(BaseModel):
|
|
|
159
160
|
)
|
|
160
161
|
|
|
161
162
|
if token:
|
|
162
|
-
self._session.headers.update({self.service_provider_auth.
|
|
163
|
+
self._session.headers.update({self.service_provider_auth.header_name: f"Bearer {token}"})
|
|
163
164
|
|
|
164
165
|
# region shells
|
|
165
166
|
|
|
@@ -729,14 +730,7 @@ def get_token_by_basic_auth(endpoint: str, username: str, password: str, timeout
|
|
|
729
730
|
|
|
730
731
|
auth = HTTPBasicAuth(username, password)
|
|
731
732
|
|
|
732
|
-
|
|
733
|
-
response = requests.post(endpoint, auth=auth, data=data, timeout=timeout)
|
|
734
|
-
logger.info(f"Request URL: {response.url}")
|
|
735
|
-
response.raise_for_status()
|
|
736
|
-
return response.json().get("access_token")
|
|
737
|
-
except requests.RequestException as e:
|
|
738
|
-
logger.error(f"Error getting token: {e}")
|
|
739
|
-
return None
|
|
733
|
+
return _get_token(endpoint, data, auth, timeout)
|
|
740
734
|
|
|
741
735
|
|
|
742
736
|
def get_token_by_password(endpoint: str, username: str, password: str, timeout=200) -> dict | None:
|
|
@@ -750,10 +744,10 @@ def get_token_by_password(endpoint: str, username: str, password: str, timeout=2
|
|
|
750
744
|
"""
|
|
751
745
|
data = {"grant_type": "password", "username": username, "password": password}
|
|
752
746
|
|
|
753
|
-
return _get_token(endpoint, data, timeout)
|
|
747
|
+
return _get_token(endpoint, data, None, timeout)
|
|
754
748
|
|
|
755
749
|
|
|
756
|
-
def _get_token(endpoint: str, data: dict[str, str], timeout: int = 200) -> dict | None:
|
|
750
|
+
def _get_token(endpoint: str, data: dict[str, str], auth: HTTPBasicAuth | None = None, timeout: int = 200) -> dict | None:
|
|
757
751
|
"""Get token from a specific authentication service provider.
|
|
758
752
|
|
|
759
753
|
:param endpoint: Get token endpoint for the authentication service provider
|
|
@@ -762,13 +756,20 @@ def _get_token(endpoint: str, data: dict[str, str], timeout: int = 200) -> dict
|
|
|
762
756
|
:return: Access token or None if an error occurred
|
|
763
757
|
"""
|
|
764
758
|
try:
|
|
765
|
-
response = requests.post(endpoint,
|
|
766
|
-
logger.
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
759
|
+
response = requests.post(endpoint, auth=auth, data=data, timeout=timeout)
|
|
760
|
+
logger.debug(f"Call REST API url '{response.url}'")
|
|
761
|
+
|
|
762
|
+
if response.status_code != STATUS_CODE_200:
|
|
763
|
+
log_response_errors(response)
|
|
764
|
+
return None
|
|
765
|
+
|
|
766
|
+
except requests.exceptions.RequestException as e:
|
|
767
|
+
logger.error(f"Error call REST API: {e}")
|
|
768
|
+
return False
|
|
769
|
+
|
|
770
|
+
content = response.content.decode("utf-8")
|
|
771
|
+
data = json.loads(content)
|
|
772
|
+
return data.get("access_token", None)
|
|
772
773
|
|
|
773
774
|
|
|
774
775
|
def create_client_by_url(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aas-http-client
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.6
|
|
4
4
|
Summary: Generic python HTTP client for communication with various types of AAS servers
|
|
5
5
|
Author-email: Daniel Klein <daniel.klein@em.ag>
|
|
6
6
|
License: # :em engineering methods AG Software License
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aas-http-client"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.6"
|
|
8
8
|
description = "Generic python HTTP client for communication with various types of AAS servers"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aas_http_client-0.4.4 → aas_http_client-0.4.6}/aas_http_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|