Skip to content

TM1Service

TM1Service(**kwargs)

All features of TM1py are exposed through this service

Can be saved and restored from File, to avoid multiple authentication with TM1.

Initiate the TM1Service

Supported kwargs arguments:

  • address (str): Address of the TM1 instance.
  • port (int): HTTPPortNumber as specified in the tm1s.cfg.
  • ssl (bool): Whether to use SSL, as specified in the tm1s.cfg.
  • instance (str): Planning Analytics engine (v12) instance name.
  • database (str): Planning Analytics engine (v12) database name.
  • base_url (str): Base URL for the REST API.
  • auth_url (str): Authentication URL for Planning Analytics engine (v12).
  • user (str): Name of the user.
  • password (str): Password of the user.
  • decode_b64 (bool): Whether the password argument is Base64 encoded.
  • namespace (str): Optional CAM namespace.
  • cam_passport (str): The CAM passport.
  • session_id (str): TM1SessionId, e.g., "q7O6e1w49AixeuLVxJ1GZg".
  • application_client_id (str): Planning Analytics engine (v12) named application client ID.
  • application_client_secret (str): Planning Analytics engine (v12) named application secret.
  • api_key (str): Planning Analytics engine (v12) API Key.
  • iam_url (str): IBM Cloud IAM URL. Default: "https://iam.cloud.ibm.com".
  • pa_url (str): Planning Analytics engine (v12) PA URL.
  • cpd_url (str): Cloud Pak for Data URL (aka ZEN).
  • tenant (str): Planning Analytics engine (v12) tenant.
  • session_context (str): Name of the application. Controls "Context" column in Arc/TM1top.
  • verify (bool or str): Path to .cer file or boolean for SSL verification.
  • logging (bool): Enable or disable verbose HTTP logging.
  • timeout (float): Number of seconds to wait for a response.
  • cancel_at_timeout (bool): Abort operation in TM1 when timeout is reached.
  • async_requests_mode (bool): Enable asynchronous request mode.
  • connection_pool_size (int): Maximum number of connections in the pool.
  • pool_connections (int): Number of connection pools to cache.
  • integrated_login (bool): True for IntegratedSecurityMode3.
  • integrated_login_domain (str): NT Domain name.
  • integrated_login_service (str): Kerberos Service type for remote Service Principal Name.
  • integrated_login_host (str): Host name for Service Principal Name.
  • integrated_login_delegate (bool): Delegate user credentials to the server.
  • impersonate (str): Name of the user to impersonate.
  • re_connect_on_session_timeout (bool): Attempt to reconnect once if session is timed out.
  • re_connect_on_remote_disconnect (bool): Attempt to reconnect once if connection is aborted by remote end.
  • remote_disconnect_max_retries (int): Maximum number of retry attempts after remote disconnect (default: 5).
  • remote_disconnect_retry_delay (float): Initial delay in seconds before first retry attempt (default: 1).
  • remote_disconnect_max_delay (float): Maximum delay cap in seconds between retry attempts (default: 30).
  • remote_disconnect_backoff_factor (float): Multiplier for exponential backoff between retry attempts (default: 2).
  • async_polling_initial_delay (float): Initial polling delay in seconds for async operations (default: 0.1).
  • async_polling_max_delay (float): Maximum polling delay cap in seconds for async operations (default: 1.0).
  • async_polling_backoff_factor (float): Multiplier for exponential backoff in async polling (default: 2).
  • proxies (dict): Dictionary of proxies, e.g., {'http': 'http://proxy.example.com:8080'}.
  • ssl_context: User-defined SSL context.
  • cert (str or tuple): Path to SSL client cert file or ('cert', 'key') pair.

Parameters:

Name Type Description Default
kwargs

See description above for all supported arguments

