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 Strategy One environment.

Creates a connection object which is used in subsequent requests and manages the user’s connection with the Strategy One 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 Strategy One REST API server.

username

Username.

project_name

Name of the connected Strategy One Project.

project_id

Id of the connected Strategy One 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 Strategy One 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 Strategy One 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 Strategy One 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

APPLICATION = 19968
APPLICATION_EXCEL = 19970
APPLICATION_POWERPOINT = 19969
APPLICATION_TABLEAU = 19972
APPLICATION_TEAMS = 19971
ATTRIBUTE = 3072
ATTRIBUTE_ABSTRACT = 3075
ATTRIBUTE_DERIVED = 3077
ATTRIBUTE_FORM = 5376
ATTRIBUTE_FORM_NORMAL = 5378
ATTRIBUTE_FORM_SYSTEM = 5377
ATTRIBUTE_RECURSIVE = 3076
ATTRIBUTE_ROLE = 3073
ATTRIBUTE_SMART = 3078
ATTRIBUTE_TRANSFORMATION = 3074
BLOB_EXCEL = 16132
BLOB_HTML_TEMPLATE = 16133
BLOB_IMAGE = 16130
BLOB_OTHER = 16129
BLOB_PROJECT_PACKAGE = 16131
BLOB_UNKNOWN = 16128
CALENDAR_CUSTOM = 20737
CALENDAR_SYSTEM = 20736
CATALOG = 6144
CATALOG_DEFINITION = 6400
CHANGE_JOURNAL = 16896
COLUMN = 6656
COMMAND_MANAGER_SCRIPT = 19456
CONFIGURATION = 9216
CONSOLIDATION = 12032
CONSOLIDATION_ELEMENT = 12288
CONSOLIDATION_MANAGED = 12033
CUSTOM_GROUP = 257
CUSTOM_PALETTE = 17921
DASHBOARD_TEMPLATE = 16384
DATAMART = 10496
DATAMART_REPORT = 4096
DATASOURCE_SCRIPT = 19459
DBMS = 14592
DB_CONNECTION = 7936
DB_LOGIN = 7680
DB_ROLE = 7424
DB_ROLE_DATA_IMPORT = 7425
DB_ROLE_GENERIC_DATA_CONNECTOR = 7430
DB_ROLE_OAUTH = 7427
DB_TABLE = 13568
DB_TABLE_PMT = 13569
DEVICE = 2304
DIMENSION_ORDERED = 3586
DIMENSION_SYSTEM = 3584
DIMENSION_USER = 3585
DIMENSION_USER_HIERARCHY = 3587
DOCUMENT_BOT = 14084
DOCUMENT_DEFINITION = 14080
DOCUMENT_THEME = 14082
DRILL_MAP = 14336
EXTERNAL_SHORTCUT_SNAPSHOT = 17154
EXTERNAL_SHORTCUT_TARGET = 17408
EXTERNAL_SHORTCUT_UNKNOWN = 17152
EXTERNAL_SHORTCUT_URL = 17153
FACT = 3328
FACT_GROUP = 4352
FILTER = 256
FLAG = 16640
FOLDER = 2048
FORMAT = 5888
FUNCTION = 2816
FUNCTION_PACKAGE_DEFINITION = 10752
GRAPH_STYLE = 15616
IAM_SECRET_VAULT = 21002
INBOX = 11520
INBOX_MESSAGE = 11776
INCREMENTAL_REFRESH_REPORT = 777
INTERFACE_LANGUAGE_CUSTOM = 21761
INTERFACE_LANGUAGE_SYSTEM = 21760
JUPYTER_NOTEBOOK_SCRIPT = 19458
MD_SECURITY_FILTER = 14848
METRIC = 1024
METRIC_AGG = 1792
METRIC_DMX = 1027
METRIC_TRAINING = 1028
MONITOR_DB_CONNECTIONS = 15107
MONITOR_JOBS = 15105
MONITOR_PERFORMANCE = 15104
MONITOR_USER_CONNECTIONS = 15106
NOT_SUPPORTED = None
NUGGETS_FILE = 23040
OLAP_CUBE = 776
PROJECT = 8192
PROMPT = 2560
PROMPT_ANSWER = 15232
PROMPT_ANSWERS = 15360
PROMPT_ANSWER_BIG_DECIMAL = 15243
PROMPT_ANSWER_BOOLEAN = 15233
PROMPT_ANSWER_DATE = 15237
PROMPT_ANSWER_DIMTY = 15242
PROMPT_ANSWER_DOUBLE = 15236
PROMPT_ANSWER_ELEMENTS = 15239
PROMPT_ANSWER_EXPRESSION = 15240
PROMPT_ANSWER_EXPRESSION_DRAFT = 15241
PROMPT_ANSWER_INT64 = 15244
PROMPT_ANSWER_LONG = 15234
PROMPT_ANSWER_OBJECTS = 15238
PROMPT_ANSWER_STRING = 15235
PROMPT_BIG_DECIMAL = 2571
PROMPT_BOOLEAN = 2561
PROMPT_DATE = 2565
PROMPT_DIMTY = 2570
PROMPT_DOUBLE = 2564
PROMPT_ELEMENTS = 2567
PROMPT_EXPRESSION = 2568
PROMPT_EXPRESSION_DRAFT = 2569
PROMPT_LONG = 2562
PROMPT_OBJECTS = 2566
PROMPT_STRING = 2563
PROPERTY_GROUP = 6912
PROPERTY_SET = 7168
RECONCILIATION = 17664
REPORT_BASE = 773
REPORT_DATAMART = 772
REPORT_ENGINE = 770
REPORT_GRAPH = 769
REPORT_GRID = 768
REPORT_GRID_AND_GRAPH = 774
REPORT_HYPER_CARD = 781
REPORT_NON_INTERACTIVE = 775
REPORT_TEXT = 771
REPORT_TRANSACTION = 778
REPORT_WRITING_DOCUMENT = 14081
REQUEST = 9472
RESOLUTION = 4864
ROLE = 11008
ROLE_TRANSFORMATION = 11009
SCHEDULE_EVENT = 12544
SCHEDULE_OBJECT = 12800
SCHEDULE_TRIGGER = 13056
SCHEMA = 5632
SCRIPT = 19457
SEARCH = 9984
SEARCH_FOLDER = 10240
SECURITY_ROLE = 11264
SERVER_DEFINITION = 8448
STREAM_CHANNEL = 23552
STYLE = 1536
SUBER_CUBE_IRR = 780
SUBSCRIPTION_ADDRESS = 65281
SUBSCRIPTION_CONTACT = 65282
SUBSCRIPTION_INSTANCE = 65283
SUBTOTAL_DEFINITION = 1025
SUPER_CUBE = 779
SYSTEM_PALETTE = 17920
SYSTEM_SUBTOTAL = 1026
TABLE = 3840
TABLE_PARTITION_MD = 3841
TABLE_PARTITION_WH = 3842
TABLE_SOURCE = 13824
TEMPLATE = 512
THRESHOLDS = 18432
TIMEZONE_CUSTOM = 20225
TIMEZONE_SYSTEM = 20224
TRANSACTION_SCRIPT = 19460
TRANSMITTER = 8705
USER = 8704
USER_GROUP = 8705
WORKFLOW = 22016
class mstrio.types.ObjectTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

