mstrio.access_and_security.security_filter package

Submodules

mstrio.access_and_security.security_filter.objects_and_references module

class mstrio.access_and_security.security_filter.objects_and_references.AttributeElement(element_id: str, display: str, attribute: Optional[mstrio.access_and_security.security_filter.objects_and_references.AttributeRef] = None)

Bases: mstrio.utils.helper.Dictable

class mstrio.access_and_security.security_filter.objects_and_references.AttributeFormNormalRef(object_id: str, name: Optional[str] = None, is_embedded: Optional[bool] = None)

Bases: mstrio.access_and_security.security_filter.objects_and_references._ObjectReferenceWithType

SUB_TYPE = 'attribute_form_normal'
class mstrio.access_and_security.security_filter.objects_and_references.AttributeFormSystemRef(object_id: str, name: Optional[str] = None, is_embedded: Optional[bool] = None)

Bases: mstrio.access_and_security.security_filter.objects_and_references._ObjectReferenceWithType

SUB_TYPE = 'attribute_form_system'
class mstrio.access_and_security.security_filter.objects_and_references.AttributeRef(object_id: str, name: Optional[str] = None, is_embedded: Optional[bool] = None)

Bases: mstrio.access_and_security.security_filter.objects_and_references._ObjectReferenceWithType

SUB_TYPE = 'attribute'
class mstrio.access_and_security.security_filter.objects_and_references.ElementPromptRef(object_id: str, name: Optional[str] = None, is_embedded: Optional[bool] = None)

Bases: mstrio.access_and_security.security_filter.objects_and_references._ObjectReferenceWithType

SUB_TYPE = 'prompt'
class mstrio.access_and_security.security_filter.objects_and_references.FilterRef(object_id: str, name: Optional[str] = None, is_embedded: Optional[bool] = None)

Bases: mstrio.access_and_security.security_filter.objects_and_references._ObjectReferenceWithType

SUB_TYPE = 'filter'
class mstrio.access_and_security.security_filter.objects_and_references.ObjectInformation(object_id: Optional[str] = None, sub_type: Optional[str] = None, name: Optional[str] = None, is_embedded: Optional[bool] = None, description: Optional[str] = None, date_created: Optional[str] = None, date_modified: Optional[str] = None, destination_folder_id: Optional[str] = None, version_id: Optional[str] = None, path: Optional[str] = None, acl: Optional[dict] = None, primary_locale: Optional[str] = None)

Bases: mstrio.utils.helper.Dictable

An object that contains all of the type-neutral information stored in the metadata about an object.

id

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

Type

string

subtype

string literal used to identify the type of a metadata object.

Type

string

name

the name of the metadata object.

Type

string

is_embedded

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.

Type

boolean

description

user supplied description of this object.

Type

string

date_created

the date/time at which this object was first saved into the metadata.

Type

string

date_modified

the date/time at which this object was last saved into the metadata.

Type

string

destination_folder_id

id of a folder in which the object is stored.

Type

string

version_id

the version number this object is currently carrying.

Type

string

path

the path of this object

Type

string

acl

an array of access control entry objects. Taken together these objects specify which users are permitted to perform which actions on this object.

Type

list of objects

primary

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

Type

string

class mstrio.access_and_security.security_filter.objects_and_references.ObjectReference(object_id: str, sub_type: str, name: Optional[str] = None, is_embedded: Optional[bool] = None)

Bases: mstrio.utils.helper.Dictable

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.

object_id (string): a globally unique identifier used to distinguish between

metadata objects within the same project.

sub_type (string): string literal used to identify the type of a metadata

object

name (string): the name of the metadata object. is_embedded (boolean): 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.

mstrio.access_and_security.security_filter.predicate_parameters module

class mstrio.access_and_security.security_filter.predicate_parameters.ConstantArrayParameter(type: Union[mstrio.access_and_security.security_filter.predicate_parameters.ConstantType, str], values: List[str])

Bases: mstrio.access_and_security.security_filter.predicate_parameters.ParameterBase

TYPE = 'array'
classmethod from_dict(source: Dict[str, Any], connection: Optional[Connection] = None, to_snake_case: bool = True)

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.

Returns

An object of type T.

Return type

T

class mstrio.access_and_security.security_filter.predicate_parameters.ConstantParameter(type: Union[mstrio.access_and_security.security_filter.predicate_parameters.ConstantType, str], value: str)

Bases: mstrio.access_and_security.security_filter.predicate_parameters.ParameterBase

