aas_client3_2.aasx_file_server
Implement the operations of the AASX File Server API.
The module also implements the AASX Async File Server API, and its Status and Result APIs.
Every public function implements exactly one operation of the specification. The
private functions _build_* and _parse_* build the request and parse
the response of the operation. They do no I/O, and constitute a semi-public
interface for the testing client, which is released in lockstep with this client.
- aas_client3_2.aasx_file_server.CONTENT_TYPE: Final[str] = 'application/asset-administration-shell-package'
Content type of an AASX package, as the OpenAPI gives it for the uploads and the downloads of the packages
- aas_client3_2.aasx_file_server.get_all_aasx_package_ids(server: Server, *, aas_id: str | None = None, limit: int | None = None, cursor: str | None = None) GetPackageDescriptionsResult[source]
List a page of the descriptions of the AASX packages on the server.
A description gives the ID of a package, and the identifiers of the shells it contains.
- Parameters:
- Returns:
a page of the descriptions of the packages
- Implements:
GetAllAASXPackageIds –
GET /packages
- aas_client3_2.aasx_file_server.post_aasx_package(server: Server, file: bytes | IO[bytes], *, aas_ids: Sequence[str] | None = None, file_name: str | None = None) PackageDescription[source]
Upload a new AASX package.
The content is either
bytes, or a binary file object which is readable and seekable; it is read from its current position to its end, in chunks, so that a large package is never held in memory. The file object must not be modified during the upload. The package is sent with the content typeCONTENT_TYPE.
- aas_client3_2.aasx_file_server.get_aasx_by_package_id(server: Server, package_id: str) ContextManager[Download][source]
Download the AASX package with the given ID.
The content is streamed, so use the result as a context manager:
with aasx_file_server.get_aasx_by_package_id(server, package_id) as download: with open("package.aasx", "wb") as fid: download.write_to(fid)
The connection is released when the context is exited.
- aas_client3_2.aasx_file_server.put_aasx_by_package_id(server: Server, package_id: str, file: bytes | IO[bytes], *, aas_ids: Sequence[str] | None = None, file_name: str | None = None) None[source]
Create or replace the AASX package with the given ID.
See
post_aasx_package()for the content.
- aas_client3_2.aasx_file_server.delete_aasx_by_package_id(server: Server, package_id: str) None[source]
Delete the AASX package with the given ID.
- aas_client3_2.aasx_file_server.post_async_aasx_package(server: Server, file: bytes | IO[bytes], *, aas_ids: Sequence[str] | None = None, file_name: str | None = None) OperationHandle[source]
Start uploading a new AASX package, and return at once.
The server processes the package asynchronously. Follow its progress with
get_aasx_async_status(), and fetch the result withget_aasx_async_result(). Seepost_aasx_package()for the content.
- aas_client3_2.aasx_file_server.get_aasx_async_status(server: Server, handle_id: str) BaseOperationResult[source]
Get the status of the asynchronous upload with the given handle.
As for the asynchronous invocations of operations, the server redirects to the result once the upload is finished. The transport usually follows the redirect (the one based on requests does); if not, the client follows it, but only to the origin of the server. Either way, the status is taken from the result, so its
execution_statetells whether the upload completed or failed.- Parameters:
server¶ – where to send the request
handle_id¶ – handle as given by
post_async_aasx_package()
- Returns:
the status of the upload
- Raises:
NotFoundif there is no such upload;UnexpectedResponseif the server redirects to another origin- Implements:
GetAasxAsyncStatus –
GET /packages-async/status/{handleId}
- aas_client3_2.aasx_file_server.get_aasx_async_result(server: Server, handle_id: str) BaseOperationResult[source]
Get the result of the finished asynchronous upload with the given handle.
A failed upload is a result with the
execution_stateFailed, not an error.- Parameters:
server¶ – where to send the request
handle_id¶ – handle as given by
post_async_aasx_package()
- Returns:
the result of the upload
- Raises:
NotFoundif there is no such upload- Implements:
GetAasxAsyncResult –
GET /packages-async/result/{handleId}