mstrio > modeling > metric > metric

enum mstrio.modeling.metric.metric.DefaultSubtotals(value)

Bases: Enum

Valid values are as follows:

AGGREGATION = <DefaultSubtotals.AGGREGATION: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='F225147A4CA0BB97368A5689D9675E73', name=None, is_embedded=None)>
AVERAGE = <DefaultSubtotals.AVERAGE: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='B328C60462634223B2387D4ADABEEB53', name=None, is_embedded=None)>
COUNT = <DefaultSubtotals.COUNT: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='078C50834B484EE29948FA9DD5300ADF', name=None, is_embedded=None)>
GEOMETRIC_MEAN = <DefaultSubtotals.GEOMETRIC_MEAN: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='E1853D5A36C74F59A9F8DEFB3F9527A1', name=None, is_embedded=None)>
MAXIMUM = <DefaultSubtotals.MAXIMUM: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='B1F4AA7DE683441BA559AA6453C5113E', name=None, is_embedded=None)>
MEDIAN = <DefaultSubtotals.MEDIAN: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='83A663067F7E43B2ABF67FD38ECDC7FE', name=None, is_embedded=None)>
MINIMUM = <DefaultSubtotals.MINIMUM: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='00B7BFFF967F42C4B71A4B53D90FB095', name=None, is_embedded=None)>
MODE = <DefaultSubtotals.MODE: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='36226A4048A546139BE0AF5F24737BA8', name=None, is_embedded=None)>
PRODUCT = <DefaultSubtotals.PRODUCT: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='54E7BFD129514717A92BC44CF1FE5A32', name=None, is_embedded=None)>
RESERVED = <DefaultSubtotals.RESERVED: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='F341109B11D5D528C00084916B98494F', name=None, is_embedded=None)>
STANDARD_DEVIATION = <DefaultSubtotals.STANDARD_DEVIATION: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='7FBA414995194BBAB2CF1BB599209824', name=None, is_embedded=None)>
SUM_OF_WYA = <DefaultSubtotals.SUM_OF_WYA: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='F7AE84A511D78008B00092BE4E571AD0', name=None, is_embedded=None)>
TOTAL = <DefaultSubtotals.TOTAL: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='96C487AF4D12472A910C1ACACFB56EFB', name=None, is_embedded=None)>
VARIANCE = <DefaultSubtotals.VARIANCE: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='1769DBFCCF2D4392938E40418C6E065E', name=None, is_embedded=None)>
WEIGHTED_YEARLY_AVERAGE = <DefaultSubtotals.WEIGHTED_YEARLY_AVERAGE: SchemaObjectReference(sub_type=ObjectSubType.SYSTEM_SUBTOTAL, object_id='F7AE852A11D78008B00092BE4E571AD0', name=None, is_embedded=None)>
class mstrio.modeling.metric.metric.Metric(connection, id=None, name=None, show_expression_as=ExpressionFormat.TOKENS)

Bases: Entity, CopyMixin, MoveMixin, DeleteMixin, ModelVldbMixin

Python representation of Strategy One Metric object.

Parameters:
id

metric’s ID

name

metric’s name

sub_type

string literal used to identify the type of a metadata object

description

metric’s description

type

object type, ObjectTypes enum

subtype

object subtype, ObjectSubTypes enum

ext_type

object extended type, ExtendedType enum

ancestors

list of ancestor folders

date_created

creation time, DateTime object

date_modified

last modification time, DateTime object

destination_folder_id

a globally unique identifier used to distinguish between metadata objects within the same project

is_embedded

If true indicates that the target object of this reference is embedded within this object. Alternatively if this object is itself embedded, then it means that the target object is embedded in the same container as this object.

owner

User object that is the owner

acg

access rights (See EnumDSSXMLAccessRightFlags for possible values)

acl

object access control list

version

the version number this object is currently carrying

expression

the Expression representing the metric’s formula

dimensionality

the object that specifies the dimensionality

conditionality

the object that specifies the conditionality

metric_subtotals

a list of the enabled subtotals for the metric

aggregate_from_base

bool used to specify whether the metric aggregates from base

