def list_usergroups(connection: "Connection", name_begins: str = None, to_dictionary: bool = False, limit: int = None, **filters) -> List["UserGroup"]: """Get list of User Group objects or User Group dicts. Optionally filter the User Groups by specifying 'name_begins' or other filters. Optionally use `to_dictionary` or `to_dataframe` to choose output format. If `to_dictionary` is True, `to_dataframe` is omitted. Wildcards available for name_begins: ? - any character * - 0 or more of any characters e.g name_begins = ?onny wil return Sonny and Tonny Args: connection: MicroStrategy connection object returned by `connection.Connection()` name_begins: Begining of a User Groups name which we want to list to_dictionary: If True returns dict, by default (False) returns User Group objects limit: limit the number of elements returned. If `None`, all objects are returned. **filters: Available filter parameters: ['name', 'id', 'type', 'abbreviation', 'description', 'subtype', 'date_created', 'date_modified', 'version', 'acg', 'owner', 'ext_type'] Examples: >>> list_user_groups(connection, name_begins='Group', description='New group') """ deprecation_warning("`list_usergroups` method", "`list_user_groups` method", "11.3.2.101") list_user_groups(connection, name_begins, to_dictionary, limit, **filters)
def last_modified(self): helper.deprecation_warning("`last_modified`", "`date_modified`", "11.3.2.101", module=False) if not self.__info_retrieved: self._get_info() return self._last_modified
def add_to_usergroups(self, groups: Union[str, List[str], "UserGroup", List["UserGroup"]]) -> None: """Add User Group to passed groups. Args: groups: List of User Group objects or ids """ deprecation_warning("`add_to_usergroups` method", "`add_to_user_groups` method", "11.3.2.101") self.add_to_user_groups(groups)
def remove_from_usergroups( self, groups: Union[str, List[str], "UserGroup", List["UserGroup"]]) -> None: """Remove User Group from passed groups Args: groups: List of User Group objects or ids """ deprecation_warning("`remove_from_usergroups` method", "`remove_from_user_groups` method", "11.3.2.101") self.remove_from_user_groups(groups)
def __init__(self, connection: "Connection", id: str = None, cube_id: str = None, name: str = None, instance_id=None, parallel=True, progress_bar=True): """Initialize an instance of a cube by its id. Note: Parameter `name` is not used when fetching. `id` is always used to uniquely identify cube. Args: connection: MicroStrategy connection object returned by `connection.Connection()`. id (str): Identifier of a pre-existing cube containing the required data. cube_id (str): Identifier of a pre-existing cube containing the required data. (deprecated) name (str): Name of a cube. instance_id (str): Identifier of an instance if cube instance has been already initialized, None by default. parallel (bool, optional): If True (default), utilize optimal number of threads to increase the download speed. If False, this feature will be disabled. progress_bar(bool, optional): If True (default), show the download progress bar. """ if cube_id: helper.deprecation_warning("`cube_id`", "`id`", "11.3.2.101", module=False) if cube_id is None and id is None: raise AttributeError( "To properly initialize cube please provide either `id` or `cube_id`." ) id = id if id else cube_id super().__init__(connection, id, name=name, instance_id=instance_id, parallel=parallel, progress_bar=progress_bar, subtype=self._OBJECT_SUBTYPE) connection._validate_application_selected() self._get_definition()
def select_project(self, project_id: str = None, project_name: str = 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. Args: 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 """ deprecation_warning("`select_project` method", "`select_application` method", "11.3.2.101") self.select_application(project_id, project_name)
from typing import Union, List from mstrio.api import objects from mstrio.connection import Connection from mstrio.utils import helper from mstrio.utils.entity import Entity, VldbMixin, ObjectTypes from pandas import DataFrame # NOTE Keep until end of deprecation and move to from mstrio.utils.helper import deprecation_warning deprecation_warning( "mstrio.admin.dataset", ("mstrio.application_objects.datasets.super_cube " "and mstrio.application_objects.datasets.olap_cube"), "11.3.2.101", ) def list_datasets(connection, name: str = None, to_dictionary: bool = False, to_dataframe: bool = False, limit: int = None, **filters): """Get all Datasets stored on the server. Args: connection(object): MicroStrategy connection object returned by 'connection.Connection()' name: exact name of the document to list
from mstrio.server.application import ( # noqa: F401 Application, ApplicationSettings, compare_application_settings, ProjectStatus) from mstrio.server.environment import Environment # noqa: F401 from mstrio.utils.helper import deprecation_warning deprecation_warning("mstrio.admin.application", "mstrio.server.application and mstrio.server.environment", "11.3.2.101")
from mstrio.distribution_services.subscription.delivery import ( # noqa: F401 SendContentAs, Orientation, CacheType, ShortcutCacheFormat, ClientType, DeliveryDictable, ZipSettings, Delivery) from mstrio.utils.helper import deprecation_warning deprecation_warning("mstrio.admin.subscription.delivery", "mstrio.distribution_services.subscription.delivery", "11.3.2.101")
from packaging import version import pandas as pd import time from tqdm.auto import tqdm from mstrio.api import datasets import mstrio.config as config from mstrio.utils.encoder import Encoder from mstrio.utils.helper import deprecation_warning import mstrio.utils.helper as helper from mstrio.utils.model import Model deprecation_warning("mstrio.dataset", "mstrio.application_objects.datasets.super_cube", "11.3.2.101") class Dataset: """Create and update data in MicroStrategy datasets. Iteratively build a dataset with `Dataset.add_table()`. Then, create the dataset using `Dataset.create()`. When updating data in the dataset, add individual tables to the dataset and define how the dataset should be updated on the MicroStrategy server, then call`Dataset.update().` By default `Dataset.update()` will upload the data to the Intelligence Server and publish the dataset. If you just want to _update_ the dataset but not publish the row-level data, use `Dataset.update(auto_publish=False)` followed by `Dataset.publish()`. Attributes: name: Name of the dataset. description: Description given to the dataset.
def dataset_id(self): helper.deprecation_warning("`dataset_id`", "`id`", "11.3.2.101", module=False) return self._dataset_id
from mstrio.application_objects.dossier import ( # noqa: F401 Dossier, list_dossiers, list_dossiers_across_projects) from mstrio.utils.helper import deprecation_warning deprecation_warning("mstrio.admin.dossier", "mstrio.application_objects.dossier", "11.3.2.101")
from mstrio.application_objects.report import Report # noqa: F401 from mstrio.utils.helper import deprecation_warning deprecation_warning("mstrio.report", "mstrio.application_objects.report", "11.3.2.101")
def cube_id(self): helper.deprecation_warning("`cube_id`", "`id`", "11.3.2.101", module=False) return self._id
from mstrio.application_objects.library import Library # noqa: F401 from mstrio.utils.helper import deprecation_warning deprecation_warning("mstrio.library", "mstrio.application_objects.library", "11.3.2.101")
from mstrio.access_and_security.privilege import Privilege, PrivilegeList # noqa: F401 from mstrio.utils.helper import deprecation_warning deprecation_warning("mstrio.admin.privilege", "mstrio.access_and_security.privilege", "11.3.2.101")
from mstrio.server.server import ServerSettings # noqa: F401 from mstrio.server.cluster import Cluster # noqa: F401 from mstrio.utils.helper import deprecation_warning deprecation_warning("mstrio.admin.server", "mstrio.server.server and mstrio.server.cluster", "11.3.2.101")
from mstrio.distribution_services.schedule import ( # noqa: F401 Schedule, ScheduleManager) from mstrio.utils.helper import deprecation_warning deprecation_warning("mstrio.admin.schedule", "mstrio.distribution_services.schedule", "11.3.2.101")
from mstrio.users_and_groups.user_connections import UserConnections # noqa: F401 from mstrio.utils.helper import deprecation_warning deprecation_warning("mstrio.admin.user_connections", "mstrio.users_and_groups.user_connections", "11.3.2.101")
def __init__(self, base_url, username=None, password=None, application_name=None, application_id=None, project_name=None, project_id=None, login_mode=1, ssl_verify=True, certificate_path=None, proxies=None, identity_token=None, verbose=True): """Establish a connection with MicroStrategy REST API. You can establish connection by either providing set of values (`username`, `password`, `login_mode`) or just `identity_token`. When both `application_id` and `application_name` are `None`, application selection is cleared. When both `application_id` and `application_name` are provided, `application_name` is ignored. Args: base_url (str): URL of the MicroStrategy REST API server. Typically of the form: "https://<mstr_env>.com/MicroStrategyLibrary/api" username (str, optional): Username password (str, optional): Password project_name (str, optional): this argument will be deprecated, use application_name instead project_id (str, optional): this argument will be deprecated, use application_id instead application_name (str, optional): Name of the application you intend to connect to (case-sensitive). Provide either Application ID or Application Name. application_id (str, optional): Id of the application you intend to connect to (case-sensitive). Provide either Application ID or Application Name. login_mode (int, optional): Specifies the authentication mode to use. Supported authentication modes are: Standard (1) (default) or LDAP (16) ssl_verify (bool, optional): If True (default), verifies the server's SSL certificates with each request certificate_path (str, optional): Path to SSL certificate file, if None and ssl_verify is True then the certificate will be looked for in current working directory proxies (dict, optional): Dictionary mapping protocol or protocol and host to the URL of the proxy (e.g. {'http': 'foo.bar:3128', 'http://host.name': 'foo.bar:4012'}) identity_token (str, optional): Identity token for delegated session. Used for connection initialized by GUI. verbose (bool, optional): True by default. Controls the amount of feedback from the I-Server. """ # set the verbosity globally config.verbose = True if verbose and config.verbose else False self.base_url = helper.url_check(base_url) self.username = username self.login_mode = login_mode self.certificate_path = certificate_path self.identity_token = identity_token self.session = self.__configure_session(ssl_verify, certificate_path, proxies) self._web_version = None self._iserver_version = None self._user_id = None self._user_full_name = None self._user_initials = None self.__password = password application_id = project_id if project_id else application_id application_name = project_name if project_name else application_name if project_id or project_name: deprecation_warning("`project_id` and `project_name`", "`application_id` or `application_name`", "11.3.2.101") if self.__check_version(): # save the version of IServer in config file config.iserver_version = self.iserver_version # delegate identity token or connect and create new sesssion self.delegate() if self.identity_token else self.connect() self.select_application(application_id=application_id, application_name=application_name) else: print("""This version of mstrio is only supported on MicroStrategy 11.1.0400 or higher. \rCurrent Intelligence Server version: {} \rCurrent MicroStrategy Web version: {} """.format(self.iserver_version, self.web_version)) helper.exception_handler(msg="MicroStrategy Version not supported.", exception_type=exceptions.VersionException)