mstrio > modeling > schema > attribute > attribute

class mstrio.modeling.schema.attribute.attribute.Attribute(connection, id=None, name=None, show_expression_as=ExpressionFormat.TREE)

Bases: Entity, CopyMixin, MoveMixin, DeleteMixin

Python representation of Strategy One Attribute object.

Parameters:
id

attribute’s ID

name

attribute’s name

sub_type

string literal used to identify the type of a metadata object

description

attribute’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

forms

the list of attribute forms

attribute_lookup_table

Information about an object referenced within the specification of another object. An object reference typically contains only enough fields to uniquely identify the referenced objects.

key_form

a key form of an attribute

displays

The collections of attribute displays and browse displays

sorts

the collections of attribute sorts and browse sorts of the attribute.

relationships

the list of relationships that one attribute has.

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

hidden

Specifies whether the object is hidden.

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_child(child=None, joint_child=None, relationship_type=RelationshipType.ONE_TO_MANY, table=None)

Add a child to the attribute.

Parameters:
  • child (SchemaObjectReference | None) – SchemaObjectReference of an attribute

  • joint_child (list[SchemaObjectReference] | None) – list of SchemaObjectReferences of an attributes

  • relationship_type (RelationshipType) – RelationshipType enum object, by default RelationshipType.ONE_TO_MANY

  • table (SchemaObjectReference | None) – SchemaObjectReference of a lookup table, if not passed attribute lookup table is used

Return type:

None

add_fact_expression(form_id, expression)

Add expression to the form. :param form_id: ID of the form to which the expression is to be added, :param expression: the expression that is to be added,

Parameters:
add_form(form=None, name=None, expressions=None, lookup_table=None, description=None, category=None, display_format=None, data_type=None, alias=None, child_forms=None, geographical_role=None, time_role=None, is_form_group=False, is_multilingual=False)

Create new attribute form and add it to the attribute.forms list. The form can be added from completed AttributeForm objects provided in form parameter, or by filling other parameters.

Parameters:
  • form (AttributeForm | None) – complete AttibuteForm object that will be added to the Attribute

  • name (str | None) – The name of the attribute form set by the attribute. Unlike category, which is the systemic name associated with each reusable form, this name is specific to the attribute using this form

  • expressions (list[FactExpression] | None) – Array with a member object for each separately defined expression currently in use by a fact. Often a fact expression takes the form of just a single column name, but more complex expressions are possible.

  • lookup_table (SchemaObjectReference | None) – lookup table of the AttributeForm. It has to be a lookup table used in one of the expressions assigned to AttributeForm

  • description (str | None) – description of the AttributeForm

  • category (str | None) – The category of the attribute form. Unlike name, this field is independent of the attribute using this form. This field can only be set when creating a new form. Once a form is created, its category becomes non-mutable. If not provided (or set as None) when an attribute is being created, a custom category will be automatically generated.

  • display_format (DisplayFormat | None) – display format of the AttributeForm

  • data_type (DataType | None) – Representation in the object model for a data-type that could be used for a SQL column.

  • alias (str | None) – alias of the AttributeForm

  • child_forms (list[FormReference] | None) – only used if ‘is_form_group’ is set to true

  • geographical_role (GeographicalRole | None) – identifies the type of geographical information this form represents

  • time_role (TimeRole | None) – time role of the AttributeForm

  • is_form_group (bool) – A boolean field indicating whether this form is a form group (if true) or a simple form (if false).

  • is_multilingual (bool) – A boolean field indicating whether this field is multilingual. Any key form of the attribute is not allowed to be set as multilingual.

add_parent(parent, relationship_type=RelationshipType.ONE_TO_MANY, table=None)

Add a parent to the attribute.

Parameters:
  • parent (SchemaObjectReference) – SchemaObjectReference of an attribute

  • relationship_type (RelationshipType) – RelationshipType enum object, by default RelationshipType.ONE_TO_MANY

  • table (SchemaObjectReference | None) – SchemaObjectReference of a lookup table, if not passed attribute lookup table is used

Return type:

None

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(sub_type=None, name=None, is_embedded=None, description=None, destination_folder_id=None, forms=None, attribute_lookup_table=None, key_form=None, displays=None, sorts=None, relationships=None, hidden=None, comments=None, owner=None)

