JSON Models

pydantic model pyil2.models.json.AllowedReadersDetailsModel

Bases: AllowedReadersModel

Allowed readers details model.

field contextId: str [Required] (alias 'contextid')

Allowed readers list name.

field readers: List[ReaderKeyModel] [Optional]

List of reader keys.

field record_reference: str | None = None (alias 'recordReference')

A record reference in the form chainId@recordSerial

pydantic model pyil2.models.json.AllowedReadersModel

Bases: BaseCamelModel

List of allow readers model.

field contextId: str [Required] (alias 'contextid')

Allowed readers list name.

field readers: List[ReaderKeyModel] [Optional]

List of reader keys.

pydantic model pyil2.models.json.EncryptedTextModel

Bases: BaseCamelModel

JSON Documents encrypted text.

field cipher: CipherAlgorithms [Required]

Cipher algorithm used to cipher the text.

field cipher_text: str | None = '' (alias 'cipherText')

Encrypted text.

field reading_keys: List[ReadingKeyModel] [Required] (alias 'readingKeys')

List of keys able to read this encrypted text.

decode(certificate: PKCS12Certificate) Dict[str, Any]

Decodes the encrypted JSON text to a dictionary using a given certificate.

Parameters:

certificate (utils.certificate.PKCS12Certificate) – PKCS12 certificate.

Returns:

Any}: Decoded JSON.

Return type:

{str

Raises:

ValueError – If there is no encrypted text or the certificate is not in the reading keys.

pydantic model pyil2.models.json.JsonDocumentModel

Bases: BaseRecordModel

Record to store JSON documents.

field application_id: int = 0 (alias 'applicationId')

Application id this record is associated with.

field chain_id: str [Required] (alias 'chainId')

Chain id that owns this record.

field created_at: datetime.datetime [Required] (alias 'createdAt')

Time of record creation.

field encrypted_json: EncryptedTextModel | None = None (alias 'encryptedJson')

JSON Documents encrypted text.

field json_text: str | None = None (alias 'jsonText')

JSON document as string.

field network: str [Required]

Network name this chain is part.

field payload_tag_id: int = 0 (alias 'payloadTagId')

The payload’s TagId.

field reference: str [Required]

Universal reference of this record.

field serial: int = 0

Block serial number. For the first record this value is zero (0).

field type: RecordType = RecordType.ROOT

Block type. Most records are of the type ‘Data’.

field version: int = 0

Version of this record structure.

pydantic model pyil2.models.json.ReaderKeyModel

Bases: BaseCamelModel

Reader key model.

field name: str [Required]

Name of the reader key

field public_key: str [Required] (alias 'publicKey')

IL2 text representation of a public key to encrypt the content for.

pydantic model pyil2.models.json.ReadingKeyModel

Bases: BaseCamelModel

Keys able to read an encrypted JSON Document record.

field encrypted_iv: str | None = None (alias 'encryptedIV')

Encrypted AES256 IV.

field encrypted_key: str | None = None (alias 'encryptedKey')

Encrypted AES256 key.

field public_key_hash: str | None = None (alias 'publicKeyHash')

Public key hash in IL2 text representation.

field reader_id: str | None = None (alias 'readerId')

Id of the key.

check_certificate(certificate: PKCS12Certificate) bool

Checks if a PKCS12 certificate corresponds to this reading key.

Parameters:

certificate (utils.certificate.PKCS12Certificate) – PKCS12 certificate.

Returns:

Returns True if the certificate corresponds to this reading key.

Return type:

bool

Raises:

ValueError – If the certificate has no private key or are a Non-RSA certificate.