Skip to main content

Simplify usage of Power Bi Admin API

Project description

SimplePBI

This is a simple library that makes it easy to use the Power Bi Admin API. One day SimplePBI will contain all the categories in the Power Bi Rest API (Admin, datasets, reports, etc). Each category is an Object. This means we need to initialize an object to start using its methods. In order to create them we need the Bearer token that can be obtain from a Token Object. Let's see how we can create an Admin Object to try the requests in that category.

# Import library
from simplepbi import token
from simplepbi import admin

We always need to import token object to create the object to run requests. Then we can pick the object of the Power Bi Rest API category we need. For instance "admin". The token can be created in two ways, the regular authentication and the service principal one. It depends which one you pick to complete the request. These are the necessary arguments to get a token:

  • tenant_id (you can get it from subscription resource in azure portal or ask for it to the IT department)
  • app_client_id (your app_id/client_id from the App registered in Azure with permissions to Power Bi Service)
  • username (professional email account in Azure AD)
  • password (professional password)
  • app_secret_key (secret key generated for the client id)
  • use_service_principal (True to athenticate with Service Principal and False to continue with user credentials)

NOTE: if you want to use service principal, be sure to have your tenant ready for that.
Register app example: https://blog.ladataweb.com.ar/post/188045227735/get-access-token
Service Principal permissions for admin api: https://docs.microsoft.com/en-us/power-bi/admin/read-only-apis-service-principal-authentication

# Creating objects

#Regular Login
tok = token.Token(tenant_id, app_client_id, username, password, None, use_service_principal=False)

#Service Principal
tok = token.Token(tenant_id, app_client_id, None, None, app_secret_key, use_service_principal=True)

ad = admin.Admin(tok.token)

As you can see the Token object contains a token attribute with the Bearer used by Azure to run rest methods. That attribute will be user to create the category objects like admin. Once we create our Object like admin, we can start using the requests adding the correct parameters if they are needed.

# Getting objects

All_Datasets = ad.get_datasets()

Datasets_In_Groups = ad.get_datasets_in_group(workspace_id)

The library get requests will return a response object .json() that python reads it as a Dict.

Change Log

0.0.1 (04/12/2020)

  • First Commit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SimplePBI-0.0.1.win-amd64.zip (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SimplePBI-0.0.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file SimplePBI-0.0.1.win-amd64.zip.

File metadata

  • Download URL: SimplePBI-0.0.1.win-amd64.zip
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for SimplePBI-0.0.1.win-amd64.zip
Algorithm Hash digest
SHA256 a1c190d8a2dc41fb2f8c0056f5697de285a59ec922400fc84721915fc7b0fe25
MD5 e20eff4817265f9af8ddb9b7bc5ee882
BLAKE2b-256 e455e685585699ff15dafb4ecf9d8ba9f513c7bc1e4841415a48bdeebbe0de0b

See more details on using hashes here.

File details

Details for the file SimplePBI-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: SimplePBI-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for SimplePBI-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c4cc4e9cd043f2690058418b20c4983a8e12bb673069c79f27a58279eebff2d
MD5 d4b6ead4295a1a21de156ac66df0a4fa
BLAKE2b-256 06a902698858a266c6deb0a5f259547d527d23c041a05e4d3248e6de169dc6ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page