mstrio > server > server

class mstrio.server.server.HistoryList(connection, id=None, message_id=None, name=None, project_id=None, scope='all_users')

Bases: EntityBase

Class representation of a Strategy history list message.

Parameters:
  • connection (Connection)

  • id (str | None)

  • message_id (str | None)

  • name (str | None)

  • project_id (str | None)

  • scope (str)

connection

A Strategy connection object.

id

History list message ID.

name

Message display name or title.

title

Message title.

display_name

Message display name.

status

Message status.

request_status

Request status.

target_info

Information about the target object.

project_id

Project ID.

project_name

Project name.

owner_id

Message owner ID.

owner_name

Message owner name.

classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)

Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of the objects that should be created.

  • source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

A list of objects of type T.

Return type:

T

classmethod from_dict(source, connection, to_snake_case=True, with_missing_value=False)
Overrides Dictable.from_dict() to instantiate an object from

a dictionary without calling any additional getters.

Parameters:
  • cls – Class (type) of an object that should be created.

  • source (dict[str, Any]) – a dictionary from which an object will be constructed.

  • connection (Connection) – A Strategy Connection object.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case, default True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

An instance of the cls class.

classmethod to_csv(objects, name, path=None, properties=None)

Exports MSTR objects to a csv file.

Optionally, saves only the object properties specified in the properties parameter.

Parameters:
  • objects (T | list[T]) – List of objects of the same type that

  • exported. (will be)

  • name (str) – The name of the csv file ending with ‘.csv’

  • path (Optional[str], optional) – A path to the directory where the file will be saved. Defaults to None.

  • properties (Optional[list[str]], optional) – A list of object’s attribute names that should be included in the exported file. Defaults to None.

Raises:
  • TypeError – If objects is not of type T or list of type T

  • objects. –

Return type:

None

static bulk_send(connection, requests)

Send multiple project-scoped objects to history list.

Return type:

dict

Parameters:
static get_messages_by_ids(connection, message_ids, **kwargs)

Get history list messages by IDs.

Parameters:
  • connection (Connection) – Strategy connection object.

  • message_ids (list[str]) – IDs of history list messages.

  • **kwargs – Parameters accepted by get_history_list_messages_by_ids.

Returns:

list[HistoryList] | list[dict] – List of history list message dictionaries or HistoryList objects.

Return type:

list[HistoryList] | list[dict]

static list_HL_messages(connection, **kwargs)

List history list messages.

Parameters:
  • connection (Connection) – Strategy connection object.

  • **kwargs – Parameters accepted by list_history_list_messages.

Returns:

list[HistoryList] | list[dict] – List of history list message dictionaries or HistoryList objects.

Return type:

list[HistoryList] | list[dict]

static send(connection, object_id, object_type, project_id, message_id=None, display_name=None)

Send a report, document, or dossier to history list.

Return type:

dict

Parameters:
  • connection (Connection)

  • object_id (str)

  • object_type (str)

  • project_id (str)

  • message_id (str | None)

  • display_name (str | None)

static update_messages_status(connection, message_statuses, project_id=None)

Update statuses of history list messages in bulk.

Return type:

dict

Parameters:
  • connection (Connection)

  • message_statuses (list[dict])

  • project_id (str | None)

__init__(connection, id=None, message_id=None, name=None, project_id=None, scope='all_users')

Initialize a history list message by ID or name.

Parameters:
  • connection (Connection) – Strategy connection object.

  • id (str, optional) – History list message ID.

  • message_id (str, optional) – Alias for id.

  • name (str, optional) – Message display name.

  • project_id (str, optional) – Project ID used to scope lookup and message operations.

  • scope (str, optional) – History list retrieval scope used to look up the message. Defaults to all_users.

Return type:

None

alter(display_name)

Alter the history list message display name.

Note

The current admin-rest implementation supports only a replace operation on /displayName. Other patch paths are rejected by the server.

Parameters:

display_name (str) – New display name.

Return type:

None

delete(force=False, remove_others_message=False)

Delete the history list message.

