# SPDX-FileCopyrightText: 2026 aas-client3.2-python AUTHORS
#
# SPDX-License-Identifier: MIT
"""
Implement the operations of the Asset Administration Shell Registry API.
The module also implements the Async Bulk Asset Administration Shell Registry API.
The status and the result of the bulk operations are in
:py:mod:`aas_client3_2.async_bulk`, since both registries share them.
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.
"""
import datetime
from typing import Optional, Sequence
import aas_core3_2.jsonization as aas_jsonization
import aas_core3_2.types as aas_types
from aas_client3_2 import _bulk
from aas_client3_2 import _json
from aas_client3_2 import _query
from aas_client3_2 import _query_language
from aas_client3_2 import errors
from aas_client3_2 import http
from aas_client3_2 import query_results
def _shell_descriptor_path(aas_identifier: str) -> str:
"""Build the path of the descriptor of the shell with the given identifier."""
return "/shell-descriptors/" + http.encode_base64url(aas_identifier)
def _submodel_descriptor_path(aas_identifier: str, submodel_identifier: str) -> str:
"""Build the path of the descriptor of the submodel through the superpath."""
return (
_shell_descriptor_path(aas_identifier)
+ "/submodel-descriptors/"
+ http.encode_base64url(submodel_identifier)
)
def _build_get_all_asset_administration_shell_descriptors(
base_url: str,
*,
asset_kind: Optional[aas_types.AssetKind] = None,
asset_type: Optional[str] = None,
asset_ids: Optional[Sequence[aas_types.SpecificAssetID]] = None,
created_from: Optional[datetime.datetime] = None,
updated_from: Optional[datetime.datetime] = None,
limit: Optional[int] = None,
cursor: Optional[str] = None,
) -> http.Request:
"""Build the request of ``GetAllAssetAdministrationShellDescriptors``."""
query: _query.Query = []
# NOTE (mristin):
# The values of AssetKind in aas-core3.2 are spelled as in the specification,
# such as ``Instance``.
if asset_kind is not None:
query.append(("assetKind", asset_kind.value))
# NOTE (mristin):
# The asset type is an identifier, which the specification encodes in
# base64url, as the identifiers in the paths.
if asset_type is not None:
query.append(("assetType", http.encode_base64url(asset_type)))
# NOTE (mristin):
# As for the shells, the specification repeats the parameter for every
# specific asset ID, serialized to JSON and encoded in base64url.
if asset_ids is not None:
query.extend(
("assetIds", _query.encode_instance(asset_id)) for asset_id in asset_ids
)
query.extend(_query.time_range(created_from, updated_from))
query.extend(_query.page(limit, cursor))
return _json.build_request(
"GET", http.build_url(base_url, "/shell-descriptors", query)
)
def _parse_get_all_asset_administration_shell_descriptors(
response: http.Response,
) -> aas_types.GetAssetAdministrationShellDescriptorsResult:
"""Parse the response of ``GetAllAssetAdministrationShellDescriptors``."""
errors.raise_for_unexpected_status(response, {200})
return _json.parse(
response,
aas_jsonization.get_asset_administration_shell_descriptors_result_from_jsonable,
)
[docs]
def get_all_asset_administration_shell_descriptors(
server: http.Server,
*,
asset_kind: Optional[aas_types.AssetKind] = None,
asset_type: Optional[str] = None,
asset_ids: Optional[Sequence[aas_types.SpecificAssetID]] = None,
created_from: Optional[datetime.datetime] = None,
updated_from: Optional[datetime.datetime] = None,
limit: Optional[int] = None,
cursor: Optional[str] = None,
) -> aas_types.GetAssetAdministrationShellDescriptorsResult:
"""
List a page of the descriptors of the Asset Administration Shells in the registry.
The filters are combined with "and".
:param server: where to send the request
:param asset_kind: if set, only the descriptors of the assets of this kind
:param asset_type: if set, only the descriptors of the assets of this type
:param asset_ids:
if set, only the descriptors with all these specific asset IDs
:param created_from: if set, only the descriptors created at or after this time
:param updated_from: if set, only the descriptors updated at or after this time
:param limit: maximum number of the descriptors in the page
:param cursor: where to continue the listing from
:returns: a page of the descriptors
:raises: :py:class:`ValueError` before sending anything if a time has no time
zone
:implements GetAllAssetAdministrationShellDescriptors: ``GET /shell-descriptors``
"""
request = _build_get_all_asset_administration_shell_descriptors(
server.base_url,
asset_kind=asset_kind,
asset_type=asset_type,
asset_ids=asset_ids,
created_from=created_from,
updated_from=updated_from,
limit=limit,
cursor=cursor,
)
response = http.send(server.transport, request)
return _parse_get_all_asset_administration_shell_descriptors(response)
def _build_post_asset_administration_shell_descriptor(
base_url: str,
asset_administration_shell_descriptor: aas_types.AssetAdministrationShellDescriptor,
) -> http.Request:
"""Build the request of ``PostAssetAdministrationShellDescriptor``."""
return _json.build_request(
"POST",
http.build_url(base_url, "/shell-descriptors"),
asset_administration_shell_descriptor,
)
def _parse_post_asset_administration_shell_descriptor(
response: http.Response,
) -> aas_types.AssetAdministrationShellDescriptor:
"""Parse the response of ``PostAssetAdministrationShellDescriptor``."""
errors.raise_for_unexpected_status(response, {201})
return _json.parse(
response, aas_jsonization.asset_administration_shell_descriptor_from_jsonable
)
[docs]
def post_asset_administration_shell_descriptor(
server: http.Server,
asset_administration_shell_descriptor: aas_types.AssetAdministrationShellDescriptor,
) -> aas_types.AssetAdministrationShellDescriptor:
"""
Register an Asset Administration Shell with a new descriptor.
:param server: where to send the request
:param asset_administration_shell_descriptor: the descriptor to be created
:returns: the created descriptor, as stored by the server
:implements PostAssetAdministrationShellDescriptor: ``POST /shell-descriptors``
"""
request = _build_post_asset_administration_shell_descriptor(
server.base_url, asset_administration_shell_descriptor
)
response = http.send(server.transport, request)
return _parse_post_asset_administration_shell_descriptor(response)
def _build_get_asset_administration_shell_descriptor_by_id(
base_url: str, aas_identifier: str
) -> http.Request:
"""Build the request of ``GetAssetAdministrationShellDescriptorById``."""
return _json.build_request(
"GET", http.build_url(base_url, _shell_descriptor_path(aas_identifier))
)
def _parse_get_asset_administration_shell_descriptor_by_id(
response: http.Response,
) -> aas_types.AssetAdministrationShellDescriptor:
"""Parse the response of ``GetAssetAdministrationShellDescriptorById``."""
errors.raise_for_unexpected_status(response, {200})
return _json.parse(
response, aas_jsonization.asset_administration_shell_descriptor_from_jsonable
)
[docs]
def get_asset_administration_shell_descriptor_by_id(
server: http.Server, aas_identifier: str
) -> aas_types.AssetAdministrationShellDescriptor:
"""
Get the descriptor of the Asset Administration Shell with the given identifier.
:param server: where to send the request
:param aas_identifier: identifier of the Asset Administration Shell
:returns: the descriptor
:implements GetAssetAdministrationShellDescriptorById: ``GET /shell-descriptors/{aasIdentifier}``
"""
request = _build_get_asset_administration_shell_descriptor_by_id(
server.base_url, aas_identifier
)
response = http.send(server.transport, request)
return _parse_get_asset_administration_shell_descriptor_by_id(response)
def _build_put_asset_administration_shell_descriptor_by_id(
base_url: str,
aas_identifier: str,
asset_administration_shell_descriptor: aas_types.AssetAdministrationShellDescriptor,
) -> http.Request:
"""Build the request of ``PutAssetAdministrationShellDescriptorById``."""
return _json.build_request(
"PUT",
http.build_url(base_url, _shell_descriptor_path(aas_identifier)),
asset_administration_shell_descriptor,
)
def _parse_put_asset_administration_shell_descriptor_by_id(
response: http.Response,
) -> None:
"""
Parse the response of ``PutAssetAdministrationShellDescriptorById``.
The server responds with 201 and the descriptor if it created the descriptor,
or with 204 if it replaced an existing one. We do not parse the descriptor,
since it is the one which the users sent.
"""
errors.raise_for_unexpected_status(response, {201, 204})
[docs]
def put_asset_administration_shell_descriptor_by_id(
server: http.Server,
aas_identifier: str,
asset_administration_shell_descriptor: aas_types.AssetAdministrationShellDescriptor,
) -> None:
"""
Create or replace the descriptor of the Asset Administration Shell.
:param server: where to send the request
:param aas_identifier: identifier of the Asset Administration Shell
:param asset_administration_shell_descriptor: the descriptor to be stored
:implements PutAssetAdministrationShellDescriptorById: ``PUT /shell-descriptors/{aasIdentifier}``
"""
request = _build_put_asset_administration_shell_descriptor_by_id(
server.base_url, aas_identifier, asset_administration_shell_descriptor
)
response = http.send(server.transport, request)
_parse_put_asset_administration_shell_descriptor_by_id(response)
def _build_delete_asset_administration_shell_descriptor_by_id(
base_url: str, aas_identifier: str
) -> http.Request:
"""Build the request of ``DeleteAssetAdministrationShellDescriptorById``."""
return _json.build_request(
"DELETE", http.build_url(base_url, _shell_descriptor_path(aas_identifier))
)
def _parse_delete_asset_administration_shell_descriptor_by_id(
response: http.Response,
) -> None:
"""Parse the response of ``DeleteAssetAdministrationShellDescriptorById``."""
errors.raise_for_unexpected_status(response, {204})
[docs]
def delete_asset_administration_shell_descriptor_by_id(
server: http.Server, aas_identifier: str
) -> None:
"""
De-register the Asset Administration Shell by deleting its descriptor.
:param server: where to send the request
:param aas_identifier: identifier of the Asset Administration Shell
:implements DeleteAssetAdministrationShellDescriptorById: ``DELETE /shell-descriptors/{aasIdentifier}``
"""
request = _build_delete_asset_administration_shell_descriptor_by_id(
server.base_url, aas_identifier
)
response = http.send(server.transport, request)
_parse_delete_asset_administration_shell_descriptor_by_id(response)
def _build_get_all_submodel_descriptors_through_superpath(
base_url: str,
aas_identifier: str,
*,
limit: Optional[int] = None,
cursor: Optional[str] = None,
) -> http.Request:
"""Build the request of ``GetAllSubmodelDescriptorsThroughSuperpath``."""
return _json.build_request(
"GET",
http.build_url(
base_url,
_shell_descriptor_path(aas_identifier) + "/submodel-descriptors",
_query.page(limit, cursor),
),
)
def _parse_get_all_submodel_descriptors_through_superpath(
response: http.Response,
) -> aas_types.GetSubmodelDescriptorsResult:
"""Parse the response of ``GetAllSubmodelDescriptorsThroughSuperpath``."""
errors.raise_for_unexpected_status(response, {200})
return _json.parse(
response, aas_jsonization.get_submodel_descriptors_result_from_jsonable
)
[docs]
def get_all_submodel_descriptors_through_superpath(
server: http.Server,
aas_identifier: str,
*,
limit: Optional[int] = None,
cursor: Optional[str] = None,
) -> aas_types.GetSubmodelDescriptorsResult:
"""
List a page of the submodel descriptors in the descriptor of the shell.
:param server: where to send the request
:param aas_identifier: identifier of the Asset Administration Shell
:param limit: maximum number of the submodel descriptors in the page
:param cursor: where to continue the listing from
:returns: a page of the submodel descriptors
:implements GetAllSubmodelDescriptorsThroughSuperpath: ``GET /shell-descriptors/{aasIdentifier}/submodel-descriptors``
"""
request = _build_get_all_submodel_descriptors_through_superpath(
server.base_url, aas_identifier, limit=limit, cursor=cursor
)
response = http.send(server.transport, request)
return _parse_get_all_submodel_descriptors_through_superpath(response)
def _build_post_submodel_descriptor_through_superpath(
base_url: str,
aas_identifier: str,
submodel_descriptor: aas_types.SubmodelDescriptor,
) -> http.Request:
"""Build the request of ``PostSubmodelDescriptor-ThroughSuperpath``."""
return _json.build_request(
"POST",
http.build_url(
base_url, _shell_descriptor_path(aas_identifier) + "/submodel-descriptors"
),
submodel_descriptor,
)
def _parse_post_submodel_descriptor_through_superpath(
response: http.Response,
) -> aas_types.SubmodelDescriptor:
"""Parse the response of ``PostSubmodelDescriptor-ThroughSuperpath``."""
errors.raise_for_unexpected_status(response, {201})
return _json.parse(response, aas_jsonization.submodel_descriptor_from_jsonable)
[docs]
def post_submodel_descriptor_through_superpath(
server: http.Server,
aas_identifier: str,
submodel_descriptor: aas_types.SubmodelDescriptor,
) -> aas_types.SubmodelDescriptor:
"""
Add a new submodel descriptor to the descriptor of the shell.
:param server: where to send the request
:param aas_identifier: identifier of the Asset Administration Shell
:param submodel_descriptor: the submodel descriptor to be created
:returns: the created submodel descriptor, as stored by the server
:implements PostSubmodelDescriptor-ThroughSuperpath: ``POST /shell-descriptors/{aasIdentifier}/submodel-descriptors``
"""
request = _build_post_submodel_descriptor_through_superpath(
server.base_url, aas_identifier, submodel_descriptor
)
response = http.send(server.transport, request)
return _parse_post_submodel_descriptor_through_superpath(response)
def _build_get_submodel_descriptor_by_id_through_superpath(
base_url: str, aas_identifier: str, submodel_identifier: str
) -> http.Request:
"""Build the request of ``GetSubmodelDescriptorByIdThroughSuperpath``."""
return _json.build_request(
"GET",
http.build_url(
base_url, _submodel_descriptor_path(aas_identifier, submodel_identifier)
),
)
def _parse_get_submodel_descriptor_by_id_through_superpath(
response: http.Response,
) -> aas_types.SubmodelDescriptor:
"""Parse the response of ``GetSubmodelDescriptorByIdThroughSuperpath``."""
errors.raise_for_unexpected_status(response, {200})
return _json.parse(response, aas_jsonization.submodel_descriptor_from_jsonable)
[docs]
def get_submodel_descriptor_by_id_through_superpath(
server: http.Server, aas_identifier: str, submodel_identifier: str
) -> aas_types.SubmodelDescriptor:
"""
Get the submodel descriptor with the given identifier from the descriptor of the
shell.
:param server: where to send the request
:param aas_identifier: identifier of the Asset Administration Shell
:param submodel_identifier: identifier of the submodel
:returns: the submodel descriptor
:implements GetSubmodelDescriptorByIdThroughSuperpath: ``GET /shell-descriptors/{aasIdentifier}/submodel-descriptors/{submodelIdentifier}``
"""
request = _build_get_submodel_descriptor_by_id_through_superpath(
server.base_url, aas_identifier, submodel_identifier
)
response = http.send(server.transport, request)
return _parse_get_submodel_descriptor_by_id_through_superpath(response)
def _build_put_submodel_descriptor_by_id_through_superpath(
base_url: str,
aas_identifier: str,
submodel_identifier: str,
submodel_descriptor: aas_types.SubmodelDescriptor,
) -> http.Request:
"""Build the request of ``PutSubmodelDescriptorByIdThroughSuperpath``."""
return _json.build_request(
"PUT",
http.build_url(
base_url, _submodel_descriptor_path(aas_identifier, submodel_identifier)
),
submodel_descriptor,
)
def _parse_put_submodel_descriptor_by_id_through_superpath(
response: http.Response,
) -> None:
"""
Parse the response of ``PutSubmodelDescriptorByIdThroughSuperpath``.
As for the shell descriptors, we do not parse the created submodel descriptor.
"""
errors.raise_for_unexpected_status(response, {201, 204})
[docs]
def put_submodel_descriptor_by_id_through_superpath(
server: http.Server,
aas_identifier: str,
submodel_identifier: str,
submodel_descriptor: aas_types.SubmodelDescriptor,
) -> None:
"""
Create or replace the submodel descriptor in the descriptor of the shell.
:param server: where to send the request
:param aas_identifier: identifier of the Asset Administration Shell
:param submodel_identifier: identifier of the submodel
:param submodel_descriptor: the submodel descriptor to be stored
:implements PutSubmodelDescriptorByIdThroughSuperpath: ``PUT /shell-descriptors/{aasIdentifier}/submodel-descriptors/{submodelIdentifier}``
"""
request = _build_put_submodel_descriptor_by_id_through_superpath(
server.base_url, aas_identifier, submodel_identifier, submodel_descriptor
)
response = http.send(server.transport, request)
_parse_put_submodel_descriptor_by_id_through_superpath(response)
def _build_delete_submodel_descriptor_by_id_through_superpath(
base_url: str, aas_identifier: str, submodel_identifier: str
) -> http.Request:
"""Build the request of ``DeleteSubmodelDescriptorByIdThroughSuperpath``."""
return _json.build_request(
"DELETE",
http.build_url(
base_url, _submodel_descriptor_path(aas_identifier, submodel_identifier)
),
)
def _parse_delete_submodel_descriptor_by_id_through_superpath(
response: http.Response,
) -> None:
"""Parse the response of ``DeleteSubmodelDescriptorByIdThroughSuperpath``."""
errors.raise_for_unexpected_status(response, {204})
[docs]
def delete_submodel_descriptor_by_id_through_superpath(
server: http.Server, aas_identifier: str, submodel_identifier: str
) -> None:
"""
Delete the submodel descriptor from the descriptor of the shell.
:param server: where to send the request
:param aas_identifier: identifier of the Asset Administration Shell
:param submodel_identifier: identifier of the submodel
:implements DeleteSubmodelDescriptorByIdThroughSuperpath: ``DELETE /shell-descriptors/{aasIdentifier}/submodel-descriptors/{submodelIdentifier}``
"""
request = _build_delete_submodel_descriptor_by_id_through_superpath(
server.base_url, aas_identifier, submodel_identifier
)
response = http.send(server.transport, request)
_parse_delete_submodel_descriptor_by_id_through_superpath(response)
def _build_query_asset_administration_shell_descriptors(
base_url: str,
query: aas_types.Query,
*,
limit: Optional[int] = None,
cursor: Optional[str] = None,
) -> http.Request:
"""
Build the request of ``QueryAssetAdministrationShellDescriptors`` for the
descriptors.
"""
_query_language.check_selects_objects(
query, "query_asset_administration_shell_descriptor_ids"
)
return _query_language.build_request(
base_url, "/query/shell-descriptors", query, limit, cursor
)
def _parse_query_asset_administration_shell_descriptors(
response: http.Response,
) -> aas_types.GetAssetAdministrationShellDescriptorsResult:
"""
Parse the response of ``QueryAssetAdministrationShellDescriptors`` with the
descriptors.
"""
errors.raise_for_unexpected_status(response, {200})
return _json.parse(
response,
aas_jsonization.get_asset_administration_shell_descriptors_result_from_jsonable,
_query_language.make_page_adapter(
"AssetAdministrationShellDescriptor", paging_metadata_required=True
),
)
[docs]
def query_asset_administration_shell_descriptors(
server: http.Server,
query: aas_types.Query,
*,
limit: Optional[int] = None,
cursor: Optional[str] = None,
) -> aas_types.GetAssetAdministrationShellDescriptorsResult:
"""
List a page of the descriptors of the shells which match :paramref:`query`.
The :paramref:`query` must not select the identifiers (``"$select": "id"``);
use :py:func:`query_asset_administration_shell_descriptor_ids` for that. Both
functions implement the same operation, but give different results.
:param server: where to send the request
:param query: query in the AAS Query Language
:param limit: maximum number of the descriptors in the page
:param cursor: where to continue the listing from
:returns: a page of the matching descriptors
:raises: :py:class:`ValueError` before sending anything if :paramref:`query`
selects the identifiers, or can not be serialized to JSON (*e.g.*,
a number literal is not finite)
:implements QueryAssetAdministrationShellDescriptors: ``POST /query/shell-descriptors``
"""
request = _build_query_asset_administration_shell_descriptors(
server.base_url, query, limit=limit, cursor=cursor
)
response = http.send(server.transport, request)
return _parse_query_asset_administration_shell_descriptors(response)
def _build_query_asset_administration_shell_descriptor_ids(
base_url: str,
query: aas_types.Query,
*,
limit: Optional[int] = None,
cursor: Optional[str] = None,
) -> http.Request:
"""
Build the request of ``QueryAssetAdministrationShellDescriptors`` for the
identifiers.
"""
_query_language.check_selects_ids(
query, "query_asset_administration_shell_descriptors"
)
return _query_language.build_request(
base_url, "/query/shell-descriptors", query, limit, cursor
)
def _parse_query_asset_administration_shell_descriptor_ids(
response: http.Response,
) -> query_results.IdsResult:
"""
Parse the response of ``QueryAssetAdministrationShellDescriptors`` with the
identifiers.
"""
errors.raise_for_unexpected_status(response, {200})
return _json.parse(
response,
_json.ids_result_from_jsonable,
_query_language.make_page_adapter(
_query_language.IDS_RESULT_TYPE, paging_metadata_required=True
),
)
[docs]
def query_asset_administration_shell_descriptor_ids(
server: http.Server,
query: aas_types.Query,
*,
limit: Optional[int] = None,
cursor: Optional[str] = None,
) -> query_results.IdsResult:
"""
List a page of the identifiers of the shells whose descriptors match
:paramref:`query`.
The :paramref:`query` must select the identifiers (``"$select": "id"``); use
:py:func:`query_asset_administration_shell_descriptors` for the descriptors.
Both functions implement the same operation, but give different results.
:param server: where to send the request
:param query: query in the AAS Query Language
:param limit: maximum number of the identifiers in the page
:param cursor: where to continue the listing from
:returns: a page of the identifiers of the matching shells
:raises: :py:class:`ValueError` before sending anything if :paramref:`query`
does not select the identifiers, or can not be serialized to JSON (*e.g.*,
a number literal is not finite)
:implements QueryAssetAdministrationShellDescriptors: ``POST /query/shell-descriptors``
"""
request = _build_query_asset_administration_shell_descriptor_ids(
server.base_url, query, limit=limit, cursor=cursor
)
response = http.send(server.transport, request)
return _parse_query_asset_administration_shell_descriptor_ids(response)
def _build_bulk_post_asset_administration_shell_descriptor(
base_url: str,
asset_administration_shell_descriptors: Sequence[
aas_types.AssetAdministrationShellDescriptor
],
) -> http.Request:
"""Build the request of ``BulkPostAssetAdministrationShellDescriptor``."""
return _bulk.build_descriptors_request(
"POST",
http.build_url(base_url, "/bulk/shell-descriptors"),
asset_administration_shell_descriptors,
)
def _parse_bulk_post_asset_administration_shell_descriptor(
response: http.Response,
) -> aas_types.OperationHandle:
"""Parse the response of ``BulkPostAssetAdministrationShellDescriptor``."""
return _bulk.parse_accepted(response)
[docs]
def bulk_post_asset_administration_shell_descriptor(
server: http.Server,
asset_administration_shell_descriptors: Sequence[
aas_types.AssetAdministrationShellDescriptor
],
) -> aas_types.OperationHandle:
"""
Start registering the Asset Administration Shells with new descriptors at once.
The server processes the bulk request asynchronously. Follow its progress with
:py:func:`aas_client3_2.async_bulk.bulk_get_async_status`, and fetch its result
with :py:func:`aas_client3_2.async_bulk.bulk_get_async_result`. The server may
accept a bulk request which it later finds invalid; only the result tells.
:param server: where to send the request
:param asset_administration_shell_descriptors: the descriptors to be created
:returns: the handle of the bulk operation
:raises: :py:class:`ValueError` before sending anything if
:paramref:`asset_administration_shell_descriptors` is empty
:implements BulkPostAssetAdministrationShellDescriptor: ``POST /bulk/shell-descriptors``
"""
request = _build_bulk_post_asset_administration_shell_descriptor(
server.base_url, asset_administration_shell_descriptors
)
response = http.send(server.transport, request)
return _parse_bulk_post_asset_administration_shell_descriptor(response)
def _build_bulk_put_asset_administration_shell_descriptor_by_id(
base_url: str,
asset_administration_shell_descriptors: Sequence[
aas_types.AssetAdministrationShellDescriptor
],
) -> http.Request:
"""Build the request of ``BulkPutAssetAdministrationShellDescriptorById``."""
return _bulk.build_descriptors_request(
"PUT",
http.build_url(base_url, "/bulk/shell-descriptors"),
asset_administration_shell_descriptors,
)
def _parse_bulk_put_asset_administration_shell_descriptor_by_id(
response: http.Response,
) -> aas_types.OperationHandle:
"""Parse the response of ``BulkPutAssetAdministrationShellDescriptorById``."""
return _bulk.parse_accepted(response)
[docs]
def bulk_put_asset_administration_shell_descriptor_by_id(
server: http.Server,
asset_administration_shell_descriptors: Sequence[
aas_types.AssetAdministrationShellDescriptor
],
) -> aas_types.OperationHandle:
"""
Start creating or replacing the descriptors of the shells at once.
The descriptors are matched to the stored ones by their ``id``. See
:py:func:`bulk_post_asset_administration_shell_descriptor` for how to follow
the bulk operation.
:param server: where to send the request
:param asset_administration_shell_descriptors: the descriptors to be stored
:returns: the handle of the bulk operation
:raises: :py:class:`ValueError` before sending anything if
:paramref:`asset_administration_shell_descriptors` is empty
:implements BulkPutAssetAdministrationShellDescriptorById: ``PUT /bulk/shell-descriptors``
"""
request = _build_bulk_put_asset_administration_shell_descriptor_by_id(
server.base_url, asset_administration_shell_descriptors
)
response = http.send(server.transport, request)
return _parse_bulk_put_asset_administration_shell_descriptor_by_id(response)
def _build_bulk_delete_asset_administration_shell_descriptor_by_id(
base_url: str, aas_identifiers: Sequence[str]
) -> http.Request:
"""Build the request of ``BulkDeleteAssetAdministrationShellDescriptorById``."""
return _bulk.build_identifiers_request(
http.build_url(base_url, "/bulk/shell-descriptors"), aas_identifiers
)
def _parse_bulk_delete_asset_administration_shell_descriptor_by_id(
response: http.Response,
) -> aas_types.OperationHandle:
"""Parse the response of ``BulkDeleteAssetAdministrationShellDescriptorById``."""
return _bulk.parse_accepted(response)
[docs]
def bulk_delete_asset_administration_shell_descriptor_by_id(
server: http.Server, aas_identifiers: Sequence[str]
) -> aas_types.OperationHandle:
"""
Start de-registering the Asset Administration Shells at once.
See :py:func:`bulk_post_asset_administration_shell_descriptor` for how to follow
the bulk operation.
:param server: where to send the request
:param aas_identifiers: identifiers of the shells whose descriptors are deleted
:returns: the handle of the bulk operation
:raises: :py:class:`ValueError` before sending anything if
:paramref:`aas_identifiers` is empty
:implements BulkDeleteAssetAdministrationShellDescriptorById: ``DELETE /bulk/shell-descriptors``
"""
request = _build_bulk_delete_asset_administration_shell_descriptor_by_id(
server.base_url, aas_identifiers
)
response = http.send(server.transport, request)
return _parse_bulk_delete_asset_administration_shell_descriptor_by_id(response)