sempy_labs.workspace package

Module contents

sempy_labs.workspace.add_user_to_workspace(email_address: str, role_name: str, principal_type: str | None = 'User', workspace: str | UUID | None = None)

Adds a user to a workspace.

This is a wrapper function for the following API: Groups - Add Group User.

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

Parameters:
  • email_address (str) – The email address of the user. Also accepts the user identifier.

  • role_name (str) – The role of the user within the workspace.

  • principal_type (str, default='User') – The principal type.

  • 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.workspace.apply_workspace_tags(tags: str | List[str], workspace: str | UUID | None = None)

Apply tags to a workspace.

This is a wrapper function for the following API: Workspaces - Apply Workspace Tags.

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

Parameters:
  • tags (str | List[str]) – A single tag as a string or a list of tags to apply to the workspace.

  • 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.workspace.assign_to_capacity(capacity: str | UUID, workspace: str | UUID | None = None, **kwargs)

Assigns a workspace to a capacity.

This is a wrapper function for the following API: Workspaces - Assign To Capacity.

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

Parameters:
  • capacity (str | uuid.UUID) – The name or ID of the capacity.

  • workspace (str | uuid.UUID, default=None) – The name or ID of the Fabric 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.workspace.delete_user_from_workspace(email_address: str, workspace: str | UUID | None = None)

Removes a user from a workspace.

This is a wrapper function for the following API: Groups - Delete User In Group.

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

Parameters:
  • email_address (str) – The email address of the user.

  • 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.workspace.delete_workspace(workspace: str | UUID | None = None)

Deletes a workspace.

This is a wrapper function for the following API: Workspaces - Delete Workspace.

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.workspace.get_git_outbound_policy(workspace: str | UUID | None = None) str

Returns Git Outbound policy for the specified workspace. In cases the workspace restricts outbound policy, a workspace admin needs to allow the use of Git integration on the specified workspace.

This is a wrapper function for the following API: Workspaces - Get Git Outbound Policy.

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

Parameters:

workspace (str | uuid.UUID, default=None) – The 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 Git outbound policy for the specified workspace.

Return type:

str

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

Returns networking communication policy for the specified workspace. This feature is currently in preview.

This is a wrapper function for the following API: Workspaces - Get Network Communication Policy.

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

Parameters:

workspace (str | uuid.UUID, default=None) – The 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:

A pandas dataframe showing the networking communication policy for the specified workspace.

Return type:

pandas.DataFrame

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

Returns the cloud connection rules for the workspace enabled with Outbound Access Protection (OAP).

This is a wrapper function for the following API: Workspaces - Get Outbound Cloud Connection Rules.

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

Parameters:

workspace (str | uuid.UUID, default=None) – The 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:

A dictionary showing the cloud connection rules for the workspace enabled with Outbound Access Protection (OAP).

Return type:

dict

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

Returns the gateway rules for the workspace enabled with Outbound Access Protection (OAP).

This is a wrapper function for the following API: Workspaces - Get Outbound Gateway Rules.

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

Parameters:

workspace (str | uuid.UUID, default=None) – The 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:

A dictionary showing the gateway rules for the workspace enabled with Outbound Access Protection (OAP).

Return type:

dict

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

Shows the members of a given workspace.

This is a wrapper function for the following API: Workspaces - List Workspace Role Assignments.

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:

A pandas dataframe showing the members of a given workspace and their roles.

Return type:

pandas.DataFrame

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

A list of all the users of a workspace and their roles.

This is a wrapper function for the following API: Workspaces - List Workspace Role Assignments.

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:

A pandas dataframe the users of a workspace and their properties.

Return type:

pandas.DataFrame

sempy_labs.workspace.set_git_outbound_policy(policy: Literal['Allow', 'Deny'], workspace: str | UUID | None = None)

Sets Git Outbound policy for the specified workspace, when Outbound policy is set to ‘Deny’.

This is a wrapper function for the following API: Workspaces - Set Git Outbound Policy.

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

Parameters:
  • policy (Literal['Allow', 'Deny']) – The policy for all Git outbound communications from a workspace.

  • workspace (str | uuid.UUID, default=None) – The 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.workspace.set_network_communication_policy(inbound_policy: Literal['Allow', 'Deny'], outbound_policy: Literal['Allow', 'Deny'], workspace: str | UUID | None = None)

Sets networking communication policy for the specified workspace. This API uses the PUT method and will overwrite all settings. Remaining policy will be set to default value if only partial policy is provided in the request body. Always run Get Network Communication Policy first and provide full policy in the request body. This feature is currently in preview.

This is a wrapper function for the following API: Workspaces - Set Network Communication Policy.

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

Parameters:
  • inbound_policy (Literal['Allow', 'Deny']) – The policy for all inbound communications to a workspace.

  • outbound_policy (Literal['Allow', 'Deny']) – The policy for all outbound communications to a workspace.

  • workspace (str | uuid.UUID, default=None) – The 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.workspace.set_outbound_gateway_rules(default_action: Literal['Allow', 'Deny'], allowed_gateways: List[UUID], workspace: str | UUID | None = None)

Sets the gateway rules for the workspace enabled with Outbound Access Protection (OAP).

This is a wrapper function for the following API: Workspaces - Set Outbound Gateway Rules.

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

Parameters:
  • default_action (Literal['Allow', 'Deny']) – The default action for outbound gateway communication policy.

  • allowed_gateways (List[uuid.UUID]) – A list of allowed gateway IDs.

  • workspace (str | uuid.UUID, default=None) – The 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.workspace.unapply_workspace_tags(tags: str | List[str], workspace: str | UUID | None = None)

Unapply tags from a workspace.

This is a wrapper function for the following API: Workspaces - Unapply Workspace Tags.

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

Parameters:
  • tags (str | List[str]) – A single tag as a string or a list of tags to unapply from the workspace.

  • 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.workspace.unassign_from_capacity(workspace: str | UUID | None = None)

Unassigns a workspace from its assigned capacity.

This is a wrapper function for the following API: Workspaces - Unassign From Capacity.

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

Parameters:

workspace (str | uuid.UUID, default=None) – The name or ID of the Fabric 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.workspace.update_workspace_user(email_address: str, role_name: str, principal_type: str | None = 'User', workspace: str | UUID | None = None)

Updates a user’s role within a workspace.

This is a wrapper function for the following API: Groups - Update Group User.

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

Parameters:
  • email_address (str) – The email address of the user.

  • role_name (str) –

    The role of the user within the workspace.

  • principal_type (str, default='User') –

    The principal type.

  • 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.