formula_join_type

join type of the metric’s formula, FormulaJoinType enumerator

smart_total

whether the metric is decomposable or not, SmartTotal enumerator

data_type

DataType object for metric values

format

MetricFormat object that stores the formatting of the metric

subtotal_from_base

bool used to specify whether the metric is a subtotal from base type

column_name_alias

name for the column representing the metric in SQL

metric_format_type

specifies whether the metric has HTML content, MetricFormatType enumerator

thresholds

list of Threshold for the metric

hidden

Specifies whether the object is hidden

class Conditionality(filter=None, embed_method=None, prompt=None, remove_elements=False)

Bases: Dictable

Object that specifies the conditionality

This class can only be used for simple metrics. For creation and altering of compound metrics, conditionality needs to be defined through the use of the Expression class.

Parameters:
filter

reference to the filter to be used for the conditionality

Type:

SchemaObjectReference, optional

embed_method

value of the enumerator that specifies the type of filter interaction between the metric and report filters

Type:

EmbedMethod, optional

prompt

reference to the prompt to be used for the conditionality, only prompts of the type Prompt Object may be used

Type:

SchemaObjectReference, optional

remove_elements

whether to remove related filter elements

Type:

bool

enum EmbedMethod(value)

Bases: AutoName

Valid values are as follows:

BOTH_FILTERS_TOGETHER = EmbedMethod.BOTH_FILTERS_TOGETHER
REPORT_INTO_METRIC_FILTER = EmbedMethod.REPORT_INTO_METRIC_FILTER
METRIC_INTO_REPORT_FILTER = EmbedMethod.METRIC_INTO_REPORT_FILTER
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

embed_method: EmbedMethod | None = None
filter: SchemaObjectReference | None = None
prompt: SchemaObjectReference | None = None
remove_elements: bool = False
enum FormulaJoinType(value)

Bases: AutoName

Valid values are as follows:

DEFAULT = FormulaJoinType.DEFAULT
INNER = FormulaJoinType.INNER
OUTER = FormulaJoinType.OUTER
enum MetricFormatType(value)

Bases: AutoName

Valid values are as follows:

RESERVED = MetricFormatType.RESERVED
HTML_TAG = MetricFormatType.HTML_TAG
LAST_ONE = MetricFormatType.LAST_ONE
class MetricSubtotal(definition=None, implementation=None)

Bases: Dictable

Object that specifies the subtotal. User can use predefined subtotals

using DefaultSubtotals enum, or specify custom made subtotals using SchemaObjectReference.

Parameters:
definition

Reference to the definition object

Type:

SchemaObjectReference or DefaultSubtotals

implementation

Reference to the implementation object. Only used when the definition Subtotal is ‘Total’ to specify what the default subtotal type for the Total should be

Type:

SchemaObjectReference or DefaultSubtotals

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 SmartTotal(value)

Bases: AutoName

Valid values are as follows:

DECOMPOSABLE_FALSE = SmartTotal.DECOMPOSABLE_FALSE
DECOMPOSABLE_TRUE = SmartTotal.DECOMPOSABLE_TRUE
acl_add(rights, trustees, denied=False, inheritable=None, propagate_to_children=None, propagation_behavior=None)

Add Access Control Element (ACE) to the object ACL.

Note

To add rights for the Root Folder and the Freeform Objects, apply the required rights for these folders:

  • Root Folder: D43364C684E34A5F9B2F9AD7108F7828

  • Freeform Objects: 93D8CF3849C1F85DC1A48E8B9E4271F1

Argument propagate_to_children is used only for objects with type ObjectTypes.FOLDER.

Parameters:
  • rights (int | Rights | AggregatedRights) – The degree to which the user or group is granted or denied access to the object. The available permissions are defined in Rights and AggregatedRights Enums

  • trustees (list[UserOrGroup] | UserOrGroup) – list of trustees (User or UserGroup objects or ids) to update the ACE for

  • denied (bool) – flag to indicate granted or denied access to the object

  • inheritable (bool | None) – Applies only to folders. If set, any objects placed in the folder inherit the folder’s entry in the ACL.

  • propagate_to_children (bool | None) – used for folder objects only, default value is None, if set to True/False adds propagateACLToChildren keyword to the request body and sets its value accordingly

  • propagation_behavior (PropagationBehavior | str | None) – Behavior of ACL propagation to children.

  • self (Entity) –

