msticpy.common.wsconfig module

Module for Log Analytics-related configuration.

class msticpy.common.wsconfig.WorkspaceConfig(workspace: str | None = None, config_file: str | None = None, interactive: bool = True, config: Dict[str, str] | None = None)

Bases: object

Workspace configuration class.

Load current Azure Notebooks configuration for Log Analytics.

Parameters:
  • config_file (Optional[str], optional) – path to a configuration file, If not specified, the defaults is to use a configured msticpyconfig.yaml If this isn’t configured, it will search for (first) a config.json and (second) a msticpyconfig.yaml in (first) the current directory and (second) the parent directory and subfolders.

  • workspace (Optional[str]) – Workspace name (where multiple workspaces are configured), by default the Default workspace will be used.

  • interactive (bool, optional) – If this is False, initializing the class will not raise an exception if no configuration is found. By default, True.

  • config (Optional[Dict[str, str]],) – Workspace configuration as dictionary.

CONF_ARGS = 'Args'
CONF_ARGS_KEY = 'args'
CONF_RES_GROUP = 'ResourceGroup'
CONF_RES_GROUP_KEY = 'resource_group'
CONF_SUB_ID = 'SubscriptionId'
CONF_SUB_ID_KEY = 'subscription_id'
CONF_TENANT_ID = 'TenantId'
CONF_TENANT_ID_KEY = 'tenant_id'
CONF_WS_ID = 'WorkspaceId'
CONF_WS_ID_KEY = 'workspace_id'
CONF_WS_NAME = 'WorkspaceName'
CONF_WS_NAME_KEY = 'workspace_name'
PKG_CONF_ARGS_KEY = 'Args'
PKG_CONF_NAME_KEY = 'WorkspaceName'
PKG_CONF_RES_GROUP_KEY = 'ResourceGroup'
PKG_CONF_SUB_KEY = 'SubscriptionId'
PKG_CONF_TENANT_KEY = 'TenantId'
PKG_CONF_WS_KEY = 'WorkspaceId'
RESOURCE_GROUP = '{{cookiecutter.resource_group}}'
SUBSCRIPTION_ID = '{{cookiecutter.subscription_id}}'
TENANT_ID = '{{cookiecutter.tenant_id}}'
WORKSPACE_ID = '{{cookiecutter.workspace_id}}'
WORKSPACE_NAME = '{{cookiecutter.workspace_name}}'
property args: Dict[str, str]

Return any additional arguments.

property code_connect_str: str

Return the Log Analytics connection string for dev code auth.

Returns:

Connection string

Return type:

str

property config_loaded: bool

Return True if workspace id and tenant id have values.

Returns:

True if configuration loaded.

Return type:

bool

classmethod from_connection_string(connection_str: str) WorkspaceConfig

Create a WorkstationConfig from a connection string.

classmethod from_settings(settings: Dict[str, Any]) WorkspaceConfig

Create a WorkstationConfig from MSTICPY Workspace settings.

get(key, default: Any | None = None)

Return key value or default.

classmethod list_workspaces() Dict

Return list of available workspaces.

Returns:

Dictionary of workspaces with workspace and tenantIds.

Return type:

Dict

property mp_settings

Return the equivalent MSTICPY settings dictionary.

prompt_for_ws()

Display an interactive prompt for Workspace details.

property settings: Dict[str, Any]

Return the current settings dictionary.

property settings_path: str | None

Return the path to the settings in the MSTICPY config.