Parameters:
  • force (bool, optional) – If True, do not ask for confirmation.

  • remove_others_message (bool, optional) – Allow removing messages from other users than the requester. Defaults to False.

Returns:

bool – True when the deletion request is sent. False when the confirmation prompt is rejected.

Return type:

bool

fetch()

Fetch history list message details from Strategy.

Return type:

None

list_properties(excluded_properties=None)

Fetch and list all properties of the history list message.

Parameters:

excluded_properties (list[str], optional) – A list of object properties that should be excluded from the returned dictionary.

Returns:

dict – Dictionary with history list message properties.

Return type:

dict

print()

Pretty Print all properties of the object.

Return type:

None

to_dataframe()

Converts all properties of the object to a dataframe.

Returns:

A DataFrame object containing object properties.

Return type:

DataFrame

to_dict(camel_case=True, whitelist_keys=None, skip_private_keys=False)

Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.

Parameters:
  • camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.

  • whitelist_keys (list[str], optional) – List of keys to include in the resulting dictionary. If None, all keys (except hidden ones) are included. Defaults to None.

  • skip_private_keys (bool, optional) – If True, skips private keys in final dict representation.

Returns:

A dictionary representation of object’s attributes and values.

By default, the dictionary keys are in camel case.

Return type:

dict

update_properties()

Save compatible local changes of the object attributes to the I-Server. Changes are retrieved from the self._altered_properties dictionary. After the process of update has finished, self._altered_properties is cleared. For this method to work properly, you must override the _alter_properties() method in a subclass.

Raises:

requests.HTTPError – If I-Server raises exception

Return type:

None

property connection: Connection

An object representation of Strategy connection specific to the object.

property folder_id: str | None
property id: str

The object’s id.

property type: ObjectTypes

The object’s type.

class mstrio.server.server.ServerSettings(connection)

Bases: BaseSettings

Object representation of Strategy I-Server Settings.

Used to fetch, view, modify, update, export to file, import from file and validate Server settings.

The object can be optionally initialized with connection, which will automatically fetch the current I-Server settings. If not specified, settings can be loaded from file using import_from() method. Object attributes (representing settings) can be modified manually. Lastly, the object can be applied to any project using the update() method.

Parameters:

connection (Connection)

settings

settings_value

__init__(connection)

Initialize ServerSettings object.

Parameters:

connection (Connection) – Strategy connection object returned by connection.Connection()

alter(**settings)

Alter settings in a command manager like way.

compare_with_files(files, show_diff_only=False)

Compare the current project settings to settings in file/files :type files: list[str] :param files: List of paths to the settings files. Supported settings

files are JSON, CSV, Pickle. Ex: “/file.csv”

Parameters:
  • show_diff_only (bool, optional) – Whether to display all settings or only different from first project in list.

  • files (str)

Returns:

DataFrame – Dataframe with values of current settings and settings from files.

Return type:

DataFrame

fetch()

Fetch current I-Server settings and update this ServerSettings object.

Return type:

None

import_from(file)

Import project settings from a ‘csv’, ‘json’ or ‘pickle’ file.

Parameters:

file (str) – Path to the file with supported extension type name. Ex: “<path>/file.csv”

Return type:

None

list_properties(show_names=True, show_description=False)

Return settings and their values as dictionary.

Parameters:
  • show_names (bool) – if True, return meaningful setting values, else, return exact setting values

  • show_description (bool) – if True return, description and value for each setting, else, return values only

Return type:

dict

to_csv(name, show_description=False)

Export the current project settings to the csv file.

Parameters:
  • name (str) – Name of file

  • show_description (bool) – if True return, description and value for each setting, else, return values only

Return type:

None

to_dataframe()

Return a DataFrame object containing settings and their values.

Return type:

DataFrame

to_json(name)

Export the current project settings to the json file :type name: str :param name: Name of file :type name: str

Return type:

None

Parameters:

name (str)

to_pickle(name)

Export the current project settings to the pickle file :type name: str :param name: Name of file :type name: str

Return type:

None

Parameters:

name (str)

update()

Update the current I-Server settings using this ServerSettings object.

Return type:

None

property info: None
property setting_types: DataFrame