aas-http-client 0.3.2__py3-none-any.whl → 0.3.3__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 +29 -3
- aas_http_client/wrapper/sdk_wrapper.py +11 -0
- {aas_http_client-0.3.2.dist-info → aas_http_client-0.3.3.dist-info}/METADATA +1 -1
- {aas_http_client-0.3.2.dist-info → aas_http_client-0.3.3.dist-info}/RECORD +7 -7
- {aas_http_client-0.3.2.dist-info → aas_http_client-0.3.3.dist-info}/WHEEL +0 -0
- {aas_http_client-0.3.2.dist-info → aas_http_client-0.3.3.dist-info}/licenses/LICENSE +0 -0
- {aas_http_client-0.3.2.dist-info → aas_http_client-0.3.3.dist-info}/top_level.txt +0 -0
aas_http_client/client.py
CHANGED
|
@@ -4,6 +4,7 @@ import json
|
|
|
4
4
|
import logging
|
|
5
5
|
import time
|
|
6
6
|
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
7
8
|
|
|
8
9
|
import basyx.aas.adapter.json
|
|
9
10
|
import basyx.aas.adapter.json.json_serialization as js
|
|
@@ -26,7 +27,7 @@ STATUS_CODE_404 = 404
|
|
|
26
27
|
HEADERS = {"Content-Type": "application/json"}
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
def log_response_errors(response: Response):
|
|
30
|
+
def log_response_errors(response: Response): # noqa: C901
|
|
30
31
|
"""Create error messages from the response and log them.
|
|
31
32
|
|
|
32
33
|
:param response: response
|
|
@@ -561,6 +562,32 @@ class AasHttpClient(BaseModel):
|
|
|
561
562
|
|
|
562
563
|
return True
|
|
563
564
|
|
|
565
|
+
def patch_submodel_element_by_path_value_only_submodel_repo(self, submodel_id: str, submodel_element_path: str, value: str) -> bool:
|
|
566
|
+
"""Updates the value of an existing SubmodelElement.
|
|
567
|
+
|
|
568
|
+
:param submodel_id: Encoded ID of the Submodel to update submodel element for
|
|
569
|
+
:param submodel_element_path: Path of the Submodel element to update
|
|
570
|
+
:param value: Submodel element value to update as string
|
|
571
|
+
:return: True if the patch was successful, False otherwise
|
|
572
|
+
"""
|
|
573
|
+
decoded_submodel_id: str = decode_base_64(submodel_id)
|
|
574
|
+
|
|
575
|
+
url = f"{self.base_url}/submodels/{decoded_submodel_id}/submodel-elements/{submodel_element_path}/$value"
|
|
576
|
+
|
|
577
|
+
try:
|
|
578
|
+
response = self._session.patch(url, headers=HEADERS, json=value, timeout=self.time_out)
|
|
579
|
+
logger.debug(f"Call REST API url '{response.url}'")
|
|
580
|
+
|
|
581
|
+
if response.status_code != STATUS_CODE_204:
|
|
582
|
+
log_response_errors(response)
|
|
583
|
+
return False
|
|
584
|
+
|
|
585
|
+
except requests.exceptions.RequestException as e:
|
|
586
|
+
logger.error(f"Error call REST API: {e}")
|
|
587
|
+
return False
|
|
588
|
+
|
|
589
|
+
return True
|
|
590
|
+
|
|
564
591
|
|
|
565
592
|
# endregion
|
|
566
593
|
|
|
@@ -635,8 +662,7 @@ def create_client_by_config(config_file: Path, password: str = "") -> AasHttpCli
|
|
|
635
662
|
|
|
636
663
|
def _create_client(config_string: str, password) -> AasHttpClient | None:
|
|
637
664
|
try:
|
|
638
|
-
|
|
639
|
-
client = AasHttpClient(**connection_settings.model_dump())
|
|
665
|
+
client = AasHttpClient.model_validate_json(config_string)
|
|
640
666
|
except ValidationError as ve:
|
|
641
667
|
raise ValidationError(f"Invalid BaSyx server connection file: {ve}") from ve
|
|
642
668
|
|
|
@@ -275,8 +275,19 @@ class SdkWrapper:
|
|
|
275
275
|
:return: Submodel element object or None if an error occurred
|
|
276
276
|
"""
|
|
277
277
|
content: dict = self._client.get_submodel_element_by_path_submodel_repo(submodel_id, submodel_element_path)
|
|
278
|
+
print(content)
|
|
278
279
|
return _to_object(content)
|
|
279
280
|
|
|
281
|
+
def patch_submodel_element_by_path_value_only_submodel_repo(self, submodel_id: str, submodel_element_path: str, value: str) -> bool:
|
|
282
|
+
"""Updates the value of an existing SubmodelElement.
|
|
283
|
+
|
|
284
|
+
:param submodel_id: Encoded ID of the Submodel to update submodel element for
|
|
285
|
+
:param submodel_element_path: Path of the Submodel element to update
|
|
286
|
+
:param value: Submodel element value to update as string
|
|
287
|
+
:return: True if the patch was successful, False otherwise
|
|
288
|
+
"""
|
|
289
|
+
return self._client.patch_submodel_element_by_path_value_only_submodel_repo(submodel_id, submodel_element_path, value)
|
|
290
|
+
|
|
280
291
|
|
|
281
292
|
# endregion
|
|
282
293
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aas-http-client
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
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
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
aas_http_client/__init__.py,sha256=cAr1mQzWp0G0LKtkAOYzc9t95OY3jM3Aj4bKnxx0Dso,901
|
|
2
|
-
aas_http_client/client.py,sha256=
|
|
2
|
+
aas_http_client/client.py,sha256=LXqhMLkNO9Itu9Pj369vJurBCd0kiqvhrgnahEmkUtI,27041
|
|
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=
|
|
10
|
-
aas_http_client-0.3.
|
|
11
|
-
aas_http_client-0.3.
|
|
12
|
-
aas_http_client-0.3.
|
|
13
|
-
aas_http_client-0.3.
|
|
14
|
-
aas_http_client-0.3.
|
|
9
|
+
aas_http_client/wrapper/sdk_wrapper.py,sha256=KOPcnW0SrpoH6Z6ycDtzSmMdbk2MHj_UqbEbKGgGfWA,15010
|
|
10
|
+
aas_http_client-0.3.3.dist-info/licenses/LICENSE,sha256=ayt4HY-Tjoe1Uvj47j6UdNq8mEufKcKFangurChIHxQ,5990
|
|
11
|
+
aas_http_client-0.3.3.dist-info/METADATA,sha256=RtgD4C2wO1BBzPXRaU7xVRxZHuGuSQX6M7ca5B-tJHM,10467
|
|
12
|
+
aas_http_client-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
+
aas_http_client-0.3.3.dist-info/top_level.txt,sha256=vzvoz2vjeTLwpuz-Y-eEfoQ7T3byoaKshVlFMFH5NaM,16
|
|
14
|
+
aas_http_client-0.3.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|