mstrio > project_objects > prompt

class mstrio.project_objects.prompt.Prompt(type, answers, key=None, id=None, name=None, use_default=False)

Bases: Dictable

A Strategy One class representing a prompt.

Parameters:
  • type (str) –

  • answers (Any | list[Any]) –

  • key (str | None) –

  • id (str | None) –

  • name (str | None) –

  • use_default (bool) –

type

Type of the prompt Possible values are:

  • UNSUPPORTED

  • VALUE

  • ELEMENTS

  • EXPRESSION

  • OBJECTS

  • LEVEL

Type:

str

answers

Singular answer or list of answers to the prompt.

Type:

Any | list[Any]

key

Unique key of the prompt.

Type:

str, optional

id

ID of the prompt.

Type:

str, optional

name

Name of the prompt.

Type:

str, optional

use_default

Whether to use default value. If True, provided answer will be ignored. Defaults to False.

Type:

bool, optional

Note that only one of the key, id, or name needs to be provided. It is recommended to always provide the key as it’s always unique as opposed to ID or name that can be shared among prompts.

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)

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.

Returns:

A dictionary representation of object’s attributes and values.

By default, the dictionary keys are in camel case.

Return type:

dict

answers: Any | list[Any]
id: str | None = None
key: str | None = None
name: str | None = None
type: str
use_default: bool = False