Alter attribute properties.

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

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

  • is_embedded (bool | None) – 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.

  • 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.

  • forms (list[AttributeForm] | None) – attribute’s forms list

  • attribute_lookup_table (SchemaObjectReference | None) – Information about an object referenced within the specification of another object. An object reference typically contains only enough fields to uniquely identify the referenced objects.

  • key_form (FormReference | None) – a key form of an attribute

  • displays (AttributeDisplays | None) – The collections of attribute displays and browse displays of the attribute.

  • sorts (AttributeSorts | None) – The collections of attribute sorts and browse sorts of the attribute.

  • relationships (Relationship | None) – the list of relationships that one attribute has.

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

  • comments (str | None) – Long description of the attribute

  • owner (str | User | None) – Owner user for the attribute

  • sub_type (str | None) –

alter_fact_expression(form_id, fact_expression_id, expression=None, tables=None)

Alter fact expression of the attribute form with given ID :param form_id: ID of the form that uses certain expression :param fact_expression_id: ID of the fact expression that is to be altered, :param expression: new expressions of the fact expression :param tables: new tables of the fact expression

Parameters:
alter_form(form_id, name=None, description=None, display_format=None, data_type=None, expressions=None, alias=None, lookup_table=None, child_forms=None, geographical_role=None, time_role=None, is_form_group=None, is_multilingual=None, comments=None)

Alter attribute form with a given form_id.

Parameters:
  • form_id (str) – ID of the attribute form that will be altered

  • name (str | None) – The name of the attribute form set by the attribute. Unlike category, which is the systemic name associated with each reusable form, this name is specific to the attribute using this form

  • description (str | None) – description of the AttributeForm

  • display_format (DisplayFormat | None) – display format of the AttributeForm

  • data_type (DataType | None) – Representation in the object model for a data-type that could be used for a SQL column.

  • expressions (list[FactExpression] | None) – Array with a member object for each separately defined expression currently in use by a fact. Often a fact expression takes the form of just a single column name, but more complex expressions are possible.

  • alias (str | None) – alias of the AttributeForm

  • lookup_table (SchemaObjectReference | None) – lookup table of the AttributeForm. It has to be a lookup table used in one of the expressions assigned to AttributeForm

  • child_forms (list[FormReference] | None) – only used if ‘is_form_group’ is set to true

  • geographical_role (GeographicalRole | None) – identifies the type of geographical information this form represents

  • time_role (TimeRole | None) – time role of the AttributeForm

  • is_form_group (bool | None) – A boolean field indicating whether this form is a form group (if true) or a simple form (if false).

  • is_multilingual (bool | None) – A boolean field indicating whether this field is multilingual. Any key form of the attribute is not allowed to be set as multilingual.

  • comments (str | None) – long description of the AttributeForm

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

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

static check_if_referenced_forms_exist(error_msg, forms, refs)

Check if all references point to a form in forms.

Parameters:
classmethod create(connection, name, sub_type, destination_folder, forms, key_form, displays, description=None, is_embedded=False, attribute_lookup_table=None, sorts=None, show_expression_as=ExpressionFormat.TREE, hidden=None)

Alter attribute properties.

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

  • name (str) – attribute’s name

  • sub_type (ObjectSubType | str) – attribute’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.

  • forms (list[AttributeForm]) – attribute’s forms list

  • key_form (FormReference) – a key form of an attribute

  • displays (AttributeDisplays) – The collections of attribute displays and browse displays of the attribute.

  • description (str | None) – attribute’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.

  • attribute_lookup_table (SchemaObjectReference | None) – Information about an object referenced within the specification of another object. An object reference typically contains only enough fields to uniquely identify the referenced objects.

  • sorts (AttributeSorts | None) – The collections of attribute sorts and browse sorts of the attribute.

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

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

Returns:

Attribute class object.

Return type:

Attribute

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

get_fact_expression(expression_id, form_id=None, form_name=None)

Retrieve a certain fact expression of a local instance of Attribute object.

Parameters:
  • form_id (str) – ID of the attribute form. It have priority over name parameter

  • form_name (str) – name of the attribute form

  • expression_id (str) – ID of the fact expression

Return type:

FactExpression | None

get_form(id=None, name=None)

Retrieve a certain attribute form of a local instance of Attribute object.

Parameters:
  • id (str) – ID of the attribute form. It has priority over name parameter

  • name (str) – name of the attribute form

Return type:

AttributeForm | None

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_relationship_candidates(already_used=True, to_dictionary=True)

