aas
aas_client3_2.aas implements the Asset Administration Shell API, the interface of a single shell.
Its functions take no identifier of the shell: the server is the endpoint of the shell, whose address you take from the descriptor in a registry (see aas_registry).
The same shell can be served by a repository among many others, or by a device which serves only its own shell; the client does not need to know which.
Here, we put a shell in the AAS Repository, and talk to it at the endpoint where the repository serves it:
import requests
import aas_core3_2.types as aas_types
from aas_client3_2 import (
aas as aas_client_aas,
aas_repository as aas_client_aas_repository,
http as aas_client_http,
requests_transport as aas_client_requests_transport,
)
transport = aas_client_requests_transport.RequestsTransport(
requests.Session()
)
repository_server = aas_client_http.Server(
transport=transport, base_url="http://localhost:5004"
)
shell = aas_types.AssetAdministrationShell(
id="https://example.com/ids/aas/getting-started/endpoint",
id_short="Valve",
asset_information=aas_types.AssetInformation(
asset_kind=aas_types.AssetKind.INSTANCE,
global_asset_id="https://example.com/ids/asset/valve-0003",
),
)
aas_client_aas_repository.post_asset_administration_shell(
repository_server, shell
)
# In practice, take the address from the endpoint of the descriptor:
# descriptor.endpoints[0].protocol_information.href
href = (
"http://localhost:5004/shells/"
+ aas_client_http.encode_base64url(shell.id)
)
endpoint = aas_client_http.Server(transport=transport, base_url=href)
Now work with the shell at its endpoint:
got = aas_client_aas.get_asset_administration_shell(endpoint)
print(got.id_short)
# Prints: Valve
asset_information = aas_client_aas.get_asset_information(endpoint)
print(asset_information.global_asset_id)
# Prints: https://example.com/ids/asset/valve-0003
The submodels of the shell are reached through the endpoint too, for example, with get_submodel_by_id(); these functions take only the identifier of the submodel.
Clean Up
Delete what we created in this chapter, so that you can run the code of this chapter again. The identifiers are unique, so the server would refuse to create the shell a second time:
aas_client_aas_repository.delete_asset_administration_shell_by_id(
repository_server, shell.id
)