@@ -91,25 +91,22 @@ def create(
9191 Returns:
9292 The created webhook.
9393 """
94- if actor_run_id is not None and is_ad_hoc is None :
95- is_ad_hoc = True
96-
97- request = WebhookCreate (
94+ webhook_create = WebhookCreate (
9895 event_types = list (event_types ),
9996 request_url = AnyUrl (request_url ),
10097 payload_template = payload_template ,
10198 headers_template = headers_template ,
10299 ignore_ssl_errors = ignore_ssl_errors ,
103100 do_not_retry = do_not_retry ,
104101 idempotency_key = idempotency_key ,
105- is_ad_hoc = is_ad_hoc ,
102+ is_ad_hoc = is_ad_hoc if actor_run_id else None ,
106103 condition = WebhookCondition (
107104 actor_run_id = actor_run_id ,
108105 actor_task_id = actor_task_id ,
109106 actor_id = actor_id ,
110107 ),
111108 )
112- result = self ._create (** request .model_dump (by_alias = True , exclude_none = True ))
109+ result = self ._create (** webhook_create .model_dump (by_alias = True , exclude_none = True ))
113110 return WebhookResponse .model_validate (result ).data
114111
115112
@@ -186,23 +183,20 @@ async def create(
186183 Returns:
187184 The created webhook.
188185 """
189- if actor_run_id is not None and is_ad_hoc is None :
190- is_ad_hoc = True
191-
192- request = WebhookCreate (
186+ webhook_create = WebhookCreate (
193187 event_types = list (event_types ),
194188 request_url = AnyUrl (request_url ),
195189 payload_template = payload_template ,
196190 headers_template = headers_template ,
197191 ignore_ssl_errors = ignore_ssl_errors ,
198192 do_not_retry = do_not_retry ,
199193 idempotency_key = idempotency_key ,
200- is_ad_hoc = is_ad_hoc ,
194+ is_ad_hoc = is_ad_hoc if actor_run_id else None ,
201195 condition = WebhookCondition (
202196 actor_run_id = actor_run_id ,
203197 actor_task_id = actor_task_id ,
204198 actor_id = actor_id ,
205199 ),
206200 )
207- result = await self ._create (** request .model_dump (by_alias = True , exclude_none = True ))
201+ result = await self ._create (** webhook_create .model_dump (by_alias = True , exclude_none = True ))
208202 return WebhookResponse .model_validate (result ).data
0 commit comments