aas-http-client 0.3.1__py3-none-any.whl → 0.3.2__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
@@ -577,19 +577,19 @@ def create_client_by_url(
577
577
  connection_time_out: int = 60,
578
578
  ssl_verify: str = True, # noqa: FBT002
579
579
  ) -> AasHttpClient | None:
580
- """Create a AAS HTTP client from the given parameters.
580
+ """Create a HTTP client for a AAS server connection from the given parameters.
581
581
 
582
- :param base_url: base URL of the BaSyx server, e.g. "http://basyx_python_server:80/"_
583
- :param username: username for the BaSyx server interface client, defaults to ""_
584
- :param password: password for the BaSyx server interface client, defaults to ""_
582
+ :param base_url: Base URL of the AAS server, e.g. "http://basyx_python_server:80/"_
583
+ :param username: Username for the AAS server, defaults to ""_
584
+ :param password: Password for the AAS server, defaults to ""_
585
585
  :param http_proxy: http proxy URL, defaults to ""_
586
586
  :param https_proxy: https proxy URL, defaults to ""_
587
- :param time_out: timeout for the API calls, defaults to 200
588
- :param connection_time_out: timeout for the connection to the API, defaults to 60
589
- :param ssl_verify: whether to verify SSL certificates, defaults to True
590
- :return: An instance of AasHttpClient initialized with the provided parameters.
587
+ :param time_out: Timeout for the API calls, defaults to 200
588
+ :param connection_time_out: Timeout for the connection to the API, defaults to 60
589
+ :param ssl_verify: Whether to verify SSL certificates, defaults to True
590
+ :return: An instance of Http client initialized with the provided parameters.
591
591
  """
592
- logger.info(f"Create BaSyx server interface client from URL '{base_url}'")
592
+ logger.info(f"Create AAS server http client from URL '{base_url}'")
593
593
  config_dict: dict[str, str] = {}
594
594
  config_dict["base_url"] = base_url
595
595
  config_dict["username"] = username
@@ -598,19 +598,31 @@ def create_client_by_url(
598
598
  config_dict["time_out"] = time_out
599
599
  config_dict["connection_time_out"] = connection_time_out
600
600
  config_dict["ssl_verify"] = ssl_verify
601
- config_string = json.dumps(config_dict, indent=4)
601
+ return create_client_by_dict(config_dict, password)
602
+
603
+
604
+ def create_client_by_dict(configuration: dict, password: str = "") -> AasHttpClient | None:
605
+ """Create a HTTP client for a AAS server connection from the given configuration.
606
+
607
+ :param configuration: Dictionary containing the BaSyx server connection settings.
608
+ :param password: Password for the AAS server, defaults to ""_
609
+ :return: An instance of Http client initialized with the provided parameters.
610
+ """
611
+ logger.info(f"Create AAS server http client from configuration '{configuration}'")
612
+ config_string = json.dumps(configuration, indent=4)
613
+
602
614
  return _create_client(config_string, password)
603
615
 
604
616
 
605
617
  def create_client_by_config(config_file: Path, password: str = "") -> AasHttpClient | None:
606
- """Create a AAS HTTP client from the given parameters.
618
+ """Create a HTTP client for a AAS server connection from a given configuration file.
607
619
 
608
- :param config_file: Path to the configuration file containing the BaSyx server connection settings.
620
+ :param config_file: Path to the configuration file containing the AAS server connection settings.
609
621
  :param password: password for the BaSyx server interface client, defaults to ""_
610
- :return: An instance of HttpClient initialized with the provided parameters.
622
+ :return: An instance of Http client initialized with the provided parameters.
611
623
  """
612
624
  config_file = config_file.resolve()
613
- logger.info(f"Create AAS HTTP client from Configuration file '{config_file}'")
625
+ logger.info(f"Create AAS server http client from configuration file '{config_file}'")
614
626
  if not config_file.exists():
615
627
  config_string = "{}"
616
628
  logger.warning(f"Configuration file '{config_file}' not found. Using default configuration.")
@@ -19,6 +19,20 @@ class SdkWrapper:
19
19
  _client: AasHttpClient = None
20
20
  base_url: str = ""
21
21
 
22
+ def __init__(self, config_string: str, password: str = ""):
23
+ """Initializes the wrapper with the given configuration.
24
+
25
+ :param config_string: Configuration string for the BaSyx server connection.
26
+ :param password: Password for the BaSyx server interface client, defaults to "".
27
+ """
28
+ client = _create_client(config_string, password)
29
+
30
+ if not client:
31
+ raise ValueError("Failed to create AAS HTTP client with the provided configuration.")
32
+
33
+ self._client = client
34
+ self.base_url = client.base_url
35
+
22
36
  # region shells
23
37
 
24
38
  def post_asset_administration_shell(self, aas: model.AssetAdministrationShell) -> model.AssetAdministrationShell | None:
@@ -266,6 +280,8 @@ class SdkWrapper:
266
280
 
267
281
  # endregion
268
282
 
283
+ # region utils
284
+
269
285
 
270
286
  def _to_object(content: dict) -> Any | None:
271
287
  try:
@@ -287,6 +303,8 @@ def _to_dict(object: Any) -> dict | None:
287
303
  return None
