Skip to content

Commit 6dbd781

Browse files
jakerobersvdusek
andauthored
feat: adds headers_template to webhooks and webhooks_collection (#239)
Adds the `headers_template` kwarg and is included in the payload on POST/PUT to the webhook endpoints. * The API for create webhook supports headersTemplate parameter. Related docs at https://docs.apify.com/api/v2#tag/WebhooksWebhook-collection/operation/webhooks_post * The API for update webhook supports headersTemplate parameter. Related docs at https://docs.apify.com/api/v2#tag/WebhooksWebhook-object/operation/webhook_put --------- Co-authored-by: Jake Robers <[email protected]> Co-authored-by: Vlada Dusek <[email protected]>
1 parent c11edb8 commit 6dbd781

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## [1.7.2](../../releases/tag/v1.7.2) - Unreleased
44

5-
...
5+
### Add
6+
7+
- add `headers_template` kwarg to webhook create and update
68

79
## [1.7.1](../../releases/tag/v1.7.1) - 2024-07-11
810

src/apify_client/clients/resource_clients/webhook.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def get_webhook_representation(
2323
event_types: list[WebhookEventType] | None = None,
2424
request_url: str | None = None,
2525
payload_template: str | None = None,
26+
headers_template: str | None = None,
2627
actor_id: str | None = None,
2728
actor_task_id: str | None = None,
2829
actor_run_id: str | None = None,
@@ -35,6 +36,7 @@ def get_webhook_representation(
3536
webhook: dict = {
3637
'requestUrl': request_url,
3738
'payloadTemplate': payload_template,
39+
'headersTemplate': headers_template,
3840
'ignoreSslErrors': ignore_ssl_errors,
3941
'doNotRetry': do_not_retry,
4042
'idempotencyKey': idempotency_key,
@@ -80,6 +82,7 @@ def update(
8082
event_types: list[WebhookEventType] | None = None,
8183
request_url: str | None = None,
8284
payload_template: str | None = None,
85+
headers_template: str | None = None,
8386
actor_id: str | None = None,
8487
actor_task_id: str | None = None,
8588
actor_run_id: str | None = None,
@@ -95,6 +98,7 @@ def update(
9598
event_types (list of WebhookEventType, optional): List of event types that should trigger the webhook. At least one is required.
9699
request_url (str, optional): URL that will be invoked once the webhook is triggered.
97100
payload_template (str, optional): Specification of the payload that will be sent to request_url
101+
headers_template (str, optional): Headers that will be sent to the request_url
98102
actor_id (str, optional): Id of the actor whose runs should trigger the webhook.
99103
actor_task_id (str, optional): Id of the actor task whose runs should trigger the webhook.
100104
actor_run_id (str, optional): Id of the actor run which should trigger the webhook.
@@ -111,6 +115,7 @@ def update(
111115
event_types=event_types,
112116
request_url=request_url,
113117
payload_template=payload_template,
118+
headers_template=headers_template,
114119
actor_id=actor_id,
115120
actor_task_id=actor_task_id,
116121
actor_run_id=actor_run_id,
@@ -190,6 +195,7 @@ async def update(
190195
event_types: list[WebhookEventType] | None = None,
191196
request_url: str | None = None,
192197
payload_template: str | None = None,
198+
headers_template: str | None = None,
193199
actor_id: str | None = None,
194200
actor_task_id: str | None = None,
195201
actor_run_id: str | None = None,
@@ -205,6 +211,7 @@ async def update(
205211
event_types (list of WebhookEventType, optional): List of event types that should trigger the webhook. At least one is required.
206212
request_url (str, optional): URL that will be invoked once the webhook is triggered.
207213
payload_template (str, optional): Specification of the payload that will be sent to request_url
214+
headers_template (str, optional): Headers that will be sent to the request_url
208215
actor_id (str, optional): Id of the actor whose runs should trigger the webhook.
209216
actor_task_id (str, optional): Id of the actor task whose runs should trigger the webhook.
210217
actor_run_id (str, optional): Id of the actor run which should trigger the webhook.
@@ -221,6 +228,7 @@ async def update(
221228
event_types=event_types,
222229
request_url=request_url,
223230
payload_template=payload_template,
231+
headers_template=headers_template,
224232
actor_id=actor_id,
225233
actor_task_id=actor_task_id,
226234
actor_run_id=actor_run_id,

src/apify_client/clients/resource_clients/webhook_collection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def create(
4848
event_types: list[WebhookEventType], # type: ignore
4949
request_url: str,
5050
payload_template: str | None = None,
51+
headers_template: str | None = None,
5152
actor_id: str | None = None,
5253
actor_task_id: str | None = None,
5354
actor_run_id: str | None = None,
@@ -66,6 +67,7 @@ def create(
6667
event_types (list of WebhookEventType): List of event types that should trigger the webhook. At least one is required.
6768
request_url (str): URL that will be invoked once the webhook is triggered.
6869
payload_template (str, optional): Specification of the payload that will be sent to request_url
70+
headers_template (str, optional): Headers that will be sent to the request_url
6971
actor_id (str, optional): Id of the actor whose runs should trigger the webhook.
7072
actor_task_id (str, optional): Id of the actor task whose runs should trigger the webhook.
7173
actor_run_id (str, optional): Id of the actor run which should trigger the webhook.
@@ -84,6 +86,7 @@ def create(
8486
event_types=event_types,
8587
request_url=request_url,
8688
payload_template=payload_template,
89+
headers_template=headers_template,
8790
actor_id=actor_id,
8891
actor_task_id=actor_task_id,
8992
actor_run_id=actor_run_id,
@@ -132,6 +135,7 @@ async def create(
132135
event_types: list[WebhookEventType], # type: ignore
133136
request_url: str,
134137
payload_template: str | None = None,
138+
headers_template: str | None = None,
135139
actor_id: str | None = None,
136140
actor_task_id: str | None = None,
137141
actor_run_id: str | None = None,
@@ -150,6 +154,7 @@ async def create(
150154
event_types (list of WebhookEventType): List of event types that should trigger the webhook. At least one is required.
151155
request_url (str): URL that will be invoked once the webhook is triggered.
152156
payload_template (str, optional): Specification of the payload that will be sent to request_url
157+
headers_template (str, optional): Headers that will be sent to the request_url
153158
actor_id (str, optional): Id of the actor whose runs should trigger the webhook.
154159
actor_task_id (str, optional): Id of the actor task whose runs should trigger the webhook.
155160
actor_run_id (str, optional): Id of the actor run which should trigger the webhook.
@@ -168,6 +173,7 @@ async def create(
168173
event_types=event_types,
169174
request_url=request_url,
170175
payload_template=payload_template,
176+
headers_template=headers_template,
171177
actor_id=actor_id,
172178
actor_task_id=actor_task_id,
173179
actor_run_id=actor_run_id,

0 commit comments

Comments
 (0)