aas-http-client 0.4.5__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.

Files changed (23) hide show
  1. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/PKG-INFO +1 -1
  2. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/client.py +19 -18
  3. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client.egg-info/PKG-INFO +1 -1
  4. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/pyproject.toml +1 -1
  5. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/LICENSE +0 -0
  6. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/README.md +0 -0
  7. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/__init__.py +0 -0
  8. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/classes/auth_classes.py +0 -0
  9. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/core/encoder.py +0 -0
  10. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/core/version_check.py +0 -0
  11. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/demo/demo_process.py +0 -0
  12. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/demo/logging_handler.py +0 -0
  13. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/utilities/__init__.py +0 -0
  14. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/utilities/model_builder.py +0 -0
  15. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/utilities/sdk_tools.py +0 -0
  16. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client/wrapper/sdk_wrapper.py +0 -0
  17. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client.egg-info/SOURCES.txt +0 -0
  18. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client.egg-info/dependency_links.txt +0 -0
  19. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client.egg-info/requires.txt +0 -0
  20. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/aas_http_client.egg-info/top_level.txt +0 -0
  21. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/setup.cfg +0 -0
  22. {aas_http_client-0.4.5 → aas_http_client-0.4.6}/tests/test_client.py +0 -0
  23. {aas_http_client-0.4.5 → 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.5
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
- result_error_messages.append(response.content)
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:
@@ -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
- try:
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, json=data, timeout=timeout)
766
- logger.info(f"Request URL: {response.url}")
767
- response.raise_for_status()
768
- return response.json().get("access_token")
769
- except requests.RequestException as e:
770
- logger.error(f"Error getting token: {e}")
771
- return None
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.5
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.5"
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