-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathuse_gateways_service.py
More file actions
63 lines (51 loc) · 1.68 KB
/
use_gateways_service.py
File metadata and controls
63 lines (51 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Demonstrates how to use the `Gateways` service."""
from pprint import pprint
from configparser import ConfigParser
from powerbi.client import PowerBiClient
# Initialize the Parser.
config = ConfigParser()
# Read the file.
config.read("config/config.ini")
# Get the specified credentials.
client_id = config.get("power_bi_api", "client_id")
redirect_uri = config.get("power_bi_api", "redirect_uri")
client_secret = config.get("power_bi_api", "client_secret")
# Initialize the Client.
power_bi_client = PowerBiClient(
client_id=client_id,
client_secret=client_secret,
scope=["https://analysis.windows.net/powerbi/api/.default"],
redirect_uri=redirect_uri,
credentials="config/power_bi_state.jsonc",
)
# Initialize the `Gateways` service.
gateways_service = power_bi_client.gateways()
# Get all Gateways the user is an admin for.
pprint(gateways_service.get_gateways())
# Get a specific Gateway by ID.
GATEWAY_ID = "12345678-1234-1234-1234-123456789012"
pprint(gateways_service.get_gateway(gateway_id=GATEWAY_ID))
# Get all Data Sources from a Gateway.
pprint(gateways_service.get_datasources(gateway_id=GATEWAY_ID))
# Get a specific Data Source from a Gateway.
DATASOURCE_ID = "12345678-1234-1234-1234-123456789012"
pprint(
gateways_service.get_datasource(
gateway_id=GATEWAY_ID,
datasource_id=DATASOURCE_ID,
)
)
# Check the connectivity status of a Data Source.
pprint(
gateways_service.get_datasource_status(
gateway_id=GATEWAY_ID,
datasource_id=DATASOURCE_ID,
)
)
# Get the users who have access to a Data Source.
pprint(
gateways_service.get_datasource_users(
gateway_id=GATEWAY_ID,
datasource_id=DATASOURCE_ID,
)
)