8000 docs: webhook docstrings (#1530) · tableau/server-client-python@7a45224 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a45224

Browse files
authored
docs: webhook docstrings (#1530)
Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
1 parent 9379c40 commit 7a45224

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

tableauserverclient/models/webhook_item.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,39 @@ def _parse_event(events):
1414

1515

1616
class WebhookItem:
17+
"""
18+
The WebhookItem represents the webhook resources on Tableau Server or
19+
Tableau Cloud. This is the information that can be sent or returned in
20+
response to a REST API request for webhooks.
21+
22+
Attributes
23+
----------
24+
id : Optional[str]
25+
The identifier (luid) for the webhook. You need this value to query a
26+
specific webhook with the get_by_id method or to delete a webhook with
27+
the delete method.
28+
29+
name : Optional[str]
30+
The name of the webhook. You must specify this when you create an
31+
instance of the WebhookItem.
32+
33+
url : Optional[str]
34+
The destination URL for the webhook. The webhook destination URL must
35+
be https and have a valid certificate. You must specify this when you
36+
create an instance of the WebhookItem.
37+
38+
event : Optional[str]
39+
The name of the Tableau event that triggers your webhook.This is either
40+
api-event-name or webhook-source-api-event-name: one of these is
41+
required to create an instance of the WebhookItem. We recommend using
42+
the api-event-name. The event name must be one of the supported events
43+
listed in the Trigger Events table.
44+
https://help.tableau.com/current/developer/webhooks/en-us/docs/webhooks-events-payload.html
45+
46+
owner_id : Optional[str]
47+
The identifier (luid) of the user who owns the webhook.
48+
"""
49+
1750
def __init__(self):
1851
self._id: Optional[str] = None
1952
self.name: Optional[str] = None

tableauserverclient/server/endpoint/webhooks_endpoint.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ def baseurl(self) -> str:
2323

2424
@api(version="3.6")
2525
def get(self, req_options: Optional["RequestOptions"] = None) -> tuple[list[WebhookItem], PaginationItem]:
26+
"""
27+
Returns a list of all webhooks on the site.
28+
29+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#list_webhooks_for_site
30+
31+
Parameters
32+
----------
33+
req_options : Optional[RequestOptions]
34+
Filter and sorting options for the request.
35+
36+
Returns
37+
-------
38+
tuple[list[WebhookItem], PaginationItem]
39+
A tuple of the list of webhooks and pagination item
40 8000 +
"""
2641
logger.info("Querying all Webhooks on site")
2742
url = self.baseurl
2843
server_response = self.get_request(url, req_options)
@@ -32,6 +47,21 @@ def get(self, req_options: Optional["RequestOptions"] = None) -> tuple[list[Webh
3247

3348
@api(version="3.6")
3449
def get_by_id(self, webhook_id: str) -> WebhookItem:
50+
"""
51+
Returns information about a specified Webhook.
52+
53+
Rest API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#get_webhook
54+
55+
Parameters
56+
----------
57+
webhook_id : str
58+
The ID of the webhook to query.
59+
60+
Returns
61+
-------
62+
WebhookItem
63+
An object containing information about the webhook.
64+
"""
3565
8000 if not webhook_id:
3666
error = "Webhook ID undefined."
3767
raise ValueError(error)
@@ -42,6 +72,20 @@ def get_by_id(self, webhook_id: str) -> WebhookItem:
4272

4373
@api(version="3.6")
4474
def delete(self, webhook_id: str) -> None:
75+
"""
76+
Deletes a specified webhook.
77+
78+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#delete_webhook
79+
80+
Parameters
81+
----------
82+
webhook_id : str
83+
The ID of the webhook to delete.
84+
85+
Returns
86+
-------
87+
None
88+
"""
4589
if not webhook_id:
4690
error = "Webhook ID undefined."
4791
raise ValueError(error)
@@ -51,6 +95,21 @@ def delete(self, webhook_id: str) -> None:
5195

5296
@api(version="3.6")
5397
def create(self, webhook_item: WebhookItem) -> WebhookItem:
98+
"""
99+
Creates a new webhook on the site.
100+
101+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#create_webhook
102+
103+
Parameters
104+
----------
105+
webhook_item : WebhookItem
106+
The webhook item to create.
107+
108+
Returns
109+
-------
110+
WebhookItem
111+
An object containing information about the created webhook
112+
"""
54113
url = self.baseurl
55114
create_req = RequestFactory.Webhook.create_req(webhook_item)
56115
server_response = self.post_request(url, create_req)
@@ -61,6 +120,24 @@ def create(self, webhook_item: WebhookItem) -> WebhookItem:
61120

62121
@api(version="3.6")
63122
def test(self, webhook_id: str):
123+
"""
124+
Tests the specified webhook. Sends an empty payload to the configured
125+
destination URL of the webhook and returns the response from the server.
126+
This is useful for testing, to ensure that things are being sent from
127+
Tableau and received back as expected.
128+
129+
Rest API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#test_webhook
130+
131+
Parameters
132+
----------
133+
webhook_id : str
134+
The ID of the webhook to test.
135+
136+
Returns
137+
-------
138+
XML Response
139+
140+
"""
64141
if not webhook_id:
65142
error = "Webhook ID undefined."
66143
raise ValueError(error)
< 32E8 /code>

0 commit comments

Comments
 (0)
0