TYPE = 'constant'
classmethod from_dict(source: Dict[str, Any], connection: Optional[Connection] = None)

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.

Returns

An object of type T.

Return type

T

class mstrio.access_and_security.security_filter.predicate_parameters.ConstantType(value)

Bases: mstrio.utils.enum_helper.AutoName

An enumeration.

DATE = 'date'
DOUBLE = 'double'
INT_32 = 'int32'
INT_64 = 'int64'
STRING = 'string'
TIME = 'time'
class mstrio.access_and_security.security_filter.predicate_parameters.DynamicDateTimeParameter(dynamic_date_time: dict)

Bases: mstrio.access_and_security.security_filter.predicate_parameters.ParameterBase

TYPE = 'dynamic_date_time'
class mstrio.access_and_security.security_filter.predicate_parameters.ExpressionParameter(expression: dict)

Bases: mstrio.access_and_security.security_filter.predicate_parameters.ParameterBase

TYPE = 'object_reference'
class mstrio.access_and_security.security_filter.predicate_parameters.ObjectReferenceParameter(target: mstrio.access_and_security.security_filter.objects_and_references.ObjectReference)

Bases: mstrio.access_and_security.security_filter.predicate_parameters.ParameterBase

TYPE = 'object_reference'
class mstrio.access_and_security.security_filter.predicate_parameters.ParameterBase

Bases: mstrio.utils.helper.Dictable

TYPE = None
class mstrio.access_and_security.security_filter.predicate_parameters.ParameterType(value)

Bases: mstrio.utils.enum_helper.AutoName

An enumeration.

ARRAY = 'array'
CONSTANT = 'constant'
DYNAMIC_DATE_TIME = 'dynamic_date_time'
EXPRESSION = 'expression'
OBJECT_REFERENCE = 'object_reference'
PROMPT = 'prompt'
class mstrio.access_and_security.security_filter.predicate_parameters.PromptParameter(prompt: mstrio.access_and_security.security_filter.objects_and_references.ObjectReference)

Bases: mstrio.access_and_security.security_filter.predicate_parameters.ParameterBase

TYPE = 'prompt'

mstrio.access_and_security.security_filter.predicates module

class mstrio.access_and_security.security_filter.predicates.LogicFunction(value)

Bases: mstrio.utils.enum_helper.AutoName

An enumeration.

AND = 'and'
OR = 'or'
class mstrio.access_and_security.security_filter.predicates.LogicOperator(function: mstrio.access_and_security.security_filter.predicates.LogicFunction, children: Union[mstrio.access_and_security.security_filter.predicates.LogicOperator, mstrio.access_and_security.security_filter.predicates.PredicateBase])

Bases: mstrio.utils.helper.Dictable

TYPE = 'operator'
classmethod from_dict(source: Dict[str, Any], connection: Optional[Connection] = None)

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.

Returns

An object of type T.

Return type

T

to_dict(camel_case=True)

Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.

Parameters

camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.

Returns

A dictionary representation of object’s attributes and values.

By default the dictionary keys are in camel case.

Return type

dict

class mstrio.access_and_security.security_filter.predicates.PredicateBase(predicate_id: Optional[str] = None, **kwargs)

Bases: mstrio.utils.helper.Dictable

TYPE = None
to_dict(camel_case=True)

Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.

Parameters

camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.

Returns

A dictionary representation of object’s attributes and values.

By default the dictionary keys are in camel case.

Return type

dict

class mstrio.access_and_security.security_filter.predicates.PredicateElementList(function: mstrio.access_and_security.security_filter.predicates.PredicateElementListFunction, attribute: mstrio.access_and_security.security_filter.objects_and_references.AttributeRef, elements: List[mstrio.access_and_security.security_filter.objects_and_references.AttributeElement], elements_prompt: Optional[List[mstrio.access_and_security.security_filter.objects_and_references.ElementPromptRef]] = None, predicate_id: Optional[str] = None)

Bases: mstrio.access_and_security.security_filter.predicates.PredicateBase

TYPE = 'predicate_element_list'
classmethod from_dict(source: Dict[str, Any], connection: Optional[Connection] = None)

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.

Returns

An object of type T.

Return type

T

class mstrio.access_and_security.security_filter.predicates.PredicateElementListFunction(value)

Bases: enum.Enum

An enumeration.

IN = 'in'
NOT_IN = 'notIn'
class mstrio.access_and_security.security_filter.predicates.PredicateFilter(filter: mstrio.access_and_security.security_filter.objects_and_references.FilterRef, is_independent: Optional[bool] = True, predicate_id: Optional[str] = None)

