aas-http-client 0.3.6__tar.gz → 0.3.8__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 (21) hide show
  1. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/PKG-INFO +1 -1
  2. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client/client.py +6 -6
  3. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client/core/version_check.py +4 -2
  4. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client/demo/demo_process.py +1 -1
  5. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client/utilities/model_builder.py +2 -12
  6. aas_http_client-0.3.8/aas_http_client/utilities/sdk_tools.py +50 -0
  7. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client/wrapper/sdk_wrapper.py +5 -30
  8. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client.egg-info/PKG-INFO +1 -1
  9. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client.egg-info/SOURCES.txt +1 -0
  10. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/pyproject.toml +1 -1
  11. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/tests/test_client.py +6 -5
  12. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/tests/test_wrapper.py +6 -5
  13. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/LICENSE +0 -0
  14. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/README.md +0 -0
  15. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client/__init__.py +0 -0
  16. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client/core/encoder.py +0 -0
  17. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client/utilities/__init__.py +0 -0
  18. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client.egg-info/dependency_links.txt +0 -0
  19. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client.egg-info/requires.txt +0 -0
  20. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/aas_http_client.egg-info/top_level.txt +0 -0
  21. {aas_http_client-0.3.6 → aas_http_client-0.3.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aas-http-client
3
- Version: 0.3.6
3
+ Version: 0.3.8
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
@@ -617,7 +617,7 @@ def create_client_by_url(
617
617
  :param trust_env: Whether to trust environment variables for proxy settings, defaults to True
618
618
  :return: An instance of Http client initialized with the provided parameters.
619
619
  """
620
- logger.info(f"Create AAS server http client from URL '{base_url}'")
620
+ logger.info(f"Create AAS server http client from URL '{base_url}'.")
621
621
  config_dict: dict[str, str] = {}
622
622
  config_dict["base_url"] = base_url
623
623
  config_dict["username"] = username
@@ -637,7 +637,7 @@ def create_client_by_dict(configuration: dict, password: str = "") -> AasHttpCli
637
637
  :param password: Password for the AAS server, defaults to ""_
638
638
  :return: An instance of Http client initialized with the provided parameters.
639
639
  """
640
- logger.info(f"Create AAS server http client from configuration '{configuration}'")
640
+ logger.info("Create AAS server http client from dictionary.")
641
641
  config_string = json.dumps(configuration, indent=4)
642
642
 
643
643
  return _create_client(config_string, password)
@@ -651,7 +651,7 @@ def create_client_by_config(config_file: Path, password: str = "") -> AasHttpCli
651
651
  :return: An instance of Http client initialized with the provided parameters.
652
652
  """
653
653
  config_file = config_file.resolve()
654
- logger.info(f"Create AAS server http client from configuration file '{config_file}'")
654
+ logger.info(f"Create AAS server http client from configuration file '{config_file}'.")
655
655
  if not config_file.exists():
656
656
  config_string = "{}"
657
657
  logger.warning(f"Configuration file '{config_file}' not found. Using default configuration.")
@@ -674,7 +674,7 @@ def _create_client(config_string: str, password: str) -> AasHttpClient | None:
674
674
  f"username: '{client.username}' | "
675
675
  f"https_proxy: '{client.https_proxy}' | "
676
676
  f"http_proxy: '{client.http_proxy}' | "
677
- f"connection_timeout: '{client.connection_time_out}'"
677
+ f"connection_timeout: '{client.connection_time_out}'."
678
678
  )
679
679
  client.initialize(password)
680
680
 
@@ -689,7 +689,7 @@ def _create_client(config_string: str, password: str) -> AasHttpClient | None:
689
689
 
690
690
  def _connect_to_api(client: AasHttpClient) -> bool:
691
691
  start_time = time.time()
692
- logger.debug(f"Try to connect to REST API '{client.base_url}' for {client.connection_time_out} seconds")
692
+ logger.debug(f"Try to connect to REST API '{client.base_url}' for {client.connection_time_out} seconds.")
693
693
  counter: int = 0
694
694
  while True:
695
695
  try:
@@ -703,7 +703,7 @@ def _connect_to_api(client: AasHttpClient) -> bool:
703
703
  raise TimeoutError(f"Connection to server API timed out after {client.connection_time_out} seconds.")
704
704
 
705
705
  counter += 1
706
- logger.warning(f"Retrying connection (attempt: {counter})")
706
+ logger.warning(f"Retrying connection (attempt: {counter}).")
707
707
  time.sleep(1)
708
708
 
709
709
 
@@ -1,6 +1,8 @@
1
- import requests
2
1
  import importlib.metadata
3
2
 
3
+ import requests
4
+
5
+
4
6
  def check_for_update(package_name="aas-http-client"):
5
7
  try:
6
8
  current_version = importlib.metadata.version(package_name)
@@ -14,4 +16,4 @@ def check_for_update(package_name="aas-http-client"):
14
16
  f"Use the following command to update the package: pip install --upgrade {package_name}"
15
17
  )
16
18
  except Exception:
17
- pass
19
+ pass
@@ -16,7 +16,7 @@ def start() -> None:
16
16
  """Start the demo process."""
17
17
  # create a submodel element
18
18
  sme_short_id: str = model_builder.create_unique_short_id("poc_sme")
19
- sme = model_builder.create_base_submodel_element_Property(sme_short_id, model.datatypes.String, "Sample Value")
19
+ sme = model_builder.create_base_submodel_element_property(sme_short_id, model.datatypes.String, "Sample Value")
20
20
 
21
21
  # create a submodel
22
22
  sm_short_id: str = model_builder.create_unique_short_id("poc_sm")
@@ -18,10 +18,10 @@ def create_unique_short_id(id_short: str) -> str:
18
18
  return f"{id_short}_{str(uuid.uuid4()).replace('-', '_')}"
19
19
 
20
20
 
21
- def create_base_submodel_element_Property(
21
+ def create_base_submodel_element_property(
22
22
  id_short: str, type: model.datatypes, value: Any, display_name: str = "", description: str = ""
23
23
  ) -> model.Property:
24
- """Create a basic Property Submodel Element."""
24
+ """Create a basic SubmodelElement of type Property."""
25
25
  sme = model.Property(id_short=id_short, value_type=type, value=value)
26
26
 
27
27
  if not description:
@@ -97,16 +97,6 @@ def create_base_ass(id_short: str, namespace: str = "fluid40", display_name: str
97
97
  return aas
98
98
 
99
99
 
100
- def add_submodel_to_aas(aas: model.AssetAdministrationShell, submodel: model.Submodel) -> None:
101
- """Add a given Submodel correctly to a provided AssetAdministrationShell.
102
-
103
- :param aas: provided AssetAdministrationShell to which the Submodel should be added
104
- :param submodel: given Submodel to add
105
- """
106
- # aas.submodel.add(submodel)
107
- aas.submodel.add(model.ModelReference.from_referable(submodel))
108
-
109
-
110
100
  def create_base_asset_information(id_short: str, namespace: str = "basyx_python_aas_server") -> model.AssetInformation:
111
101
  """Return a basic AssetInformation instance.
112
102
 
@@ -0,0 +1,50 @@
1
+ """Utility functions for working with the BaSyx SDK framework objects."""
2
+
3
+ import json
4
+ import logging
5
+ from typing import Any
6
+
7
+ import basyx.aas.adapter.json
8
+ from basyx.aas import model
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+
13
+ def add_submodel_to_aas(aas: model.AssetAdministrationShell, submodel: model.Submodel) -> None:
14
+ """Add a given Submodel correctly to a provided AssetAdministrationShell.
15
+
16
+ :param aas: provided AssetAdministrationShell to which the Submodel should be added
17
+ :param submodel: given Submodel to add
18
+ """
19
+ # aas.submodel.add(submodel)
20
+ aas.submodel.add(model.ModelReference.from_referable(submodel))
21
+
22
+
23
+ def convert_to_object(content: dict) -> Any | None:
24
+ """Convert a dictionary to a BaSyx SDK framework object.
25
+
26
+ :param content: dictionary to convert
27
+ :return: BaSyx SDK framework object or None
28
+ """
29
+ try:
30
+ dict_string = json.dumps(content)
31
+ return json.loads(dict_string, cls=basyx.aas.adapter.json.AASFromJsonDecoder)
32
+ except Exception as e:
33
+ logger.error(f"Decoding error: {e}")
34
+ logger.error(f"In JSON: {content}")
35
+ return None
36
+
37
+
38
+ def convert_to_dict(object: Any) -> dict | None:
39
+ """Convert a BaSyx SDK framework object. to a dictionary.
40
+
41
+ :param object: BaSyx SDK framework object to convert
42
+ :return: dictionary representation of the object or None
43
+ """
44
+ try:
45
+ data_string = json.dumps(object, cls=basyx.aas.adapter.json.AASToJsonEncoder)
46
+ return json.loads(data_string)
47
+ except Exception as e:
48
+ logger.error(f"Encoding error: {e}")
49
+ logger.error(f"In object: {object}")
50
+ return None
@@ -3,12 +3,12 @@
3
3
  import json
4
4
  import logging
5
5
  from pathlib import Path
6
- from typing import Any
7
6
 
8
- import basyx.aas.adapter.json
9
7
  from basyx.aas import model
10
8
 
11
9
  from aas_http_client.client import AasHttpClient, _create_client
10
+ from aas_http_client.utilities.sdk_tools import convert_to_dict as _to_dict
11
+ from aas_http_client.utilities.sdk_tools import convert_to_object as _to_object
12
12
 
13
13
  logger = logging.getLogger(__name__)
14
14
 
@@ -298,31 +298,6 @@ class SdkWrapper:
298
298
  return self._client
299
299
 
300
300
 
301
- # region utils
302
-
303
-
304
- def _to_object(content: dict) -> Any | None:
305
- try:
306
- dict_string = json.dumps(content)
307
- return json.loads(dict_string, cls=basyx.aas.adapter.json.AASFromJsonDecoder)
308
- except Exception as e:
309
- logger.error(f"Decoding error: {e}")
310
- logger.error(f"In JSON: {content}")
311
- return None
312
-
313
-
314
- def _to_dict(object: Any) -> dict | None:
315
- try:
316
- data_string = json.dumps(object, cls=basyx.aas.adapter.json.AASToJsonEncoder)
317
- return json.loads(data_string)
318
- except Exception as e:
319
- logger.error(f"Encoding error: {e}")
320
- logger.error(f"In object: {object}")
321
- return None
322
-
323
-
324
- # endregion
325
-
326
301
  # region wrapper
327
302
 
328
303
 
@@ -350,7 +325,7 @@ def create_wrapper_by_url(
350
325
  :param trust_env: Whether to trust environment variables for proxy settings, defaults to True
351
326
  :return: An instance of SdkWrapper initialized with the provided parameters.
352
327
  """
353
- logger.info(f"Create AAS server wrapper from URL '{base_url}'")
328
+ logger.info(f"Create AAS server wrapper from URL '{base_url}'.")
354
329
  config_dict: dict[str, str] = {}
355
330
  config_dict["base_url"] = base_url
356
331
  config_dict["username"] = username
@@ -370,7 +345,7 @@ def create_wrapper_by_dict(configuration: dict, password: str = "") -> SdkWrappe
370
345
  :param password: Password for the BaSyx server interface client, defaults to "".
371
346
  :return: An instance of SdkWrapper initialized with the provided parameters.
372
347
  """
373
- logger.info(f"Create AAS server wrapper from configuration '{configuration}'")
348
+ logger.info("Create AAS server wrapper from dictionary.")
374
349
  config_string = json.dumps(configuration, indent=4)
375
350
  return SdkWrapper(config_string, password)
376
351
 
@@ -382,7 +357,7 @@ def create_wrapper_by_config(config_file: Path, password: str = "") -> SdkWrappe
382
357
  :param password: password for the BaSyx server interface client, defaults to ""_
383
358
  :return: An instance of SdkWrapper initialized with the provided parameters.
384
359
  """
385
- logger.info(f"Create AAS wrapper client from configuration file '{config_file}'")
360
+ logger.info(f"Create AAS wrapper client from configuration file '{config_file}'.")
386
361
  if not config_file.exists():
387
362
  config_string = "{}"
388
363
  logger.warning(f"Configuration file '{config_file}' not found. Using default config.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aas-http-client
3
- Version: 0.3.6
3
+ Version: 0.3.8
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
@@ -13,6 +13,7 @@ aas_http_client/core/version_check.py
13
13
  aas_http_client/demo/demo_process.py
14
14
  aas_http_client/utilities/__init__.py
15
15
  aas_http_client/utilities/model_builder.py
16
+ aas_http_client/utilities/sdk_tools.py
16
17
  aas_http_client/wrapper/sdk_wrapper.py
17
18
  tests/test_client.py
18
19
  tests/test_wrapper.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "aas-http-client"
7
- version = "0.3.6"
7
+ version = "0.3.8"
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" }
@@ -3,6 +3,7 @@ from pathlib import Path
3
3
  from aas_http_client.client import create_client_by_config, AasHttpClient, create_client_by_dict, create_client_by_url
4
4
  from basyx.aas import model
5
5
  import aas_http_client.utilities.model_builder as model_builder
6
+ import aas_http_client.utilities.sdk_tools as sdk_tools
6
7
  import json
7
8
  import basyx.aas.adapter.json
8
9
  from urllib.parse import urlparse
@@ -41,22 +42,22 @@ def client(request) -> AasHttpClient:
41
42
  @pytest.fixture(scope="module")
42
43
  def shared_sme_string() -> model.Property:
43
44
  # create a Submodel
44
- return model_builder.create_base_submodel_element_Property("sme_property_string", model.datatypes.String, "Sample String Value")
45
+ return model_builder.create_base_submodel_element_property("sme_property_string", model.datatypes.String, "Sample String Value")
45
46
 
46
47
  @pytest.fixture(scope="module")
47
48
  def shared_sme_bool() -> model.Property:
48
49
  # create a Submodel
49
- return model_builder.create_base_submodel_element_Property("sme_property_bool", model.datatypes.Boolean, True)
50
+ return model_builder.create_base_submodel_element_property("sme_property_bool", model.datatypes.Boolean, True)
50
51
 
51
52
  @pytest.fixture(scope="module")
52
53
  def shared_sme_int() -> model.Property:
53
54
  # create a Submodel
54
- return model_builder.create_base_submodel_element_Property("sme_property_int", model.datatypes.Integer, 262)
55
+ return model_builder.create_base_submodel_element_property("sme_property_int", model.datatypes.Integer, 262)
55
56
 
56
57
  @pytest.fixture(scope="module")
57
58
  def shared_sme_float() -> model.Property:
58
59
  # create a Submodel
59
- return model_builder.create_base_submodel_element_Property("sme_property_float", model.datatypes.Float, 262.3)
60
+ return model_builder.create_base_submodel_element_property("sme_property_float", model.datatypes.Float, 262.3)
60
61
 
61
62
  @pytest.fixture(scope="module")
62
63
  def shared_sm() -> model.Submodel:
@@ -69,7 +70,7 @@ def shared_aas(shared_sm: model.Submodel) -> model.AssetAdministrationShell:
69
70
  aas = model_builder.create_base_ass(id_short="aas_http_client_unit_tests", namespace="")
70
71
 
71
72
  # add Submodel to AAS
72
- model_builder.add_submodel_to_aas(aas, shared_sm)
73
+ sdk_tools.add_submodel_to_aas(aas, shared_sm)
73
74
 
74
75
  return aas
75
76
 
@@ -3,6 +3,7 @@ from pathlib import Path
3
3
  from aas_http_client.wrapper.sdk_wrapper import create_wrapper_by_config, SdkWrapper, create_wrapper_by_dict, create_wrapper_by_url
4
4
  from basyx.aas import model
5
5
  import aas_http_client.utilities.model_builder as model_builder
6
+ import aas_http_client.utilities.sdk_tools as sdk_tools
6
7
  from urllib.parse import urlparse
7
8
  import json
8
9
 
@@ -41,22 +42,22 @@ def wrapper(request) -> SdkWrapper:
41
42
  @pytest.fixture(scope="module")
42
43
  def shared_sme_string() -> model.Property:
43
44
  # create a Submodel
44
- return model_builder.create_base_submodel_element_Property("sme_property_string", model.datatypes.String, "Sample String Value")
45
+ return model_builder.create_base_submodel_element_property("sme_property_string", model.datatypes.String, "Sample String Value")
45
46
 
46
47
  @pytest.fixture(scope="module")
47
48
  def shared_sme_bool() -> model.Property:
48
49
  # create a Submodel
49
- return model_builder.create_base_submodel_element_Property("sme_property_bool", model.datatypes.Boolean, True)
50
+ return model_builder.create_base_submodel_element_property("sme_property_bool", model.datatypes.Boolean, True)
50
51
 
51
52
  @pytest.fixture(scope="module")
52
53
  def shared_sme_int() -> model.Property:
53
54
  # create a Submodel
54
- return model_builder.create_base_submodel_element_Property("sme_property_int", model.datatypes.Integer, 262)
55
+ return model_builder.create_base_submodel_element_property("sme_property_int", model.datatypes.Integer, 262)
55
56
 
56
57
  @pytest.fixture(scope="module")
57
58
  def shared_sme_float() -> model.Property:
58
59
  # create a Submodel
59
- return model_builder.create_base_submodel_element_Property("sme_property_float", model.datatypes.Float, 262.3)
60
+ return model_builder.create_base_submodel_element_property("sme_property_float", model.datatypes.Float, 262.3)
60
61
 
61
62
  @pytest.fixture(scope="module")
62
63
  def shared_sm() -> model.Submodel:
@@ -71,7 +72,7 @@ def shared_aas(shared_sm: model.Submodel) -> model.AssetAdministrationShell:
71
72
  aas = model_builder.create_base_ass(id_short="aas_http_client_unit_tests", namespace="")
72
73
 
73
74
  # add Submodel to AAS
74
- model_builder.add_submodel_to_aas(aas, shared_sm)
75
+ sdk_tools.add_submodel_to_aas(aas, shared_sm)
75
76
 
76
77
  return aas
77
78
 
File without changes