Package: tableau-utilities
tableau-utilitiesA module and CLI Utility for managing Tableau objects, locally, and in Tableau Online.Quick startInstallationFrom pypipip install tableau-utilitiesLocally using pipcd tableau-utilitiespip install ./Confirm installationwhich tableau_utilitiesDescribes where tableau-utilities has been installedtableau_utilities --helpShould populate a list of available commandsModule UsageSamplefromtableau_utilitiesimportDatasource,TableauServerfromtableau_utilitiesimporttableau_file_objectsastfofrommy_secretsimporttableau_credsdefmain():# The datasource identified by the IDdatasource_id='abc123'# Create a Tableau Connectionts=TableauServer(**tableau_creds)# Download a Datasourcedatasource_path=ts.download_datasource(datasource_id=datasource_id)# Define a Datasource object from the datasource_pathdatasource=Datasource(datasource_path)# Define a new folderfolder=tfo.Folder(name='Time Dimensions')# Define a new Columncolumn=tfo.Column(name='Calculation_1',caption='Max Created Datetime',role='dimension',type='ordinal',datatype='datetime',desc='The maximum Created Datetime.',calculation='MAX([Created Datetime])')# Add the new column to the new folder, as a folder-itemfolder_item=tfo.FolderItem(name=column.name)folder.folder_item.add(folder_item)# Add the column and folder to the datasourcedatasource.columns.add(column)datasource.folders_common.add(folder)# Enforce the Column, to update the Metadatadatasource.enforce_column(column,remote_name='max_created_at')# Save changes to the Datasourcedatasource.save()# Publish & Overwrite the Datasourcets.publish_datasource(datasource_path,datasource_id=datasource_id)if__name__=='__main__':main()CLI UsageHelpSee the top level CLI arguments including the commands.tableau_utilities --helpSee the help for acommand.
Each command has arguments for a different grouping of actions.tableau_utilities server_operate --helpAuthentication OptionsPass your credentials into the commandtableau_utilities --token_name my_token_name --token_secret 1q2w3e4r5t6y7u8i9o --site mysitename --server 10az server_info --list_object datasource --list_format namesUse a settings YAML filetableau_utilities  --settings_path my_settings.yaml server_info --list_object datasource --list_format namesUse environment variablestableau_utilities server_info --list_object datasource --list_format namesUsing the 1password CLI with op runop run --env-file=.env -- tableau_utilities server_info list_--list_object datasource --list_format namesExamples for each commandserver_infoLists all datasources in your site ordered by IDtableau_utilities --token_name my_token_name --token_secret 1q2w3e4r5t6y7u8i9o --site mysitename --server 10az server_info --list_object datasource --list_format ids_names --list_sort_field idserver_operateDownload a datasource by nametableau_utilities --token_name my_token_name --token_secret 1q2w3e4r5t6y7u8i9o --site_name mysitename --server 10az --name 'My Awesome Datasource' --project_name 'My Fabulous Project' server_operate --download datasourcePublish Datasource with embedded connection credentialstableau_utilities -tn my_token_name -ts 1q2w3e4r5t6y7u8i9o -sn mysitename -s 10az -n 'My Awesome Datasource' -pn 'My Fabulous Project' --file_path '/Downloads/My Awesome Datasource.tdsx' --conn_user username --conn_pw abc123 server_operate --publish datasourceEmbed Connection credentials for a Datasourcetableau_utilities -tn my_token_name -ts 1q2w3e4r5t6y7u8i9o -sn mysitename -s 10az -n 'My Awesome Datasource' -pn 'My Fabulous Project' --conn_user username --conn_pw abc123 server_operate --embed_connectiondatasourceSave the TDS for a datasource from a local datasource to view the raw XMLtableau_utilities --location local --file_path '/Downloads/My Awesome Datasource.tdsx' --save_tds  datasourceSave the TDS for a datasource from an online datasource to view the raw XMLtableau_utilities --token_name my_token_name --token_secret 1q2w3e4r5t6y7u8i9o --site mysitename --server 10az --location online --name 'My Awesome Datasource' --project_name 'My Cool Project' --save_tds datasourceChange the folder for a columntableau_utilities --location local --file_path '/Downloads/Metadata Alter.tdsx' datasource --column_name COLUMN_NAME --folder_name 'Folder Name'Update/Add attributes for a columntableau_utilities --location local --file_path '/Downloads/Metadata Alter.tdsx' datasource --column_name COLUMN_NAME --remote_name COLUMN_NAME_FROM_CONNECTION --caption 'My Pretty Column Name' --persona string_dimension --desc 'A help description for Tableau users to understand the data'Delete foldertableau_utilities --location local --file_path '/Downloads/Metadata Alter.tdsx' datasource --folder_name 'Folder Name' --delete folderEnforce Datasource connection credentialstableau_utilities -l local -f '/Downloads/Metadata Alter.tdsx' --conn_type snowflake --conn_host https://some.url.com --conn_user username --conn_pw password --conn_db database_name --conn_schema schema_name --conn_role role_name --conn_warehouse warehouse_name datasource --embed_connectiongenerate_configGenerate a config from a datasource in online/servertableau_utilities --token_name my_token_name --token_secret 1q2w3e4r5t6y7u8i9o --site mysitename --server 10az --location online --name 'My Awseome Datasource' --project_name 'My Team Project' generate_configGenerate a config from a datasource in online/server and add definitions from a csvtableau_utilities --token_name my_token_name --token_secret 1q2w3e4r5t6y7u8i9o --site mysitename --server 10az --location online --name 'My Awseome Datasource' --project_name 'My Team Project' generate_config --definitions_csv /Desktop/new_descriptions.csvGenerate a config from a local file. Add a file prefix and print the debugging logs to the consoletableau_utilities --debugging_logs generate_config --location local --file_path '/code/tableau-utilities/tmp_tdsx_and_config/My Awesome Datasource.tdsx' --file_prefixcsv_configWrite the config to a csv with 1 row per field per datasourcetableau_utilities csv_config --config_list /code/airflow/dags/tableau/configs/column_config.json /code/airflow/dags/tableau/configs/tableau_calc_config.jsonmerge_configMerge a new config into your main configtableau_utilities merge_config --merge_with config --existing_config /code/tableau-utilities/tmp_tdsx_and_config/main__column_config.json --additional_config /code/tableau-utilities/tmp_tdsx_and_config/new__column_config.json --merged_config code/dbt-repo/tableau_datasource_configs/column_configMerge data defintions from a csv into your main configtableau_utilities --definitions_csv /Desktop/new_definitions.csv merge_config --merge_with csv  merge_config --existing_config code/dbt-repo/tableau_datasource_configs/column_config.json --merged_config code/dbt-repo/tableau_datasource_configs/column_configDevelopmentpip install -r requirements.txtCreatesettings.yamlfile in the directory wheretableau_utilitiesis called.Seesample_settings.yamlfor an example.test_tableau_utilitiesAdd tests as neededRun when making changesMaintenanceThis project is actively maintained by the Data Platform team at@hoverinc.