mstrio package

Subpackages

Submodules

mstrio.config module

mstrio.config.custom_formatwarning(msg, category, *args, **kwargs)
mstrio.config.get_logging_level() int

Calculate and return logging level to configure logger.

mstrio.config.toggle_debug_mode() None

Toggle debug mode between INFO and DEBUG. It will change root logger’s logging level.

mstrio.connection module

class mstrio.connection.Connection(base_url: str, username: str | None = None, password: str | None = None, project_name: str | None = None, project_id: str | None = None, login_mode: int = 1, ssl_verify: bool = True, certificate_path: str | None = None, proxies: dict | None = None, identity_token: str | None = None, verbose: bool = True)

Bases: object

Connect to and interact with the MicroStrategy environment.

Creates a connection object which is used in subsequent requests and manages the user’s connection with the MicroStrategy REST and Intelligence Servers. The connection is automatically renewed, or reconnected if server’s session associated with the connection expires due to inactivity.

Examples

>>> from mstrio import connection
>>>
>>> # connect to the environment and chosen project
>>> conn = connection.Connection(
>>>     base_url="https://demo.microstrategy.com/MicroStrategyLibrary",
>>>     username="username",
>>>     password="password",
>>>     project_name="MicroStrategy Tutorial"
>>> )
>>> # disconnect
>>> conn.close()
base_url

URL of the MicroStrategy REST API server.

username

Username.

project_name

Name of the connected MicroStrategy Project.

project_id

Id of the connected MicroStrategy Project.

login_mode

Authentication mode. Standard = 1 (default) or LDAP = 16.

ssl_verify

If True (default), verifies the server’s SSL certificates with each request.

user_id

Id of the authenticated user

user_full_name

Full name of the authenticated user

user_initials

Initials of the authenticated user

iserver_version

Version of the I-Server

web_version

Version of the Web Server

token

authentication token

timeout

time after the server’s session expires, in seconds

close()

Closes a connection with MicroStrategy REST API.

connect() None

Authenticates the user and creates a new connection with the Intelligence Server.

If an active connection is detected, the session is renewed.

delegate()

Delegates identity token to get authentication token and connect to MicroStrategy Intelligence Server.

delete(url=None, *, endpoint=None, **kwargs)

Sends a DELETE request.

get(url=None, *, endpoint=None, **kwargs)

Sends a GET request.

get_identity_token() str

Create new identity token using existing authentication token.

head(url=None, *, endpoint=None, **kwargs)

Sends a HEAD request.

patch(url=None, *, endpoint=None, **kwargs)

Sends a PATCH request.

post(url=None, *, endpoint=None, **kwargs)

Sends a POST request.

put(url=None, *, endpoint=None, **kwargs)

Sends a PUT request.

renew() None

Authenticates the user and creates a new connection with the Intelligence Server.

If an active connection is detected, the session is renewed.

select_project(project_id: str | None = None, project_name: str | None = None) None

Select project for the given connection based on project_id or project_name.

When both project_id and project_name are None, project selection is cleared. When both project_id and project_name are provided, project_name is ignored.

Parameters:
  • project_id – id of project to select

  • project_name – name of project to select

Raises:

ValueError – if project with given id or name does not exist

status() bool

Checks if the session is still alive.

Raises:

HTTPError if I-Server behaves unexpectedly

validate_identity_token() bool

Validate the identity token.

mstrio.connection.get_connection(workstation_data: dict, project_name: str | None = None, project_id: str | None = None, ssl_verify: bool = False) mstrio.connection.Connection | None

Connect to environment without providing user’s credentials.

It is possible to provide project_id or project_name to select project. When both project_id and project_name are None, project selection is cleared. When both project_id and project_name are provided, project_name is ignored. Project can be also selected later by calling method select_project on Connection object.

Note

ssl_verify is set to False by default just for the get_connection function as it is designed for usage inside Workstation. When ssl_verify is set to False, warning about missing certificate verification (InsecureRequestWarning) is disabled.

Parameters:
  • workstation_data (object) – object which is stored in a ‘workstationData’ variable within Workstation

  • project_name (str, optional) – name of project (aka project) to select

  • project_id (str, optional) – id of project (aka project) to select

  • ssl_verify (bool, optional) – If False (default), does not verify the server’s SSL certificates

Returns:

connection to I-Server or None is case of some error

mstrio.helpers module

