Querying Tableau workbook permissions for all groups and users with Python and the REST API

Поділитися
Вставка
  • Опубліковано 17 лип 2022
  • Data governance can be hard.
    In this tutorial we'll explore one way to automate the process of identifying exactly who (groups and users) can do what as far as workbooks are concerned in your Tableau environment.
    Medium tutorial article on triggering extract refreshes:
    towardsdatascience.com/query-...
    For more written tutorials, check out the Medium blog posts!
    / elliottstam​
    Python version used: 3.8
    To make sure you have all the latest features, update tableau-api-lib:
    pip install -U tableau-api-lib
    Getting started with tableau-api-lib: • tableau-api-lib (blitz...
    Join the Tableau Developer Program to get involved. It coms with a free Tableau Online developer site!
    www.tableau.com/developer

КОМЕНТАРІ • 14

  • @ekaterinakalabush5541
    @ekaterinakalabush5541 Рік тому

    Thank you!!!🙂

  • @fabersoaks4975
    @fabersoaks4975 Рік тому

    Hey @Devyx, can we modify this to get a data frame with all workbooks inside a particular group and a User?

    • @devyx
      @devyx  Рік тому +1

      Yes, the code is fully available via the article (points to a GitHub gist) and you can modify to your heart's content.
      You could also take the output CSV to a Tableau workbook as I did, and then filter by users and groups with convenient quickfilters.

    • @fabersoaks4975
      @fabersoaks4975 Рік тому

      @@devyx thanks 😊

  • @kunalbose6360
    @kunalbose6360 Рік тому

    If we have tableau data source file and we want to update some formula like we have profit or something like that

    • @devyx
      @devyx  Рік тому

      Tableau's REST API doesn't support modifying calculations. You can manually download and edit the datasource and republish it, or implement custom code.
      You could probably do what you want but with quite a bit of custom code. You can download the .tdsx file (supported by API), then unzip the resulting .tdsx file, then edit the .tds file (it is really just an XML file) and modify the formula. Then you can save the .tds file, zip it back into a .tdsx file, and then republish (supported by REST API). All those steps can be done with code, so it can be executed as a Python script.
      But again, there is no REST API endpoint to edit formulas within a datasource.

    • @kunalbose6360
      @kunalbose6360 Рік тому

      @@devyx Thanks bro

    • @kunalbose6360
      @kunalbose6360 Рік тому

      @@devyx Bruh can please share me some source for parsing nd modify .tds file using python ..... I want to know how it actually works

  • @kunalbose6360
    @kunalbose6360 Рік тому

    Please make videos of Tableau document api python also

    • @devyx
      @devyx  Рік тому

      Hey Kunal, good suggestion. Will keep this in mind 👍

  • @workperson8159
    @workperson8159 Рік тому

    I was running the code in jupyter but after fetching a certain number of group permissions for workbooks, suddenly I got this error!
    KeyError Traceback (most recent call last)
    Input In [12], in ()
    33 print(f"fetching group permissions for workbook '{workbook.workbook_name}...'")
    34 response = conn.query_workbook_permissions(workbook_id=workbook.workbook_id)
    ---> 35 permissions_df = pd.DataFrame(response.json()["permissions}["granteeCapabilities"])
    36 if "group" not in permissions_df.columns:
    37 continue
    KeyError: 'granteeCapabilities'
    Can you please tell why is this error poping up?

    • @devyx
      @devyx  Рік тому

      Ah, this likely happens because you have a workbook with no grantees on the problematic workbook, meaning no groups or users have permissions defined for the workbook. In my environment all workbooks have some permission capabilities assigned so I did not encounter this.
      You have multiple options:
      * Add a filter which removes the workbooks where permissions are irrelevant
      * Add logic that checks if the key exists in any given JSON response before attempting to access it
      * Add a try/except on KeyError for each loop iteration that continues the next iteration if the exception is thrown
      This will probably be fairly common, so I'll plan to update the code in the GitHub gist accordingly.

    • @devyx
      @devyx  Рік тому

      The Github gist is now updated, introducing a try/except clause which will handle workbooks which do not have group or user permissions defined:
      gist.github.com/divinorum-webb/3ec37e8669bb8b48caac9bfe4e6f3ff3

    • @workperson8159
      @workperson8159 Рік тому

      @@devyx Wow, Elliott much appreciated