8
8
9
9
import argparse
10
10
import logging
11
+ import requests
12
+ import json
11
13
12
14
import tableauserverclient as TSC
13
15
@@ -28,41 +30,34 @@ def main():
28
30
)
29
31
parser .add_argument ("resource_id" )
30
32
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 )
39
33
# Set logging level based on user input, or error by default
40
34
logging_level = getattr (logging , args .logging_level .upper ())
41
35
logging .basicConfig (level = logging_level )
42
36
43
37
# Sign in
44
38
tableau_auth = TSC .PersonalAccessTokenAuth (args .token_name , args .token_value , site_id = args .site )
45
39
server = TSC .Server (args .server , use_server_version = True )
40
+
46
41
with server .auth .sign_in (tableau_auth ):
47
42
endpoint = server .datasources
48
43
49
44
# Get the resource by its ID
50
45
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"
51
50
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
+ }
55
56
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 )
58
58
59
- for permission in permissions :
60
- grantee = permission .grantee
61
- capabilities = permission .capabilities
62
- print (f"\n Capabilities for { grantee .tag_name } { grantee .id } :" )
59
+ print (response .text )
63
60
64
- for capability in capabilities :
65
- print (f"\t { capability } - { capabilities [capability ]} " )
66
61
67
62
68
63
if __name__ == "__main__" :
0 commit comments