class mstrio.helpers.AggregatedRights(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntFlag

Enumeration constants used to specify combination of Rights values.

ALL = 255
CONSUME = 69
MODIFY = 221
NONE = 0
VIEW = 197
exception mstrio.helpers.IServerError(message, http_code)

Bases: OSError

exception mstrio.helpers.IServerException

Bases: Exception

exception mstrio.helpers.MstrException(err_data: dict)

Bases: Exception

Base class for exceptions returned by the MicroStrategy REST API.

code

Error code

message

Error message

ticket_id

MSTR Ticket ID

exception mstrio.helpers.MstrTimeoutError(err_data: dict)

Bases: MstrException

exception mstrio.helpers.NotSupportedError

Bases: Exception

exception mstrio.helpers.PartialSuccess(data: list[dict])

Bases: Exception

This error holds details about the requested operation.

succeeded

list of succeeded operations dict elements

failed

list of failed operations dict elements

class mstrio.helpers.Permissions(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enumeration constants used to specify combination of Rights values similar to workstation Security Access.

This has to be string-based to discern between ‘Denied All’ and ‘Full Control’, which have the same mask.

CONSUME = 'Consume'
DEFAULT_ALL = 'Default All'
DENIED_ALL = 'Denied All'
FULL_CONTROL = 'Full Control'
MODIFY = 'Modify'
VIEW = 'View'
exception mstrio.helpers.PromptedContentError

Bases: Exception

class mstrio.helpers.Rights(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntFlag

“Enumeration constants used to specify the access granted attribute of the DSS objects.

BROWSE = 1
CONTROL = 32
DELETE = 16
EXECUTE = 128
INHERITABLE = 536870912
READ = 4
USE = 64
USE_EXECUTE = 2
WRITE = 8
exception mstrio.helpers.Success(data: list[dict])

Bases: Exception

This error holds details about the requested operation.

succeeded

list of succeeded operations dict elements

exception mstrio.helpers.VersionException

Bases: Exception

mstrio.types module

class mstrio.types.ExtendedType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

CUSTOM_SQL_FREE_FORM = 3
CUSTOM_SQL_WIZARD = 4
DATA_IMPORT_CUSTOM_SQL = 304
DATA_IMPORT_CUSTOM_SQL_WIZARD = 352
DATA_IMPORT_FILE_EXCEL = 272
DATA_IMPORT_FILE_TEXT = 288
DATA_IMPORT_GENERAL = 256
DATA_IMPORT_OAUTH = 336
DATA_IMPORT_OAUTH_DROPBOX = 339
DATA_IMPORT_OAUTH_GDRIVE = 338
DATA_IMPORT_OAUTH_SFDC = 337
DATA_IMPORT_SPARK = 416
DATA_IMPORT_TABLE = 320
MDX = 2
RELATIONAL = 1
RESERVED = 0
class mstrio.types.ObjectSubTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

ATTRIBUTE = 3072
ATTRIBUTE_ABSTRACT = 3075
ATTRIBUTE_FORM = 5376
ATTRIBUTE_RECURSIVE = 3076
ATTRIBUTE_ROLE = 3073
ATTRIBUTE_TRANSFORMATION = 3074
FILTER = 256
FUNCTION = 2816
FUNCTION_PACKAGE_DEFINITION = 10752
INCREMENTAL_REFRESH_REPORT = 777
MD_SECURITY_FILTER = 14848
NOT_SUPPORTED = None
OLAP_CUBE = 776
REPORT_ENGINE = 770
REPORT_GRAPH = 769
REPORT_GRID = 768
REPORT_GRID_AND_GRAPH = 774
REPORT_HYPER_CARD = 781
REPORT_TRANSACTION = 778
REPORT_WRITING_DOCUMENT = 14081
ROLE_TRANSFORMATION = 11009
SEARCH = 9984
SUPER_CUBE = 779
USER = 8704
USER_GROUP = 8705
class mstrio.types.ObjectTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

AGG_METRIC = 7
ATTRIBUTE = 12
ATTRIBUTE_FORM = 21
COLUMN = 26
CONFIGURATION = 36
CONSOLIDATION = 47
DBCONNECTION = 31
DBLOGIN = 30
DBMS = 57
DBROLE = 29
DBTABLE = 53
DIMENSION = 14
DOCUMENT_DEFINITION = 55
DRILL_MAP = 56
DRIVER = 84
FACT = 13
FILTER = 1
FOLDER = 8
FUNCTION = 11
LOCALE = 45
METRIC = 4
MONITOR = 20
NOT_SUPPORTED = None
PROJECT = 32
PROMPT = 10
PROPERTY_SET = 28
REPORT_DEFINITION = 3
ROLE = 43
SCHEDULE_EVENT = 49
SCHEDULE_OBJECT = 50
SCHEDULE_TRIGGER = 51
SEARCH = 39
SECURITY_FILTER = 58
SECURITY_ROLE = 44
SHORTCUT = 67
SHORTCUT_TARGET = 68
SHORTCUT_TYPE = 18
SUBSCRIPTION_DEVICE = 9
SUBSCRIPTION_TRANSMITTER = 35
TABLE = 15
USER = 34
USERGROUP = 34
static contains(item)

Module contents

mstrio: Simple and Secure Access to MicroStrategy Data

Mstrio provides a high-level interface for Python and is designed to give data scientists, developers, and administrators simple and secure access to their MicroStrategy environment.

It wraps MicroStrategy REST APIs into simple workflows, allowing users to fetch data from cubes and reports, create new datasets, add new data to existing datasets, and manage Users/User Groups, Servers, Projects, and more. Since it enforces MicroStrategy’s user and object security model, you don’t need to worry about setting up separate security rules.

With mstrio-py for data science, it’s easy to integrate cross-departmental, trustworthy business data in machine learning workflows and enable decision-makers to take action on predictive insights in MicroStrategy Reports, Dossiers, HyperIntelligence Cards, and customized, embedded analytical applications.

With mstrio-py for system administration, it’s easy to minimize costs by automating critical, time-consuming administrative tasks, even enabling administrators to leverage the power of Python to address complex administrative workflows for maintaining a MicroStrategy environment.

MicroStrategy for Jupyter is an extension for Jupyter Notebook which provides a graphical user interface for mstrio-py methods with the help of which user can perform all of the import and export actions without writing a single line of code manually. MicroStrategy for Jupyter is contained within mstrio-py package and is available after installation and enabling as Jupyter extension.