mstrio > server > lock

class mstrio.server.lock.BaseLock(connection)

Bases: object

Parameters:

connection (Connection)

fetch()

Fetch the lock status of the target.

lock(lock_type, lock_id=None)

Lock the target.

Parameters:
  • lock_type (str, LockType) – Lock type.

  • lock_id (str, optional) – Lock ID. Will be generated if not provided.

Return type:

None

unlock(lock_type=None, lock_id=None, force=False)

Unlock the target.

Parameters:
  • lock_type (str, LockType, optional) – Lock type. Optional only if force is set to True.

  • lock_id (str, optional) – Lock ID.

  • force (bool, optional) – If True, will force-unlock the target.

Return type:

None

connection: Connection
property lock_id: str | None

Lock ID of the target.

property status: LockStatus

Lock status of the target.

class mstrio.server.lock.ConfigurationLock(connection)

Bases: BaseLock

Parameters:

connection (Connection)

fetch()

Fetch the lock status of the target.

lock(lock_type, lock_id=None)

Lock the target.

Parameters:
  • lock_type (str, LockType) – Lock type.

  • lock_id (str, optional) – Lock ID. Will be generated if not provided.

Return type:

None

unlock(lock_type=None, lock_id=None, force=False)

Unlock the target.

Parameters:
  • lock_type (str, LockType, optional) – Lock type. Optional only if force is set to True.

  • lock_id (str, optional) – Lock ID.

  • force (bool, optional) – If True, will force-unlock the target.

Return type:

None

connection: Connection
property lock_id: str | None

Lock ID of the target.

property status: LockStatus

Lock status of the target.

class mstrio.server.lock.LockStatus(lock_type, lock_time=None, comment=None, machine_name=None, owner=None)

Bases: Dictable

Object representation of lock status (configuration, project).

Parameters:
  • lock_type (LockType)

  • lock_time (datetime | None)

  • comment (str | None)

  • machine_name (str | None)

  • owner (User | None)

lock_type

Lock type

lock_time

Lock time

comment

Lock comment

machine_name

Machine name

owner

User object

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=None, to_snake_case=True, with_missing_value=False)

Creates an object from a dictionary. The dictionary’s 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 _FROM_DICT_MAP.

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

  • source (Dict[str, Any]) – A dictionary from which an object 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:

An object of type T.

Return type:

T

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

comment: str | None = None
lock_time: datetime | None = None
lock_type: LockType
machine_name: str | None = None
owner: User | None = None
enum mstrio.server.lock.LockType(value)

Bases: AutoName

Enum representing the type of lock applied to a target (project or configuration).

TEMPORAL_INDIVIDUAL: A temporary lock that restricts all other sessions

except the current user’s session from editing the project or configuration. It does not affect objects. This lock disappears when the user’s session expires.

TEMPORAL_CONSTITUENT: A temporary lock that restricts all other sessions

except the current user’s session from editing the project or configuration and all related objects. This lock disappears when the user’s session expires.

PERMANENT_INDIVIDUAL: A permanent lock that prevents all users from

editing the project or configuration. It does not affect objects. This lock does not expire and must be removed before the project or configuration can be edited again.

PERMANENT_CONSTITUENT: A permanent lock that prevents all users from

editing the project or configuration and all related objects. This lock does not expire and must be removed before the affected scope can be edited again.

NOT_LOCKED: Represents the state where the target is not locked

and can be edited by users.

Valid values are as follows:

TEMPORAL_INDIVIDUAL = LockType.TEMPORAL_INDIVIDUAL
TEMPORAL_CONSTITUENT = LockType.TEMPORAL_CONSTITUENT
PERMANENT_INDIVIDUAL = LockType.PERMANENT_INDIVIDUAL
PERMANENT_CONSTITUENT = LockType.PERMANENT_CONSTITUENT
NOT_LOCKED = LockType.NOT_LOCKED

The Enum and its members also have the following methods:

classmethod has_value(value)