AGG_METRIC = 7
APPLICATION = 78
ATTRIBUTE = 12
ATTRIBUTE_FORM = 21
AUTO_STYLE = 6
BLOB = 63
CALENDAR = 81
CATALOG = 24
CATALOG_DEFINITION = 25
CHANGE_JOURNAL = 66
COLUMN = 26
CONFIGURATION = 36
CONSOLIDATION = 47
CONSOLIDATION_ELEMENT = 48
CONTENT_BUNDLE = 77
DASHBOARD_PERSONAL_VIEW = 73
DATAMART = 41
DATAMART_REPORT = 16
DBCONNECTION = 31
DBLOGIN = 30
DBMS = 57
DBROLE = 29
DBTABLE = 53
DIMENSION = 14
DOCUMENT_DEFINITION = 55
DRILL_MAP = 56
DRIVER = 84
FACT = 13
FACT_GROUP = 17
FEATURE_FLAG = 74
FILTER = 1
FOLDER = 8
FORMAT = 23
FUNCTION = 11
GRAPH_STYLE = 61
IAM = 82
INTERFACE_LANGUAGE = 85
KPI_WATCHER = 83
LAYER = 70
LOCALE = 45
METRIC = 4
MONITOR = 20
NOT_SUPPORTED = None
OBJECT_TAG = 65
PACKAGE_DEFINITION = 42
PALETTE = 71
PROJECT = 32
PROMPT = 10
PROMPT_ANSWER = 59
PROMPT_ANSWERS = 60
PROPERTY_SET = 28
RECONCILIATION = 69
REPORT_DEFINITION = 3
REQUEST = 37
RESOLUTION = 19
ROLE = 43
RUNTIME = 80
SCHEDULE_EVENT = 49
SCHEDULE_OBJECT = 50
SCHEDULE_TRIGGER = 51
SCHEMA = 22
SCRIPT = 76
SEARCH = 39
SEARCH_FOLDER = 40
SECURITY_FILTER = 58
SECURITY_ROLE = 44
SERVER_DEFINITION = 33
SHORTCUT = 67
SHORTCUT_TARGET = 68
SHORTCUT_TYPE = 18
SUBSCRIPTION_DEVICE = 9
SUBSCRIPTION_TRANSMITTER = 35
TABLE = 15
TABLE_SOURCE = 54
TEMPLATE = 2
THRESHOLDS = 72
TIMEZONE = 79
USER = 34
USERGROUP = 34
WORKFLOW = 86
static contains(item)
get_subtypes()

Module contents

mstrio: Simple and Secure Access to Strategy One 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 Strategy One environment.

It wraps Strategy One 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 Strategy One’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 Strategy One Reports, Dashboards, 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 Strategy One environment.