Return type:

None

Examples

>>> obj.acl_add(rights=Rights.BROWSE | Rights.EXECUTE,
>>>             trustees=user_obj, denied=True)
acl_alter(rights, trustees, denied=False, inheritable=None, propagate_to_children=None, propagation_behavior=None)

Alter an existing Access Control Element (ACE) of the object ACL.

Note

To alter rights for the Root Folder and the Freeform Objects, change the required rights for these folders:

  • Root Folder: D43364C684E34A5F9B2F9AD7108F7828

  • Freeform Objects: 93D8CF3849C1F85DC1A48E8B9E4271F1

Argument propagate_to_children is used only for objects with type ObjectTypes.FOLDER.

Parameters:
  • rights (int | Rights | AggregatedRights) – The degree to which the user or group is granted or denied access to the object. The available permissions are defined in Rights and AggregatedRights Enums

  • trustees (list[UserOrGroup] | UserOrGroup) – list of trustees (User or UserGroup objects or ids) to update the ACE for

  • denied (bool) – flag to indicate granted or denied access to the object

  • inheritable (bool | None) – Applies only to folders. If set, any objects placed in the folder inherit the folder’s entry in the ACL.

  • propagate_to_children (bool | None) – used for folder objects only, default value is None, if set to True/False adds propagateACLToChildren keyword to the request body and sets its value accordingly

  • propagation_behavior (PropagationBehavior | str | None) – Behavior of ACL propagation to children.

  • self (Entity) –

Return type:

None

Examples

>>> obj.acl_alter(rights=Rights.BROWSE | Rights.EXECUTE,
>>>               trustees=user_obj, denied=True)
acl_remove(rights, trustees, denied=False, inheritable=None, propagate_to_children=None, propagation_behavior=None)

Remove Access Control Element (ACE) from the object ACL.

Note

To remove rights from the Root Folder and the Freeform Objects, remove them from these folders:

  • Root Folder: D43364C684E34A5F9B2F9AD7108F7828

  • Freeform Objects: 93D8CF3849C1F85DC1A48E8B9E4271F1

Argument propagate_to_children is used only for objects with type ObjectTypes.FOLDER.

Parameters:
  • rights (int | Rights | AggregatedRights) – The degree to which the user or group is granted or denied access to the object. The available permissions are defined in Rights and AggregatedRights Enums

  • trustees (list[UserOrGroup] | UserOrGroup) – list of trustees (User or UserGroup objects or ids) to update the ACE for

  • denied (bool) – flag to indicate granted or denied access to the object

  • inheritable (bool | None) – Applies only to folders. If set, any objects placed in the folder inherit the folder’s entry in the ACL.

  • propagate_to_children (bool | None) – used for folder objects only, default value is None, if set to True/False adds propagateACLToChildren keyword to the request body and sets its value accordingly

  • propagation_behavior (PropagationBehavior | str | None) – Behavior of ACL propagation to children.

  • self (Entity) –

Return type:

None

Examples

>>> obj.acl_remove(rights=Rights.BROWSE | Rights.EXECUTE,
>>>                trustees=user_obj, denied=True)
add_translation(translations)

Adds translations to the Object.

Parameters:
  • translations (list[OperationData]) – list of translations to be added to the Object

  • self (Entity) –

Returns:

A list of translations for the Object.

Return type:

list[’Translation’]

alter(name=None, destination_folder_id=None, expression=None, description=None, dimensionality=None, conditionality=None, metric_subtotals=None, aggregate_from_base=False, formula_join_type=FormulaJoinType.DEFAULT, smart_total=None, data_type=None, format=None, subtotal_from_base=False, column_name_alias=None, metric_format_type=None, thresholds=None, show_expression_as=ExpressionFormat.TOKENS, hidden=None, comments=None, owner=None)

