aas_client3_2.serialization

Implement the operation of the Serialization API.

The public function implements exactly one operation of the specification. The private functions _build_* give the request 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.serialization.SerializationFormat(*values)[source]

Give the formats of a serialization, as the media types of the header Accept.

Part 2 lists JSON and XML as the values of SerializationFormat, with XML as the default. The OpenAPI gives the AASX package as a third format, with its own spelling of the media type, which the client follows, although the table of the HTTP API and the AASX File Server API spell it differently.

JSON = 'application/json'

Environment serialized to JSON

XML = 'application/xml'

Environment serialized to XML

AASX = 'application/aas+zip'

AASX package, as the OpenAPI spells its media type

aas_client3_2.serialization.generate_serialization_by_ids(server: Server, *, aas_ids: Sequence[str] | None = None, submodel_ids: Sequence[str] | None = None, include_concept_descriptions: bool | None = None, serialization_format: SerializationFormat = SerializationFormat.XML) → ContextManager[Download][source]

Download the serialization of the given shells and submodels as an environment.

The serialization can be large, so it is always streamed, whatever its format; use the result as a context manager. For example, to parse the JSON with aas-core3.2:

import json

import aas_core3_2.jsonization as aas_jsonization

with serialization.generate_serialization_by_ids(
    server,
    aas_ids=["urn:example:aas:1"],
    serialization_format=serialization.SerializationFormat.JSON,
) as download:
    environment = aas_jsonization.environment_from_jsonable(
        json.loads(b"".join(download.iter_chunks()))
    )

The client asks for the format with the header Accept, and always sends it, so that the result does not depend on a default of the server.

Parameters:
  • server – where to send the request

  • aas_ids – if set, the identifiers of the shells to be included

  • submodel_ids – if set, the identifiers of the submodels to be included

  • include_concept_descriptions – if set, whether to include the concept descriptions which the submodels refer to; the default of the OpenAPI is to include them

  • serialization_format – the format of the serialization

Returns:

a context manager which gives the download

Implements:
  • GenerateSerializationByIds – GET /serialization