mstrio > modeling > custom_group

class mstrio.modeling.custom_group.CustomGroup(connection, id=None, name=None, show_expression_as=ExpressionFormat.TREE, show_filter_tokens=False)

Bases: Entity, CopyMixin, MoveMixin, DeleteMixin, ModelVldbMixin

Python representation of a Custom Group object.

Parameters:
  • connection (Connection) –

  • id (str | None) –

  • name (str | None) –

  • show_expression_as (ExpressionFormat | str) –

  • show_filter_tokens (bool) –

name

Name of the custom group.

Type:

str

id

ID of the custom group.

Type:

str

description

Description of the custom group.

Type:

str

sub_type

Subtype of the object in metadata, here: CUSTOM_GROUP.

Type:

ObjectSubType

version

Version of the object in metadata.

Type:

str

ancestors

List of ancestor folders.

Type:

list[dict]

type

Type of the object in metadata, here: FILTER.

Type:

ObjectTypes

date_created

Date and time when the object was created.

Type:

datetime

date_modified

Date and time when the object was last modified.

Type:

datetime

owner

Information about the owner of the object.

Type:

dict

acg

Access rights flags for the object.

Type:

Rights

acl

Access control list for the object.

Type:

list[ACE]

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. If this field is omitted (as is usual) then the target is not embedded.

Type:

bool

path

Path to the object in the project/folder structure.

Type:

str

primary_locale

The primary locale of the object, in the IETF BCP 47 language tag format, such as “en-US”. Read only.

Type:

str

hidden

Whether the object is hidden in the folder structure.

Type:

bool

elements

List of custom group elements. Note: IDs of the elements are generated by the server independently from the client-side generated IDs and differ between fetches.

Type:

list[CustomGroupElement]

drill_map

Drill map used by the custom group.

Type:

dict, optional

options

Display options for the custom group.

Type:

CustomGroupOptions, optional

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, description=None, primary_locale=None, elements=None, options=None, drill_map=None, drill_map_id=None, drill_map_name=None, remove_drill_map=False, hidden=None, comments=None, owner=None, journal_comment=None)

Alter properties of the Custom Group object. :param name: New name of the custom group. :type name: str, optional :param description: New description of the custom group. :type description: str, optional :param primary_locale: New primary locale of the object,

in the IETF BCP 47 language tag format, such as “en-US”.

Parameters:
  • elements (list[CustomGroupElement], optional) – New list of elements to include in the custom group. This will completely replace the existing list of elements.

  • options (CustomGroupOptions, optional) – New display options for the custom group. May be partially specified to update only certain options.

  • drill_map (Object | str, optional) – Object or ID or name specifying the drill map. May be used instead of drill_map_id or drill_map_name.

  • drill_map_id (str, optional) – ID of a drill map.

  • drill_map_name (str, optional) – Name of a drill map.

  • remove_drill_map (bool, optional) – If True, removes the drill map from the custom group. Defaults to False.

  • hidden (bool, optional) – Whether the object is hidden in the folder structure.

  • comments (str, optional) – Long description for the object.

  • owner (str | User, optional) – New owner of the object. Can be specified either as User object or user ID.

  • journal_comment (str, optional) – Comment that will be added to the object’s change journal entry.

  • name (str | None) –

  • description (str | None) –

  • primary_locale (str, optional) –

alter_element(id, name=None, display=None, element_format=None, items_format=None, reset_format=False, qualification=None, journal_comment=None)

Alter properties of a specific Custom Group Element.

Parameters:
  • id (str) – ID of the custom group element to alter.

  • name (str, optional) – New name of the custom group element.

  • display (ElementDisplayOption, optional) – New display option for the element.

  • element_format (MetricFormat, optional) – Format settings for the element.

  • items_format (MetricFormat, optional) – Format settings for individual items in the report.

  • reset_format (bool, optional) – If True, erase format settings previously set on the server for both element_format and items_format. Defaults to False.

  • qualification (Expression, optional) – New qualification expression for the element.

  • journal_comment (str, optional) – Comment that will be added to the object’s change journal entry.

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

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, elements, destination_folder=None, destination_folder_path=None, description=None, primary_locale=None, options=None, drill_map=None, drill_map_id=None, drill_map_name=None, show_expression_as=ExpressionFormat.TREE, journal_comment=None)