Alter a metric’s specified properties

Parameters:
  • name (str | None) – metric’s name

  • destination_folder_id (str | None) – A globally unique identifier used to distinguish between metadata objects within the same project. It is possible for two metadata objects in different projects to have the same Object Id.

  • expression (Expression | None) – the Expression representing the metric’s formula

  • description (str | None) – metric’s description

  • dimensionality (Dimensionality | None) – the object that specifies the dimensionality

  • conditionality (Conditionality | None) – the object that specifies the conditionality

  • metric_subtotals (list[MetricSubtotal] | None) – a list of the enabled subtotals for the metric

  • aggregate_from_base (bool) – bool used to specify whether the metric aggregates from base

  • formula_join_type (FormulaJoinType | None) – join type of the metric’s formula, FormulaJoinType enumerator

  • smart_total (SmartTotal | None) – whether the metric is decomposable or not, SmartTotal enumerator

  • data_type (DataType | None) – DataType object for metric values

  • format (MetricFormat | None) – MetricFormat object that stores the formatting of the metric

  • subtotal_from_base (bool) – bool used to specify whether the metric is a subtotal from base type

  • column_name_alias (str | None) – name of the column representing the metric in SQL

  • metric_format_type (MetricFormatType | None) – specifies whether the metric has HTML content, MetricFormatType enumerator

  • thresholds (list[Threshold] | None) – list of Threshold for the metric

  • show_expression_as (ExpressionFormat, str) – specify how expressions should be presented Available values: - ExpressionFormat.TREE or tree - ExpressionFormat.TOKENS or `tokens (default)

  • hidden (bool | None) – Specifies whether the metric is hidden

  • owner (User | str | None) – owner of the metric

  • comments (str | None) –

alter_translation(translations)

Alters translations of the Object.

Parameters:
  • translations (list[OperationData]) – list of translations to be added to the Object

  • self (Entity) –

Return type:

None

alter_vldb_settings(names_to_values)

Alter VLDB settings according to given name to value pairs.

Note

Only common value type conversion will be done by default, such as int->float, bool->int, int->bool and only if that is possible according to interval of allowed values, error will be thrown in other cases.

Parameters:

names_to_values (dict[str, str | int | float | bool]) – Dict with VlDB settings names as keys and newly requested to set values as dictionary values. As VLDB Setting name you can provide both: key or display name.

Raises:
  • ValueError – If there are no VldbSetting objects for some provided names or names and values are not provided or some of provided values will not be possible to set.

  • TypeError – If some of provided values to set have wrong type, different from type of default VLDB setting value.

Returns:

None

Return type:

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 create(connection, name, sub_type, destination_folder, expression, description=None, is_embedded=False, dimensionality=None, conditionality=None, metric_subtotals=None, aggregate_from_base=False, formula_join_type=FormulaJoinType.DEFAULT, smart_total=None, data_type=None, format=None, subtotal_from_base=False, column_name_alias=None, metric_format_type=None, thresholds=None, show_expression_as=ExpressionFormat.TOKENS, hidden=None)

Create a new metric with specified properties.

Parameters:
  • connection (Connection) – Strategy One connection object returned by connection.Connection()

  • name (str) – metric’s name

  • sub_type (ObjectSubType | str) – metric’s sub_type

  • destination_folder (Folder | str) – A globally unique identifier used to distinguish between metadata objects within the same project. It is possible for two metadata objects in different projects to have the same Object Id

  • description (str | None) – metric’s description

  • is_embedded (bool) – If true indicates that the target object of this reference is embedded within this object. Alternatively if this object is itself embedded, then it means that the target object is embedded in the same container as this object.

  • expression (Expression) – the Expression representing the metric’s formula

  • dimensionality (Dimensionality | None) – the object that specifies the dimensionality

  • conditionality (Conditionality | None) – the object that specifies the conditionality

  • metric_subtotals (list[MetricSubtotal] | None) – a list of the enabled subtotals for the metric

  • aggregate_from_base (bool) – bool used to specify whether the metric aggregates from base

  • formula_join_type (FormulaJoinType | None) – join type of the metric’s formula, FormulaJoinType enumerator

  • smart_total (SmartTotal | None) – whether the metric is decomposable or not, SmartTotal enumerator

  • data_type (DataType | None) – DataType object for metric values

  • format (MetricFormat | None) – MetricFormat object that stores the formatting of the metric

  • subtotal_from_base (bool) – bool used to specify whether the metric is a subtotal from base type

  • column_name_alias (str | None) – name of the column representing the metric in SQL

  • metric_format_type (MetricFormatType | None) – specifies whether the metric has HTML content, MetricFormatType enumerator

  • thresholds (list[Threshold] | None) – list of Threshold for the metric

  • show_expression_as (ExpressionFormat, str) – specify how expressions should be presented Available values: - ExpressionFormat.TREE or tree - ExpressionFormat.TOKENS or `tokens (default)

  • hidden (bool, optional) – Specifies whether the object is hidden. Default value: False.

