Skip to content

ServerService

LogLevel

Bases: Enum

DEBUG = 'debug' class-attribute instance-attribute

ERROR = 'error' class-attribute instance-attribute

FATAL = 'fatal' class-attribute instance-attribute

INFO = 'info' class-attribute instance-attribute

OFF = 'off' class-attribute instance-attribute

WARNING = 'warning' class-attribute instance-attribute

ServerService(rest)

Bases: ObjectService

Service to query common information from the TM1 Server

Source code in TM1py/Services/ServerService.py
def __init__(self, rest: RestService):
    super().__init__(rest)
    warn("Server Service will be moved to a new location in a future version", DeprecationWarning, 2)
    self.transaction_logs = TransactionLogService(rest)
    self.message_logs = MessageLogService(rest)
    self.configuration = ConfigurationService(rest)
    self.audit_logs = AuditLogService(rest)
    self.loggers = LoggerService(rest)

audit_logs = AuditLogService(rest) instance-attribute

configuration = ConfigurationService(rest) instance-attribute

loggers = LoggerService(rest) instance-attribute

message_logs = MessageLogService(rest) instance-attribute

transaction_logs = TransactionLogService(rest) instance-attribute

activate_audit_log()

Source code in TM1py/Services/ServerService.py
def activate_audit_log(self):
    self.audit_logs.activate()

deactivate_audit_log()

Source code in TM1py/Services/ServerService.py
@require_ops_admin
def deactivate_audit_log(self):
    config = {"Administration": {"AuditLog": {"Enable": False}}}
    self.update_static_configuration(config)

delete_persistent_feeders(**kwargs)

Source code in TM1py/Services/ServerService.py
@require_data_admin
def delete_persistent_feeders(self, **kwargs) -> Response:
    from TM1py.Services import ProcessService

    ti = "DeleteAllPersistentFeeders;"
    process_service = ProcessService(self._rest)
    return process_service.execute_ti_code(ti, **kwargs)

execute_audit_log_delta_request(**kwargs)

Source code in TM1py/Services/ServerService.py
def execute_audit_log_delta_request(self, **kwargs) -> Dict:
    return self.audit_logs.execute_delta_request(**kwargs)

execute_message_log_delta_request(**kwargs)

Source code in TM1py/Services/ServerService.py
def execute_message_log_delta_request(self, **kwargs) -> Dict:
    return self.message_logs.execute_delta_request(**kwargs)

execute_transaction_log_delta_request(**kwargs)

Source code in TM1py/Services/ServerService.py
def execute_transaction_log_delta_request(self, **kwargs) -> Dict:
    return self.transaction_logs.execute_delta_request(**kwargs)

get_active_configuration(**kwargs)

Read effective(!) TM1 config settings as dictionary from TM1 Server

Returns:

Type Description
Dict

config as dictionary

Source code in TM1py/Services/ServerService.py
def get_active_configuration(self, **kwargs) -> Dict:
    """Read effective(!) TM1 config settings as dictionary from TM1 Server

    :return: config as dictionary
    """
    return self.configuration.get_active()

get_admin_host(**kwargs)

Source code in TM1py/Services/ServerService.py
def get_admin_host(self, **kwargs) -> str:
    return self.configuration.get_admin_host()

get_all_message_logger_level()

Get all tm1 message loggers

Returns:

Type Description
Source code in TM1py/Services/ServerService.py
@require_admin
def get_all_message_logger_level(self):
    """
    Get all tm1 message loggers

    :return:
    """

    return self.loggers.get_all()

get_api_metadata()

Read effective(!) TM1 config settings as dictionary from TM1 Server

Returns:

Type Description

config as dictionary

Source code in TM1py/Services/ServerService.py
def get_api_metadata(self):
    """Read effective(!) TM1 config settings as dictionary from TM1 Server

    :return: config as dictionary
    """
    return self._rest.get_api_metadata()

get_audit_log_entries(user=None, object_type=None, object_name=None, since=None, until=None, top=None, **kwargs)

Parameters:

Name Type Description Default
user str

UserName

None
object_type str

ObjectType

None
object_name str

ObjectName

None
since datetime

of type datetime. If it doesn't have tz information, UTC is assumed.

None
until datetime

of type datetime. If it doesn't have tz information, UTC is assumed.

None
top int

int

None

Returns:

