submodel_registry
aas_client3_2.submodel_registry implements the Submodel Registry API: it stores the descriptors of the submodels, which tell where each submodel lives.
A client looks up the descriptor, and then talks to the submodel at its endpoint (see submodel).
import requests
import aas_core3_2.types as aas_types
from aas_client3_2 import (
http as aas_client_http,
requests_transport as aas_client_requests_transport,
submodel_registry as aas_client_submodel_registry,
)
server = aas_client_http.Server(
transport=aas_client_requests_transport.RequestsTransport(
requests.Session()
),
base_url="http://localhost:5008",
)
submodel_id = "https://example.com/ids/sm/getting-started/registry"
descriptor = aas_types.SubmodelDescriptor(
id=submodel_id,
id_short="Maintenance",
endpoints=[
aas_types.Endpoint(
interface="SUBMODEL-3.2",
protocol_information=aas_types.ProtocolInformation(
href="http://localhost:5005/submodels/"
+ aas_client_http.encode_base64url(submodel_id),
endpoint_protocol="HTTP",
),
)
],
)
aas_client_submodel_registry.post_submodel_descriptor(
server, descriptor
)
Look it up, and list all the descriptors:
got = aas_client_submodel_registry.get_submodel_descriptor_by_id(
server, submodel_id
)
print(got.id_short)
# Prints: Maintenance
page = aas_client_submodel_registry.get_all_submodel_descriptors(
server, limit=10
)
Change and delete it:
got.id_short = "MaintenancePlan"
aas_client_submodel_registry.put_submodel_descriptor_by_id(
server, submodel_id, got
)
aas_client_submodel_registry.delete_submodel_descriptor_by_id(
server, submodel_id
)