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:
DictableAn 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
- __init__(lock_type, date_created=None, comment=None, machine_name=None, owner_name=None, owner_id=None)¶
Initialize schema lock status. When schema is unlocked, only its lock_type is provided.
- Parameters:
lock_type (str, enum) –
a type of lock status that could be returned from the schema. The lock state any of the lock types, but it is also possible that the schema is not actually locked. Available lock types are: - absolute_individual: When placed no one, including
administrator, can perform changes on the schema objects. The purpose of this lock is to prevent accidental modifications to the schema in a project.
exclusive_constituent: It is a lock exclusive to the changeset holding the lock; only that changeset can change the schema or its constituents (tables, attributes, etc.).
absolute_constituent: According to REST API documentation this type is currently not in use.
none: Schema is unlocked.
lock_type can be provided as string or enum SchemaLockType.
date_created (str, optional) – The date/time at which this lock was placed on the schema.
comment (str, optional) – Optional comment provided by the user that applied the lock. If used, this comment may help to justify why the schema was locked.
machine_name (str, optional) – Name of the machine used by the user that applied the lock.
owner_name (str, optional) – Name of the owner of the lock.
owner_id (str, optional) – ID of the owner of the lock.
- Raises:
TypeError –
a SchemaLockType. –
ValueError –
a proper value of enum SchemaLockType. –
- to_dict(camel_case=True, whitelist_keys=None, skip_private_keys=False)¶
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.
whitelist_keys (list[str], optional) – List of keys to include in the resulting dictionary. If None, all keys (except hidden ones) are included. Defaults to None.
skip_private_keys (bool, optional) – If True, skips private keys in final dict representation.
- 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:
AutoNameEnumeration 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¶
The
Enumand its members also have the following methods:- classmethod has_value(value)¶
- class mstrio.modeling.schema.schema_management.SchemaManagement(connection, project=None, project_id=None, project_name=None)¶
Bases:
objectRepresentation of schema management object.
- Parameters:
connection (Connection)
project (Project | str | None)
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
- 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.
- __init__(connection, project=None, project_id=None, project_name=None)¶
Initialize schema management object for the given project.
- Parameters:
connection (Connection) – Strategy One connection object returned by connection.Connection().
project (Project | str, optional) – Project object or ID or name specifying the project. May be used instead of project_id or project_name.
project_id (str, optional) – Project ID
project_name (str, optional) – Project name
- Raises:
ValueError –
- get_lock_status()¶
Get the lock status of the schema.
- Returns:
SchemaLockStatus– 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– 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 (
Union[str,SchemaLockType]) – (string or object): Type of lock which will be placed on the schema.- Returns:
bool– 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:
Optional[SchemaTask] – 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:
bool– True when schema was successfully unlocked or it has already been unlocked. False when procedure of unlocking schema failed.- Return type:
bool
- property lock_type¶
Current lock type of the schema.
- property project_id¶
Id of project which is managed by the SchemaManagement object.
- property tasks¶
List with tasks created while running reload on the given instance of SchemaManagement.
- class mstrio.modeling.schema.schema_management.SchemaTask(id, status, start_time=None, end_time=None, errors=None)¶
Bases:
DictableDetailed 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
- __init__(id, status, start_time=None, end_time=None, errors=None)¶
Initialize task.
- Parameters:
id (str) – Task ID.
status (str, enum) – Task status. Possible values are defined in enum SchemaTaskStatus.
start_time (
str|None) – (str, optional): The date/time at which the execution of task started.end_time (str, optional) – The date/time at which the task execution completed (or failed). This value is not defined when task is still running.
errors (
list[SchemaTaskError] |None) – (list, optional): List of errors if the task execution failed. Errors are represented by class SchemaTaskError.
- Raises:
TypeError –
a SchemaTaskStatus. –
ValueError –
a proper value of enum SchemaTaskStatus. –
- to_dict(camel_case=True, whitelist_keys=None, skip_private_keys=False)¶
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.
whitelist_keys (list[str], optional) – List of keys to include in the resulting dictionary. If None, all keys (except hidden ones) are included. Defaults to None.
skip_private_keys (bool, optional) – If True, skips private keys in final dict representation.
- 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:
DictableRepresentation 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
- __init__(code, message, additional_properties=None)¶
Initialize task error.
- Parameters:
code (str) – Internal application error code.
message (str) – Description of error.
additional_properties (dict, optional) – Additional information related to the error (if any).
- to_dict(camel_case=True, whitelist_keys=None, skip_private_keys=False)¶
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.
whitelist_keys (list[str], optional) – List of keys to include in the resulting dictionary. If None, all keys (except hidden ones) are included. Defaults to None.
skip_private_keys (bool, optional) – If True, skips private keys in final dict representation.
- 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:
AutoNameEnumeration constants used to specify status of the task.
Valid values are as follows:
- RUNNING = SchemaTaskStatus.RUNNING¶
- COMPLETED = SchemaTaskStatus.COMPLETED¶
- FAILED = SchemaTaskStatus.FAILED¶
The
Enumand its members also have the following methods:- classmethod has_value(value)¶
- enum mstrio.modeling.schema.schema_management.SchemaUpdateType(value)¶
Bases:
AutoNameEnumeration 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¶
The
Enumand its members also have the following methods:- classmethod has_value(value)¶