aas-http-client 0.2.61__py3-none-any.whl → 0.3.1__py3-none-any.whl

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/client.py CHANGED
@@ -109,7 +109,7 @@ class AasHttpClient(BaseModel):
109
109
  url = f"{self.base_url}/shells"
110
110
 
111
111
  try:
112
- response = self._session.get(url, headers=HEADERS, timeout=2)
112
+ response = self._session.get(url, headers=HEADERS, timeout=10)
113
113
  logger.debug(f"Call REST API url '{response.url}'")
114
114
 
115
115
  if response.status_code != STATUS_CODE_200:
@@ -510,6 +510,57 @@ class AasHttpClient(BaseModel):
510
510
  content = response.content.decode("utf-8")
511
511
  return json.loads(content)
512
512
 
513
+ def get_submodel_element_by_path_submodel_repo(self, submodel_id: str, submodel_element_path: str) -> dict | None:
514
+ """Returns a specific submodel element from the Submodel at a specified path.
515
+
516
+ :param submodel_id: Encoded ID of the Submodel to retrieve element from
517
+ :param submodel_element_path: Path of the Submodel element to retrieve
518
+ :return: Submodel element data or None if an error occurred
519
+ """
520
+ decoded_submodel_id: str = decode_base_64(submodel_id)
521
+
522
+ url = f"{self.base_url}/submodels/{decoded_submodel_id}/submodel-elements/{submodel_element_path}"
523
+
524
+ try:
525
+ response = self._session.get(url, headers=HEADERS, timeout=self.time_out)
526
+ logger.debug(f"Call REST API url '{response.url}'")
527
+
528
+ if response.status_code != STATUS_CODE_200:
529
+ log_response_errors(response)
530
+ return None
531
+
532
+ except requests.exceptions.RequestException as e:
533
+ logger.error(f"Error call REST API: {e}")
534
+ return None
535
+
536
+ content = response.content.decode("utf-8")
537
+ return json.loads(content)
538
+
539
+ def delete_submodel_element_by_path_submodel_repo(self, submodel_id: str, submodel_element_path: str):
540
+ """Deletes a submodel element at a specified path within the submodel elements hierarchy.
541
+
542
+ :param submodel_id: Encoded ID of the Submodel to delete submodel element from
543
+ :param submodel_element_path: Path of the Submodel element to delete
544
+ :return: True if the deletion was successful, False otherwise
545
+ """
546
+ decoded_submodel_id: str = decode_base_64(submodel_id)
547
+
548
+ url = f"{self.base_url}/submodels/{decoded_submodel_id}/submodel-elements/{submodel_element_path}"
549
+
550
+ try:
551
+ response = self._session.delete(url, headers=HEADERS, timeout=self.time_out)
552
+ logger.debug(f"Call REST API url '{response.url}'")
553
+
554
+ if response.status_code != STATUS_CODE_204:
555
+ log_response_errors(response)
556
+ return False
557
+
558
+ except requests.exceptions.RequestException as e:
559
+ logger.error(f"Error call REST API: {e}")
560
+ return False
561
+
562
+ return True
563
+
513
564
 
514
565
  # endregion
515
566
 
@@ -253,6 +253,16 @@ class SdkWrapper:
253
253
  content: dict = self._client.post_submodel_element_submodel_repo(submodel_id, sme_data)
254
254
  return _to_object(content)
255
255
 
256
+ def get_submodel_element_by_path_submodel_repo(self, submodel_id: str, submodel_element_path: str) -> model.SubmodelElement | None:
257
+ """Returns a specific submodel element from the Submodel at a specified path.
258
+
259
+ :param submodel_id: Encoded ID of the Submodel to retrieve element from
260
+ :param submodel_element_path: Path of the Submodel element to retrieve
261
+ :return: Submodel element object or None if an error occurred
262
+ """
263
+ content: dict = self._client.get_submodel_element_by_path_submodel_repo(submodel_id, submodel_element_path)
264
+ return _to_object(content)
265
+
256
266
 