Returns:

Metric class object.

Return type:

Metric

create_copy(name=None, folder_id=None, project=None)

Create a copy of the object on the I-Server.

Parameters:
  • name (str | None) – New name of the object. If None, a default name is generated, such as ‘Old Name (1)’

  • folder_id (str | None) – ID of the destination folder. If None, the object is saved in the same folder as the source object.

  • project (Project | str | None) – By default, the project selected when creating Connection object. Override project to specify project where the current object exists.

  • self (Entity) –

Returns:

New python object holding the copied object.

Return type:

Any

create_shortcut(target_folder_id=None, target_folder_path=None, target_folder=None, project_id=None, project_name=None, project=None, to_dictionary=False)

Create a shortcut to the object.

Parameters:
  • target_folder_id (str, optional) – ID of the target folder. Target folder must be specified, but target_folder_id may be substituted with target_folder_path or target_folder.

  • target_folder_path (str, optional) – Path to the target folder, e.g. ‘/MicroStrategy Tutorial/Public Objects’. May be used instead of target_folder_id.

  • target_folder (Folder, optional) – Target folder object. May be used instead of target_folder_id.

  • project_id (str, optional) – ID of the target project of the new shortcut. The project may be specified by either project_id, project_name or project. If the project is not specified in either way, the project from the connection object is used.

  • project_name (str, optional) – Name of the target project. May be used instead of project_id.

  • project (Project, optional) – Project object specifying the target project. May be used instead of project_id.

  • to_dictionary (bool, optional) – If True, the method will return a dictionary with the shortcut’s properties instead of a Shortcut object. Defaults to False.

Return type:

Shortcut

delete(force=False)

Delete object.

Parameters:
  • force (bool) – If True, then no additional prompt will be shown before deleting object.

  • self (Entity) –

Returns:

True on success. False otherwise.

Return type:

bool

fetch(attr=None)

Fetch the latest object’s state from the I-Server.

Note

This method can overwrite local changes made to the object.

Parameters:
  • attr (Optional[str]) – Attribute name to be fetched. If not specified

  • dictionary. (it will use all getters specified in _API_GETTERS) –

  • None. (Defaults to) –

Raises:

ValueError – If attr cannot be fetched.

Return type:

None

classmethod from_dict(source, connection=None, with_missing_value=False)
Overrides Dictable.from_dict() to instantiate an object from

a dictionary without calling any additional getters.

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) – A Strategy One Connection object.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case, default 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

get(name)

Get object’s attribute by its name.

list_acl(to_dataframe=False, to_dictionary=False, **filters)

Get Access Control List (ACL) for this object. Optionally filter ACLs by specifying filters.

Parameters:
  • to_dataframe (bool, optional) – if True, return datasets as pandas DataFrame

  • to_dictionary (bool, optional) – if True, return datasets as dicts

  • **filters – Available filter parameters: [deny, type, rights, trustee_id, trustee_name, trustee_type, trustee_subtype, inheritable]

Return type:

DataFrame | list[dict | mstrio.utils.acl.ACE]

Examples