Create a new Custom Group object on the server.

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

  • name (str) – Name of the custom group.

  • elements (list[CustomGroupElement]) – List of elements to include in the custom group.

  • destination_folder (Folder | tuple | list | str, optional) – Folder object or ID or name or path specifying the folder where to create object.

  • destination_folder_path (str, optional) –

    Path of the folder. The path has to be provided in the following format:

    /MicroStrategy Tutorial/Public Objects/Metrics

  • description (str, optional) – Description of the custom group.

  • primary_locale (str, optional) – the primary locale of the object, in the IETF BCP 47 language tag format, such as “en-US”

  • options (CustomGroupOptions, optional) – Display options for the custom group.

  • drill_map (Object | str, optional) – Object or ID or name specifying the drill map. May be used instead of drill_map_id or drill_map_name.

  • drill_map_id (str, optional) – ID of a drill map.

  • drill_map_name (str, optional) – Name of a drill map.

  • show_expression_as (ExpressionFormat | str, optional) – How expressions should be presented. Defaults to ExpressionFormat.TREE.

  • journal_comment (optional, str) – Comment that will be added to the object’s change journal entry

Returns:

Newly created Custom Group object.

Return type:

CustomGroup | dict

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[T]) –

Returns:

New python object holding the copied object.

Return type:

T

create_element(name, display, qualification, element_format=None, items_format=None, journal_comment=None)

Create a new Custom Group Element and add it to the Custom Group.

Parameters:
  • name (str) – Name of the custom group element.

  • display (ElementDisplayOption) – Display option for the element.

  • element_format (MetricFormat, optional) – Format settings for the element.

  • items_format (MetricFormat, optional) – Format settings for individual items in the report.

  • qualification (Expression) – Qualification expression for the element.

  • journal_comment (str, optional) – Comment that will be added to the object’s change journal entry.

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

Create a shortcut to the object.

Parameters:
  • target_folder (Folder | tuple | list | str, optional) – Folder object or ID or name or path specifying the folder. May be used instead of target_folder_id, target_folder_name or target_folder_path.

  • target_folder_id (str, optional) – ID of a folder.

  • target_folder_name (str, optional) – Name of a folder.

  • target_folder_path (str, optional) –

    Path of the folder. The path has to be provided in the following format:

    /MicroStrategy Tutorial/Public Objects/Metrics

  • 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

  • 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, journal_comment=None, **kwargs)

Delete object.

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

  • journal_comment (str | None) – Comment to be added to the change journal for this deletion. If None, no comment is added.

  • **kwargs – Any additional arguments within overridden versions of this method in inheritance chain.

  • self (Entity) –

Returns:

True on success. False otherwise.

Return type:

bool

delete_element(id, journal_comment=None)

Delete a specific Custom Group Element from the Custom Group.

Parameters:
  • id (str) – ID of the custom group element to delete.

  • journal_comment (str, optional) – Comment that will be added to the object’s change journal entry.

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

fetch_all_change_journal_entries()

Fetch change journal entries from the API.

Return type:

None

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

a dictionary without calling any additional getters.

Parameters:
  • cls – 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 instance of the cls class.

get(name)

Get object’s attribute by its name.

get_element(id=None, name=None, to_dictionary=False)

Get a specific Custom Group Element by its ID or name.

Note

Provide either id or name parameter, but not both.

Parameters:
  • id (str, optional) – ID of the custom group element. May be omitted if name parameter is provided.

  • name (str, optional) – Name of the custom group element.

  • to_dictionary (bool, optional) – If True returns a dictionary instead of a CustomGroupElement object. Default is False.

Returns:

The specified custom group element

or None if not found.

Return type:

CustomGroupElement | dict | None

has_dependents()

Check if the object has any dependents.

Returns:

True if the object has dependents, False otherwise.

Parameters:

self (Entity) –

Return type:

bool

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, scope=None, 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).

  • scope (SearchScope, str, optional) – Scope of the search with regard to System Managed Objects. Possible values are available in ENUM mstrio.object_management.SearchScope.

  • 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, scope=None, 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).

  • scope (SearchScope, str, optional) – Scope of the search with regard to System Managed Objects. Possible values are available in ENUM mstrio.object_management.SearchScope.

  • 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

Return type:

list[dict] | list[’Entity’]

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.

move(folder=None, folder_id=None, folder_name=None, folder_path=None)

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