257
267
  # endregion
258
268
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aas-http-client
3
- Version: 0.2.61
3
+ Version: 0.3.1
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
@@ -108,6 +108,10 @@ License: # :em engineering methods AG Software License
108
108
  Project-URL: Homepage, https://github.com/fluid40/aas-http-client
109
109
  Description-Content-Type: text/markdown
110
110
  License-File: LICENSE
111
+ Requires-Dist: typing>=3.7.4.3
112
+ Requires-Dist: pydantic>=2.11.5
113
+ Requires-Dist: requests>=2.32.3
114
+ Requires-Dist: basyx-python-sdk>=1.2.1
111
115
  Dynamic: license-file
112
116
 
113
117
  <!-- TODO: Go through the readme and enter the information here -->
@@ -1,14 +1,14 @@
1
1
  aas_http_client/__init__.py,sha256=cAr1mQzWp0G0LKtkAOYzc9t95OY3jM3Aj4bKnxx0Dso,901
2
- aas_http_client/client.py,sha256=9_yw-DNbTRYKIpQ-YTWvrji4nUR2ytIcXc-7TKgyXE4,23131
2
+ aas_http_client/client.py,sha256=neuEMk1lyOHOgVv3OBzNeXDWEtkN4qfox-hMRjtDWHM,25350
3
3
  aas_http_client/core/encoder.py,sha256=FS7P0FPakzFsGz70eRFDHQZFA_2nlKLlWIxavtnFrPg,660
4
4
  aas_http_client/core/version_check.py,sha256=721Zs3xSRrJTYZtAxkaUWg9LLKtpU7oFM62DzQHZdE4,705
5
5
  aas_http_client/demo/demo_process.py,sha256=6sN_N3QbA4iLUmzeg1Y_XOwVAuDNtwkR4grAg7EkjWM,3301
6
6
  aas_http_client/demo/logging_handler.py,sha256=VJtZ4u3x_LhYZQtfNck7FuXhGFZm7gid0uDhvf9GjJ8,5596
7
7
  aas_http_client/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  aas_http_client/utilities/model_builder.py,sha256=EUqVvKgXiyJNtyUeFrL6ronfF4hiF1KCipxSaLj6EiE,4465
9
- aas_http_client/wrapper/sdk_wrapper.py,sha256=zRhVcQed6GeqUU_jfC6nyHRxALx_LWga79K9Tu4pHws,12896
10
- aas_http_client-0.2.61.dist-info/licenses/LICENSE,sha256=ayt4HY-Tjoe1Uvj47j6UdNq8mEufKcKFangurChIHxQ,5990
11
- aas_http_client-0.2.61.dist-info/METADATA,sha256=p07mGRcuwUTF_CU8Kmf1lkgboS7DHjagX_f1YUQHMyg,10334
12
- aas_http_client-0.2.61.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- aas_http_client-0.2.61.dist-info/top_level.txt,sha256=vzvoz2vjeTLwpuz-Y-eEfoQ7T3byoaKshVlFMFH5NaM,16
14
- aas_http_client-0.2.61.dist-info/RECORD,,
9
+ aas_http_client/wrapper/sdk_wrapper.py,sha256=pphxkTwnaoG44hOqelwnqBWupGfDX2ExBDhAdZNFQuQ,13512
10
+ aas_http_client-0.3.1.dist-info/licenses/LICENSE,sha256=ayt4HY-Tjoe1Uvj47j6UdNq8mEufKcKFangurChIHxQ,5990
11
+ aas_http_client-0.3.1.dist-info/METADATA,sha256=LAC3u23U1X84glQ5zg77p3oPn-pl1mAOGHOgYaWsTdU,10467
12
+ aas_http_client-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ aas_http_client-0.3.1.dist-info/top_level.txt,sha256=vzvoz2vjeTLwpuz-Y-eEfoQ7T3byoaKshVlFMFH5NaM,16
14
+ aas_http_client-0.3.1.dist-info/RECORD,,