Bases: mstrio.access_and_security.security_filter.predicates.PredicateBase

TYPE = 'predicate_filter_qualification'
classmethod from_dict(source: Dict[str, Any], connection: Optional[Connection] = None)

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.

Returns

An object of type T.

Return type

T

class mstrio.access_and_security.security_filter.predicates.PredicateForm(function: PredicateFormFunction, parameters: List[ParameterBase], attribute: AttributeRef, form: Union[AttributeFormSystemRef, AttributeFormNormalRef], data_locale: Optional[str] = None, predicate_id: Optional[str] = None)

Bases: mstrio.access_and_security.security_filter.predicates.PredicateBase

TYPE = 'predicate_form_qualification'
classmethod from_dict(source: Dict[str, Any], connection: Optional[Connection] = None)

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.

Returns

An object of type T.

Return type

T

class mstrio.access_and_security.security_filter.predicates.PredicateFormFunction(value)

Bases: mstrio.utils.enum_helper.AutoName

An enumeration.

BEGINS_WITH = 'begins_with'
BETWEEN = 'between'
CONTAINS = 'contains'
EQUALS = 'equals'
GREATER = 'greater'
GREATER_EQUALS = 'greater_equals'
IN = 'in'
IS_NOT_NULL = 'is_not_null'
IS_NULL = 'is_null'
LESS = 'less'
LESS_EQUAL = 'less_equal'
LIKE = 'like'
NOT_BEGINS_WITH = 'not_begins_with'
NOT_BETWEEN = 'not_between'
NOT_CONTAINS = 'not_contains'
NOT_EQUAL = 'not_equals'
NOT_IN = 'not_in'
NOT_LIKE = 'not_like'
class mstrio.access_and_security.security_filter.predicates.PredicateJointElementList(level: List[mstrio.access_and_security.security_filter.objects_and_references.AttributeRef], tuples: List[List[mstrio.access_and_security.security_filter.objects_and_references.AttributeElement]], predicate_id: Optional[str] = None)

Bases: mstrio.access_and_security.security_filter.predicates.PredicateBase

TYPE = 'predicate_joint_element_list'
classmethod from_dict(source: Dict[str, Any], connection: Optional[Connection] = None)

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.

Returns

An object of type T.

Return type

T

mstrio.access_and_security.security_filter.qualification module

class mstrio.access_and_security.security_filter.qualification.Qualification(tree: Union[LogicOperator, PredicateBase], text: Optional[str] = None, tokens: Optional[List[dict]] = None)

Bases: mstrio.utils.helper.Dictable

The security filter definition written as an expression tree over predicate nodes.

We do not attempt to represent the entire filter using expression nodes. Instead we use predicate nodes as leaves of the main tree expression.

Most predicate nodes use a simple data structure. Security filter support five types of predicates, including: PredicateCustomExpression, PredicateJointElementList, PredicateElementList, PredicateForm, PredicateFilter. These simple predicates correspond to the most common qualifications that are used in security filters. It is possible to combine predicates using class LogicOperator.

It is invalid for a security filter expression to contain no nodes.

tree

security filter definition written as an expression tree over predicate nodes

Type

dict

text

human readable description of the expression. It is generated from the current specification of the expression. This string will appear similar to a parsable description of the expression in the current user’s locale. It is intended to be used to allow a user to easily distinguish between expressions. But this string cannot actually be used as input to a parser session because it does not contain hidden information about ambiguities in the parse text. Since this representation is not able to fully describe an expression, there is no point in the client ever sending it to the service.

Type

string

tokens

optional array, used if the expression is to be presented as a stream of tokens. When this representation is used by the service we would expect that the tokens would either completely parse the expression, or would describe an error in the parsing. When this representation is used by the client the tokens would either correspond to fresh text from the user (a client token) or to parts of the text that the user has not edited (a parsed token).

Type

array of dicts

classmethod from_dict(source: Dict[str, Any], connection: Optional[Connection] = None)

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.

Returns

An object of type T.

Return type

T

mstrio.access_and_security.security_filter.security_filter module

class mstrio.access_and_security.security_filter.security_filter.SecurityFilter(connection: Connection, id: str, name: Optional[str] = None)

Bases: mstrio.utils.entity.Entity, mstrio.utils.entity.CopyMixin, mstrio.utils.entity.MoveMixin, mstrio.utils.entity.DeleteMixin

