Skip to content

Conversation

@vchavatapalli
Copy link
Contributor

@vchavatapalli vchavatapalli commented Jul 15, 2025

This are new API's coming up in next release

  1. Update multiple connections in a single workbook - Takes multiple connection, authType and credentials as input
  2. Update multiple connections in a single datasource - Takes multiple connection, authType and credentials as input

Attaching our test document for more details:
https://salesforce.quip.com/gQy6AHWU1Utt


@api(version="3.26")
def update_connections(
self, datasource_item: DatasourceItem, connection_luids: list[str], authentication_type: str, username: Optional[str] = None, password: Optional[str] = None, embed_password: Optional[bool] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It changes the username, password, embed, and auth type setting uniformly across all of the listed connections?

The type for connection_luids should actually be Iterable[str] since the only criteria is that it can be looped over.

Comment on lines 354 to 379
from xml.etree.ElementTree import Element, SubElement, tostring

url = f"{self.baseurl}/{datasource_item.id}/connections"
print("Method URL:", url)

ts_request = Element("tsRequest")

# <connectionLuids>
conn_luids_elem = SubElement(ts_request, "connectionLuids")
for luid in connection_luids:
SubElement(conn_luids_elem, "connectionLuid").text = luid

# <connection>
connection_elem = SubElement(ts_request, "connection")
connection_elem.set("authenticationType", authentication_type)

if username:
connection_elem.set("userName", username)

if password:
connection_elem.set("password", password)

if embed_password is not None:
connection_elem.set("embedPassword", str(embed_password).lower())

request_body = tostring(ts_request)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML payload generation is typically done in the request_factory.py. Can this be moved?


# Update workbook_connections
@api(version="3.26")
def update_connections(self, workbook_item: WorkbookItem, connection_luids: list[str], authentication_type: str, username: Optional[str] = None, password: Optional[str] = None, embed_password: Optional[bool] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as the datasource function signature.

Comment on lines 360 to 384
from xml.etree.ElementTree import Element, SubElement, tostring

url = f"{self.baseurl}/{workbook_item.id}/connections"

ts_request = Element("tsRequest")

# <connectionLuids>
conn_luids_elem = SubElement(ts_request, "connectionLuids")
for luid in connection_luids:
SubElement(conn_luids_elem, "connectionLuid").text = luid

# <connection>
connection_elem = SubElement(ts_request, "connection")
connection_elem.set("authenticationType", authentication_type)

if username:
connection_elem.set("userName", username)

if password:
connection_elem.set("password", password)

if embed_password is not None:
connection_elem.set("embedPassword", str(embed_password).lower())

request_body = tostring(ts_request)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as datasource, this belongs in request factory

jorwoods added 2 commits July 19, 2025 21:57
Also correct the type hints to clarify that it accepts any
Iterable.
@bcantoni
Copy link
Contributor

bcantoni commented Jul 20, 2025

@vchavatapalli thanks for adding this. For a better trail for the record, could you update this PR title & description to explain which are the new APIs you're adding?

Also, make sure to run black and mypy as explained here so your PR will pass the checks: https://tableau.github.io/server-client-python/docs/dev-guide

@vchavatapalli
Copy link
Contributor Author

@bcantoni / @jorwoods - Working on the comments, will update you shortly

chore: refactor XML payload into RequestFactory
@vchavatapalli vchavatapalli requested a review from jorwoods July 21, 2025 21:17
@bcantoni bcantoni changed the title Updated TSC with new API's New APIs: Update multiple connections in a single workbook/datasource Jul 21, 2025
@bcantoni bcantoni merged commit d8922ed into tableau:development Jul 21, 2025
22 checks passed
@vchavatapalli vchavatapalli deleted the Adding-new-update-connections-api branch July 22, 2025 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants