Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/_includes/analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-BVCN');</script>
<!-- End Google Tag Manager -->
2 changes: 2 additions & 0 deletions docs/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

{% if jekyll.environment == "production" %}{% include analytics.html %}{% endif %}
8 changes: 8 additions & 0 deletions docs/docs/api-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ Modifies a workbook. The workbook item object must include the workbook ID and o
Workbooks.update(wb_item_object)
```

### Update workbook connection

Updates a workbook connection string. The workbook connections must be populated before they strings can be updated.

```py
Workbooks.update_conn(workbook, workbook.connections[0])
```

### Delete Workbook

Deletes a workbook with the given ID.
Expand Down
13 changes: 13 additions & 0 deletions docs/docs/populate-connections-views.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ server.workbooks.populate_connections(workbook)
print([connection.datasource_name for connection in workbook.connections])
```

## Update connections for workbooks

```py
server.workbooks.populate_connections(workbook)
conn_to_update = workbook.connections[0]
conn_to_update.server_address = 'new_address'
conn_to_update.server_port = 1234
conn_to_update.username = 'username'
conn_to_update.password = 'password'
conn_to_update.embed_password = True/False
server.workbooks.update_conn(workbook, conn_to_update)
```

## Populate connections for data sources

```py
Expand Down
7 changes: 7 additions & 0 deletions tableauserverclient/server/endpoint/workbooks_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def update(self, workbook_item):
updated_workbook = copy.copy(workbook_item)
return updated_workbook._parse_common_tags(server_response.content)

# Update workbook_connection
def update_conn(self, workbook_item, connection_item):
url = "{0}/{1}/connections/{2}".format(self.baseurl, workbook_item.id, connection_item.id)
update_req = RequestFactory.WorkbookConnection.update_req(connection_item)
server_response = self.put_request(url, update_req)
logger.info('Updated workbook item (ID: {0} & connection item {1}'.format(workbook_item.id, connection_item.id))

# Download workbook contents with option of passing in filepath
def download(self, workbook_id, filepath=None):
if not workbook_id:
Expand Down
18 changes: 18 additions & 0 deletions tableauserverclient/server/request_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,23 @@ def publish_req_chunked(self, workbook_item, connection_credentials=None):
return _add_multipart(parts)


class WorkbookConnection(object):
def update_req(self, connection_item):
xml_request = ET.Element('tsRequest')
connection_element = ET.SubElement(xml_request, 'connection')
if connection_item.server_address:
connection_element.attrib['serverAddress'] = connection_item.server_address.lower()
if connection_item.server_port:
connection_element.attrib['port'] = str(connection_item.server_port)
if connection_item.username:
connection_element.attrib['userName'] = connection_item.username
if connection_item.password:
connection_element.attrib['password'] = connection_item.password
if connection_item.embed_password:
connection_element.attrib['embedPassword'] = connection_item.embed_password
return ET.tostring(xml_request)


class RequestFactory(object):
Auth = AuthRequest()
Datasource = DatasourceRequest()
Expand All @@ -326,3 +343,4 @@ class RequestFactory(object):
Tag = TagRequest()
User = UserRequest()
Workbook = WorkbookRequest()
WorkbookConnection = WorkbookConnection()