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 +26 -14
- aas_http_client/wrapper/sdk_wrapper.py +33 -22
- {aas_http_client-0.3.1.dist-info → aas_http_client-0.3.2.dist-info}/METADATA +1 -1
- {aas_http_client-0.3.1.dist-info → aas_http_client-0.3.2.dist-info}/RECORD +7 -7
- {aas_http_client-0.3.1.dist-info → aas_http_client-0.3.2.dist-info}/WHEEL +0 -0
- {aas_http_client-0.3.1.dist-info → aas_http_client-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {aas_http_client-0.3.1.dist-info → aas_http_client-0.3.2.dist-info}/top_level.txt +0 -0
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
|
|
580
|
+
"""Create a HTTP client for a AAS server connection from the given parameters.
|
|
581
581
|
|
|
582
|
-
:param base_url:
|
|
583
|
-
:param username:
|
|
584
|
-
:param password:
|
|
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:
|
|
588
|
-
:param connection_time_out:
|
|
589
|
-
:param ssl_verify:
|
|
590
|
-
:return: An instance of
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
342
|
+
return create_wrapper_by_dict(config_dict, password)
|
|
325
343
|
|
|
326
|
-
wrapper = SdkWrapper()
|
|
327
|
-
client = _create_client(config_string, password)
|
|
328
344
|
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
333
|
-
|
|
334
|
-
return
|
|
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
|
|
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
|
|
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.
|
|
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=
|
|
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=
|
|
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=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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|