Skip to content

Commit 542d0e8

Browse files
Merge pull request #1892 from sushmasreedharan-tableau/dev/sreedharan/w-24145082-wif-docs
@W-24145082 - docs: document WIF connection fields and bulk kwargs
2 parents 59ab30b + 865a6c1 commit 542d0e8

1 file changed

Lines changed: 91 additions & 5 deletions

File tree

‎docs/api-ref.md‎

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ Name | Description
233233
`server_address` | The server address for the connection (host name for the Tableau Server).
234234
`server_port` | The port used for the connection.
235235
`connection_credentials` | The Connection Credentials object containing authentication details for the connection. Replaces username/password/embed_password when publishing a flow, document or workbook file in the request body.
236+
`workgroup_auth_mode` | (Optional) The Workload Identity Federation (WIF) auth mode for the connection. Set to one of the values on the `ConnectionItem.WorkgroupAuthMode` nested value set: `WIF` (`"workload-identity-federation"`, e.g. Snowflake direct WIF) or `WIF_IMPERSONATION` (`"workload-identity-federation-impersonation"`, e.g. Google BigQuery impersonation WIF). Requires REST API 3.30+ (Tableau Server release 26.3) with WIF configured on the site. Older servers silently ignore the attribute.
237+
`auth_federation_service_account` | (Optional) The service account email the server impersonates for WIF. Set this only together with `workgroup_auth_mode = WorkgroupAuthMode.WIF_IMPERSONATION`; the server rejects a service account alongside the direct `WIF` mode.
236238

237239
Source file: models/connection_item.py
238240

@@ -1724,13 +1726,42 @@ server.datasources.update_connection(datasource_item, conn)
17241726