Parameters:
  • folder (Folder | tuple | list | str, optional) – Folder object or ID or name or path specifying the folder. May be used instead of folder_id, folder_name or folder_path.

  • folder_id (str, optional) – ID of a folder.

  • folder_name (str, optional) – Name of a folder.

  • folder_path (str, optional) –

    Path of the folder. The path has to be provided in the following format:

    if it’s inside of a project, start with a Project Name:

    /MicroStrategy Tutorial/Public Objects/Metrics

    if it’s a root folder, start with CASTOR_SERVER_CONFIGURATION:

    /CASTOR_SERVER_CONFIGURATION/Users

  • self (Entity) –

Return type:

None

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, 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

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, 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

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.custom_group.CustomGroupElement(name, display, qualification, element_format=None, items_format=None, id=None)

Bases: Dictable

Custom Group Element representation.

Parameters:
name

Name of the custom group element.

Type:

str

display

Display option for the element.

Type:

ElementDisplayOption

element_format

Format settings for the element.

Type:

MetricFormat

items_format

Format settings for individual items in the report.

Type:

MetricFormat

qualification

Qualification expression for the element.

Type:

Expression

id

ID of the custom group element. If not provided, it will be generated automatically and replaced by server-generated ID when Custom Group is created on the server.

Type:

str, optional

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, 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.custom_group.CustomGroupOptions(hierarchy_display=None, subtotals_display=None, element_header_above_child=None)

Bases: Dictable

Custom Group display options.

Parameters:
  • hierarchy_display (bool | None) –

  • subtotals_display (bool | None) –

  • element_header_above_child (bool | None) –

hierarchy_display

Whether to enable hierarchical display. Default is True.

subtotals_display

Whether to enable subtotals display. Default is False.

element_header_above_child

Whether to display element header above child elements. Default is True.

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, 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.custom_group.ElementDisplayOption(value)

Bases: AutoName

Enumeration of Custom Group Element display options.

ELEMENT

Display only the element name.

INDIVIDUAL

Display only individual items within the element.

INDIVIDUAL_EXPAND

Display individual items within the element. Expand individual items if possible.

ELEMENT_INDIVIDUAL_EXPAND

Display both the element name and individual items. Expand individual items if possible.

Valid values are as follows:

ELEMENT = ElementDisplayOption.ELEMENT
INDIVIDUAL = ElementDisplayOption.INDIVIDUAL
INDIVIDUAL_EXPAND = ElementDisplayOption.INDIVIDUAL_EXPAND
ELEMENT_INDIVIDUAL_EXPAND = ElementDisplayOption.ELEMENT_INDIVIDUAL_EXPAND
mstrio.modeling.custom_group.list_custom_groups(connection, name=None, to_dictionary=False, limit=None, project=None, project_id=None, project_name=None, search_pattern=SearchPattern.CONTAINS, show_expression_as=ExpressionFormat.TREE, folder=None, folder_id=None, folder_name=None, folder_path=None, **filters)

Get a list of CustomGroup objects or dicts. Optionally filter the objects by specifying filters parameters.

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

  • name (str, optional) – value the search pattern is set to, which will be applied to the names of CustomGroup objects being searched

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

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

  • 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

  • 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 or str, optional) – specify how expressions should be presented Available values: - None (expression is returned in “text” format) - ExpressionFormat.TREE or tree (expression is returned in text and tree formats) - ExpressionFormat.TOKENS or tokens (expression is returned in text and tokens formats)

  • folder (Folder | tuple | list | str, optional) – Folder object or ID or name or path specifying the folder. May be used instead of folder_id, folder_name or folder_path.

  • folder_id (str, optional) – ID of a folder.

  • folder_name (str, optional) – Name of a folder.

  • folder_path (str, optional) –

    Path of the folder. The path has to be provided in the following format:

    if it’s inside of a project, start with a Project Name:

    /MicroStrategy Tutorial/Public Objects/Metrics

    if it’s a root folder, start with CASTOR_SERVER_CONFIGURATION:

    /CASTOR_SERVER_CONFIGURATION/Users

  • **filters – Available filter parameters: [‘id’, ‘name’, ‘type’, ‘subtype’, ‘date_created’, ‘date_modified’, ‘version’, ‘acg’, ‘owner’, ‘ext_type’]

Returns:

list of filter objects or list of filter dictionaries.

Return type:

list[’CustomGroup’] | list[dict]