Skip to content

Commit d04bf1f

Browse files
jacalataclaude
andauthored
Document that publish server_address matches connections rather than changing them (#1903)
* Document that publish server_address matches connections rather than changing them Users passing a ConnectionItem with a new server_address to workbooks.publish expected the published connection to point at that server, and got error 403007 instead. The server uses server_address to find the matching connection embedded in the workbook file; it does not change it. Explain this, show how to change the address afterwards with workbooks.update_connection, and correct the ConnectionItem server_address description (it is the data source host, not the Tableau Server host). Closes #337 Co-Authored-By: Claude Code <noreply@anthropic.com> * Correct workbooks.publish and update_connection reference entries The publish signature listed file_path and publish_mode (the parameters are file and mode) and omitted the parameters argument and defaults, a parameter description repeated workbook_item twice, and workbooks.update_connection was documented as returning None when it returns the updated ConnectionItem. Co-Authored-By: Claude Code <noreply@anthropic.com> * Remove the unverified 403007 claim from the workbooks.publish note Co-Authored-By: Claude Code <noreply@anthropic.com> --------- Co-authored-by: Claude Code <noreply@anthropic.com>
1 parent a9b435b commit d04bf1f

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

‎docs/api-ref.md‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ Name | Description
679679
`username` | The username for the connection (see ConnectionCredentials).
680680
`password` | The password used for the connection (see ConnectionCredentials).
681681
`embed_password` | (Boolean) Determines whether to embed the password (`True`) for the workbook or data source connection or not (`False`) (see ConnectionCredentials).
682-
`server_address` | The server address for the connection (host name for the Tableau Server).
682+
`server_address` | The server address for the connection (host name of the data source server). When publishing a workbook, this identifies which embedded connection the credentials apply to and does not change it; use `workbooks.update_connection` to change it after publishing.
683683
`server_port` | The port used for the connection.
684684
`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.
685685
`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.
@@ -10386,7 +10386,7 @@ print(workbook.name)
1038610386
#### workbooks.publish
1038710387

1038810388
```py
10389-
workbooks.publish(workbook_item, file_path, publish_mode, connections, skip_connection_check, as_job)
10389+
workbooks.publish(workbook_item, file, mode, connections=None, as_job=False, skip_connection_check=False, parameters=None)
1039010390
```
1039110391

1039210392
Publish a workbook to the specified site.
@@ -10407,12 +10407,14 @@ REST API: [Publish Workbook](https://help.tableau.com/current/api/rest_api/en-us
1040710407
Name | Description
1040810408
:--- | :---
1040910409
`workbook_item` | The `workbook_item` specifies the workbook you are publishing. When you are adding a workbook, you need to first create a new instance of a `workbook_item` that includes a `project_id` of an existing project. The name of the workbook will be the name of the file, unless you also specify a name for the new workbook when you create the instance. See [WorkbookItem](#workbookitem-class).
10410-
`file` | The file path or file object of the workbook to publish. When providing a file object, you must also specifiy the name of the workbook in your instance of the `workbook_item``workbook_item` , as the name cannot be derived from the file name.
10410+
`file` | The file path or file object of the workbook to publish. When providing a file object, you must also specifiy the name of the workbook in your instance of the `workbook_item`, as the name cannot be derived from the file name.
1041110411
`mode` | Specifies whether you are publishing a new workbook (`CreateNew`) or overwriting an existing workbook (`Overwrite`). You cannot appending workbooks. You can also use the publish mode attributes, for example: `TSC.Server.PublishMode.Overwrite`.
10412-
`connections` | List of `ConnectionItems` objects for the connections created within the workbook.
10412+
`connections` | List of `ConnectionItems` objects that supply credentials for the connections embedded in the workbook. The `server_address` of each item is used to find the matching connection in the workbook file; it does not change the connection's server address. See the note below.
1041310413
`skip_connection_check` | (Optional) Set to `True` to skip connection check at time of upload. Publishing will succeed but unchecked connection issues may result in a non-functioning workbook. Defaults to `False`.
1041410414
`as_job` | (Optional) Set to `True` to run the upload as a job (asynchronous upload). If set to `True` a job will start to perform the publishing process and a `Job` object is returned. Defaults to `False`.
1041510415

10416+
**Note:** When you publish, the `server_address` of each `ConnectionItem` in `connections` identifies which connection embedded in the workbook file the credentials belong to. It does not change the server address of that connection; the workbook is published with the server address saved in the file. If `server_address` does not match a connection in the file, the credentials are not applied. To point an embedded connection at a different server, publish the workbook first and then call [workbooks.update_connection](#workbooksupdate_connection). See the second example below.
10417+
1041610418

1041710419

1041810420
**Exceptions**
@@ -10448,6 +10450,25 @@ with server.auth.sign_in(tableau_auth):
1044810450
wb_item = server.workbooks.publish(wb_item, 'SampleWB.twbx', 'Overwrite')
1044910451
```
1045010452

10453+
**Example: publish, then change the server address of an embedded connection**
10454+
10455+
```py
10456+
with server.auth.sign_in(tableau_auth):
10457+
wb_item = TSC.WorkbookItem(name='Sample', project_id='1f2f3e4e-5d6d-7c8c-9b0b-1a2a3f4f5e6e')
10458+
10459+
# server_address must match the server address saved in the workbook file
10460+
connection = TSC.ConnectionItem()
10461+
connection.server_address = 'dev-db.example.com'
10462+
connection.connection_credentials = TSC.ConnectionCredentials('db_user', 'db_password', embed=True)
10463+
wb_item = server.workbooks.publish(wb_item, 'SampleWB.twbx', 'CreateNew', connections=[connection])
10464+
10465+
# point the published connection at a different server
10466+
server.workbooks.populate_connections(wb_item)
10467+
conn = next(c for c in wb_item.connections if c.server_address == 'dev-db.example.com')
10468+
conn.server_address = 'prod-db.example.com'
10469+
server.workbooks.update_connection(wb_item, conn)
10470+
```
10471+
1045110472
<br>
1045210473
<br>
1045310474

@@ -10853,7 +10874,7 @@ Name | Description
1085310874

1085410875
**Returns**
1085510876

10856-
None. The connection information is updated with the information in the `ConnectionItem`.
10877+
The updated `ConnectionItem`. The connection information on the server is updated with the information in the `ConnectionItem` you passed in.
1085710878

1085810879

1085910880

0 commit comments

Comments
 (0)