288
304
 
289
305
 
306
+ # endregion
307
+
290
308
  # region wrapper
291
309
 
292
310
 
@@ -300,7 +318,7 @@ def create_wrapper_by_url(
300
318
  connection_time_out: int = 60,
301
319
  ssl_verify: str = True, # noqa: FBT002
302
320
  ) -> SdkWrapper | None:
303
- """Create a wrapper for the BaSyx Python SDK from the given parameters.
321
+ """Create a wrapper for a AAS server connection from the given parameters.
304
322
 
305
323
  :param base_url: base URL of the BaSyx server, e.g. "http://basyx_python_server:80/"_
306
324
  :param username: username for the BaSyx server interface client, defaults to ""_
@@ -312,7 +330,7 @@ def create_wrapper_by_url(
312
330
  :param ssl_verify: whether to verify SSL certificates, defaults to True
313
331
  :return: An instance of SdkWrapper initialized with the provided parameters.
314
332
  """
315
- logger.info(f"Create BaSyx Python SDK wrapper from URL '{base_url}'")
333
+ logger.info(f"Create AAS server wrapper from URL '{base_url}'")
316
334
  config_dict: dict[str, str] = {}
317
335
  config_dict["base_url"] = base_url
318
336
  config_dict["username"] = username
@@ -321,43 +339,36 @@ def create_wrapper_by_url(
321
339
  config_dict["time_out"] = time_out
322
340
  config_dict["connection_time_out"] = connection_time_out
323
341
  config_dict["ssl_verify"] = ssl_verify
324
- config_string = json.dumps(config_dict, indent=4)
342
+ return create_wrapper_by_dict(config_dict, password)
325
343
 
326
- wrapper = SdkWrapper()
327
- client = _create_client(config_string, password)
328
344
 
329
- if not client:
330
- return None
345
+ def create_wrapper_by_dict(configuration: dict, password: str = "") -> SdkWrapper | None:
346
+ """Create a wrapper for a AAS server connection from the given configuration.
331
347
 
332
- wrapper._client = client
333
- wrapper.base_url = client.base_url
334
- return wrapper
348
+ :param config: Dictionary containing the BaSyx server connection settings.
349
+ :param password: Password for the BaSyx server interface client, defaults to "".
350
+ :return: An instance of SdkWrapper initialized with the provided parameters.
351
+ """
352
+ logger.info(f"Create AAS server wrapper from configuration '{configuration}'")
353
+ config_string = json.dumps(configuration, indent=4)
354
+ return SdkWrapper(config_string, password)
335
355
 
336
356
 
337
357
  def create_wrapper_by_config(config_file: Path, password: str = "") -> SdkWrapper | None:
338
- """Create a wrapper for the BaSyx Python SDK from the given parameters.
358
+ """Create a wrapper for a AAS server connection from a given configuration file.
339
359
 
340
360
  :param config_file: Path to the configuration file containing the BaSyx server connection settings.
341
361
  :param password: password for the BaSyx server interface client, defaults to ""_
342
362
  :return: An instance of SdkWrapper initialized with the provided parameters.
343
363
  """
344
- logger.info(f"Create BaSyx Python SDK wrapper from configuration file '{config_file}'")
364
+ logger.info(f"Create AAS wrapper client from configuration file '{config_file}'")
345
365
  if not config_file.exists():
346
366
  config_string = "{}"
347
367
  logger.warning(f"Configuration file '{config_file}' not found. Using default config.")
348
368
  else:
349
369
  config_string = config_file.read_text(encoding="utf-8")
350
370
  logger.debug(f"Configuration file '{config_file}' found.")
351
-
352
- wrapper = SdkWrapper()
353
- client = _create_client(config_string, password)
354
-
355
- if not client:
356
- return None
357
-
358
- wrapper._client = client
359
- wrapper.base_url = client.base_url
360
- return wrapper
371
+ return SdkWrapper(config_string, password)
361
372
 
362
373
 
363
374
  # endregion
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aas-http-client
3
- Version: 0.3.1
3
+ Version: 0.3.2
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=neuEMk1lyOHOgVv3OBzNeXDWEtkN4qfox-hMRjtDWHM,25350
2
+ aas_http_client/client.py,sha256=tangqT-KJgI28y-CrPPWVc26ZEik4IfgZBjmakkG4lU,25930
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=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,,
9
+ aas_http_client/wrapper/sdk_wrapper.py,sha256=SU-JZwT4O_bOGfjlBUrN_GIJXrSNY8NvfDCGWC7zCOk,14353
10
+ aas_http_client-0.3.2.dist-info/licenses/LICENSE,sha256=ayt4HY-Tjoe1Uvj47j6UdNq8mEufKcKFangurChIHxQ,5990
11
+ aas_http_client-0.3.2.dist-info/METADATA,sha256=etLzP5usn0WyK9ovOEUctZKzDdPOMrCfa3HtbsN0_zQ,10467
12
+ aas_http_client-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ aas_http_client-0.3.2.dist-info/top_level.txt,sha256=vzvoz2vjeTLwpuz-Y-eEfoQ7T3byoaKshVlFMFH5NaM,16
14
+ aas_http_client-0.3.2.dist-info/RECORD,,