mstrio > modeling > schema > schema_management¶
- class mstrio.modeling.schema.schema_management.SchemaLockStatus(lock_type, date_created=None, comment=None, machine_name=None, owner_name=None, owner_id=None)¶
Bases:
Dictable
An object that contains all of the information about the lock status of the schema. If the schema is not locked then properties of the lock are not provided.
- Parameters:
lock_type (SchemaLockType | str) –
date_created (str | None) –
comment (str | None) –
machine_name (str | None) –
owner_name (str | None) –
owner_id (str | None) –
- 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.schema_management.SchemaLockType(value)¶
Bases:
AutoName
Enumeration constants used to specify a type of lock that can be placed on schema. Type UNLOCKED is used only when displaying status.
Valid values are as follows:
- ABSOLUTE_INDIVIDUAL = SchemaLockType.ABSOLUTE_INDIVIDUAL¶
- EXCLUSIVE_CONSTITUENT = SchemaLockType.EXCLUSIVE_CONSTITUENT¶
- ABSOLUTE_CONSTITUENT = SchemaLockType.ABSOLUTE_CONSTITUENT¶
- UNLOCKED = SchemaLockType.UNLOCKED¶
- class mstrio.modeling.schema.schema_management.SchemaManagement(connection, project_id=None, project_name=None)¶
Bases:
object
Representation of schema management object.
- Parameters:
connection (Connection) –
project_id (str | None) –
project_name (str | None) –
- connection¶
instance of Connection object
- lock_type¶
type of lock which is placed on the schema
- project_id¶
ID of project on which schema is managed
- project_name¶
Project name
- tasks¶
array with objects of type SchemaTask. It represents tasks which were created for the current object of SchemaManagement. They are created when schema is reloaded asynchronously.
- get_lock_status()¶
Get the lock status of the schema.
- Returns:
Lock status of the schema as SchemaLockStatus object.
- Return type:
- get_task(task_index)¶
Get all details of the task which is stored at a given task_index in a list from property tasks.
- Parameters:
task_index (int) – Index of the task in the list stored in property tasks.
- Returns:
SchemaTask object with all details about the task from the given index. When index is not proper then None is returned and warning with explanation message is shown.
- Return type:
- lock(lock_type)¶
Lock the schema. After successfully locking the schema its lock_type property is updated.
- Parameters:
lock_type (str | SchemaLockType) – (string or object): Type of lock which will be placed on the schema.
- Returns:
True when schema was successfully locked or schema has already been locked. False when procedure of locking schema failed.
- Raises:
TypeError –
a SchemaLockType. –
ValueError –
a proper value of enum SchemaLockType. –
- Return type:
bool
- reload(update_types=None, respond_async=True)¶
Reload (update) the schema. This operation can be performed asynchronously. In that case the task is created and it is saved in property tasks to help tracking its status.
- Parameters:
update_types (optional, list or object or string) –
Field with update type(s). Values in this field can be of type string or SchemaUpdateType or be a list of those types. This field can contain empty, any of the following options, or all of them: - table_key: Use this option if you changed the key structure
of a table.
entry_level: Use this option if you changed the level at which a fact is stored.
logical_size: Use this option to recalculate logical table sizes and override any modifications you made to logical table sizes.
clear_element_cache: Use this option to clear up the attribute element cache saved on the Intelligence Server.
respond_async (optional, bool) – When True reload is performed asynchronously. Otherwise it is performed synchronously. Default value is True.
- Returns:
When respond_async is set to True then SchemaTask object with all details about the task of reloading schema is returned. Otherwise None is returned.
- Raises:
TypeError –
a SchemaUpdateType. –
ValueError –
which is not a proper value of enum SchemaUpdateType. –
- Return type:
SchemaTask | None
- unlock()¶
Unlock the schema. After successfully unlocking the schema its lock_type property is updated.
- Returns:
True when schema was successfully unlocked or it has already been unlocked. False when procedure of unlocking schema failed.
- Return type:
bool
- class mstrio.modeling.schema.schema_management.SchemaTask(id, status, start_time=None, end_time=None, errors=None)¶
Bases:
Dictable
Detailed information about a task which is performed on the schema.
- Parameters:
id (str) –
status (str | SchemaTaskStatus) –
start_time (str | None) –
end_time (str | None) –
errors (list[SchemaTaskError] | None) –
- 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
- class mstrio.modeling.schema.schema_management.SchemaTaskError(code, message, additional_properties=None)¶
Bases:
Dictable
Representation of properties used to report an error related to schema task.
- Parameters:
code (str) –
message (str) –
additional_properties (dict | None) –
- 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.schema_management.SchemaTaskStatus(value)¶
Bases:
AutoName
Enumeration constants used to specify status of the task.
Valid values are as follows:
- RUNNING = SchemaTaskStatus.RUNNING¶
- COMPLETED = SchemaTaskStatus.COMPLETED¶
- FAILED = SchemaTaskStatus.FAILED¶
- enum mstrio.modeling.schema.schema_management.SchemaUpdateType(value)¶
Bases:
AutoName
Enumeration constants used to specify type of update for the schema.
Valid values are as follows:
- TABLE_KEY = SchemaUpdateType.TABLE_KEY¶
- ENTRY_LEVEL = SchemaUpdateType.ENTRY_LEVEL¶
- LOGICAL_SIZE = SchemaUpdateType.LOGICAL_SIZE¶
- CLEAR_ELEMENT_CACHE = SchemaUpdateType.CLEAR_ELEMENT_CACHE¶