17251727
See [`samples/update_connection_auth.py`](https://github.com/tableau/server-client-python/blob/master/samples/update_connection_auth.py) for a runnable end-to-end example, and the REST API [authenticationType reference](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_data_sources.htm#update_data_source_connection) for the full list of supported values.
17261728

1729+
**How-to: convert an existing connection to Workload Identity Federation (WIF)**
1730+
1731+
As of REST API v3.30 (Tableau Server release 26.3), an existing connection on a WIF-configured site can be flipped to WIF authentication in place. Set `workgroup_auth_mode` on the `ConnectionItem` to one of the values on the `ConnectionItem.WorkgroupAuthMode` nested value set; for the impersonation mode, also set `auth_federation_service_account` to the service account email. The server derives the stored auth type from the mode, so leave `auth_type` unset or `"oauth"`.
1732+
1733+
Direct WIF (e.g., Snowflake):
1734+
1735+
```py
1736+
server.datasources.populate_connections(datasource_item)
1737+
conn = next(c for c in datasource_item.connections if c.connection_type == 'snowflake')
1738+
conn.workgroup_auth_mode = TSC.ConnectionItem.WorkgroupAuthMode.WIF
1739+
server.datasources.update_connection(datasource_item, conn)
1740+
```
1741+
1742+
Impersonation WIF (e.g., Google BigQuery):
1743+
1744+
```py
1745+
server.datasources.populate_connections(datasource_item)
1746+
conn = next(c for c in datasource_item.connections if c.connection_type == 'googlebigquery')
1747+
conn.workgroup_auth_mode = TSC.ConnectionItem.WorkgroupAuthMode.WIF_IMPERSONATION
1748+
conn.auth_federation_service_account = 'sa@proj.iam.gserviceaccount.com'
1749+
server.datasources.update_connection(datasource_item, conn)
1750+
```
1751+
1752+
Usage rules the server enforces:
1753+
1754+
- Resend `workgroup_auth_mode` on every subsequent update of a WIF connection; omitting it on a later update returns HTTP 400.
1755+
- Set `auth_federation_service_account` only with `WorkgroupAuthMode.WIF_IMPERSONATION`. The server rejects a service account alongside the direct `WIF` mode.
1756+
- The server does not echo `workgroupAuthMode` or `authFederationServiceAccount` on connections-GET responses today, so `ConnectionItem.workgroup_auth_mode` and `ConnectionItem.auth_federation_service_account` parsed from a response will typically be `None` even when the connection is WIF-configured.
1757+
17271758
<br>
17281759
<br>
17291760

17301761
#### datasources.update_connections
17311762

17321763
```py
1733-
datasources.update_connections(datasource_item, connection_luids, authentication_type, username=None, password=None, embed_password=None)
1764+
datasources.update_connections(datasource_item, connection_luids, authentication_type, username=None, password=None, embed_password=None, workgroup_auth_mode=None, auth_federation_service_account=None)
17341765
```
17351766

17361767
Bulk updates one or more datasource connections by LUID.
@@ -1739,18 +1770,20 @@ REST API: [Update Data Source Connections](https://help.tableau.com/current/api/
17391770

17401771
**Version**
17411772

1742-
This endpoint is available with REST API version 3.26 and up.
1773+
This endpoint is available with REST API version 3.26 and up. The `workgroup_auth_mode` and `auth_federation_service_account` parameters require REST API 3.30+ (Tableau Server release 26.3).
17431774

17441775
**Parameters**
17451776

17461777
Name | Description
17471778
:--- | :---
17481779
`datasource_item` | The `DatasourceItem` containing the connections to update.
17491780
`connection_luids` | An iterable of connection LUIDs (strings) to update.
1750-
`authentication_type` | The authentication type to use (e.g., `'auth-keypair'`).
1781+
`authentication_type` | The authentication type to use (e.g., `'auth-keypair'`). Leave unset or `"oauth"` when sending `workgroup_auth_mode`; the server derives the stored auth type from the WIF mode.
17511782
`username` | (Optional) The username to set.
17521783
`password` | (Optional) The password or secret to set.
17531784
`embed_password` | (Optional) Whether to embed the password.
1785+
`workgroup_auth_mode` | (Optional) WIF auth mode to apply to every LUID in the request. One of `ConnectionItem.WorkgroupAuthMode.WIF` or `ConnectionItem.WorkgroupAuthMode.WIF_IMPERSONATION`. Requires REST API 3.30+.
1786+
`auth_federation_service_account` | (Optional) Service account email to apply to every LUID. Set only together with `WIF_IMPERSONATION`.
17541787

17551788
**Returns**
17561789

@@ -1764,6 +1797,19 @@ luids = [conn.id for conn in datasource_item.connections]
17641797
updated = server.datasources.update_connections(datasource_item, luids, 'auth-keypair', username='myuser', password='mysecret')
17651798
```
17661799

1800+
**Example — flip connections to WIF (impersonation):**
1801+
1802+
```py
1803+
server.datasources.populate_connections(datasource_item)
1804+
luids = [conn.id for conn in datasource_item.connections if conn.connection_type == 'googlebigquery']
1805+
updated = server.datasources.update_connections(
1806+
datasource_item, luids,
1807+
authentication_type='oauth',
1808+
workgroup_auth_mode=TSC.ConnectionItem.WorkgroupAuthMode.WIF_IMPERSONATION,
1809+
auth_federation_service_account='sa@proj.iam.gserviceaccount.com',
1810+
)
1811+
```
1812+
17671813
<br>
17681814
<br>
17691815

@@ -2933,6 +2979,8 @@ connection.server_address = 'new-server.example.com'
29332979
updated_connection = server.flows.update_connection(flow, connection)
29342980
```
29352981

2982+
**Workload Identity Federation (WIF):** setting `connection_item.workgroup_auth_mode` (and, for impersonation, `connection_item.auth_federation_service_account`) emits the matching attributes on the request payload via the shared `Connection.update_req` builder. Server-side handling of WIF on flow connections is governed by the flow endpoint and may differ from workbook and datasource behavior.
2983+
29362984
<br>
29372985
<br>
29382986

@@ -10375,6 +10423,26 @@ connection.password = 'PASSWORD'
1037510423
server.workbooks.update_connection(workbook, connection)
1037610424
```
1037710425

10426+
**How-to: convert an existing workbook connection to Workload Identity Federation (WIF)**
10427+
10428+
As of REST API v3.30 (Tableau Server release 26.3), an existing connection on a WIF-configured site can be flipped to WIF authentication in place. Set `workgroup_auth_mode` on the `ConnectionItem` to one of the values on the `ConnectionItem.WorkgroupAuthMode` nested value set; for the impersonation mode, also set `auth_federation_service_account`. The server derives the stored auth type from the mode, so leave `auth_type` unset or `"oauth"`.
10429+
10430+
```py
10431+
# Direct WIF (e.g., Snowflake)
10432+
server.workbooks.populate_connections(workbook)
10433+
conn = next(c for c in workbook.connections if c.connection_type == 'snowflake')
10434+
conn.workgroup_auth_mode = TSC.ConnectionItem.WorkgroupAuthMode.WIF
10435+
server.workbooks.update_connection(workbook, conn)
10436+
10437+
# Impersonation WIF (e.g., Google BigQuery)
10438+
conn = next(c for c in workbook.connections if c.connection_type == 'googlebigquery')
10439+
conn.workgroup_auth_mode = TSC.ConnectionItem.WorkgroupAuthMode.WIF_IMPERSONATION
10440+
conn.auth_federation_service_account = 'sa@proj.iam.gserviceaccount.com'
10441+
server.workbooks.update_connection(workbook, conn)
10442+
```
10443+
10444+
Resend `workgroup_auth_mode` on every subsequent update of a WIF connection; omitting it on a later update returns HTTP 400. Set `auth_federation_service_account` only with `WIF_IMPERSONATION` — the server rejects a service account alongside the direct `WIF` mode. The server does not echo these attributes on connections-GET responses today, so parsed values are typically `None`.
10445+
1037810446
<br>
1037910447
<br>
1038010448

@@ -10774,23 +10842,29 @@ result = server.workbooks.schedule_extract_refresh('schedule-id-here', workbook)
1077410842
#### workbooks.update_connections
1077510843

1077610844
```py
10777-
workbooks.update_connections(workbook_item, connection_luids, authentication_type, username=None, password=None, embed_password=None)
10845+
workbooks.update_connections(workbook_item, connection_luids, authentication_type, username=None, password=None, embed_password=None, workgroup_auth_mode=None, auth_federation_service_account=None)
1077810846
```
1077910847

1078010848
Bulk updates one or more workbook connections by LUID, including the authentication type, username, password, and whether to embed the password.
1078110849

1078210850
REST API: [Update Workbook Connections](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooks_and_views.htm#update_workbook_connections)
1078310851

10852+
**Version**
10853+
10854+
The `workgroup_auth_mode` and `auth_federation_service_account` parameters require REST API 3.30+ (Tableau Server release 26.3).
10855+
1078410856
**Parameters**
1078510857

1078610858
Name | Description
1078710859
:--- | :---
1078810860
`workbook_item` | The `WorkbookItem` containing the connections to update.
1078910861
`connection_luids` | An iterable of connection LUIDs (strings) to update.
10790-
`authentication_type` | The authentication type to use (e.g., `'AD Service Principal'`).
10862+
`authentication_type` | The authentication type to use (e.g., `'AD Service Principal'`). Leave unset or `"oauth"` when sending `workgroup_auth_mode`; the server derives the stored auth type from the WIF mode.
1079110863
`username` | (Optional) The username to set (e.g., client ID for keypair auth).
1079210864
`password` | (Optional) The password or secret to set.
1079310865
`embed_password` | (Optional) Whether to embed the password.
10866+
`workgroup_auth_mode` | (Optional) WIF auth mode to apply to every LUID in the request. One of `ConnectionItem.WorkgroupAuthMode.WIF` or `ConnectionItem.WorkgroupAuthMode.WIF_IMPERSONATION`. Requires REST API 3.30+.
10867+
`auth_federation_service_account` | (Optional) Service account email to apply to every LUID. Set only together with `WIF_IMPERSONATION`.
1079410868

1079510869
**Returns**
1079610870

@@ -10805,6 +10879,18 @@ luids = [conn.id for conn in workbook.connections]
1080510879
updated = server.workbooks.update_connections(workbook, luids, 'UserNameAndPassword', username='myuser', password='mypassword', embed_password=True)
1080610880
```
1080710881

10882+
**Example — flip workbook connections to WIF (direct):**
10883+
10884+
```py
10885+
server.workbooks.populate_connections(workbook)
10886+
luids = [conn.id for conn in workbook.connections if conn.connection_type == 'snowflake']
10887+
updated = server.workbooks.update_connections(
10888+
workbook, luids,
10889+
authentication_type='oauth',
10890+
workgroup_auth_mode=TSC.ConnectionItem.WorkgroupAuthMode.WIF,
10891+
)
10892+
```
10893+
1080810894
<br>
1080910895
<br>
1081010896

0 commit comments

Comments
 (0)