Skip to content

Commit

Permalink
added descriptions to admin functions
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kovalsky committed Sep 19, 2024
1 parent a5f64c5 commit 2f577e7
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Semantic Link Labs

[![PyPI version](https://badge.fury.io/py/semantic-link-labs.svg)](https://badge.fury.io/py/semantic-link-labs)
[![Read The Docs](https://readthedocs.org/projects/semantic-link-labs/badge/?version=0.7.5&style=flat)](https://readthedocs.org/projects/semantic-link-labs/)
[![Read The Docs](https://readthedocs.org/projects/semantic-link-labs/badge/?version=0.8.0&style=flat)](https://readthedocs.org/projects/semantic-link-labs/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Downloads](https://static.pepy.tech/badge/semantic-link-labs)](https://pepy.tech/project/semantic-link-labs)

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
project = 'semantic-link-labs'
copyright = '2024, Microsoft and community'
author = 'Microsoft and community'
release = '0.7.5'
release = '0.8.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- pytest-cov
- pytest-mock
- pip:
- semantic-link-sempy>=0.7.7
- semantic-link-sempy>=0.8.0
- azure-identity==1.7.1
- azure-storage-blob>=12.9.0
- pandas-stubs
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name="semantic-link-labs"
authors = [
{ name = "Microsoft Corporation" },
]
version="0.7.5"
version="0.8.0"
description="Semantic Link Labs for Microsoft Fabric"
readme="README.md"
requires-python=">=3.10,<3.12"
Expand All @@ -23,7 +23,7 @@ classifiers = [
license= { text = "MIT License" }

dependencies = [
"semantic-link-sempy>=0.7.7",
"semantic-link-sempy>=0.8.0",
"anytree",
"powerbiclient",
"azure-mgmt-resource",
Expand Down
70 changes: 63 additions & 7 deletions src/sempy_labs/admin/_basic_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
def list_workspaces(
top: Optional[int] = 5000, skip: Optional[int] = None
) -> pd.DataFrame:
"""
Lists workspaces for the organization. This function is the admin version of list_workspaces.
Parameters
----------
top : int, default=5000
Returns only the first n results. This parameter is mandatory and must be in the range of 1-5000.
skip : int, default=None
Skips the first n results. Use with top to fetch results beyond the first 5000.
Returns
-------
pandas.DataFrame
A pandas dataframe showing a list of workspaces for the organization.
"""

df = pd.DataFrame(
columns=[
Expand Down Expand Up @@ -72,7 +87,7 @@ def assign_workspaces_to_capacity(
workspace: Optional[str | List[str]] = None,
):
"""
Assigns a workspace to a capacity.
Assigns a workspace to a capacity. This function is the admin version.
Parameters
----------
Expand Down Expand Up @@ -137,7 +152,7 @@ def assign_workspaces_to_capacity(

def list_capacities() -> pd.DataFrame:
"""
Shows the a list of capacities and their properties.
Shows the a list of capacities and their properties. This function is the admin version.
Parameters
----------
Expand Down Expand Up @@ -250,6 +265,14 @@ def _list_capacities_meta() -> pd.DataFrame:


def unassign_workspaces_from_capacity(workspaces: str | List[str]):
"""
Unassigns workspace(s) from their capacity. This function is the admin version of list_workspaces.
Parameters
----------
workspaces : str | List[str]
The Fabric workspace name(s).
"""

# https://learn.microsoft.com/en-us/rest/api/power-bi/admin/capacities-unassign-workspaces-from-capacity

Expand All @@ -271,6 +294,14 @@ def unassign_workspaces_from_capacity(workspaces: str | List[str]):


def list_external_data_shares():
"""
Lists external data shares in the tenant. This function is for admins.
Returns
-------
pandas.DataFrame
A pandas dataframe showing a list of external data shares in the tenant.
"""

# https://learn.microsoft.com/en-us/rest/api/fabric/admin/external-data-shares/list-external-data-shares?tabs=HTTP

Expand Down Expand Up @@ -325,6 +356,20 @@ def list_external_data_shares():
def revoke_external_data_share(
external_data_share_id: UUID, item_id: UUID, workspace: str
):
"""
Revokes the specified external data share. Note: This action cannot be undone.
Parameters
----------
external_data_share_id : UUID
The external data share ID.
item_id : int, default=None
The Item ID
workspace : str
The Fabric workspace name.
"""

# https://learn.microsoft.com/en-us/rest/api/fabric/admin/external-data-shares/revoke-external-data-share?tabs=HTTP

(workspace, workspace_id) = resolve_workspace_name_and_id(workspace)

Expand All @@ -341,7 +386,20 @@ def revoke_external_data_share(
)


def list_capacities_delegated_tenant_settings(return_dataframe: Optional[bool] = True):
def list_capacities_delegated_tenant_settings(return_dataframe: Optional[bool] = True) -> Optional[pd.Dataframe | dict]:
"""
Returns list of tenant setting overrides that override at the capacities.
Parameters
----------
return_dataframe : bool, default=True
If True, returns a dataframe. If False, returns a dictionary
Returns
-------
pandas.DataFrame
A pandas dataframe showing a list of tenant setting overrides that override at the capacities.
"""

# https://learn.microsoft.com/en-us/rest/api/fabric/admin/tenants/list-capacities-tenant-settings-overrides?tabs=HTTP

Expand Down Expand Up @@ -700,17 +758,15 @@ def list_items(
dfC = list_capacities()
dfC_filt = dfC[dfC["Capacity Name"] == capacity_name]
if len(dfC_filt) == 0:
raise ValueError()
raise ValueError(f"{icons.red_dot} The '{capacity_name}' capacity does not exist.")
capacity_id = dfC_filt["Capacity Id"].iloc[0]
url += f"capacityId={capacity_id}&"
if state is not None:
url += f"state={state}&"
if type is not None:
url += f"type={type}&"

if url.endswith("?"):
url = url[:-1]
if url.endswith("&"):
if url.endswith("?") or url.endswith("&"):
url = url[:-1]

client = fabric.FabricRestClient()
Expand Down

0 comments on commit 2f577e7

Please sign in to comment.