You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* First Draft for adding webhooks Issue ID #739 TFS ID 1438037
* Adding to TOC, making formatting changes, and updated sample code post testing
* Delete Gemfile
* Update api-ref.md
* Update api-ref.md
Removing --- from code blocks per Brain's review
* Update api-ref.md
Adding a space between "=" and adding a line before print statements
* adding spaces before print statement, lower case for webhook (consistency) and recommendation for using short event name
* Restore original Gemfile
Co-authored-by: Brian Cantoni <bcantoni@salesforce.com>
Copy file name to clipboardExpand all lines: docs/api-ref.md
+205-4Lines changed: 205 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4700,21 +4700,222 @@ See [ViewItem class](#viewitem-class)
4700
4700
4701
4701
4702
4702
---
4703
+
## Webhooks
4704
+
<br>
4705
+
<br>
4706
+
Using the Tableau Server Client (TSC), you can create a new webhook, get a list of all the webhooks, get details about a specific webhook, or delete a webhook.
4707
+
<br>
4703
4708
4709
+
The webhook resource for Tableau Server and Tableau Cloud are defined in the `WebhookItem` class. The class corresponds to the webhook resources you can access using the Tableau REST API. For example, using REST API, you can gather information about a workbook, like the name of the Webbook, the event it is associated with, and the destination URL, and you can get the same information using TSC as well.
4710
+
<br>
4704
4711
4705
-
## Workbooks
4712
+
Tableau webhook REST API endpoints are available in **REST API version 3.16** and later.
4713
+
<br>
4714
+
<br>
4706
4715
4707
-
Using the TSC library, you can get information about a specific workbook or all the workbooks on a site, and you can publish, update, or delete workbooks.
4716
+
### WebhookItem class
4717
+
The `WebhookItem` represents the webhook resources on Tableau Server or Tableau Cloud. This is the information that can be sent or returned in response to a REST API request for webhooks.
4708
4718
4709
-
The project resources for Tableau are defined in the `WorkbookItem` class. The class corresponds to the workbook resources you can access using the Tableau REST API. The workbook methods are based upon the endpoints for projects in the REST API and operate on the `WorkbookItem` class.
4719
+
**Attributes**
4710
4720
4721
+
Name | Description
4722
+
:--- | :---
4723
+
`id` | The identifier (*luid*) for the webhook. You need this value to query a specific webhook with the `get_by_id` method or to delete a webhook with the `delete` method.
4724
+
`name` | The name of the webhook. You must specify this when you create an instance of the `WebhookItem`.
4725
+
`url` | The destination URL for the webhook. The webhook destination URL must be https and have a valid certificate. You must specify this when you create an instance of the `WebhookItem`.
4726
+
`event` | The name of the Tableau event that triggers your webhook.This is either `api-event-name` or `webhook-source-api-event-name`: one of these is required to create an instance of the `WebhookItem`. We recommend using the `api-event-name`. <br> The event name must be one of the supported events listed in the [Trigger Events](https://help.tableau.com/current/developer/webhooks/en-us/docs/webhooks-events-payload.html) table.
4727
+
`owner_id` | The identifier of the owner of the webhook.
4711
4728
4729
+
**Example**
4712
4730
4731
+
```py
4732
+
import tableauserverclient asTSC
4713
4733
4734
+
# Create new Webhook_item
4735
+
4736
+
new_webhook =TSC.WebhookItem()
4737
+
```
4738
+
Source file: models/webhook_item.py
4739
+
4740
+
<br>
4741
+
<br>
4742
+
4743
+
### Webhook methods
4744
+
The Tableau Server Client provides several methods for interacting with webhook resources, or endpoints. These methods correspond to endpoints in the Tableau REST API.
4745
+
4746
+
Source file: server/endpoint/webhooks_endpoint.py
4714
4747
4715
4748
<br>
4716
4749
<br>
4717
4750
4751
+
#### webhook.create
4752
+
```py
4753
+
webhooks.create(webhook_item)
4754
+
4755
+
```
4756
+
Creates a new webhook on a specified site.
4757
+
4758
+
To create a webhook, you must first create a new instance of a `WebhookItem` and pass it to the create method.
4759
+
4760
+
To specify the site to create the new webhook in, create a `TableauAuth` instance using the content URL for the site `(site_id)` and sign in to that site. For more information on how to specify a site, see the [TableauAuth class](#tableauauth-class).
webhook_item | Specifies the properties for the webhook. The webhook_item is the request package. To create a request package, create a new instance of `WebhokItem`. The `WebhookItem` includes the `name`, destination `url`, and the `event` or `source`. The `event` or `source` specifies the Tableau event that should be associated with the webhook.
4769
+
4770
+
**Returns**
4771
+
Returns the new webhook item.
4772
+
4773
+
**Example**
4774
+
```py
4775
+
# import tableauserverclient as TSC
4776
+
# server = TSC.Server('https://SERVER')
4777
+
# sign in . For authentication examples, see https://github.com/tableau/server-client-python/blob/master/samples/login.py
4778
+
4779
+
# create a webhook item
4780
+
with server.auth.sign_in(tableau_auth):
4781
+
new_webhook =TSC.WebhookItem()
4782
+
new_webhook.name ='testWebhook'
4783
+
new_webhook.event ="workbook-refresh-failed"# alternately, you can also use new_webhook.source="webhook-source-event-workbook-refresh-failed"
To specify the site, create a `TableauAuth` instance using the content URL for the site `(site_id)` and sign in to the site. For more information on how to specify a site, see the [TableauAuth class](#tableauauth-class).
To specify the site, create a `TableauAuth` instance using the content URL for the site `(site_id)`, and sign in to that site. For more information on how to specify a site, see the [TableauAuth class](#tableauauth-class).
`req_option`| (Optional) You can pass themthod oa request object that contains additional parameters to filter the request. For example, you could specify the name of the webhook or the name of the owner. For more information, see [Filter and Sort](filter-sort).
4845
+
4846
+
**Returns**
4847
+
4848
+
Returns a list of all `ProjectItem` objects and a `PagainationItem`. Use these values to iterate through the results.
4849
+
4850
+
**Example**
4851
+
4852
+
```py
4853
+
# import tableauserverclient as TSC
4854
+
# server = TSC.Server('https://SERVER')
4855
+
# sign in . For authentication examples, see https://github.com/tableau/server-client-python/blob/master/samples/login.py
print("\nThere are {} webhooks on site: ".format(pagination_item.total_available))
4862
+
print(["Webhook Name:"+ webhook.name+";"+"ID:"+ webhook.id for webhook in all_webhooks])
4863
+
4864
+
```
4865
+
4866
+
#### webhook.get_by_id
4867
+
4868
+
```py
4869
+
webhooks.get_by_ide(webhook_id)
4870
+
```
4871
+
4872
+
Returns information about the specified workbook for a site.
4873
+
4874
+
To specify the site, create a `TableauAuth` instance using the content URL for the site `(site_id)`, and sign in to that site. For more information on how to specify a site, see the [TableauAuth class](#tableauauth-class).
4875
+
4876
+
**Parameters**
4877
+
4878
+
Name|Description
4879
+
:---|:---
4880
+
`webhook_id`| The ID of the webhook. The ID is a *luid*.
4881
+
4882
+
**Exceptions**
4883
+
4884
+
Error|Description
4885
+
:---|:---
4886
+
`Webhook ID undefined`| Raises an exception if a `webhook_id` is not provided.
4887
+
4888
+
4889
+
**Example**
4890
+
```py
4891
+
# import tableauserverclient as TSC
4892
+
# server = TSC.Server('https://SERVER')
4893
+
# sign in . For authentication examples, see https://github.com/tableau/server-client-python/blob/master/samples/login.py
Using the TSC library, you can get information about a specific workbook or all the workbooks on a site, and you can publish, update, or delete workbooks.
4914
+
4915
+
The project resources for Tableau are defined in the `WorkbookItem` class. The class corresponds to the workbook resources you can access using the Tableau REST API. The workbook methods are based upon the endpoints for projects in the REST API and operate on the `WorkbookItem` class.
0 commit comments