>>> list_acl(deny=True, trustee_name="John")
list_dependencies(project=None, name=None, pattern=4, domain=2, object_types=None, used_by_recursive=False, root=None, root_path=None, limit=None, offset=None, results_format='LIST', to_dictionary=True, **filters)

List list_dependencies of an object.

Parameters:
  • project (string) – Project object or ID

  • name (string) – Value the search pattern is set to, which will be applied to the names of object types being searched. For example, search for all report objects (type) whose name begins with (pattern) B (name).

  • pattern (integer or enum class object) – Pattern to search for, such as Begin With or Exactly. Possible values are available in ENUM mstrio.object_management.SearchPattern. Default value is CONTAINS (4).

  • domain (integer or enum class object) – Domain where the search will be performed, such as Local or Project. Possible values are available in ENUM mstrio.object_management.SearchDomain. Default value is PROJECT (2).

  • root (string, optional) – Folder ID of the root folder where the search will be performed.

  • root_path (str, optional) –

    Path of the root folder in which the search will be performed. Can be provided as an alternative to root parameter. If both are provided, root is used.

    the path has to be provided in the following format:
    if it’s inside of a project, example:

    /MicroStrategy Tutorial/Public Objects/Metrics

    if it’s a root folder, example:

    /CASTOR_SERVER_CONFIGURATION/Users

  • class (object_types(enum class object or integer or list of enum) – objects or integers): Type(s) of object(s) to be searched, such as Folder, Attribute or User. Possible values available in ENUMs mstrio.types.ObjectTypes and mstrio.types.ObjectSubTypes

  • used_by_recursive (boolean, optional) – Control the Intelligence server to also find objects that are used by the given objects indirectly. Default value is false.

  • results_format (SearchResultsFormat) – either a list or a tree format

  • to_dictionary (bool) – If False returns objects, by default (True) returns dictionaries.

  • limit (int) – limit the number of elements returned. If None (default), all objects are returned.

  • offset (int) – Starting point within the collection of returned results. Used to control paging behavior. Default is 0.

  • **filters – Available filter parameters: [‘id’, ‘name’, ‘description’ ,’date_created’, ‘date_modified’, ‘acg’]

  • self (Entity) –

  • object_types (TypeOrSubtype | None) –

Returns:

list of objects or list of dictionaries

list_dependents(project=None, name=None, pattern=4, domain=2, object_types=None, uses_recursive=False, root=None, root_path=None, limit=None, offset=None, results_format='LIST', to_dictionary=True, **filters)

List dependents of an object.

Parameters:
  • project (string) – Project object or ID

  • name (string) – Value the search pattern is set to, which will be applied to the names of object types being searched. For example, search for all report objects (type) whose name begins with (pattern) B (name).

  • pattern (integer or enum class object) – Pattern to search for, such as Begin With or Exactly. Possible values are available in ENUM mstrio.object_management.SearchPattern. Default value is CONTAINS (4).

  • domain (integer or enum class object) – Domain where the search will be performed, such as Local or Project. Possible values are available in ENUM mstrio.object_management.SearchDomain. Default value is PROJECT (2).

  • root (string, optional) – Folder ID of the root folder where the search will be performed.

  • root_path (str, optional) –

    Path of the root folder in which the search will be performed. Can be provided as an alternative to root parameter. If both are provided, root is used.

    the path has to be provided in the following format:
    if it’s inside of a project, example:

    /MicroStrategy Tutorial/Public Objects/Metrics

    if it’s a root folder, example:

    /CASTOR_SERVER_CONFIGURATION/Users

  • class (object_types(enum class object or integer or list of enum) – objects or integers): Type(s) of object(s) to be searched, such as Folder, Attribute or User. Possible values available in ENUMs mstrio.types.ObjectTypes and mstrio.types.ObjectSubTypes

  • uses_recursive (boolean) – Control the Intelligence server to also find objects that use the given objects indirectly. Default value is false.

  • results_format (SearchResultsFormat) – either a list or a tree format

  • to_dictionary (bool) – If False returns objects, by default (True) returns dictionaries.

  • limit (int) – limit the number of elements returned. If None (default), all objects are returned.

  • offset (int) – Starting point within the collection of returned results. Used to control paging behavior. Default is 0.

  • **filters – Available filter parameters: [‘id’, ‘name’, ‘description’ ,’date_created’, ‘date_modified’, ‘acg’]

  • self (Entity) –

  • object_types (TypeOrSubtype | None) –

