mstrio.access_and_security package

Submodules

mstrio.access_and_security.privilege module

class mstrio.access_and_security.privilege.Privilege(connection: Connection, name: str | None = None, id: str | None = None)

Bases: EntityBase

Object representation of MicroStrategy Privilege object.

connection

A MicroStrategy connection object

id

privilege ID

name

privilege name

description

privilege description

categories

privilege category

is_project_level_privilege

specify if privilege is compatible with server configuration level or project level

add_to_user(users: list[typing.Union[ForwardRef('User'), str]]) None

Add privilege to user.

Parameters:

users – list of User objects or names.

add_to_user_group(groups: list[Union[mstrio.users_and_groups.user_group.UserGroup, str]]) None

Add privilege to User Group.

Parameters:

groups – list of UserGroup objects or names.

classmethod list_privileges(connection: Connection, to_dictionary: bool = False, to_dataframe: bool = False, **filters) list[mstrio.access_and_security.privilege.Privilege] | list[dict] | pandas.core.frame.DataFrame

Get list of privilege objects or privilege dicts. Filter the privileges by specifying the filters keyword arguments.

Optionally use to_dictionary or to_dataframe to choose output format.

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

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

  • to_dataframe – If True, returns DataFrame.

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

Examples

>>> Privilege.list_privileges(connection, to_dataframe=True,
>>>                           is_project_level_privilege='True',
>>>                           id=[1,2,3,4,5])
revoke_from_user(users: list[typing.Union[ForwardRef('User'), str]]) None

Revoke privilege from user.

Parameters:

users – list of User objects or names.

revoke_from_user_group(groups: list[Union[mstrio.users_and_groups.user_group.UserGroup, str]]) None

Revoke privilege from User Group.

Parameters:

groups – list of UserGroup objects or names.

class mstrio.access_and_security.privilege.PrivilegeList(connection: Connection)

Bases: object

Class for browsing MSTR privileges.

connection

A MicroStrategy connection object

to_dataframe()

Returns DataFrame with privileges.

to_dict()

Returns list of privileges dicts.

mstrio.access_and_security.privilege_mode module

class mstrio.access_and_security.privilege_mode.PrivilegeMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: AutoUpperName

ALL = 'ALL'
GRANTED = 'GRANTED'
INHERITED = 'INHERITED'

mstrio.access_and_security.security_role module

class mstrio.access_and_security.security_role.SecurityRole(connection: Connection, name: str | None = None, id: str | None = None)

Bases: Entity, DeleteMixin, TranslationMixin

A security role is a set of privileges that can be assigned to users and reused from project to project. Security roles enable you to assign a unique set of privileges to users on a per project basis. They are created and maintained at the project source level and assigned to users at the project level.

connection

A MicroStrategy connection object

id

Security Role ID

name

Security Role name

description

Security Role description

type

Object type

subtype

Object subtype

date_created

Creation time, DateTime object

date_modified

Last modification time, DateTime object

version

Version ID

owner

owner ID and name

privileges

Security Role privileges per project

projects

Project members tuple for the security role

acg

Access rights (See EnumDSSXMLAccessRightFlags for possible values)

acl

Object access control list

alter(name: str | None = None, description: str | None = None, comments: str | None = None)

Alter Security Role name or/and description.

Parameters:
  • name – new name of the Security Role

  • description – new description of the Security Role

  • comments – long description of the Security Role

classmethod create(connection: Connection, name: str, privileges: Union[ForwardRef('Privilege'), int, str]]], description: str = '')

Create a new Security Role.

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

  • name (string) – Name of the Security Role

  • privileges – List of privileges which will be assigned to this security role. Use privilege IDs or Privilege objects.

  • description (string, optional) – Description of the Security Role

Returns:

Newly created Security Role if the HTTP server has successfully

created the Security Role.

grant_privilege(privilege: Union[ForwardRef('Privilege'), int, str]]]) None

Grant new project-level privileges to the Security Role.

Parameters:

privilege – list of privilege objects, ids or names

grant_to(members: Union[UserOrGroup, list['UserOrGroup']], project: Union[Project, str]) None

Assign users/user groups to a Security Role.

Parameters:
  • members (list) – List of objects or IDs of Users or User Groups which will be assigned to this Security Role.

  • project (Project, str) – Project object or name to which this removal will apply.

list_members(project_name: str | None = None)

List all members of the Security Role. Optionally, filter the results by Project name.

Parameters:

project_name (str, optional) – Project name

list_privileges(to_dataframe: bool = False) dict | pandas.core.frame.DataFrame

List ALL privileges for Security Role. Optionally return a DataFrame object.

Parameters:

to_dataframe – If True, return a DataFrame object containing privileges

revoke_all_privileges(force: bool = False) None

Revoke all granted project-level privileges.

Parameters:

force (bool, optional) – If true, overrides the prompt.

revoke_from(members: Union[UserOrGroup, list['UserOrGroup']], project: Union[Project, str]) None

Remove users/user groups from a Security Role.

Parameters:
  • members (list) – List of objects or IDs of Users or User Groups which will be removed from this Security Role.

  • project (Project, str) – Project object or name to which this removal will apply.

revoke_privilege(privilege: Union[ForwardRef('Privilege'), int, str]]]) None

Revoke project-level privileges from the Security Role.

Parameters:

privilege – list of privilege objects, ids or names

mstrio.access_and_security.security_role.list_security_roles(connection: Connection, to_dictionary: bool = False, to_dataframe: bool = False, limit: int | None = None, **filters)

Get all Security Roles stored on the server.

Optionally use to_dictionary or to_dataframe to choose output format.

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

  • to_dictionary (bool, optional) – if True, return Security Roles as list of dicts

  • to_dataframe (bool, optional) – if True, return Security Roles as pandas DataFrame

  • limit (int, optional) – maximum number of security roles returned.

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

Returns:

List of security roles.

Module contents