aas_client3_2.async_bulk

Implement the operations of the Async Bulk Status API and the Async Bulk Result API.

Both registries serve these endpoints for their bulk operations (see aas_client3_2.aas_registry and aas_client3_2.submodel_registry), so the functions take the server of the registry which accepted the bulk request.

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.

class aas_client3_2.async_bulk.BulkStatus(running: BaseOperationResult | None, retry_after: int | None = None)[source]

Represent the status of a bulk operation.

running: BaseOperationResult | None

Status as given by the server while the bulk operation runs, or None once it is finished

retry_after: int | None = None

Seconds to wait before asking again, if the server says so while the bulk operation runs

property finished: bool

Tell whether the bulk operation is finished, so its result can be fetched.

__dataclass_fields__ = {'retry_after': Field(name='retry_after',type=typing.Optional[int],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'running': Field(name='running',type=typing.Optional[aas_core3_2.types.BaseOperationResult],default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=True,match_args=True,kw_only=False,slots=False,weakref_slot=False)
__delattr__(name)

Implement delattr(self, name).

__eq__(other)

Return self==value.

__hash__()

Return hash(self).

__init__(running: BaseOperationResult | None, retry_after: int | None = None) → None
__match_args__ = ('running', 'retry_after')
__repr__()

Return repr(self).

__setattr__(name, value)

Implement setattr(self, name, value).

aas_client3_2.async_bulk.bulk_get_async_status(server: Server, handle_id: str) → BulkStatus[source]

Get the status of the bulk operation with the given handle.

While the bulk operation runs, the server gives its status, and possibly how long to wait before asking again. Once it is finished, the server redirects to the result, and the status is BulkStatus.finished; fetch the result with bulk_get_async_result() to learn whether it succeeded.

The client does not follow the redirect, and asks the transport not to follow it either, since the server may delete the result once it has been fetched.

import time

handle = aas_registry.bulk_post_asset_administration_shell_descriptor(
    server, descriptors
)

while True:
    status = async_bulk.bulk_get_async_status(server, handle.handle_id)
    if status.finished:
        break
    time.sleep(status.retry_after if status.retry_after is not None else 1)

# Raises errors.BadRequest with the messages if the bulk operation failed.
async_bulk.bulk_get_async_result(server, handle.handle_id)
Parameters:
  • server – the registry which accepted the bulk request

  • handle_id – handle as given by the bulk operation

Returns:

the status of the bulk operation

Raises:

NotFound if there is no such bulk operation; UnexpectedResponse if the transport followed the redirect anyway

Implements:
  • BulkGetAsyncStatus – GET /bulk/status/{handleId}

aas_client3_2.async_bulk.bulk_get_async_result(server: Server, handle_id: str) → None[source]

Get the result of the finished bulk operation with the given handle.

A bulk operation is atomic: either all of its items are processed, or none of them. Hence a successful result has no content, and this function returns nothing. A failed bulk operation raises BadRequest, whose result gives at least one message for every failed item, as far as the server got before it stopped.

The server may delete the result once it has been fetched, or after a while, and then gives NotFound.

Parameters:
  • server – the registry which accepted the bulk request

  • handle_id – handle as given by the bulk operation

Raises:

BadRequest if the bulk operation failed; NotFound if there is no such result (anymore)

Implements:
  • BulkGetAsyncResult – GET /bulk/result/{handleId}