mstrio > project_objects > content_cache

class mstrio.project_objects.content_cache.ContentCache(connection, id, content_cache_dict=None)

Bases: Cache, ContentCacheMixin

Manage content cache.

_CACHE_TYPE is a variable used by ContentCache class for cache filtering purposes.

Parameters:
  • connection (Connection)

  • id (str)

  • content_cache_dict (dict | None)

classmethod delete_all_caches(connection, force=None, **filters)

Delete all content caches filtered by the class type. Optionally filter by additional conditions.

Parameters:
  • cls (object) – Class type for objects to be filtered by

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

  • force (bool, optional) – If True, then no additional prompt will be shown before deleting objects.

  • **filters – Available filter parameters: [‘db_connection_id’, ‘db_login_id’, ‘owner’, ‘status’, ‘size’, ‘wh_tables’, ‘security_filter_id’]

Return type:

None

classmethod from_dict(connection, caches)

Creates Caches from a provided dictionary.

Parameters:
  • cls (object) – Class type for objects to be created

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

  • caches (list[dict]) – list of dictionaries the Caches will be created from

Returns:

list[ContentCache] – List of Caches created from the provided dictionaries.

Return type:

list[ContentCache]

classmethod list_caches(connection, to_dictionary=False, status='ready', project_id=None, nodes=None, content_type=None, limit=None, db_connection_id=None, db_login_id=None, id=None, owner=None, size=None, wh_tables=None, security_filter_id=None)

List content caches. You can filter them by id, database connection (db_connection_id) and project (project_id).

You can specify from which nodes caches will be retrieved. If nodes are None then all nodes are retrieved from the cluster.

Parameters:
  • connection (Connection) – Strategy One connection object returned by connection.Connection().

  • to_dictionary (bool, optional) – If True returns dict, by default (False) returns ContentCache objects

  • status (str, optional) – When provided, only caches with given status will be returned (if any). Default value ready

  • project_id (str, optional) – When provided only caches for project with given ID will be returned (if any).

  • nodes (list[str] | str, optional) – names of nodes on which caches will be searched. By default, it equals None and in that case all nodes names are loaded from the cluster.

  • content_type (str | CacheSource.Type, optional) – When provided, only caches of given type will be returned (if any).

  • limit (int, optional) – Cut-off value for the number of objects returned. This is a local limit as we always need to fetch all caches first to allow proper filtering on mstrio-py side.

  • db_connection_id (str, optional) – When provided, only caches for the database connection with given ID will be returned (if any).

  • db_login_id (str, optional) – When provided, only caches for the database login with given ID will be returned (if any).

  • id (str, optional) – When provided, only cache with given ID will be returned (if any).

  • owner (str, optional) – Owner of the content cache. Exact match on the owner’s full name.

  • size (str, optional) – Size condition for the content cache (in KB). When provided, only caches which satisfy the condition will be returned (if any).

  • wh_tables (str | list[str], optional) – When provided, only caches using any of given warehouse tables will be returned (if any).

  • security_filter_id (str, optional) – When provided, only caches using given security filter will be returned (if any).

Returns:

list[ContentCache] | list[dict] – List of ContentCache objects when parameter to_dictionary is set to False (default value) or list of dictionaries otherwise.

Return type:

list[ContentCache] | list[dict]

classmethod load_all_caches(connection, **filters)

Load all content caches filtered by the class type. Optionally filter by additional conditions.

Parameters:
  • cls (object) – Class type for objects to be filtered by

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

  • **filters – Available filter parameters: [‘db_connection_id’, ‘db_login_id’, ‘owner’, ‘status’, ‘size’, ‘wh_tables’, ‘security_filter_id’]

Return type:

None

classmethod unload_all_caches(connection, **filters)

Unload all content caches filtered by the class type. Optionally filter by additional conditions.

Parameters:
  • cls (object) – Class type for objects to be filtered by

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

  • **filters – Available filter parameters: [‘db_connection_id’, ‘db_login_id’, ‘owner’, ‘status’, ‘size’, ‘wh_tables’, ‘security_filter_id’]

Return type:

None

static delete_caches(connection, cache_ids, force=None)

Bulk delete caches.

Parameters:
  • connection (Connection) – Strategy One connection object returned

  • 'connection.Connection()' (by)

  • cache_ids (list[str]) – list of cache ids to be deleted

  • force (bool, optional) – If True, then no additional prompt will be shown before deleting objects.

