Skip to content

Commit 2b0b966

Browse files
committed
calling hbi endpoint
1 parent 282be60 commit 2b0b966

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

samples/vizql_data_service_smoke_test_cap.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import argparse
1010
import logging
11+
import requests
12+
import json
1113

1214
import tableauserverclient as TSC
1315

@@ -28,41 +30,34 @@ def main():
2830
)
2931
parser.add_argument("resource_id")
3032

31-
args = parser.parse_args()
32-
# Convert Namespace to dictionary
33-
args_dict = vars(args)
34-
35-
# Format the dictionary as a string
36-
args_str = ', '.join(f'{key}={value}' for key, value in args_dict.items())
37-
38-
print(args_str)
3933
# Set logging level based on user input, or error by default
4034
logging_level = getattr(logging, args.logging_level.upper())
4135
logging.basicConfig(level=logging_level)
4236

4337
# Sign in
4438
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
4539
server = TSC.Server(args.server, use_server_version=True)
40+
4641
with server.auth.sign_in(tableau_auth):
4742
endpoint = server.datasources
4843

4944
# Get the resource by its ID
5045
resource = endpoint.get_by_id(args.resource_id)
46+
print(server)
47+
48+
49+
url = "https://" + args.server + "/api/v1/vizql-data-service/read-metadata"
5150

52-
# Populate permissions for the resource
53-
endpoint.populate_permissions(resource)
54-
permissions = resource.permissions
51+
payload = "{\n \"datasource\": {\n \"datasourceLuid\": \"" + args.resource_id + "\"\n },\n \"options\": {\n \"debug\": true\n }\n}"
52+
headers = {
53+
'X-Tableau-Auth': server.auth_token,
54+
'Content-Type': 'application/json',
55+
}
5556

56-
# Print result
57-
print(f"\n{len(permissions)} permission rule(s) found for workbook {args.resource_id}.")
57+
response = requests.request("POST", url, headers=headers, data=payload)
5858

59-
for permission in permissions:
60-
grantee = permission.grantee
61-
capabilities = permission.capabilities
62-
print(f"\nCapabilities for {grantee.tag_name} {grantee.id}:")
59+
print(response.text)
6360

64-
for capability in capabilities:
65-
print(f"\t{capability} - {capabilities[capability]}")
6661

6762

6863
if __name__ == "__main__":

0 commit comments

Comments
 (0)