Returns:

list of objects or list of dictionaries

list_properties(excluded_properties=None)

Fetches all attributes from the server and converts all properties of the object to a dictionary.

Parameters:

excluded_properties (list[str], optional) – A list of object properties that should be excluded from the dict. Defaults to None.

Returns:

A dictionary which keys are object’s attribute names, and

which values are object’s attribute values.

Return type:

dict

list_translations(languages=None, to_dictionary=False)

Lists translations for the Object.

Parameters:
  • languages (list, optional) –

    list of languages to list the translations for, only translations from these languages will be listed. Languages in the list should be one of the following:

    • lcid attribute of the language

    • ID of the language

    • Language class object

  • to_dictionary (bool, optional) – If True returns dict, by default (False) returns Translation objects

  • self (Entity) –

Returns:

A list of dictionaries representing translations for the Object or a list of Translation Objects.

Return type:

list[’Translation’] | list[dict]

list_vldb_settings(set_names=None, names=None, groups=None, to_dictionary=False, to_dataframe=False)

List VLDB settings according to given parameters.

Parameters:
  • set_names (list[str], optional) – List of names of VLDB settings sets.

  • names (list[str], optional) – List of names of VLDB settings.

  • groups (list[int], list[str], optional) – List of group names or ids.

  • to_dictionary (bool, optional) – If True, return VldbSetting objects as list of dicts, default False.

  • to_dataframe (bool, optional) – If True, return VldbSetting objects as pandas DataFrame, default False.

Raises:
  • ValueError – If there are no VldbSetting objects with given parameters or some of the parameters are incorrectly specified.

  • TypeError – If groups list parameter consists of objects of different types.

Returns:

Dict with settings names as keys and VldbSetting objects as values.

Return type:

dict[str, mstrio.utils.vldb_mixin.VldbSetting] | DataFrame

move(folder)

Move the object to a folder on the I-Server.

Parameters:
  • folder (Folder | str) – Destination folder, specified either by id or the Folder object.

  • self (Entity) –

print()

Pretty Print all properties of the object.

Return type:

None

remove_translation(translations)

Removes translations from the Object.

Parameters:
  • translations (list[OperationData]) – list of translations to be added to the Object

  • self (Entity) –

Return type:

None

reset_vldb_settings(set_names=None, names=None, groups=None, force=False)

Reset VLDB settings specified by parameters to its default values. If call was without parameters then additional prompt will be shown.

Parameters:
  • set_names (list[str], optional) – List of names of VLDB setting sets.

  • names (list[str], optional) – List of names of VLDB settings.

  • groups (list[int], list[str], optional) – List of groups names or ids.

  • force (bool) – (bool, optional): If True, no additional prompt will be shown before resetting in case when all other arguments are not provided, default False.

Raises:
  • ValueError – If there are no VldbSetting objects with given parameters or some of the parameters are incorrectly specified.

  • TypeError – If groups list parameter consists of objects of different types.

Returns:

None

Return type:

None

classmethod to_csv(objects, name, path=None, properties=None)

Exports MSTR objects to a csv file.

Optionally, saves only the object properties specified in the properties parameter.

Parameters:
  • objects (T | list[T]) – List of objects of the same type that

  • exported. (will be) –

  • name (str) – The name of the csv file ending with ‘.csv’

  • path (Optional[str], optional) – A path to the directory where the file will be saved. Defaults to None.

  • properties (Optional[list[str]], optional) – A list of object’s attribute names that should be included in the exported file. Defaults to None.

Raises:
  • TypeError – If objects is not of type T or list of type T

  • objects.

Return type:

None

to_dataframe()

Converts all properties of the object to a dataframe.

Returns:

A DataFrame object containing object properties.

Return type:

DataFrame

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

update_properties()