Type Description
Dict
Source code in TM1py/Services/ServerService.py
@require_data_admin
@deprecated_in_version(version="12.0.0")
@require_version(version="11.6")
def get_audit_log_entries(
    self,
    user: str = None,
    object_type: str = None,
    object_name: str = None,
    since: datetime = None,
    until: datetime = None,
    top: int = None,
    **kwargs,
) -> Dict:
    """
    :param user: UserName
    :param object_type: ObjectType
    :param object_name: ObjectName
    :param since: of type datetime. If it doesn't have tz information, UTC is assumed.
    :param until: of type datetime. If it doesn't have tz information, UTC is assumed.
    :param top: int
    :return:
    """
    return self.audit_logs.get_entries(
        user=user, object_type=object_type, object_name=object_name, since=since, until=until, top=top, **kwargs
    )

get_configuration(**kwargs)

Source code in TM1py/Services/ServerService.py
def get_configuration(self, **kwargs) -> Dict:
    return self.configuration.get_all()

get_data_directory(**kwargs)

Source code in TM1py/Services/ServerService.py
def get_data_directory(self, **kwargs) -> str:
    return self.configuration.get_data_directory()

get_last_process_message_from_message_log(process_name, **kwargs)

Get the latest message log entry for a process

Parameters:

Name Type Description Default
process_name str

name of the process

required

Returns:

Type Description
Optional[str]

String - the message, for instance: "Ausführung normal beendet, verstrichene Zeit 0.03 Sekunden"

Source code in TM1py/Services/ServerService.py
@require_ops_admin
@deprecated_in_version(version="12.0.0")
def get_last_process_message_from_message_log(self, process_name: str, **kwargs) -> Optional[str]:
    """Get the latest message log entry for a process

    :param process_name: name of the process
    :return: String - the message, for instance: "Ausführung normal beendet, verstrichene Zeit 0.03  Sekunden"
    """
    self.message_logs.get_last_process_message(process_name, **kwargs)

get_message_log_entries(reverse=True, since=None, until=None, top=None, logger=None, level=None, msg_contains=None, msg_contains_operator='and', **kwargs)

Parameters:

Name Type Description Default
reverse bool

Boolean

True
since datetime

of type datetime. If it doesn't have tz information, UTC is assumed.

None
until datetime

of type datetime. If it doesn't have tz information, UTC is assumed.

None
top int

Integer

None
logger str

string, eg TM1.Server, TM1.Chore, TM1.Mdx.Interface, TM1.Process

None
level str

string, ERROR, WARNING, INFO, DEBUG, UNKNOWN

None
msg_contains Iterable

iterable, find substring in log message; list of substrings will be queried as AND statement

None
msg_contains_operator str

'and' or 'or'

'and'
kwargs
{}

Returns:

Type Description
Dict

Dict of server log

Source code in TM1py/Services/ServerService.py
@deprecated_in_version(version="12.0.0")
@require_ops_admin
def get_message_log_entries(
    self,
    reverse: bool = True,
    since: datetime = None,
    until: datetime = None,
    top: int = None,
    logger: str = None,
    level: str = None,
    msg_contains: Iterable = None,
    msg_contains_operator: str = "and",
    **kwargs,
) -> Dict:
    """
    :param reverse: Boolean
    :param since: of type datetime. If it doesn't have tz information, UTC is assumed.
    :param until: of type datetime. If it doesn't have tz information, UTC is assumed.
    :param top: Integer
    :param logger: string, eg TM1.Server, TM1.Chore, TM1.Mdx.Interface, TM1.Process
    :param level: string, ERROR, WARNING, INFO, DEBUG, UNKNOWN
    :param msg_contains: iterable, find substring in log message; list of substrings will be queried as AND statement
    :param msg_contains_operator: 'and' or 'or'

    :param kwargs:
    :return: Dict of server log
    """

    return self.message_logs.get_entries(
        reverse=reverse,
        since=since,
        until=until,
        top=top,
        logger=logger,
        level=level,
        msg_contains=msg_contains,
        msg_contains_operator=msg_contains_operator,
        **kwargs,
    )

get_product_version(**kwargs)

Ask TM1 Server for its version

:Returns: String, the version

Source code in TM1py/Services/ServerService.py
def get_product_version(self, **kwargs) -> str:
    """Ask TM1 Server for its version

    :Returns:
        String, the version
    """
    return self.configuration.get_product_version()

get_server_name(**kwargs)

Ask TM1 Server for its name

:Returns: String, the server name

Source code in TM1py/Services/ServerService.py
def get_server_name(self, **kwargs) -> str:
    """Ask TM1 Server for its name

    :Returns:
        String, the server name
    """
    return self.configuration.get_server_name()

get_static_configuration(**kwargs)

Source code in TM1py/Services/ServerService.py
def get_static_configuration(self, **kwargs) -> Dict:
    return self.configuration.get_static()

get_transaction_log_entries(reverse=True, user=None, cube=None, since=None, until=None, top=None, element_tuple_filter=None, element_position_filter=None, **kwargs)

Parameters:

Name Type Description Default
reverse bool

