Model Export Format

  1. top level is a dict with one entry for each instance in the model

  2. the key in this dict is the object reference handle

  3. the value is the serialized instance

  4. the serialized instance is a dict with three fields: type, attributes and relation.

  5. type is the fully qualified name of the type

  6. attributes is a dict, with as keys the names of the attributes and as values a dict with one entry.

  7. An attribute can have one or more of tree keys: unknows, nones and values. The “values” entry has as value a list with the attribute values.

    If any of the values is Unknown or None, it is removed from the values array and the index at which it was removed is recorded in respective the unknowns or nones value

  8. relations is like attributes, but the list of values contains the reference handles to which this relations points

Basic structure as pseudo jinja template

{
{% for instance in instances %}
 '{{instance.handle}}':{
        "type":"{{instance.type.fqn}}",
        "attributes":[
                {% for attribute in instance.attributes %}
                "{{attribute.name}}": [ {{ attribute.values | join(",") }} ]
                {% endfor %}
        ]
        "relations" : [
                {% for relation in instance.relations %}
                "{{relation.name}}": [
                        {% for value in relation.values %}
                                {{value.handle}}
                        {% endfor %}
                ]
                {% endfor %}
        ]

{% endif %}
}

Type Export Format

class inmanta.model.Attribute(mytype: str, nullable: bool, multi: bool, comment: str, location: Location)[source]

Attribute defined on an entity

Parameters:
  • mytype (str) – fully qualified name of the type of this attribute

  • nullable (bool) – can this attribute be null

  • multi (bool) – is this attribute a list

  • comment (str) – docstring for this attribute

  • location (inmanta.model.Location) – source location where this attribute is defined

to_dict() dict[str, Any][source]

Convert to serialized form:

{
    "type": self.type,
    "multi": self.multi,
    "nullable": self.nullable,
    "comment": self.comment,
    "location": self.location.to_dict()
}
class inmanta.model.DirectValue(value: Value)[source]

A primitive value, directly represented in the serialized form.

Parameters:

value – the value itself, as string or number

to_dict() dict[str, Any][source]

Convert to serialized form:

{"value": self.value}
class inmanta.model.Entity(parents: list[str], attributes: dict[str, Attribute], relations: dict[str, Relation], location: Location)[source]

An entity type

Parameters:
  • parents (List[str]) – parent types

  • Attribute] (Dict[str,) – all attributes declared on this entity directly, by name

  • Relation] (Dict[str,) – all relations declared on this entity directly, by name

  • location (inmanta.model.Location) – source location this entity was defined at

to_dict() dict[str, Any][source]

Convert to serialized form:

{
"parents": self.parents,
"attributes": {n: a.to_dict() for n, a in self.attributes.items()},
"relations": {n: r.to_dict() for n, r in self.relations.items()},
"location": self.location.to_dict(),
}
class inmanta.model.Location(file: str, lnr: int)[source]

Position in the source

Parameters:
  • file (str) – source file name

  • lnr (int) – line in the source file

to_dict() dict[str, Any][source]

Convert to serialized form:

{
    "file": self.file,
    "lnr": self.lnr
}
class inmanta.model.ReferenceValue(reference)[source]

A reference to an instance of an entity.

Parameters:

reference (str) – the handle for the entity this value refers to

to_dict() dict[str, Any][source]

Convert to serialized form:

{"reference": self.reference}
class inmanta.model.Relation(mytype: str, multi: tuple[int, int | None], reverse: str, comment: str, location: Location, source_annotations: list[Value], target_annotations: list[Value])[source]

A relation between two entities.

Parameters:
  • mytype (str) – the type this relation refers to

  • multi (Tuple[int, int]) – the multiplicity of this relation in the form (lower,upper), -1 for unbounded

  • reverse (str) – the fully qualified name of the inverse relation

  • location (inmanta.model.Location) – source location this relation was defined at

  • source_annotations (List[Value]) – annotations on this relation on the source side

  • target_annotations (List[Value]) – annotations on this relation on the target side

to_dict() dict[str, Any][source]

Convert to serialized form:

{
 "type": self.type,
 "multi": [self.multi[0], self.multi[1]],
 "reverse": self.reverse,
 "comment": self.comment,
 "location": self.location.to_dict(),
 "source_annotations": [x.to_dict() for x in self.source_annotations],
 "target_annotations": [x.to_dict() for x in self.target_annotations]
 }
class inmanta.model.Value[source]

A value reference from a type either DirectValue or ReferenceValue