alter(qualification: Optional[Union[mstrio.access_and_security.security_filter.qualification.Qualification, dict]] = None, top_level: Union[List[dict], List[mstrio.access_and_security.security_filter.objects_and_references.AttributeRef]] = [], bottom_level: Union[List[dict], List[mstrio.access_and_security.security_filter.objects_and_references.AttributeRef]] = [], name: Optional[str] = None, description: Optional[str] = None, folder_id: Optional[str] = None)

Alter the security filter object in the metadata. It is possible to change its qualification, top level, bottom level, name, description or destination folder.

Parameters
  • qualification (object or dict) – optional new security filter definition written as an expression tree over predicate nodes. It can be provided as Qualification object or dictionary.

  • top_level (list of objects or list of dicts) – the top level attribute list.

  • bottom_level (list of objects or list of dicts) – the bottom level attribute list.

  • name (str) – optional new name of security filter top_level (list of object): the top level attribute list.

  • description (str) – optional new description of security filter

  • folder_id (str) – id of folder to which security filter will be moved

apply(users_and_groups: Union[UserOrGroup, List[UserOrGroup]] = []) bool

Apply security filter to user(s) and/or user group(s).

Parameters
  • users_and_groups (string, object, list of strings or objects) – list

  • groups (or a single element specifying to which users and user) –

  • whole (security filter will be applied. It is possible to provide the) –

  • object (providing a list it can contain User) –

  • object

  • id (s) –

Returns

True when applying was successful. False otherwise.

classmethod create(connection: Connection, qualification: Union[Qualification, dict], name: str, folder_id: str, description: str = None, top_level: Union[List[dict], List[AttributeRef]] = [], bottom_level: Union[List[dict], List[AttributeRef]] = []) SecurityFilter

Create a security filter by providing its qualification, name and id of folder in which it will be created. Optionally it is possible to set description, top level and bottom level of security filter.

Parameters
  • connection – MicroStrategy connection object returned by connection.Connection().

  • qualification (object or dict) – new security filter definition written as an expression tree over predicate nodes. It can be provided as Qualification object or dictionary.

  • name (str) – name of new security filter

  • folder_id (str) – id of folder in which new security filter will be created

  • description (str) – optional description of new security filter

  • top_level (list of objects or list of dicts) – the top level attribute list.

  • bottom_level (list of object or list of dicts) – the bottom level attribute list.

fetch(attr: Optional[str] = None, fetch_definition: bool = True, fetch_members: bool = True) None

Fetch the latest security filter state from the I-Server. Additionally fetch its definition and members.

Note

This method can overwrite local changes made to the object.

Parameters
  • attr (str, optional) – Attribute name to be fetched.

  • fetch_definition (bool, optional) – flag which indicates whether definition of security filter is fetched. By default True.

  • fetch_members (bool, optional) – flag which indicates whether members of security filter is fetched. By default True.

Raises

ValueError – if attr cannot be fetched.

revoke(users_and_groups: Union[UserOrGroup, List[UserOrGroup]] = []) bool

Revoke security filter from user(s) and/or user group(s).

Parameters
  • users_and_groups (string, object, list of strings or objects) – list

  • groups (or a single element specifying from which users and user) –

  • whole (security filter will be revoked. It is possible to provide the) –

  • object (providing a list it can contain User) –

  • object

  • id (s) –

Returns

True when revoking was successful. False otherwise.

mstrio.access_and_security.security_filter.security_filter.list_security_filters(connection: Connection, to_dictionary: bool = False, name: Optional[str] = None, search_pattern: Union[mstrio.object_management.search_enums.SearchPattern, int] = SearchPattern.CONTAINS, limit: Optional[int] = None, project_id: Optional[str] = None, user: Optional[Union[User, str]] = None, user_group: Optional[Union[str, UserGroup]] = None, **filters) Union[List[SecurityFilter], List[dict]]

Get list of security filter objects or security filter dicts for the project specified in the connection object. It can be filtered by user or user group.

Note: It is not possible to provide both user and user_group parameter.

When both arguments are provided error is raised.

Parameters
  • connection – MicroStrategy connection object returned by connection.Connection()

  • to_dictionary – If True returns dict, by default (False) returns SecurityFilter objects.

  • name (string, optional) – value the search pattern is set to, which will be applied to the names of security filters being searched

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

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

  • project_id (string, optional) – Project ID

  • user (str or object, optional) – Id of user or User object used to filter security filters

  • user_group (str or object, optional) – Id of user group or UserGroup object used to filter security filters

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

Returns

list of security filter objects or list of security filter dicts.

Module contents