aas-http-client 0.3.6__py3-none-any.whl → 0.3.9__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
@@ -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:
@@ -39,17 +39,15 @@ def create_base_submodel_element_Property(
39
39
  return sme
40
40
 
41
41
 
42
- def create_base_submodel(id_short: str, namespace: str = "fluid40", display_name: str = "", description: str = "") -> model.Submodel:
42
+ def create_base_submodel(identifier: str, id_short: str, display_name: str = "", description: str = "") -> model.Submodel:
43
43
  """Create a basic Submodel.
44
44
 
45
+ :param identifier: identifier of the Submodel
45
46
  :param id_short: ID short of the Submodel
46
- :param namespace: namespace of the Submodel , defaults to "fluid40"
47
47
  :param display_name: display name of the Submodel, defaults to ""
48
48
  :param description: description of the Submodel, defaults to ""
49
49
  :return: Submodel instance
50
50
  """
51
- identifier = f"{namespace}/{id_short}" if namespace else id_short
52
-
53
51
  sm = model.Submodel(identifier)
54
52
  sm.id_short = id_short
55
53
 
@@ -68,16 +66,16 @@ def create_base_submodel(id_short: str, namespace: str = "fluid40", display_name
68
66
  return sm
69
67
 
70
68
 
71
- def create_base_ass(id_short: str, namespace: str = "fluid40", display_name: str = "", description: str = "") -> model.AssetAdministrationShell:
69
+ def create_base_ass(identifier: str, id_short: str, display_name: str = "", description: str = "") -> model.AssetAdministrationShell:
72
70
  """Create a basic AAS.
73
71
 
72
+ :param identifier: identifier of the AAS
74
73
  :param id_short: ID short of the AAS
75
- :param namespace: namespace of the AAS, defaults to "basyx_python_aas_server"
76
74
  :param display_name: display name of the AAS, defaults to ""
77
75
  :param description: description of the AAS, defaults to ""
78
76
  :return: AssetAdministrationShell instance
79
77
  """
80
- asset_info = create_base_asset_information(id_short, namespace)
78
+ asset_info = create_base_asset_information(identifier)
81
79
 
82
80
  aas = model.AssetAdministrationShell(id_=asset_info.global_asset_id, asset_information=asset_info)
83
81
  aas.id_short = id_short
@@ -97,24 +95,13 @@ def create_base_ass(id_short: str, namespace: str = "fluid40", display_name: str
97
95
  return aas
98
96
 
99
97
 
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
- def create_base_asset_information(id_short: str, namespace: str = "basyx_python_aas_server") -> model.AssetInformation:
98
+ def create_base_asset_information(identifier: str) -> model.AssetInformation:
111
99
  """Return a basic AssetInformation instance.
112
100
 
113
101
  :param id_short: short ID of the AssetInformation
114
102
  :param namespace: namespace of the AssetInformation, defaults to "basyx_python_aas_server"
115
103
  :return: AssetInformation instance
116
104
  """
117
- identifier = f"{namespace}/{id_short}" if namespace else id_short
118
105
  return model.AssetInformation(model.AssetKind.INSTANCE, identifier)
119
106
 
120
107
 
@@ -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.9
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
@@ -0,0 +1,14 @@
1
+ aas_http_client/__init__.py,sha256=cAr1mQzWp0G0LKtkAOYzc9t95OY3jM3Aj4bKnxx0Dso,901
2
+ aas_http_client/client.py,sha256=CtX1nlIo65-Um9AlXZ3gOfEMJwcLDJNOssxkGXAlsg0,27205
3
+ aas_http_client/core/encoder.py,sha256=FS7P0FPakzFsGz70eRFDHQZFA_2nlKLlWIxavtnFrPg,660
4
+ aas_http_client/core/version_check.py,sha256=9dR0Q6jCFygH_ctj4vyrjerpHvolT87ayengZFlBWCw,708
5
+ aas_http_client/demo/demo_process.py,sha256=s60SBx0le1G2BU_uJ8vC5i6zTcSGQprSnYafZPUtOtE,3299
6
+ aas_http_client/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ aas_http_client/utilities/model_builder.py,sha256=6pZ0mcfofkuCu24wp71vhBKyaLXJcHpU8N4PBHx_Xpo,3782
8
+ aas_http_client/utilities/sdk_tools.py,sha256=QPpItZdhw8y13IgpS015vTAb8e8QfPeidUuE6-K0JIo,1637
9
+ aas_http_client/wrapper/sdk_wrapper.py,sha256=67RiQ5qAgFq84817QurGX-GJBsM3QI3k4-uBC7sOQio,14807
10
+ aas_http_client-0.3.9.dist-info/licenses/LICENSE,sha256=ayt4HY-Tjoe1Uvj47j6UdNq8mEufKcKFangurChIHxQ,5990
11
+ aas_http_client-0.3.9.dist-info/METADATA,sha256=K5XFYdZO6g17aBYyKwQxN2-OotE7FVSiaYVM55ze_9s,10467
12
+ aas_http_client-0.3.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ aas_http_client-0.3.9.dist-info/top_level.txt,sha256=vzvoz2vjeTLwpuz-Y-eEfoQ7T3byoaKshVlFMFH5NaM,16
14
+ aas_http_client-0.3.9.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- aas_http_client/__init__.py,sha256=cAr1mQzWp0G0LKtkAOYzc9t95OY3jM3Aj4bKnxx0Dso,901
2
- aas_http_client/client.py,sha256=7D6Ue_hmlpYm7YjZZccbFZY44NpCdaw58Gb8S98OVtM,27221
3
- aas_http_client/core/encoder.py,sha256=FS7P0FPakzFsGz70eRFDHQZFA_2nlKLlWIxavtnFrPg,660
4
- aas_http_client/core/version_check.py,sha256=721Zs3xSRrJTYZtAxkaUWg9LLKtpU7oFM62DzQHZdE4,705
5
- aas_http_client/demo/demo_process.py,sha256=J-f5CEvCQYfqDoMzM2EgQhHFfTXdZDgbmIus8dB8iiQ,3299
6
- aas_http_client/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- aas_http_client/utilities/model_builder.py,sha256=EUqVvKgXiyJNtyUeFrL6ronfF4hiF1KCipxSaLj6EiE,4465
8
- aas_http_client/wrapper/sdk_wrapper.py,sha256=mL3Syj7g5btDcwVrZ1ZFlKTsBkHjuMJTM1jp-L5mbu8,15388
9
- aas_http_client-0.3.6.dist-info/licenses/LICENSE,sha256=ayt4HY-Tjoe1Uvj47j6UdNq8mEufKcKFangurChIHxQ,5990
10
- aas_http_client-0.3.6.dist-info/METADATA,sha256=NpZM_yLtBHun9DYeJ-uRH82h7GKuCFTpKHWjuoacNQw,10467
11
- aas_http_client-0.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- aas_http_client-0.3.6.dist-info/top_level.txt,sha256=vzvoz2vjeTLwpuz-Y-eEfoQ7T3byoaKshVlFMFH5NaM,16
13
- aas_http_client-0.3.6.dist-info/RECORD,,