Lists potential relationship candidates for the Attribute.

Parameters:
  • already_used (bool) – whether to show Attributes References, which are already parents or children

  • to_dictionary (bool) – whether to return results as a dict or list

Returns:

Dictionary with table names as keys and list of SchemaObjectReferences of the attributes as values if to_dictionary set to True, list of SchemaObjectReference of attributes as list otherwise.

Return type:

dict | list[SchemaObjectReference]

list_tables(expression=None)

List all tables in the given expression. If expression is not specified, list all tables for attribute.

Parameters:

expression (FactExpression | str | None) – the expression for which to list tables

Returns:

List of tables in the given expression or all tables for attribute.

Return type:

list[SchemaObjectReference]

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]

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_child(child=None, joint_child=None)

Removes a child of the attribute.

Parameters:
  • child (SchemaObjectReference | None) – SchemaObjectReference of an attribute to be removed from child relationship

  • joint_child (list[SchemaObjectReference] | None) – list of SchemaObjectReferences of an attributes to be removed from joint child relationship

Return type:

None

remove_fact_expression(form_id, fact_expression_id, new_lookup_table=None)

Remove expression from the form. If the expressions left are not using lookup table assigned to the form, provide new lookup table for the form.

Parameters:
  • form_id (str) – ID of the form from which the expression is to be removed,

  • expression_id – ID of the expression that is to be removed,

  • new_lookup_table (SchemaObjectReference | None) – new lookup table of the form

  • fact_expression_id (str) –

remove_form(form_id, new_key_form=None)

Remove attribute form with a given form_id. If this form was present in displays or sorts, it will be automatically removed from there.

Parameters:
  • form_id (str) – ID of the form that should be removed

  • new_key_form (FormReference | None) – new value of the attribute’s key_form parameter. Mandatory if the form that is to be removed is the current key form, otherwise optional.

remove_parent(parent)

Removes a parent of the attribute.

Parameters:

parent (SchemaObjectReference) – SchemaObjectReference of an attribute to be removed from parent relationship

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

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

static validate_displays(displays, forms)
Validate whether the Attribute Displays are populated correctly and

only use references to forms present in the Attribute Forms of this particular attribute.

Parameters:
Returns:

Validated, non-empty and properly referencing Attribute Displays

Return type:

AttributeDisplays

static validate_key_form(key_form, forms, error_msg=None)
Validate whether the key form exists in the list of attribute forms

provided

Parameters:
  • key_form (FormReference) – a key form of an attribute to perform validation on

  • forms (list[AttributeForm]) – the list of the attribute forms

  • error_msg (optional) – optional message to display instead of the standard one

Returns:

A validated key form.

Return type:

FormReference

static validate_sorts(sorts, forms)
Validate whether the sorts use form references that aren’t present

in the provided forms

Parameters:
  • sorts (AttributeSorts) – the collections of attribute sorts and browse sorts of the attribute

  • forms (list[AttributeForm]) – list of AttributeForm objects of the Attribute

Returns:

Validated sorts or nothing if the provided sorts were empty.

Return type:

AttributeSorts | None

mstrio.modeling.schema.attribute.attribute.list_attributes(connection, name=None, attribute_subtype=None, to_dictionary=False, limit=None, search_pattern=SearchPattern.CONTAINS, project_id=None, project_name=None, show_expression_as=ExpressionFormat.TREE, **filters)

Get list of Attribute objects or dicts with them. Optionally filter attributes by specifying ‘name’, ‘attribute_subtype’.

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 (string, optional) – value the search pattern is set to, which will be applied to the names of attributes being searched

  • attribute_subtype (ObjectSubTypes) – one of attribute subtypes: attribute, attribute_abstract, attribute_recursive, attribute_role, attribute_transformation

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

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

  • 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, str) –

    specify how expressions should be presented Available values:

    • ExpressionFormat.TREE or tree (default)

    • ExpressionFormat.TOKENS or `tokens

  • **filters

    Available filter parameters: id str: Attribute’s ID name str: Attribute’s name description str: Attribute’s description date_created str: format: 2001-01-02T20:48:05.000+0000 date_modified str: format: 2001-01-02T20:48:05.000+0000 version str: Attribute’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 subtype str: object’s subtype ext_type str: object’s extended type

Returns:

list with Attribute objects or list of dictionaries

Return type:

list[Attribute] | list[dict]