Returns:

Response | None – Response object.

Return type:

Response | None

static fetch_nodes(connection, project_id)

Fetches the nodes for the specified connection and project.

Parameters:
  • connection (Connection) – Strategy One connection object returned by ‘connection.Connection()’

  • project_id (string) – id of the project to fetch the nodes from

Returns:

list[str] – A list of node names for the specified project.

Return type:

list[str]

static invalidate_caches(connection, cache_ids)

Bulk invalidate caches.

Parameters:
  • connection (Connection) – Strategy One connection object returned

  • 'connection.Connection()' (by)

  • cache_ids (list[str]) – List of cache ids to be invalidated

Returns:

Response | None – Response object.

Return type:

Response | None

static load_caches(connection, cache_ids)

Bulk load caches.

Parameters:
  • connection (Connection) – Strategy One connection object returned

  • 'connection.Connection()' (by)

  • cache_ids (list[str]) – list of cache ids to be loaded

Returns:

Response | None – Response object.

Return type:

Response | None

static unload_caches(connection, cache_ids)

Bulk unload caches.

Parameters:
  • connection (Connection) – Strategy One connection object returned

  • 'connection.Connection()' (by)

  • cache_ids (list[str]) – list of cache ids to be unloaded

Returns:

Response | None – Response object.

Return type:

Response | None

__init__(connection, id, content_cache_dict=None)

Initialize the ContentCache object. If content_cache_dict is provided no I-Server request will be sent.

Parameters:
  • connection (Connection) – Strategy One connection object returned by connection.Connection().

  • id (string) – content cache id

  • content_cache_dict (dict, optional) – dictionary with properties of content cache object. If it is provided then cache dictionary will not be retrieved from I-Server.

Return type:

None

delete(force=None)

Delete content cache.

Parameters:

force (bool, optional) – If True, then no additional prompt will be shown before deleting object.

Returns:

Response | None – Response object.

Return type:

Response | None

fetch()

Fetches the cache from the server, refreshing the variables to match those currently stored on the server.

Return type:

None

invalidate()

Invalidate content cache. Invalidated cache will be removed from the server.

Return type:

bool

list_properties()

List properties for content cache.

Return type:

dict

load()

Load content cache.

Return type:

bool

unload()

Unload content cache.

Return type:

bool

property cache_location
property chapter
property combined_id
property creation_time
property creator_name
property data_language
property database_connection_id
property database_login_id
property expiration_time
property format
property group_by
property hit_count
property host
property id
property last_hit_time
property last_load_time
property last_update_time
property location
property metadata_language
property project_id
property prompt_answer
property report_caches_used
property result_cache_type
property security_filter_id
property size
property source
property status
property warehouse_tables_used
property xml_content
enum mstrio.project_objects.content_cache.ContentCacheFormat(value)

Bases: AutoName

Valid values are as follows:

EXCEL = ContentCacheFormat.EXCEL
PDF = ContentCacheFormat.PDF
CSV = ContentCacheFormat.CSV
HTML = ContentCacheFormat.HTML
XML = ContentCacheFormat.XML
PLAIN_TEXT = ContentCacheFormat.PLAIN_TEXT
BINARY_DEFINITION = ContentCacheFormat.BINARY_DEFINITION
BINARY_DATA = ContentCacheFormat.BINARY_DATA
HTML5 = ContentCacheFormat.HTML5
FLASH = ContentCacheFormat.FLASH
TRANSACTION = ContentCacheFormat.TRANSACTION
BINARY_DEFINITION_BINARY_DATA = ContentCacheFormat.BINARY_DEFINITION_BINARY_DATA
BINARY_DATA_BINARY_DEFINITION = ContentCacheFormat.BINARY_DATA_BINARY_DEFINITION

The Enum and its members also have the following methods:

classmethod has_value(value)
class mstrio.project_objects.content_cache.ContentCacheStatus(ready, processing, invalid, expired, loaded, filed, dirty)

Bases: Dictable

Parameters:
  • ready (bool)

  • processing (bool)

  • invalid (bool)

  • expired (bool)

  • loaded (bool)

  • filed (bool)

  • dirty (bool)

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

dirty: bool
expired: bool
filed: bool
invalid: bool
loaded: bool
processing: bool
ready: bool