msticpy.config.ce_common module

Component edit utility functions.

msticpy.config.ce_common.dict_to_txt(dict_val: str | Dict[str, Any]) str

Return string as “key:val; key2:val2” pairs from dict_val.

Parameters:

dict_val (Union[str, Dict[str, Any]]) – Dict of key/val pairs or string of single key/value

Returns:

str formatted as “key:val; key2:val2”

Return type:

str

msticpy.config.ce_common.get_def_tenant_id(sub_id: str) str | None

Get the tenant ID for a subscription.

Parameters:

sub_id (str) – Subscription ID

Returns:

TenantID or None if it could not be found.

Return type:

Optional[str]

Notes

This function returns the tenant ID that owns the subscription.

msticpy.config.ce_common.get_defn_or_default(defn: Tuple[str, Any] | Any) Tuple[str, Dict]

Return the type and options (or a default) for the setting definition.

Parameters:

defn (Optional[Tuple[str, dict]]) – Setting definition. Returns a default of “str”, {} if no definition is passed.

Returns:

Tuple of setting type and options.

Return type:

Tuple[str, Dict]

msticpy.config.ce_common.get_managed_tenant_id(sub_id: str) List[str] | None

Get the tenant IDs that are managing a subscription.

Parameters:

sub_id (str) – Subscription ID

Returns:

A list of tenant IDs or None if it could not be found.

Return type:

Optional[list[str]]

msticpy.config.ce_common.get_or_create_mpc_section(mp_controls: MpConfigControls, section: str, subkey: str | None = None) Any

Return (and create if it doesn’t exist) a settings section.

Parameters:
  • mp_controls (MpConfigControls) – The MP Config database.

  • section (str) – The section name (top level settings item)

  • subkey (Optional[str], optional) – Optional subkey to create, by default None

Returns:

The settings at that section[subkey] location.

Return type:

Any

msticpy.config.ce_common.get_subscription_metadata(sub_id: str) dict

Get the subscription metadata for a subscription.

Parameters:

sub_id (str) – Subscription ID

Returns:

Subscription metadata

Return type:

dict

msticpy.config.ce_common.get_wgt_ctrl(setting_path: str, var_name: str, mp_controls: MpConfigControls, wgt_style: Dict[str, Any] | None = None, instance_name: str = None) ipywidgets.Widget

Return widget appropriate to value type of var_name.

Parameters:
  • setting_path (str) – The setting path (parent path) as dotted string.

  • var_name (str) – The key name for the setting below setting_path.

  • mp_controls (MpConfigControls) – Instance of MpConfigControls data

  • wgt_style (Optional[Dict[str, Any]]) –

    Dict of style and layout items: .. parsed-literal:

    {
        "style": {"description_width": "100px"},
        "layout": widgets.Layout(width="50%")
    }
    

  • instance_name (Optional[str]) – An optional sub-path to an instance of this provider (e.g. ‘Cluster1’ of path.Kusto-Cluster1)

Returns:

The widget.

Return type:

widgets.Widget

msticpy.config.ce_common.print_debug(*args)

Print nothing std_out (Prod version).

msticpy.config.ce_common.py_to_widget(value: Any, ctrl: ipywidgets.Widget | None = None, val_type: str | None = None) Any

Adjust type and format to suit target widget.

Parameters:
  • value (Any) – The value to process

  • ctrl (Optional[widgets.Widget], optional) – The target widget type, by default None

  • val_type (Optional[str], optional) – The target value type (“str”, “bool”), by default None

Returns:

The converted value

Return type:

Any

Raises:

ValueError – If neither a target control or expected val_type are specified.

Notes

This function handles conversion of None to an empty string or bools expressed as text strings into actual bools.

msticpy.config.ce_common.txt_to_dict(txt_val: str) Dict[str, Any]

Return dict from string of “key:val; key2:val2” pairs.

Parameters:

txt_val (str) – The key/value string (items separated by “;”, key/value separated by “:”)

Returns:

Dictionary of key/values

Return type:

Dict[str, Any]

msticpy.config.ce_common.widget_to_py(ctrl: ipywidgets.Widget | SettingsControl) Any

Adjust type and format of value returned from ctrl.value.

Parameters:

ctrl (Union[widgets.Widget, SettingsControl]) – The source widget

Returns:

Converted value.

Return type:

Any

Notes

This function handles conversion of widget values to configuration (Python) values.