{}
Source code in TM1py/Services/TM1Service.py
def __init__(self, **kwargs):
    """Initiate the TM1Service

    Supported kwargs arguments:

    - **address** (str): Address of the TM1 instance.
    - **port** (int): HTTPPortNumber as specified in the tm1s.cfg.
    - **ssl** (bool): Whether to use SSL, as specified in the tm1s.cfg.
    - **instance** (str): Planning Analytics engine (v12) instance name.
    - **database** (str): Planning Analytics engine (v12) database name.
    - **base_url** (str): Base URL for the REST API.
    - **auth_url** (str): Authentication URL for Planning Analytics engine (v12).
    - **user** (str): Name of the user.
    - **password** (str): Password of the user.
    - **decode_b64** (bool): Whether the password argument is Base64 encoded.
    - **namespace** (str): Optional CAM namespace.
    - **cam_passport** (str): The CAM passport.
    - **session_id** (str): TM1SessionId, e.g., "q7O6e1w49AixeuLVxJ1GZg".
    - **application_client_id** (str): Planning Analytics engine (v12) named application client ID.
    - **application_client_secret** (str): Planning Analytics engine (v12) named application secret.
    - **api_key** (str): Planning Analytics engine (v12) API Key.
    - **iam_url** (str): IBM Cloud IAM URL. Default: "https://iam.cloud.ibm.com".
    - **pa_url** (str): Planning Analytics engine (v12) PA URL.
    - **cpd_url** (str): Cloud Pak for Data URL (aka ZEN).
    - **tenant** (str): Planning Analytics engine (v12) tenant.
    - **session_context** (str): Name of the application. Controls "Context" column in Arc/TM1top.
    - **verify** (bool or str): Path to .cer file or boolean for SSL verification.
    - **logging** (bool): Enable or disable verbose HTTP logging.
    - **timeout** (float): Number of seconds to wait for a response.
    - **cancel_at_timeout** (bool): Abort operation in TM1 when timeout is reached.
    - **async_requests_mode** (bool): Enable asynchronous request mode.
    - **connection_pool_size** (int): Maximum number of connections in the pool.
    - **pool_connections** (int): Number of connection pools to cache.
    - **integrated_login** (bool): True for IntegratedSecurityMode3.
    - **integrated_login_domain** (str): NT Domain name.
    - **integrated_login_service** (str): Kerberos Service type for remote Service Principal Name.
    - **integrated_login_host** (str): Host name for Service Principal Name.
    - **integrated_login_delegate** (bool): Delegate user credentials to the server.
    - **impersonate** (str): Name of the user to impersonate.
    - **re_connect_on_session_timeout** (bool): Attempt to reconnect once if session is timed out.
    - **re_connect_on_remote_disconnect** (bool): Attempt to reconnect once if connection is aborted by remote end.
    - **remote_disconnect_max_retries** (int): Maximum number of retry attempts after remote disconnect (default: 5).
    - **remote_disconnect_retry_delay** (float): Initial delay in seconds before first retry attempt (default: 1).
    - **remote_disconnect_max_delay** (float): Maximum delay cap in seconds between retry attempts (default: 30).
    - **remote_disconnect_backoff_factor** (float): Multiplier for exponential backoff between retry attempts (default: 2).
    - **async_polling_initial_delay** (float): Initial polling delay in seconds for async operations (default: 0.1).
    - **async_polling_max_delay** (float): Maximum polling delay cap in seconds for async operations (default: 1.0).
    - **async_polling_backoff_factor** (float): Multiplier for exponential backoff in async polling (default: 2).
    - **proxies** (dict): Dictionary of proxies, e.g., {'http': 'http://proxy.example.com:8080'}.
    - **ssl_context**: User-defined SSL context.
    - **cert** (str or tuple): Path to SSL client cert file or ('cert', 'key') pair.

    :param kwargs: See description above for all supported arguments

    """
    self._tm1_rest = RestService(**kwargs)
    self.annotations = AnnotationService(self._tm1_rest)
    self.cells = CellService(self._tm1_rest)
    self.chores = ChoreService(self._tm1_rest)
    self.cubes = CubeService(self._tm1_rest)
    self.dimensions = DimensionService(self._tm1_rest)
    self.elements = ElementService(self._tm1_rest)
    self.git = GitService(self._tm1_rest)
    self.hierarchies = HierarchyService(self._tm1_rest)
    self.processes = ProcessService(self._tm1_rest)
    self.security = SecurityService(self._tm1_rest)
    self.subsets = SubsetService(self._tm1_rest)
    self.applications = ApplicationService(self._tm1_rest)
    self.views = ViewService(self._tm1_rest)
    self.sandboxes = SandboxService(self._tm1_rest)
    self.files = FileService(self._tm1_rest)
    self.jobs = JobService(self._tm1_rest)
    self.users = UserService(self._tm1_rest)
    self.threads = ThreadService(self._tm1_rest)
    self.sessions = SessionService(self._tm1_rest)
    self.transaction_logs = TransactionLogService(self._tm1_rest)
    self.message_logs = MessageLogService(self._tm1_rest)
    self.configuration = ConfigurationService(self._tm1_rest)
    self.audit_logs = AuditLogService(self._tm1_rest)

    # higher level modules
    self.power_bi = PowerBiService(self._tm1_rest)
    self.loggers = LoggerService(self._tm1_rest)

    self._server = None
    self._monitoring = None

