@@ -49,74 +49,53 @@ import aas_api_python_client
49
49
Please follow the [ installation procedure] ( #installation--usage ) and then run the following:
50
50
51
51
``` python
52
- from __future__ import print_function
53
- import time
54
- import aas_api_python_client
55
- from aas_api_python_client.rest import ApiException
56
- from pprint import pprint
52
+ from aas_api_python_client import ApiClient, Configuration, AssetAdministrationShellRepositoryAPIApi, SubmodelRepositoryAPIApi
53
+ from aas_api_python_client.util import string_to_base64url
54
+ from basyx.aas import model
57
55
58
56
configuration = Configuration()
59
57
configuration.host = " http://localhost:8080/api/v3.0"
60
58
61
- # create an instance of the API class
62
- api_instance = aas_api_python_client.AASXFileServerAPIApi(aas_api_python_client.ApiClient(configuration))
63
- package_id = ' B' # str | The package Id (UTF8-BASE64-URL-encoded)
64
-
65
- try :
66
- # Deletes a specific AASX package from the server
67
- api_instance.delete_aasxby_package_id(package_id)
68
- except ApiException as e:
69
- print (" Exception when calling AASXFileServerAPIApi->delete_aasxby_package_id: %s \n " % e)
70
-
71
- # create an instance of the API class
72
- api_instance = aas_api_python_client.AASXFileServerAPIApi(aas_api_python_client.ApiClient(configuration))
73
- package_id = ' B' # str | The package Id (UTF8-BASE64-URL-encoded)
74
-
75
- try :
76
- # Returns a specific AASX package from the server
77
- api_response = api_instance.get_aasxby_package_id(package_id)
78
- pprint(api_response)
79
- except ApiException as e:
80
- print (" Exception when calling AASXFileServerAPIApi->get_aasxby_package_id: %s \n " % e)
81
-
82
- # create an instance of the API class
83
- api_instance = aas_api_python_client.AASXFileServerAPIApi(aas_api_python_client.ApiClient(configuration))
84
- aas_id = ' B' # str | The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (optional)
85
- limit = 56 # int | The maximum number of elements in the response array (optional)
86
- cursor = ' cursor_example' # str | A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue (optional)
87
-
88
- try :
89
- # Returns a list of available AASX packages at the server
90
- api_response = api_instance.get_all_aasx_package_ids(aas_id = aas_id, limit = limit, cursor = cursor)
91
- pprint(api_response)
92
- except ApiException as e:
93
- print (" Exception when calling AASXFileServerAPIApi->get_all_aasx_package_ids: %s \n " % e)
94
-
95
- # create an instance of the API class
96
- api_instance = aas_api_python_client.AASXFileServerAPIApi(aas_api_python_client.ApiClient(configuration))
97
- aas_ids = [' aas_ids_example' ] # list[str] |
98
- file = ' file_example' # str |
99
- file_name = ' file_name_example' # str |
100
-
101
- try :
102
- # Stores the AASX package at the server
103
- api_response = api_instance.post_aasx_package(aas_ids, file , file_name)
104
- pprint(api_response)
105
- except ApiException as e:
106
- print (" Exception when calling AASXFileServerAPIApi->post_aasx_package: %s \n " % e)
107
-
108
- # create an instance of the API class
109
- api_instance = aas_api_python_client.AASXFileServerAPIApi(aas_api_python_client.ApiClient(configuration))
110
- aas_ids = [' aas_ids_example' ] # list[str] |
111
- file = ' file_example' # str |
112
- file_name = ' file_name_example' # str |
113
- package_id = ' B' # str | The package Id (UTF8-BASE64-URL-encoded)
114
-
115
- try :
116
- # Updates the AASX package at the server
117
- api_instance.put_aasxby_package_id(aas_ids, file , file_name, package_id)
118
- except ApiException as e:
119
- print (" Exception when calling AASXFileServerAPIApi->put_aasxby_package_id: %s \n " % e)
59
+ api_client = ApiClient(configuration = configuration)
60
+
61
+ aasRepoClient = AssetAdministrationShellRepositoryAPIApi(api_client = api_client)
62
+
63
+ # query all asset administration shells
64
+ all_aas = aasRepoClient.get_all_asset_administration_shells().result
65
+ print (all_aas)
66
+
67
+ # query specific asset administration shell
68
+ aas = aasRepoClient.get_asset_administration_shell_by_id(string_to_base64url(' https://acplt.org/Test_AssetAdministrationShell' ))
69
+ print (aas)
70
+
71
+ # query asset information
72
+ aas_info = aasRepoClient.get_asset_information_aas_repository(string_to_base64url(' https://acplt.org/Test_AssetAdministrationShell' ))
73
+ print (aas_info)
74
+
75
+ # create a new asset administration shell
76
+ new_aas = model.AssetAdministrationShell(aas_info, " https://acplt.org/Test_AAS" )
77
+ aasRepoClient.post_asset_administration_shell(new_aas)
78
+
79
+
80
+ submodelRepoClient = SubmodelRepositoryAPIApi(api_client = api_client)
81
+
82
+ # query all submodels
83
+ all_submodels = submodelRepoClient.get_all_submodels().result
84
+ print (all_submodels)
85
+
86
+ # modify a submodel
87
+ test_submodel = all_submodels[0 ]
88
+ test_submodel.id_short = " Test123"
89
+ submodelRepoClient.put_submodel_by_id(test_submodel, string_to_base64url(test_submodel.id))
90
+
91
+ # delete a submodel
92
+ submodelRepoClient.delete_submodel_by_id(string_to_base64url(test_submodel.id))
93
+
94
+ # create a new submodel
95
+ new_submodel = model.Submodel(" https://acplt.org/TestSubmodel" )
96
+ submodelRepoClient.post_submodel(new_submodel)
97
+
98
+
120
99
```
121
100
122
101
## Documentation for API Endpoints
0 commit comments