aasx_file_server
aas_client3_2.aasx_file_server implements the AASX File Server API: it stores the AASX packages, the files which bundle the shells, the submodels and their attachments, as defined in Part 5 of the specification.
The packages are uploaded and downloaded in chunks, as the other files (see Upload and Download Files).
import tempfile
import requests
from aas_client3_2 import (
aasx_file_server as aas_client_aasx_file_server,
http as aas_client_http,
requests_transport as aas_client_requests_transport,
)
server = aas_client_http.Server(
transport=aas_client_requests_transport.RequestsTransport(
requests.Session()
),
base_url="http://localhost:5010",
)
shell_id = "https://example.com/ids/aas/getting-started/aasx"
with open("motor.aasx", "rb") as fid:
description = aas_client_aasx_file_server.post_aasx_package(
server, fid, aas_ids=[shell_id], file_name="motor.aasx"
)
package_id = description.package_id
List the packages, optionally only those which contain a given shell:
page = aas_client_aasx_file_server.get_all_aasx_package_ids(
server, aas_id=shell_id
)
for a_description in page.over_result_or_empty():
print(
a_description.package_id,
list(a_description.over_aas_ids_or_empty()),
)
Download a package to a file, and delete it:
with aas_client_aasx_file_server.get_aasx_by_package_id(
server, package_id
) as download:
with tempfile.TemporaryFile() as fid:
download.write_to(fid)
aas_client_aasx_file_server.delete_aasx_by_package_id(
server, package_id
)
Large packages can be uploaded asynchronously with post_async_aasx_package(), which gives a handle to poll with get_aasx_async_status().