annotations = AnnotationService(self._tm1_rest) instance-attribute

applications = ApplicationService(self._tm1_rest) instance-attribute

audit_logs = AuditLogService(self._tm1_rest) instance-attribute

cells = CellService(self._tm1_rest) instance-attribute

chores = ChoreService(self._tm1_rest) instance-attribute

configuration = ConfigurationService(self._tm1_rest) instance-attribute

connection property

cubes = CubeService(self._tm1_rest) instance-attribute

dimensions = DimensionService(self._tm1_rest) instance-attribute

elements = ElementService(self._tm1_rest) instance-attribute

files = FileService(self._tm1_rest) instance-attribute

git = GitService(self._tm1_rest) instance-attribute

hierarchies = HierarchyService(self._tm1_rest) instance-attribute

jobs = JobService(self._tm1_rest) instance-attribute

loggers = LoggerService(self._tm1_rest) instance-attribute

message_logs = MessageLogService(self._tm1_rest) instance-attribute

metadata property

monitoring property

power_bi = PowerBiService(self._tm1_rest) instance-attribute

processes = ProcessService(self._tm1_rest) instance-attribute

sandboxes = SandboxService(self._tm1_rest) instance-attribute

security = SecurityService(self._tm1_rest) instance-attribute

server property

sessions = SessionService(self._tm1_rest) instance-attribute

subsets = SubsetService(self._tm1_rest) instance-attribute

threads = ThreadService(self._tm1_rest) instance-attribute

transaction_logs = TransactionLogService(self._tm1_rest) instance-attribute

users = UserService(self._tm1_rest) instance-attribute

version property

views = ViewService(self._tm1_rest) instance-attribute

whoami property

__enter__()

Source code in TM1py/Services/TM1Service.py
def __enter__(self):
    return self

__exit__(exception_type, exception_value, traceback)

Source code in TM1py/Services/TM1Service.py
def __exit__(self, exception_type, exception_value, traceback):
    try:
        self.logout()
    except Exception as e:
        warnings.warn(f"Logout Failed due to Exception: {e}")

logout(**kwargs)

Source code in TM1py/Services/TM1Service.py
def logout(self, **kwargs):
    self._tm1_rest.logout(**kwargs)

re_authenticate()

Source code in TM1py/Services/TM1Service.py
def re_authenticate(self):
    self._tm1_rest.connect()

re_connect()

Source code in TM1py/Services/TM1Service.py
def re_connect(self):
    self._tm1_rest.connect()

restore_from_file(file_name) classmethod

Source code in TM1py/Services/TM1Service.py
@classmethod
def restore_from_file(cls, file_name):
    with open(file_name, "rb") as file:
        return pickle.load(file)

save_to_file(file_name)

Source code in TM1py/Services/TM1Service.py
def save_to_file(self, file_name):
    with open(file_name, "wb") as file:
        pickle.dump(self, file)