Boolean

True
user str

UserName

None
cube str

CubeName

None
since datetime

of type datetime. If it doesn't have tz information, UTC is assumed.

None
until datetime

of type datetime. If it doesn't have tz information, UTC is assumed.

None
top int

int

None
element_tuple_filter Dict[str, str]

of type dict. Element name as key and comparison operator as value

None
element_position_filter Dict[int, Dict[str, str]]

not yet implemented tuple={'Actual':'eq','2020': 'ge'}

None

Returns:

Type Description
Dict
Source code in TM1py/Services/ServerService.py
@deprecated_in_version(version="12.0.0")
@require_admin
def get_transaction_log_entries(
    self,
    reverse: bool = True,
    user: str = None,
    cube: str = None,
    since: datetime = None,
    until: datetime = None,
    top: int = None,
    element_tuple_filter: Dict[str, str] = None,
    element_position_filter: Dict[int, Dict[str, str]] = None,
    **kwargs,
) -> Dict:
    """
    :param reverse: Boolean
    :param user: UserName
    :param cube: CubeName
    :param since: of type datetime. If it doesn't have tz information, UTC is assumed.
    :param until: of type datetime. If it doesn't have tz information, UTC is assumed.
    :param top: int
    :param element_tuple_filter: of type dict. Element name as key and comparison operator as value
    :param element_position_filter: not yet implemented
    tuple={'Actual':'eq','2020': 'ge'}
    :return:
    """
    return self.transaction_logs.get_entries(
        reverse=reverse,
        user=user,
        cube=cube,
        since=since,
        until=until,
        top=top,
        element_tuple_filter=element_tuple_filter,
        element_position_filter=element_position_filter,
        **kwargs,
    )

initialize_audit_log_delta_requests(filter=None, **kwargs)

Source code in TM1py/Services/ServerService.py
def initialize_audit_log_delta_requests(self, filter=None, **kwargs):
    return self.audit_logs.initialize_delta_requests(filter, **kwargs)

initialize_message_log_delta_requests(filter=None, **kwargs)

Source code in TM1py/Services/ServerService.py
def initialize_message_log_delta_requests(self, filter=None, **kwargs):
    return self.message_logs.initialize_delta_requests(filter, **kwargs)

initialize_transaction_log_delta_requests(filter=None, **kwargs)

Source code in TM1py/Services/ServerService.py
def initialize_transaction_log_delta_requests(self, filter=None, **kwargs):
    return self.transaction_logs.initialize_delta_requests(filter, **kwargs)

save_data(**kwargs)

Source code in TM1py/Services/ServerService.py
@deprecated_in_version(version="12.0.0")
@require_data_admin
def save_data(self, **kwargs) -> Response:
    from TM1py.Services import ProcessService

    ti = "SaveDataAll;"
    process_service = ProcessService(self._rest)
    return process_service.execute_ti_code(ti, **kwargs)

start_performance_monitor()

Source code in TM1py/Services/ServerService.py
def start_performance_monitor(self):
    config = {"Administration": {"PerformanceMonitorOn": True}}
    self.configuration.update_static(config)

stop_performance_monitor()

Source code in TM1py/Services/ServerService.py
def stop_performance_monitor(self):
    config = {"Administration": {"PerformanceMonitorOn": False}}
    self.configuration.update_static(config)

update_message_logger_level(logger, level)

Updates tm1 message log levels

Parameters:

Name Type Description Default
logger
required
level
required

Returns:

Type Description
Source code in TM1py/Services/ServerService.py
@require_admin
def update_message_logger_level(self, logger, level):
    """
    Updates tm1 message log levels
    :param logger:
    :param level:
    :return:
    """

    return self.loggers.set_level(logger, level)

update_static_configuration(configuration)

Update the .cfg file and triggers TM1 to re-read the file.

Parameters:

Name Type Description Default
configuration Dict
required

Returns:

Type Description
Response

Response

Source code in TM1py/Services/ServerService.py
def update_static_configuration(self, configuration: Dict) -> Response:
    """Update the .cfg file and triggers TM1 to re-read the file.

    :param configuration:
    :return: Response
    """
    return self.configuration.update_static(configuration)

write_to_message_log(level, message, **kwargs)

Parameters:

Name Type Description Default
level str

string, FATAL, ERROR, WARN, INFO, DEBUG

required
message str

string

required

Returns:

Type Description
None
Source code in TM1py/Services/ServerService.py
@require_data_admin
def write_to_message_log(self, level: str, message: str, **kwargs) -> None:
    """
    :param level: string, FATAL, ERROR, WARN, INFO, DEBUG
    :param message: string
    :return:
    """

    return self.message_logs.create_entry(level=level, message=message, **kwargs)