Save compatible local changes of the object attributes to the I-Server. Changes are retrieved from the self._altered_properties dictionary. After the process of update has finished, self._altered_properties is cleared. For this method to work properly, you must override the _alter_properties() method in a subclass.

Raises:

requests.HTTPError – If I-Server raises exception

Return type:

None

class mstrio.modeling.metric.metric.Threshold(format, condition=None, name=None, replace_text=None, semantics=None, scope=None, enable=True)

Bases: Dictable

Object that specifies a threshold

Parameters:
  • format (list[FormatProperty]) –

  • condition (Expression | None) –

  • name (str | None) –

  • replace_text (str | None) –

  • semantics (Semantics | None) –

  • scope (Scope | None) –

  • enable (bool) –

format

list of format properties for the threshold

Type:

list[FormatProperty]

condition

expression that specifies the condition on which the threshold is going to be applied

Type:

Expression, optional

name

name of the threshold

Type:

string, optional

replace_text

text that will replace the metric’s value if the threshold is met

Type:

string, optional

semantics

value of an enumerator that specifies the type of replacement in the replace_text string

Type:

Semantics, optional

scope

value of an enumerator that specifies what the threshold applies to, the metric values, the subtotal value or both

Type:

Scope, optional

enable

whether the threshold is enabled or not, True by default

Type:

bool

enum Scope(value)

Bases: AutoName

Valid values are as follows:

METRIC_ONLY = Scope.METRIC_ONLY
SUBTOTAL_ONLY = Scope.SUBTOTAL_ONLY
METRIC_AND_SUBTOTAL = Scope.METRIC_AND_SUBTOTAL
enum Semantics(value)

Bases: AutoName

Valid values are as follows:

NUMBER = Semantics.NUMBER
TEXT = Semantics.TEXT
PICTURE = Semantics.PICTURE
SYMBOL = Semantics.SYMBOL
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

condition: Expression | None = None
enable: bool = True
format: list[FormatProperty]
name: str | None = None
replace_text: str | None = None
scope: Scope | None = None
semantics: Semantics | None = None
mstrio.modeling.metric.metric.list_metrics(connection, name=None, metric_type=ObjectTypes.METRIC, project_id=None, project_name=None, to_dictionary=False, limit=None, search_pattern=SearchPattern.CONTAINS, show_expression_as=ExpressionFormat.TOKENS, **filters)

Get list of Metric objects or dicts with them.

Optionally use to_dictionary to choose output format.

Wildcards available for ‘name’:

? - any character * - 0 or more of any characters e.g. name_begins = ?onny will return Sonny and Tonny

Specify either project_id or project_name. When project_id is provided (not None), project_name is omitted.

Note

When project_id is None and project_name is None, then its value is overwritten by project_id from connection object.

Parameters:
  • connection (Connection) – Strategy One connection object returned by connection.Connection()

  • name (str, optional) – characters that the metric name must begin with

  • metric_type (ObjectTypes) – one of metric subtypes: Metric or AggMetric

  • project_id (str, optional) – ID of the project to list the metrics from

  • project_name (str, optional) – Project name

  • to_dictionary (bool, optional) – If True returns dict, by default (False) returns Metric objects

  • limit (integer, optional) – limit the number of elements returned. If None all object are returned.

  • search_pattern (SearchPattern enum or int, optional) – pattern to search for, such as Begin With or Exactly. Possible values are available in ENUM mstrio.object_management.SearchPattern. Default value is CONTAINS (4).

  • show_expression_as (ExpressionFormat, str) –

    specify how expressions should be presented Available values:

    • ExpressionFormat.TREE or tree

    • ExpressionFormat.TOKENS or `tokens (default)

  • **filters

    Available filter parameters: id (str): Metric’s ID name (str): Metric’s name date_created (str): format: 2001-01-02T20:48:05.000+0000 date_modified (str): format: 2001-01-02T20:48:05.000+0000 version (str): Metric’s version owner dict: e.g. {‘id’: <user’s id>, ‘name’: <user’s name>},

    with one or both of the keys: id, name

    acg (str | int): access control group

Returns:

list with Metric objects or list of dictionaries

Return type:

list[Metric] | list[dict]