aas_client3_2.aas
Implement the operations of the Asset Administration Shell API.
The Asset Administration Shell API is the interface of a single shell. Its paths
are relative to the endpoint of the shell, as a registry lists it in
protocolInformation.href of a descriptor with the interface AAS-3.2. Hence
the base URL of the Server is the endpoint itself,
such as https://example.com/shells/dXJuOmV4YW1wbGU6YWFzOjE, and the paths are
appended without the prefix /aas of the OpenAPI. Part 2 says that the client just
uses the endpoint as provided in the registry, so that it can not tell a single shell
from a repository, and Eclipse BaSyx Go components serve the shell under it, too.
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.aas.get_asset_administration_shell(server: Server) AssetAdministrationShell[source]
Get the Asset Administration Shell.
- Parameters:
server¶ – where to send the request
- Returns:
the shell
- Implements:
GetAssetAdministrationShell –
GET /aas
- aas_client3_2.aas.put_asset_administration_shell(server: Server, asset_administration_shell: AssetAdministrationShell) None[source]
Create or replace the Asset Administration Shell.
- aas_client3_2.aas.get_asset_administration_shell_reference(server: Server) Reference[source]
Get a reference to the Asset Administration Shell.
- Parameters:
server¶ – where to send the request
- Returns:
the reference to the shell
- Implements:
GetAssetAdministrationShell-Reference –
GET /aas/$reference
- aas_client3_2.aas.get_asset_information(server: Server) AssetInformation[source]
Get the asset information of the Asset Administration Shell.
- Parameters:
server¶ – where to send the request
- Returns:
the asset information
- Implements:
GetAssetInformation –
GET /aas/asset-information
- aas_client3_2.aas.put_asset_information(server: Server, asset_information: AssetInformation) None[source]
Replace the asset information of the Asset Administration Shell.
- aas_client3_2.aas.get_all_submodel_references(server: Server, *, limit: int | None = None, cursor: str | None = None) GetReferencesResult[source]
List a page of the submodel references of the Asset Administration Shell.
This is not to be confused with
get_all_submodels_referenceof the Submodel Repository API, which lists a reference for each submodel in a repository.
- aas_client3_2.aas.post_submodel_reference(server: Server, submodel_reference: Reference) Reference[source]
Add a submodel reference to the Asset Administration Shell.
- aas_client3_2.aas.delete_submodel_reference(server: Server, submodel_identifier: str) None[source]
Remove the reference to the submodel from the Asset Administration Shell.
The submodel itself is not deleted.
- aas_client3_2.aas.get_thumbnail(server: Server) ContextManager[Download][source]
Download the thumbnail of the asset of the Asset Administration Shell.
The content is streamed, so use the result as a context manager:
with aas.get_thumbnail(server) as download: with open("thumbnail.png", "wb") as fid: download.write_to(fid)
The connection is released when the context is exited. If the thumbnail refers to an external resource, the server may redirect to it; whether the redirect is followed is up to the transport.
- aas_client3_2.aas.put_thumbnail(server: Server, content: bytes | IO[bytes], *, file_name: str | None = None, content_type: str | None = None) None[source]
Upload the thumbnail of the asset of the Asset Administration Shell.
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 file is never held in memory. It must be seekable so that the client knows the length of the body up-front, and can send the content again, for example, after a refreshed token. The file object must not be modified during the upload.- Parameters:
server¶ – where to send the request
content¶ – content of the thumbnail
file_name¶ – if set, the name of the file, such as
thumbnail.pngcontent_type¶ – if set, the content type of the thumbnail, such as
image/png, otherwiseapplication/octet-stream. The servers may take it as the new content type of the thumbnail.
- Raises:
TypeErrorbefore sending anything if the content is neither bytes nor a binary file object;ValueErrorbefore sending anything if the content can not be read again, or if the file name or the content type contain double quotes, backslashes or control characters- Implements:
PutThumbnail –
PUT /aas/asset-information/thumbnail
- aas_client3_2.aas.delete_thumbnail(server: Server) None[source]
Delete the thumbnail of the asset of the Asset Administration Shell.
- Parameters:
server¶ – where to send the request
- Implements:
DeleteThumbnail –
DELETE /aas/asset-information/thumbnail
- aas_client3_2.aas.get_submodel_by_id(server: Server, submodel_identifier: str, *, level: Level | None = None, extent: Extent | None = None) Submodel[source]
Get the submodel with the given identifier.
- aas_client3_2.aas.put_submodel_by_id(server: Server, submodel_identifier: str, submodel: Submodel) None[source]
Replace the submodel with the given identifier.
- aas_client3_2.aas.patch_submodel_by_id(server: Server, submodel_identifier: str, submodel: Submodel) None[source]
Update the existing submodel with the given identifier.
Part 2 replaces the elements of the stored submodel one by one with the elements of
submodel, which must all exist on the server.The query parameter
levelis omitted, since it allows only the valuecore.
- aas_client3_2.aas.delete_submodel_by_id(server: Server, submodel_identifier: str) None[source]
Delete the submodel with the given identifier.
- aas_client3_2.aas.get_submodel_by_id_metadata(server: Server, submodel_identifier: str) SubmodelMetadata[source]
Get the metadata of the submodel with the given identifier.
- aas_client3_2.aas.patch_submode_by_id_metadata(server: Server, submodel_identifier: str, submodel_metadata: SubmodelMetadata) None[source]
Update the metadata of the submodel with the given identifier.
The submodel elements remain unchanged.
The query parameter
levelis omitted, since it allows only the valuecore.
- aas_client3_2.aas.get_submodel_by_id_value_only(server: Server, submodel_identifier: str, *, level: Level | None = None, extent: Extent | None = None) Mapping[str, Any][source]
Get the values of the submodel with the given identifier.
The values are in the ValueOnly serialization, a JSON object keyed by the ID-shorts of the submodel elements. They can not be parsed further without knowing the structure of the submodel, for example, from
get_submodel_by_id_metadata(), since the ValueOnly serialization drops the model types: a range{"min": 1, "max": 5}looks exactly like a collection with the propertiesminandmax.- Parameters:
- Returns:
the values of the submodel
- Implements:
GetSubmodelById-ValueOnly_AAS –
GET /aas/submodels/{submodelIdentifier}/$value
- aas_client3_2.aas.patch_submodel_by_id_value_only(server: Server, submodel_identifier: str, submodel: Submodel) None[source]
Update the values of the submodel with the given identifier.
The client sends only the values of
submodel, in the ValueOnly serialization. Part 2 replaces the values of the stored elements one by one, and the elements must all exist on the server. Everything else, such as the semantic IDs, remains unchanged.The query parameter
levelis omitted, since it allows only the valuecore.- Parameters:
- Raises:
ValueErrorif a value ofsubmodelcan not be serialized, such as a propertyxs:intwith the value"abc"- Implements:
PatchSubmodelById-ValueOnly_AAS –
PATCH /aas/submodels/{submodelIdentifier}/$value
- aas_client3_2.aas.get_submodel_by_id_reference(server: Server, submodel_identifier: str) Reference[source]
Get a reference to the submodel with the given identifier.
- aas_client3_2.aas.get_submodel_by_id_path(server: Server, submodel_identifier: str, *, level: Level | None = None) List[str][source]
List the ID-short paths of the elements of the submodel.
The paths start at the top-level elements, such as
MotorandMotor.Speed, since the submodel itself has no path. Withlevelset to core, only the paths of the top-level elements are listed.
- aas_client3_2.aas.get_all_submodel_elements(server: Server, submodel_identifier: str, *, limit: int | None = None, cursor: str | None = None, level: Level | None = None, extent: Extent | None = None) GetSubmodelElementsResult[source]
List a page of the top-level submodel elements of the submodel.
- Parameters:
- Returns:
a page of the submodel elements
- Implements:
GetAllSubmodelElements_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements
- aas_client3_2.aas.post_submodel_element(server: Server, submodel_identifier: str, submodel_element: SubmodelElement) SubmodelElement[source]
Add a new top-level submodel element to the submodel.
- Parameters:
- Returns:
the created submodel element, as stored by the server
- Implements:
PostSubmodelElement_AAS –
POST /aas/submodels/{submodelIdentifier}/submodel-elements
- aas_client3_2.aas.get_all_submodel_elements_metadata(server: Server, submodel_identifier: str, *, limit: int | None = None, cursor: str | None = None) GetSubmodelElementsMetadataResult[source]
List a page of the metadata of the top-level submodel elements of the submodel.
- Parameters:
- Returns:
a page of the metadata of the submodel elements
- Implements:
GetAllSubmodelElements-Metadata_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/$metadata
- aas_client3_2.aas.get_all_submodel_elements_value_only(server: Server, submodel_identifier: str, *, limit: int | None = None, cursor: str | None = None, level: Level | None = None, extent: Extent | None = None) GetSubmodelElementsValueResult[source]
List a page of the values of the top-level submodel elements of the submodel.
Each item of the page is a JSON object with a single key, the ID-short of the element, whose value is the ValueOnly serialization of the element. Unlike the OpenAPI, which types the page as a single JSON object, aas-core3.2 follows Eclipse BaSyx Go components and the prose of Part 2 here.
- Parameters:
- Returns:
a page of the values of the submodel elements
- Implements:
GetAllSubmodelElements-ValueOnly_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/$value
- aas_client3_2.aas.get_all_submodel_elements_reference(server: Server, submodel_identifier: str, *, limit: int | None = None, cursor: str | None = None) GetReferencesResult[source]
List a page of the references to the top-level submodel elements of the submodel.
- Parameters:
- Returns:
a page of the references
- Implements:
GetAllSubmodelElementsReference_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/$reference
- aas_client3_2.aas.get_all_submodel_elements_path(server: Server, submodel_identifier: str, *, limit: int | None = None, cursor: str | None = None, level: Level | None = None) GetPathItemsResult[source]
List a page of the ID-short paths of the elements of the submodel.
The limit applies to the paths, not to the top-level elements.
- Parameters:
- Returns:
a page of the paths
- Implements:
GetAllSubmodelElementsPath_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/$path
- aas_client3_2.aas.get_submodel_element_by_path(server: Server, submodel_identifier: str, id_short_path: str, *, level: Level | None = None, extent: Extent | None = None) SubmodelElement[source]
Get the submodel element at the given ID-short path.
- Parameters:
- Returns:
the submodel element
- Implements:
GetSubmodelElementByPath_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}
- aas_client3_2.aas.post_submodel_element_by_path(server: Server, submodel_identifier: str, id_short_path: str, submodel_element: SubmodelElement) SubmodelElement[source]
Add a new submodel element as a child of the element at the given ID-short path.
The element at
id_short_pathmust be able to hold children, such as a submodel element collection, a submodel element list or an entity.- Parameters:
- Returns:
the created submodel element, as stored by the server
- Implements:
PostSubmodelElementByPath_AAS –
POST /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}
- aas_client3_2.aas.put_submodel_element_by_path(server: Server, submodel_identifier: str, id_short_path: str, submodel_element: SubmodelElement) None[source]
Create or replace the submodel element at the given ID-short path.
- Parameters:
- Implements:
PutSubmodelElementByPath_AAS –
PUT /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}
- aas_client3_2.aas.patch_submodel_element_value_by_path(server: Server, submodel_identifier: str, id_short_path: str, submodel_element: SubmodelElement, *, level: Level | None = None) None[source]
Update the existing submodel element at the given ID-short path.
Part 2 replaces the stored element and its children one by one with
submodel_elementand its children, which must all exist on the server.Unlike the Submodel Repository API, the OpenAPI allows both values of the query parameter
levelhere.- Parameters:
- Implements:
PatchSubmodelElementValueByPath_AAS –
PATCH /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}
- aas_client3_2.aas.delete_submodel_element_by_path(server: Server, submodel_identifier: str, id_short_path: str) None[source]
Delete the submodel element at the given ID-short path.
- aas_client3_2.aas.get_submodel_element_by_path_metadata(server: Server, submodel_identifier: str, id_short_path: str) SubmodelElementMetadata[source]
Get the metadata of the submodel element at the given ID-short path.
- Parameters:
- Returns:
the metadata of the submodel element
- Implements:
GetSubmodelElementByPath-Metadata_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata
- aas_client3_2.aas.patch_submodel_element_value_by_path_metadata(server: Server, submodel_identifier: str, id_short_path: str, submodel_element_metadata: SubmodelElementMetadata, *, level: Level | None = None) None[source]
Update the metadata of the submodel element at the given ID-short path.
The value of the element remains unchanged.
- Parameters:
server¶ – where to send the request
submodel_identifier¶ – identifier of the submodel
id_short_path¶ – ID-short path of the element
submodel_element_metadata¶ – the new metadata of the submodel element
level¶ – depth of the submodel element in the request; the OpenAPI gives the parameter here, although the metadata carries no children
- Implements:
PatchSubmodelElementValueByPath-Metadata_AAS –
PATCH /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata
- aas_client3_2.aas.get_submodel_element_by_path_value_only(server: Server, submodel_identifier: str, id_short_path: str, *, level: Level | None = None) None | bool | int | float | str | Sequence[Any] | Mapping[str, Any][source]
Get the value of the submodel element at the given ID-short path.
The value is in the ValueOnly serialization, without the ID-short of the element; for example,
5for a propertyxs:int, or{"min": 1, "max": 5}for a range. The value can not be parsed further without knowing the kind of the element, since the ValueOnly serialization drops the model types; for example, the range above looks exactly like a collection with the propertiesminandmax. If you know the kind, you can parse some kinds with aas-core3.2, for example, a range withaas_core3_2.jsonization.range_value_from_jsonable().- Parameters:
- Returns:
the value of the submodel element
- Implements:
GetSubmodelElementByPath-ValueOnly_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value
- aas_client3_2.aas.patch_submodel_element_value_by_path_value_only(server: Server, submodel_identifier: str, id_short_path: str, submodel_element: SubmodelElement, *, level: Level | None = None) None[source]
Update the value of the submodel element at the given ID-short path.
The client sends only the value of
submodel_element, in the ValueOnly serialization. Part 2 replaces the value of the stored element, and of its children one by one, which must all exist on the server. Everything else, such as the semantic ID, remains unchanged.Unlike the Submodel Repository API, the OpenAPI allows both values of the query parameter
levelhere.- Parameters:
- Raises:
ValueErrorifsubmodel_elementis an operation or a capability, which have no value, or if its value can not be serialized, such as a propertyxs:intwith the value"abc"- Implements:
PatchSubmodelElementValueByPathValueOnly_AAS –
PATCH /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value
- aas_client3_2.aas.get_submodel_element_by_path_reference(server: Server, submodel_identifier: str, id_short_path: str) Reference[source]
Get a reference to the submodel element at the given ID-short path.
The reference is a model reference with a key for the submodel, followed by a key for each element along the path. The key of an element in a list holds its index, such as
0.The deprecated query parameter
levelis omitted, since it allows only the valuecore.- Parameters:
- Returns:
the reference to the submodel element
- Implements:
GetSubmodelElementByPath-Reference_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$reference
- aas_client3_2.aas.get_submodel_element_by_path_path(server: Server, submodel_identifier: str, id_short_path: str, *, level: Level | None = None) List[str][source]
List the ID-short paths of the submodel element and of its descendants.
The paths include the path of the element itself. With
levelset to core, only the paths of the element and of its direct children are listed.- Parameters:
- Returns:
the paths
- Implements:
GetSubmodelElementByPath-Path_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$path
- aas_client3_2.aas.get_file_by_path(server: Server, submodel_identifier: str, id_short_path: str) ContextManager[Download][source]
Download the content of the file element at the given ID-short path.
The content is streamed, so use the result as a context manager:
with aas.get_file_by_path( server, "urn:example:submodel:1", "Documentation.Manual" ) as download: with open("manual.pdf", "wb") as fid: download.write_to(fid)
The connection is released when the context is exited. If the file element refers to an external resource, the server may redirect to it; whether the redirect is followed is up to the transport.
- Parameters:
- Returns:
a context manager which gives the download
- Raises:
MethodNotAllowedif the element is not a file element- Implements:
GetFileByPath_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment
- aas_client3_2.aas.put_file_by_path(server: Server, submodel_identifier: str, id_short_path: str, content: bytes | IO[bytes], *, file_name: str | None = None, content_type: str | None = None) None[source]
Upload the content of the file element at the given ID-short path.
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 file is never held in memory. It must be seekable so that the client knows the length of the body up-front, and can send the content again, for example, after a refreshed token. The file object must not be modified during the upload.- Parameters:
server¶ – where to send the request
submodel_identifier¶ – identifier of the submodel
id_short_path¶ – ID-short path of the file element, such as
Manualcontent¶ – content of the file
file_name¶ – if set, the name of the file
content_type¶ – if set, the content type of the file, such as
application/pdf, otherwiseapplication/octet-stream. The servers may take it as the new content type of the file element.
- Raises:
TypeErrorbefore sending anything if the content is neither bytes nor a binary file object;ValueErrorbefore sending anything if the content can not be read again, or if the file name or the content type contain double quotes, backslashes or control characters;MethodNotAllowedif the element is not a file element- Implements:
PutFileByPath_AAS –
PUT /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment
- aas_client3_2.aas.delete_file_by_path(server: Server, submodel_identifier: str, id_short_path: str) None[source]
Delete the content of the file element at the given ID-short path.
The file element itself stays.
- aas_client3_2.aas.invoke_operation_sync(server: Server, submodel_identifier: str, id_short_path: str, operation_request: OperationRequest) OperationResult[source]
Invoke the operation at the given ID-short path, and wait for its result.
The connection stays open until the server has the result. Set
client_timeout_durationofoperation_request, such asPT30S, to tell the server how long the client waits; the timeout of the transport should be longer.- Parameters:
- Returns:
the result of the operation; check its
execution_stateandsuccess, since a failed operation still gives a result- Raises:
MethodNotAllowedif the element is not an operation- Implements:
InvokeOperationSync_AAS –
POST /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke
- aas_client3_2.aas.invoke_operation_sync_value_only(server: Server, submodel_identifier: str, id_short_path: str, operation_request: OperationRequestValueOnly) OperationResultValueOnly[source]
Invoke the operation with the arguments in Value-Only, and wait for its result.
The arguments map the ID-shorts of the variables to their values, such as
{"speed": 5}; the numbers in the result are floats, as everywhere in Value-Only, since JSON knows a single numeric type. The value types of the variables tell which of the numbers are integers.- Parameters:
- Returns:
the result of the operation
- Raises:
MethodNotAllowedif the element is not an operation- Implements:
InvokeOperationSync-ValueOnly_AAS –
POST /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke/$value
- aas_client3_2.aas.invoke_operation_async(server: Server, submodel_identifier: str, id_short_path: str, operation_request: OperationRequestAsync) OperationHandle[source]
Start the operation at the given ID-short path on the server, and return at once.
Poll
get_operation_async_status()with the handle until the operation is finished, and then fetchget_operation_async_result():handle = aas.invoke_operation_async( server, "urn:example:submodel:1", "Control.Start", aas_types.OperationRequestAsync(client_timeout_duration="PT60S"), ) while True: status = aas.get_operation_async_status( server, "urn:example:submodel:1", "Control.Start", handle.handle_id ) if status.execution_state not in ( aas_types.ExecutionState.INITIATED, aas_types.ExecutionState.RUNNING, ): break time.sleep(1) result = aas.get_operation_async_result( server, "urn:example:submodel:1", "Control.Start", handle.handle_id )
Note that the server may accept an invocation which fails later. The failure then shows in the result.
- Parameters:
- Returns:
the handle of the invocation, as given in the header
Location- Raises:
MethodNotAllowedif the element is not an operation- Implements:
InvokeOperationAsync_AAS –
POST /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async
- aas_client3_2.aas.invoke_operation_async_value_only(server: Server, submodel_identifier: str, id_short_path: str, operation_request: OperationRequestAsyncValueOnly) OperationHandle[source]
Start the operation with the arguments in Value-Only, and return at once.
See
invoke_operation_async()for how to poll the status; fetch the result withget_operation_async_result_value_only().- Parameters:
- Returns:
the handle of the invocation, as given in the header
Location- Implements:
InvokeOperationAsync-ValueOnly_AAS –
POST /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async/$value
- aas_client3_2.aas.get_operation_async_status(server: Server, submodel_identifier: str, id_short_path: str, handle_id: str) BaseOperationResult[source]
Get the status of the asynchronous invocation with the given handle.
While the operation runs, the server gives the status. Once it is finished, the server redirects to the result. 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 operation completed, failed or timed out.- Parameters:
server¶ – where to send the request
submodel_identifier¶ – identifier of the submodel
id_short_path¶ – ID-short path of the operation, such as
Control.Starthandle_id¶ – handle as given by
invoke_operation_async()
- Returns:
the status of the invocation
- Raises:
NotFoundif there is no such invocation;UnexpectedResponseif the server redirects to another origin- Implements:
GetOperationAsyncStatus_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-status/{handleId}
- aas_client3_2.aas.get_operation_async_result(server: Server, submodel_identifier: str, id_short_path: str, handle_id: str) OperationResult[source]
Get the result of the finished asynchronous invocation with the given handle.
- Parameters:
server¶ – where to send the request
submodel_identifier¶ – identifier of the submodel
id_short_path¶ – ID-short path of the operation, such as
Control.Starthandle_id¶ – handle as given by
invoke_operation_async()
- Returns:
the result of the operation; a failed operation still gives a result, with
execution_stateset toFailed- Raises:
NotFoundif there is no such invocation- Implements:
GetOperationAsyncResult_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}
- aas_client3_2.aas.get_operation_async_result_value_only(server: Server, submodel_identifier: str, id_short_path: str, handle_id: str) OperationResultValueOnly[source]
Get the result of the finished asynchronous invocation in Value-Only.
- Parameters:
server¶ – where to send the request
submodel_identifier¶ – identifier of the submodel
id_short_path¶ – ID-short path of the operation, such as
Control.Starthandle_id¶ – handle as given by
invoke_operation_async()orinvoke_operation_async_value_only()
- Returns:
the result of the operation
- Raises:
NotFoundif there is no such invocation- Implements:
GetOperationAsyncResult-ValueOnly_AAS –
GET /aas/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}/$value