sempy_labs.onelake package

Module contents

sempy_labs.onelake.delete_onelake_lifecycle_policy(workspace: str | UUID | None = None)

Deletes the OneLake lifecycle management policy for a workspace.

This sends an empty rules array to the import policy API, which removes the existing policy.

This is a wrapper function for the following API: OneLake Lifecycle Policy - Import Policy.

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.onelake.export_onelake_lifecycle_policy(workspace: str | UUID | None = None) dict

Exports the OneLake lifecycle management policy for a workspace.

This is a wrapper function for the following API: OneLake Lifecycle Policy - Export Policy.

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The OneLake workspace lifecycle policy, containing the policy properties (including lastModifiedTime and policy rules) and the ARM resource type.

Return type:

dict

sempy_labs.onelake.get_onelake_settings(workspace: str | UUID | None = None) DataFrame

Obtains the workspace OneLake settings.

This is a wrapper function for the following API: OneLake Settings - Get Settings.

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.UUID, default=None) – The name or ID of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The workspace OneLake settings.

Return type:

pandas.DataFrame

sempy_labs.onelake.import_onelake_lifecycle_policy(policy: dict, workspace: str | UUID | None = None) dict

Imports (creates or replaces) the OneLake lifecycle management policy for a workspace.

The policy must be sent in full as a complete replacement. To delete the existing policy, send a request with an empty rules array.

This is a wrapper function for the following API: OneLake Lifecycle Policy - Import Policy.

Service Principal Authentication is supported (see here for examples).

Parameters:
  • policy (dict) – The lifecycle policy request body. May be specified either as the full request body ({"properties": {"policy": {"rules": [...]}}}) or as just the policy contents ({"policy": {"rules": [...]}} or {"rules": [...]}). The structure follows Azure Storage lifecycle management. Note that the tierToArchive action, delete action and blobIndexMatch filter are not supported.

  • workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The OneLake workspace lifecycle policy response, containing the policy properties and the ARM resource type.

Return type:

dict

sempy_labs.onelake.modify_default_tier(default_tier: Literal['Hot', 'Cool', 'Cold'], workspace: str | UUID | None = None)
sempy_labs.onelake.modify_immutability_policy(retention_days: int, scope: Literal['DiagnosticLogs'] = 'DiagnosticLogs', workspace: str | UUID | None = None)

Create or update OneLake immutability settings. Set immutability policy for data stored in OneLake. Currently, this feature supports configuring a retention period specifically for diagnostic logs within a workspace, ensuring they remain unaltered once written.

This is a wrapper function for the following API: OneLake Settings - Modify Immutability Policy.

Service Principal Authentication is supported (see here for examples).

Parameters:
  • retention_days (int) – Retention Days for the action.

  • scope (Literal["DiagnosticLogs"], default="DiagnosticLogs") – The scope of the immutability policy. Currently, only “DiagnosticLogs” is supported.

  • workspace (str | uuid.UUID, default=None) – The name or ID of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.onelake.modify_onelake_diagnostics(workspace: str | UUID | None = None, enabled: bool = True, destination_lakehouse: str | UUID | None = None, destination_workspace: str | UUID | None = None)

Obtains the workspace OneLake settings.

This is a wrapper function for the following API: OneLake Settings - Modify Diagnostics.

Service Principal Authentication is supported (see here for examples).

Parameters:
  • workspace (str | uuid.UUID, default=None) – The name or ID of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • enabled (bool, default=True) – Whether to enable or disable OneLake diagnostics.

  • destination_lakehouse (str | uuid.UUID, default=None) – The name or ID of the destination lakehouse. Defaults to None which resolves to the lakehouse of the attached lakehouse or if no lakehouse attached, resolves to the lakehouse of the notebook.

  • destination_workspace (str | uuid.UUID, default=None) – The name or ID of the destination workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.