mstrio > modeling > schema > attribute > relationship

class mstrio.modeling.schema.attribute.relationship.Relationship(relationship_type, relationship_table, parent, child=None, joint_child=None)

Bases: Dictable

Python representation of Strategy One Attributes Relationship object.

Parameters:
parent

parent in a relationship

child

child in a relationship

joint_child

list of joint children in a relationship

relationship_table

relationship table in a relationship

ralationship_type

type of relationship, one of: one_to_many, one_to_one, many_to_many

enum RelationshipType(value)

Bases: AutoName

Enumeration constants used to specify type of the relationship

Valid values are as follows:

ONE_TO_MANY = RelationshipType.ONE_TO_MANY
ONE_TO_ONE = RelationshipType.ONE_TO_ONE
MANY_TO_MANY = RelationshipType.MANY_TO_MANY
classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)

Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of the objects that should be created.

  • source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

A list of objects of type T.

Return type:

T

classmethod from_dict(source, connection=None, to_snake_case=True, with_missing_value=False)

Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of an object that should be created.

  • source (Dict[str, Any]) – A dictionary from which an object will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

An object of type T.

Return type:

T

to_dict(camel_case=True)

Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.

Parameters:

camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.

Returns:

A dictionary representation of object’s attributes and values.

By default, the dictionary keys are in camel case.

Return type:

dict

enum mstrio.modeling.schema.attribute.relationship.RelationshipType(value)

Bases: AutoName

Enumeration constants used to specify type of the relationship

Valid values are as follows:

ONE_TO_MANY = RelationshipType.ONE_TO_MANY
ONE_TO_ONE = RelationshipType.ONE_TO_ONE
MANY_TO_MANY = RelationshipType.MANY_TO_MANY