mstrio.access_and_security package

Subpackages

Submodules

mstrio.access_and_security.privilege module

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

Bases: mstrio.utils.entity.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[Union[mstrio.users_and_groups.user.User, str]]) None

Add privilege to user.

Parameters

users – list of User objects or names.

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

Add privilege to User Group.

Parameters

groups – list of UserGroup objects or names.

classmethod list_privileges(connection: mstrio.connection.Connection, to_dictionary: bool = False, to_dataframe: bool = False, **filters) Union[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’, ‘categories’, ‘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[Union[mstrio.users_and_groups.user.User, str]]) None

Revoke privilege from user.

Parameters

users – list of User objects or names.

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

Revoke privilege from User Group.

Parameters

groups – list of UserGroup objects or names.

class mstrio.access_and_security.privilege.PrivilegeList(connection: mstrio.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)

Bases: mstrio.utils.enum_helper.AutoUpperName

An enumeration.

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

mstrio.access_and_security.security_role module

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

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

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: Optional[str] = None, description: Optional[str] = None)

Alter Security Role name or/and description.

Parameters
  • name – new name of the Security Role

  • description – new description of the Security Role

classmethod create(connection: mstrio.connection.Connection, name: str, privileges: Union[Privilege, int, str, List[Union[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[Privilege, int, str, List[Union[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: Optional[str] = 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) Union[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[Privilege, int, str, List[Union[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: mstrio.connection.Connection, to_dictionary: bool = False, to_dataframe: bool = False, limit: Optional[int] = 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