Dbx to Pbi Wrapper
Project description
DbxPbiApiWrapper
Overview
DbxPbiApiWrapper is a Python-based wrapper designed to simplify interactions with the Power BI API. It provides a set of classes and methods for handling common tasks such as dataset management, refresh operations, and user access management. This library is optimized for integration with Databricks, making it ideal for seamless data analytics workflows.
Features
- Azure AD Token Management: Automated handling of Azure Active Directory (AAD) token validation.
- Dataset Operations: Retrieve, list, and manage datasets within specified Power BI workspaces.
- Refresh Functionality: Easily trigger and monitor dataset refreshes, with built-in checks for ongoing operations.
- User Access Management: Fetch detailed user access information for specific datasets.
- Refresh History: Retrieve the history of dataset refresh operations.
Prerequisites
- Python 3.8 or higher
- Microsoft Power BI Service account with the following API permissions:
Dataset.Read.AllDataset.Write.AllGroup.Read.All
- Azure AD App registration configured with the necessary permissions.
Installation
To install the package, clone the repository and use:
pip install DbxPbiApiWrapper
Usage
Initialization
Initialize the DbxPbiDatasetWrapper class with your Azure AD tenant details and credentials.
from DbxPbiWrapper import DbxPbiDatasetWrapper
# Define your credentials
tenant = "your-tenant-id"
account_key = "your-account-key"
account_secret = "your-account-secret"
# Initialize the wrapper
pbi_wrapper = DbxPbiDatasetWrapper(tenant, account_key, account_secret)
Example 1: Refresh a Power BI Dataset
Trigger a refresh for a specific dataset in a workspace:
workspace_name = "SalesWorkspace"
dataset_name = "SalesDataset"
try:
*Trigger dataset refresh* pbi_wrapper.refreshPbiDataset(workspace_name, dataset_name)
print("Dataset refresh initiated successfully.")
except Exception as e:
print(f"Failed to refresh dataset: {str(e)}")
Example 2: List All Datasets in a Workspace
Retrieve all datasets in a specified workspace:
workspace_name = "MarketingWorkspace"
# Fetch and display datasets
datasets = pbi_wrapper.getAllDatasetsInWorkspace(workspace_name)
if datasets:
for dataset in datasets:
print(f"Dataset Name: {dataset['name']}, Dataset ID: {dataset['id']}")
else:
print("No datasets found in the workspace.")
Example 3: Get Users with Access to a Dataset
Fetch a list of users who have access to a specific dataset:
workspace_name = "FinanceWorkspace"
dataset_name = "RevenueDataset"
# Retrieve user access details
users = pbi_wrapper.getUsersInDataset(workspace_name, dataset_name)
if users:
for user in users:
print(f"User: {user['displayName']}, Role: {user['datasetUserAccessRight']}")
else:
print("No users found with access to this dataset.")
Class Descriptions
DbxPbiDatasetWrapper
Main interface for interacting with Power BI services:
refreshPbiDataset(workspaceName, datasetName): Initiates a dataset refresh.getAllDatasetsInWorkspace(workspaceName): Lists all datasets in a workspace.getAllWorkspaces(): Retrieves a list of all available workspaces.getUsersInDataset(workspaceName, datasetName): Fetches users with access to a dataset.getDatasetRefreshHistory(workspaceName, datasetName): Returns the refresh history of a dataset.
Error Handling
The library includes basic error handling for common issues like:
- Invalid Azure AD credentials
- Insufficient API permissions
- Ongoing dataset refresh preventing new refresh requests
- It is recommended to implement proper exception handling when integrating this library into your projects.
Contribution
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a new branch (feature/your-feature-name).
- Submit a pull request for review.
Contact
For support or questions, please contact the author at info@j2datagroup.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbxpbiapiwrapper-0.0.8.tar.gz.
File metadata
- Download URL: dbxpbiapiwrapper-0.0.8.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9121b86f23e09312ae391e8dc135938ca7a73a4a6831a060519d607d006afe2
|
|
| MD5 |
d82253d04252e7c79dbc0c492826908f
|
|
| BLAKE2b-256 |
36f63802525217182a7f6cdc38e20005c9bbd743207d71c6372c6927daffd4ab
|
Provenance
The following attestation bundles were made for dbxpbiapiwrapper-0.0.8.tar.gz:
Publisher:
pypublish.yml on J2DataGroup/DbxPbiWrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbxpbiapiwrapper-0.0.8.tar.gz -
Subject digest:
d9121b86f23e09312ae391e8dc135938ca7a73a4a6831a060519d607d006afe2 - Sigstore transparency entry: 148004769
- Sigstore integration time:
-
Permalink:
J2DataGroup/DbxPbiWrapper@0225d418a3034816fc424fadb23ba550e5b3086c -
Branch / Tag:
refs/tags/V0.0.8 - Owner: https://github.com/J2DataGroup
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypublish.yml@0225d418a3034816fc424fadb23ba550e5b3086c -
Trigger Event:
release
-
Statement type:
File details
Details for the file DbxPbiApiWrapper-0.0.8-py3-none-any.whl.
File metadata
- Download URL: DbxPbiApiWrapper-0.0.8-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5986567e54f7b779a7786573f0eac764ca50366f8dff1479bd02655c92d860e2
|
|
| MD5 |
80c57fae928e22ee4186bec6f883c4c4
|
|
| BLAKE2b-256 |
a70cef68c438a4b78c01edaa9a705f5827cd39fe12ca0d43e44cfc27db8f6837
|
Provenance
The following attestation bundles were made for DbxPbiApiWrapper-0.0.8-py3-none-any.whl:
Publisher:
pypublish.yml on J2DataGroup/DbxPbiWrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbxpbiapiwrapper-0.0.8-py3-none-any.whl -
Subject digest:
5986567e54f7b779a7786573f0eac764ca50366f8dff1479bd02655c92d860e2 - Sigstore transparency entry: 148004771
- Sigstore integration time:
-
Permalink:
J2DataGroup/DbxPbiWrapper@0225d418a3034816fc424fadb23ba550e5b3086c -
Branch / Tag:
refs/tags/V0.0.8 - Owner: https://github.com/J2DataGroup
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypublish.yml@0225d418a3034816fc424fadb23ba550e5b3086c -
Trigger Event:
release
-
Statement type: