Publish datasource and connection elements
Describe the bug
It appears to me that the publish datasource method utilizes a connectionCredentials subelement, and not a connections element.
https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#publish_data_source
The way I see it, we could solve this by one of two routes:
- Combine the connections and connection_credentials inside the function call to a single object that gets passed to the publish request factory.
- Make connection credentials accept a sequence, and surface an error to TSC users when they provide both.
Versions Details of your environment, including:
- Tableau Server version (or note if using Tableau Online) N/A
- Python version 3.8.10
- TSC library version 0.19.0
Yes - I'm trying to figure out how this happened, but so far it's a mystery. I think we want to end up with just the connection_credentials option as a sequence, but I'll take a look to see if there's a way we can temporarily support both inputs.
Looking at it again, workbook endpoint's publish method uses a connections element instead of a connection_credentials element. I think if we leave both inputs there, but just provide a warning, then the function signature can be the same between workbook and datasource.
What I have resorted to doing in my client code is to publishing the datasource, then running update_connection after it was published. Passing only connection_credentials to the datasource publish is technically ambiguous because you can put multiple connection_credentials elements as children to the datasource element. If you have multiple connections to different databases, with the same username but different passwords... How would the API know which credential is supposed to go with which connection?
That has me leaning towards option 1, IMO.
Circling back to this. I think the best option might be to mirror the workbook.publish endpoint and have it be connections=Sequence[ConnectionItem]. I think that would support the most scenarios and have the benefit of keeping the workbook and datasource endpoints as similar.