Debian Codegraph @

src/auth0/management/actions/raw_client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 import typing
4 from json.decoder import JSONDecodeError
5
6 from ..core.api_error import ApiError
7 from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8 from ..core.http_response import AsyncHttpResponse, HttpResponse
9 from ..core.jsonable_encoder import encode_path_param
10 from ..core.pagination import AsyncPager, SyncPager
11 from ..core.parse_error import ParsingError
12 from ..core.pydantic_utilities import parse_obj_as
13 from ..core.request_options import RequestOptions
14 from ..core.serialization import convert_and_respect_annotation_metadata
15 from ..errors.bad_request_error import BadRequestError
16 from ..errors.forbidden_error import ForbiddenError
17 from ..errors.not_found_error import NotFoundError
18 from ..errors.too_many_requests_error import TooManyRequestsError
19 from ..errors.unauthorized_error import UnauthorizedError
20 from ..types.action import Action
21 from ..types.action_module_reference import ActionModuleReference
22 from ..types.action_secret_request import ActionSecretRequest
23 from ..types.action_trigger import ActionTrigger
24 from ..types.action_trigger_type_enum import ActionTriggerTypeEnum
25 from ..types.action_version_dependency import ActionVersionDependency
26 from ..types.create_action_response_content import CreateActionResponseContent
27 from ..types.deploy_action_response_content import DeployActionResponseContent
28 from ..types.get_action_response_content import GetActionResponseContent
29 from ..types.list_actions_paginated_response_content import ListActionsPaginatedResponseContent
30 from ..types.test_action_payload import TestActionPayload
31 from ..types.test_action_response_content import TestActionResponseContent
32 from ..types.update_action_response_content import UpdateActionResponseContent
33 from pydantic import ValidationError
34
35 # this is used as the default value for optional parameters
36 OMIT = typing.cast(typing.Any, ...)
37
38
39 class RawActionsClient:
40 def __init__(self, *, client_wrapper: SyncClientWrapper):
41 self._client_wrapper = client_wrapper
42
43 def list(
44 self,
45 *,
46 trigger_id: typing.Optional[ActionTriggerTypeEnum] = None,
47 action_name: typing.Optional[str] = None,
48 deployed: typing.Optional[bool] = None,
49 page: typing.Optional[int] = 0,
50 per_page: typing.Optional[int] = 50,
51 installed: typing.Optional[bool] = None,
52 request_options: typing.Optional[RequestOptions] = None,
53 ) -> SyncPager[Action, ListActionsPaginatedResponseContent]:
54 """
55 Retrieve all actions.
56
57 Parameters
58 ----------
59 trigger_id : typing.Optional[ActionTriggerTypeEnum]
60 An actions extensibility point.
61
62 action_name : typing.Optional[str]
63 The name of the action to retrieve.
64
65 deployed : typing.Optional[bool]
66 Optional filter to only retrieve actions that are deployed.
67
68 page : typing.Optional[int]
69 Use this field to request a specific page of the list results.
70
71 per_page : typing.Optional[int]
72 The maximum number of results to be returned by the server in single response. 20 by default
73
74 installed : typing.Optional[bool]
75 Optional. When true, return only installed actions. When false, return only custom actions. Returns all actions by default.
76
77 request_options : typing.Optional[RequestOptions]
78 Request-specific configuration.
79
80 Returns
81 -------
82 SyncPager[Action, ListActionsPaginatedResponseContent]
83 The actions were retrieved.
84 """
85 page = page if page is not None else 0
86
87 _response = self._client_wrapper.httpx_client.request(
88 "actions/actions",
89 method="GET",
90 params={
91 "triggerId": trigger_id,
92 "actionName": action_name,
93 "deployed": deployed,
94 "page": page,
95 "per_page": per_page,
96 "installed": installed,
97 },
98 request_options=request_options,
99 )
100 try:
101 if 200 <= _response.status_code < 300:
102 _parsed_response = typing.cast(
103 ListActionsPaginatedResponseContent,
104 parse_obj_as(
105 type_=ListActionsPaginatedResponseContent, # type: ignore
106 object_=_response.json(),
107 ),
108 )
109 _items = _parsed_response.actions
110 _has_next = len(_items or []) > 0
111 _get_next = lambda: self.list(
112 trigger_id=trigger_id,
113 action_name=action_name,
114 deployed=deployed,
115 page=page + 1,
116 per_page=per_page,
117 installed=installed,
118 request_options=request_options,
119 )
120 return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
121 if _response.status_code == 400:
122 raise BadRequestError(
123 headers=dict(_response.headers),
124 body=typing.cast(
125 typing.Any,
126 parse_obj_as(
127 type_=typing.Any, # type: ignore
128 object_=_response.json(),
129 ),
130 ),
131 )
132 if _response.status_code == 401:
133 raise UnauthorizedError(
134 headers=dict(_response.headers),
135 body=typing.cast(
136 typing.Any,
137 parse_obj_as(
138 type_=typing.Any, # type: ignore
139 object_=_response.json(),
140 ),
141 ),
142 )
143 if _response.status_code == 403:
144 raise ForbiddenError(
145 headers=dict(_response.headers),
146 body=typing.cast(
147 typing.Any,
148 parse_obj_as(
149 type_=typing.Any, # type: ignore
150 object_=_response.json(),
151 ),
152 ),
153 )
154 if _response.status_code == 429:
155 raise TooManyRequestsError(
156 headers=dict(_response.headers),
157 body=typing.cast(
158 typing.Any,
159 parse_obj_as(
160 type_=typing.Any, # type: ignore
161 object_=_response.json(),
162 ),
163 ),
164 )
165 _response_json = _response.json()
166 except JSONDecodeError:
167 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
168 except ValidationError as e:
169 raise ParsingError(
170 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
171 )
172 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
173
174 def create(
175 self,
176 *,
177 name: str,
178 supported_triggers: typing.Sequence[ActionTrigger],
179 code: typing.Optional[str] = OMIT,
180 dependencies: typing.Optional[typing.Sequence[ActionVersionDependency]] = OMIT,
181 runtime: typing.Optional[str] = OMIT,
182 secrets: typing.Optional[typing.Sequence[ActionSecretRequest]] = OMIT,
183 modules: typing.Optional[typing.Sequence[ActionModuleReference]] = OMIT,
184 deploy: typing.Optional[bool] = OMIT,
185 request_options: typing.Optional[RequestOptions] = None,
186 ) -> HttpResponse[CreateActionResponseContent]:
187 """
188 Create an action. Once an action is created, it must be deployed, and then bound to a trigger before it will be executed as part of a flow.
189
190 Parameters
191 ----------
192 name : str
193 The name of an action.
194
195 supported_triggers : typing.Sequence[ActionTrigger]
196 The list of triggers that this action supports. At this time, an action can only target a single trigger at a time.
197
198 code : typing.Optional[str]
199 The source code of the action.
200
201 dependencies : typing.Optional[typing.Sequence[ActionVersionDependency]]
202 The list of third party npm modules, and their versions, that this action depends on.
203
204 runtime : typing.Optional[str]
205 The Node runtime. For example: `node22`, defaults to `node22`
206
207 secrets : typing.Optional[typing.Sequence[ActionSecretRequest]]
208 The list of secrets that are included in an action or a version of an action.
209
210 modules : typing.Optional[typing.Sequence[ActionModuleReference]]
211 The list of action modules and their versions used by this action.
212
213 deploy : typing.Optional[bool]
214 True if the action should be deployed after creation.
215
216 request_options : typing.Optional[RequestOptions]
217 Request-specific configuration.
218
219 Returns
220 -------
221 HttpResponse[CreateActionResponseContent]
222 Action successfully created.
223 """
224 _response = self._client_wrapper.httpx_client.request(
225 "actions/actions",
226 method="POST",
227 json={
228 "name": name,
229 "supported_triggers": convert_and_respect_annotation_metadata(
230 object_=supported_triggers, annotation=typing.Sequence[ActionTrigger], direction="write"
231 ),
232 "code": code,
233 "dependencies": convert_and_respect_annotation_metadata(
234 object_=dependencies, annotation=typing.Sequence[ActionVersionDependency], direction="write"
235 ),
236 "runtime": runtime,
237 "secrets": convert_and_respect_annotation_metadata(
238 object_=secrets, annotation=typing.Sequence[ActionSecretRequest], direction="write"
239 ),
240 "modules": convert_and_respect_annotation_metadata(
241 object_=modules, annotation=typing.Sequence[ActionModuleReference], direction="write"
242 ),
243 "deploy": deploy,
244 },
245 headers={
246 "content-type": "application/json",
247 },
248 request_options=request_options,
249 omit=OMIT,
250 )
251 try:
252 if 200 <= _response.status_code < 300:
253 _data = typing.cast(
254 CreateActionResponseContent,
255 parse_obj_as(
256 type_=CreateActionResponseContent, # type: ignore
257 object_=_response.json(),
258 ),
259 )
260 return HttpResponse(response=_response, data=_data)
261 if _response.status_code == 400:
262 raise BadRequestError(
263 headers=dict(_response.headers),
264 body=typing.cast(
265 typing.Any,
266 parse_obj_as(
267 type_=typing.Any, # type: ignore
268 object_=_response.json(),
269 ),
270 ),
271 )
272 if _response.status_code == 401:
273 raise UnauthorizedError(
274 headers=dict(_response.headers),
275 body=typing.cast(
276 typing.Any,
277 parse_obj_as(
278 type_=typing.Any, # type: ignore
279 object_=_response.json(),
280 ),
281 ),
282 )
283 if _response.status_code == 403:
284 raise ForbiddenError(
285 headers=dict(_response.headers),
286 body=typing.cast(
287 typing.Any,
288 parse_obj_as(
289 type_=typing.Any, # type: ignore
290 object_=_response.json(),
291 ),
292 ),
293 )
294 if _response.status_code == 429:
295 raise TooManyRequestsError(
296 headers=dict(_response.headers),
297 body=typing.cast(
298 typing.Any,
299 parse_obj_as(
300 type_=typing.Any, # type: ignore
301 object_=_response.json(),
302 ),
303 ),
304 )
305 _response_json = _response.json()
306 except JSONDecodeError:
307 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
308 except ValidationError as e:
309 raise ParsingError(
310 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
311 )
312 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
313
314 def get(
315 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
316 ) -> HttpResponse[GetActionResponseContent]:
317 """
318 Retrieve an action by its ID.
319
320 Parameters
321 ----------
322 id : str
323 The ID of the action to retrieve.
324
325 request_options : typing.Optional[RequestOptions]
326 Request-specific configuration.
327
328 Returns
329 -------
330 HttpResponse[GetActionResponseContent]
331 The action was retrieved.
332 """
333 _response = self._client_wrapper.httpx_client.request(
334 f"actions/actions/{encode_path_param(id)}",
335 method="GET",
336 request_options=request_options,
337 )
338 try:
339 if 200 <= _response.status_code < 300:
340 _data = typing.cast(
341 GetActionResponseContent,
342 parse_obj_as(
343 type_=GetActionResponseContent, # type: ignore
344 object_=_response.json(),
345 ),
346 )
347 return HttpResponse(response=_response, data=_data)
348 if _response.status_code == 400:
349 raise BadRequestError(
350 headers=dict(_response.headers),
351 body=typing.cast(
352 typing.Any,
353 parse_obj_as(
354 type_=typing.Any, # type: ignore
355 object_=_response.json(),
356 ),
357 ),
358 )
359 if _response.status_code == 401:
360 raise UnauthorizedError(
361 headers=dict(_response.headers),
362 body=typing.cast(
363 typing.Any,
364 parse_obj_as(
365 type_=typing.Any, # type: ignore
366 object_=_response.json(),
367 ),
368 ),
369 )
370 if _response.status_code == 403:
371 raise ForbiddenError(
372 headers=dict(_response.headers),
373 body=typing.cast(
374 typing.Any,
375 parse_obj_as(
376 type_=typing.Any, # type: ignore
377 object_=_response.json(),
378 ),
379 ),
380 )
381 if _response.status_code == 404:
382 raise NotFoundError(
383 headers=dict(_response.headers),
384 body=typing.cast(
385 typing.Any,
386 parse_obj_as(
387 type_=typing.Any, # type: ignore
388 object_=_response.json(),
389 ),
390 ),
391 )
392 if _response.status_code == 429:
393 raise TooManyRequestsError(
394 headers=dict(_response.headers),
395 body=typing.cast(
396 typing.Any,
397 parse_obj_as(
398 type_=typing.Any, # type: ignore
399 object_=_response.json(),
400 ),
401 ),
402 )
403 _response_json = _response.json()
404 except JSONDecodeError:
405 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
406 except ValidationError as e:
407 raise ParsingError(
408 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
409 )
410 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
411
412 def delete(
413 self, id: str, *, force: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None
414 ) -> HttpResponse[None]:
415 """
416 Deletes an action and all of its associated versions. An action must be unbound from all triggers before it can be deleted.
417
418 Parameters
419 ----------
420 id : str
421 The ID of the action to delete.
422
423 force : typing.Optional[bool]
424 Force action deletion detaching bindings
425
426 request_options : typing.Optional[RequestOptions]
427 Request-specific configuration.
428
429 Returns
430 -------
431 HttpResponse[None]
432 """
433 _response = self._client_wrapper.httpx_client.request(
434 f"actions/actions/{encode_path_param(id)}",
435 method="DELETE",
436 params={
437 "force": force,
438 },
439 request_options=request_options,
440 )
441 try:
442 if 200 <= _response.status_code < 300:
443 return HttpResponse(response=_response, data=None)
444 if _response.status_code == 400:
445 raise BadRequestError(
446 headers=dict(_response.headers),
447 body=typing.cast(
448 typing.Any,
449 parse_obj_as(
450 type_=typing.Any, # type: ignore
451 object_=_response.json(),
452 ),
453 ),
454 )
455 if _response.status_code == 401:
456 raise UnauthorizedError(
457 headers=dict(_response.headers),
458 body=typing.cast(
459 typing.Any,
460 parse_obj_as(
461 type_=typing.Any, # type: ignore
462 object_=_response.json(),
463 ),
464 ),
465 )
466 if _response.status_code == 403:
467 raise ForbiddenError(
468 headers=dict(_response.headers),
469 body=typing.cast(
470 typing.Any,
471 parse_obj_as(
472 type_=typing.Any, # type: ignore
473 object_=_response.json(),
474 ),
475 ),
476 )
477 if _response.status_code == 404:
478 raise NotFoundError(
479 headers=dict(_response.headers),
480 body=typing.cast(
481 typing.Any,
482 parse_obj_as(
483 type_=typing.Any, # type: ignore
484 object_=_response.json(),
485 ),
486 ),
487 )
488 if _response.status_code == 429:
489 raise TooManyRequestsError(
490 headers=dict(_response.headers),
491 body=typing.cast(
492 typing.Any,
493 parse_obj_as(
494 type_=typing.Any, # type: ignore
495 object_=_response.json(),
496 ),
497 ),
498 )
499 _response_json = _response.json()
500 except JSONDecodeError:
501 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
502 except ValidationError as e:
503 raise ParsingError(
504 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
505 )
506 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
507
508 def update(
509 self,
510 id: str,
511 *,
512 name: typing.Optional[str] = OMIT,
513 supported_triggers: typing.Optional[typing.Sequence[ActionTrigger]] = OMIT,
514 code: typing.Optional[str] = OMIT,
515 dependencies: typing.Optional[typing.Sequence[ActionVersionDependency]] = OMIT,
516 runtime: typing.Optional[str] = OMIT,
517 secrets: typing.Optional[typing.Sequence[ActionSecretRequest]] = OMIT,
518 modules: typing.Optional[typing.Sequence[ActionModuleReference]] = OMIT,
519 request_options: typing.Optional[RequestOptions] = None,
520 ) -> HttpResponse[UpdateActionResponseContent]:
521 """
522 Update an existing action. If this action is currently bound to a trigger, updating it will **not** affect any user flows until the action is deployed.
523
524 Parameters
525 ----------
526 id : str
527 The id of the action to update.
528
529 name : typing.Optional[str]
530 The name of an action.
531
532 supported_triggers : typing.Optional[typing.Sequence[ActionTrigger]]
533 The list of triggers that this action supports. At this time, an action can only target a single trigger at a time.
534
535 code : typing.Optional[str]
536 The source code of the action.
537
538 dependencies : typing.Optional[typing.Sequence[ActionVersionDependency]]
539 The list of third party npm modules, and their versions, that this action depends on.
540
541 runtime : typing.Optional[str]
542 The Node runtime. For example: `node22`, defaults to `node22`
543
544 secrets : typing.Optional[typing.Sequence[ActionSecretRequest]]
545 The list of secrets that are included in an action or a version of an action.
546
547 modules : typing.Optional[typing.Sequence[ActionModuleReference]]
548 The list of action modules and their versions used by this action.
549
550 request_options : typing.Optional[RequestOptions]
551 Request-specific configuration.
552
553 Returns
554 -------
555 HttpResponse[UpdateActionResponseContent]
556 Action successfully updated.
557 """
558 _response = self._client_wrapper.httpx_client.request(
559 f"actions/actions/{encode_path_param(id)}",
560 method="PATCH",
561 json={
562 "name": name,
563 "supported_triggers": convert_and_respect_annotation_metadata(
564 object_=supported_triggers, annotation=typing.Sequence[ActionTrigger], direction="write"
565 ),
566 "code": code,
567 "dependencies": convert_and_respect_annotation_metadata(
568 object_=dependencies, annotation=typing.Sequence[ActionVersionDependency], direction="write"
569 ),
570 "runtime": runtime,
571 "secrets": convert_and_respect_annotation_metadata(
572 object_=secrets, annotation=typing.Sequence[ActionSecretRequest], direction="write"
573 ),
574 "modules": convert_and_respect_annotation_metadata(
575 object_=modules, annotation=typing.Sequence[ActionModuleReference], direction="write"
576 ),
577 },
578 headers={
579 "content-type": "application/json",
580 },
581 request_options=request_options,
582 omit=OMIT,
583 )
584 try:
585 if 200 <= _response.status_code < 300:
586 _data = typing.cast(
587 UpdateActionResponseContent,
588 parse_obj_as(
589 type_=UpdateActionResponseContent, # type: ignore
590 object_=_response.json(),
591 ),
592 )
593 return HttpResponse(response=_response, data=_data)
594 if _response.status_code == 400:
595 raise BadRequestError(
596 headers=dict(_response.headers),
597 body=typing.cast(
598 typing.Any,
599 parse_obj_as(
600 type_=typing.Any, # type: ignore
601 object_=_response.json(),
602 ),
603 ),
604 )
605 if _response.status_code == 401:
606 raise UnauthorizedError(
607 headers=dict(_response.headers),
608 body=typing.cast(
609 typing.Any,
610 parse_obj_as(
611 type_=typing.Any, # type: ignore
612 object_=_response.json(),
613 ),
614 ),
615 )
616 if _response.status_code == 403:
617 raise ForbiddenError(
618 headers=dict(_response.headers),
619 body=typing.cast(
620 typing.Any,
621 parse_obj_as(
622 type_=typing.Any, # type: ignore
623 object_=_response.json(),
624 ),
625 ),
626 )
627 if _response.status_code == 404:
628 raise NotFoundError(
629 headers=dict(_response.headers),
630 body=typing.cast(
631 typing.Any,
632 parse_obj_as(
633 type_=typing.Any, # type: ignore
634 object_=_response.json(),
635 ),
636 ),
637 )
638 if _response.status_code == 429:
639 raise TooManyRequestsError(
640 headers=dict(_response.headers),
641 body=typing.cast(
642 typing.Any,
643 parse_obj_as(
644 type_=typing.Any, # type: ignore
645 object_=_response.json(),
646 ),
647 ),
648 )
649 _response_json = _response.json()
650 except JSONDecodeError:
651 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
652 except ValidationError as e:
653 raise ParsingError(
654 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
655 )
656 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
657
658 def deploy(
659 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
660 ) -> HttpResponse[DeployActionResponseContent]:
661 """
662 Deploy an action. Deploying an action will create a new immutable version of the action. If the action is currently bound to a trigger, then the system will begin executing the newly deployed version of the action immediately. Otherwise, the action will only be executed as a part of a flow once it is bound to that flow.
663
664 Parameters
665 ----------
666 id : str
667 The ID of an action.
668
669 request_options : typing.Optional[RequestOptions]
670 Request-specific configuration.
671
672 Returns
673 -------
674 HttpResponse[DeployActionResponseContent]
675 Request to create action version was accepted.
676 """
677 _response = self._client_wrapper.httpx_client.request(
678 f"actions/actions/{encode_path_param(id)}/deploy",
679 method="POST",
680 request_options=request_options,
681 )
682 try:
683 if 200 <= _response.status_code < 300:
684 _data = typing.cast(
685 DeployActionResponseContent,
686 parse_obj_as(
687 type_=DeployActionResponseContent, # type: ignore
688 object_=_response.json(),
689 ),
690 )
691 return HttpResponse(response=_response, data=_data)
692 if _response.status_code == 400:
693 raise BadRequestError(
694 headers=dict(_response.headers),
695 body=typing.cast(
696 typing.Any,
697 parse_obj_as(
698 type_=typing.Any, # type: ignore
699 object_=_response.json(),
700 ),
701 ),
702 )
703 if _response.status_code == 401:
704 raise UnauthorizedError(
705 headers=dict(_response.headers),
706 body=typing.cast(
707 typing.Any,
708 parse_obj_as(
709 type_=typing.Any, # type: ignore
710 object_=_response.json(),
711 ),
712 ),
713 )
714 if _response.status_code == 403:
715 raise ForbiddenError(
716 headers=dict(_response.headers),
717 body=typing.cast(
718 typing.Any,
719 parse_obj_as(
720 type_=typing.Any, # type: ignore
721 object_=_response.json(),
722 ),
723 ),
724 )
725 if _response.status_code == 429:
726 raise TooManyRequestsError(
727 headers=dict(_response.headers),
728 body=typing.cast(
729 typing.Any,
730 parse_obj_as(
731 type_=typing.Any, # type: ignore
732 object_=_response.json(),
733 ),
734 ),
735 )
736 _response_json = _response.json()
737 except JSONDecodeError:
738 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
739 except ValidationError as e:
740 raise ParsingError(
741 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
742 )
743 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
744
745 def test(
746 self, id: str, *, payload: TestActionPayload, request_options: typing.Optional[RequestOptions] = None
747 ) -> HttpResponse[TestActionResponseContent]:
748 """
749 Test an action. After updating an action, it can be tested prior to being deployed to ensure it behaves as expected.
750
751 Parameters
752 ----------
753 id : str
754 The id of the action to test.
755
756 payload : TestActionPayload
757
758 request_options : typing.Optional[RequestOptions]
759 Request-specific configuration.
760
761 Returns
762 -------
763 HttpResponse[TestActionResponseContent]
764 Test action version successfully created.
765 """
766 _response = self._client_wrapper.httpx_client.request(
767 f"actions/actions/{encode_path_param(id)}/test",
768 method="POST",
769 json={
770 "payload": payload,
771 },
772 headers={
773 "content-type": "application/json",
774 },
775 request_options=request_options,
776 omit=OMIT,
777 )
778 try:
779 if 200 <= _response.status_code < 300:
780 _data = typing.cast(
781 TestActionResponseContent,
782 parse_obj_as(
783 type_=TestActionResponseContent, # type: ignore
784 object_=_response.json(),
785 ),
786 )
787 return HttpResponse(response=_response, data=_data)
788 if _response.status_code == 400:
789 raise BadRequestError(
790 headers=dict(_response.headers),
791 body=typing.cast(
792 typing.Any,
793 parse_obj_as(
794 type_=typing.Any, # type: ignore
795 object_=_response.json(),
796 ),
797 ),
798 )
799 if _response.status_code == 401:
800 raise UnauthorizedError(
801 headers=dict(_response.headers),
802 body=typing.cast(
803 typing.Any,
804 parse_obj_as(
805 type_=typing.Any, # type: ignore
806 object_=_response.json(),
807 ),
808 ),
809 )
810 if _response.status_code == 403:
811 raise ForbiddenError(
812 headers=dict(_response.headers),
813 body=typing.cast(
814 typing.Any,
815 parse_obj_as(
816 type_=typing.Any, # type: ignore
817 object_=_response.json(),
818 ),
819 ),
820 )
821 if _response.status_code == 429:
822 raise TooManyRequestsError(
823 headers=dict(_response.headers),
824 body=typing.cast(
825 typing.Any,
826 parse_obj_as(
827 type_=typing.Any, # type: ignore
828 object_=_response.json(),
829 ),
830 ),
831 )
832 _response_json = _response.json()
833 except JSONDecodeError:
834 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
835 except ValidationError as e:
836 raise ParsingError(
837 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
838 )
839 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
840
841
842 class AsyncRawActionsClient:
843 def __init__(self, *, client_wrapper: AsyncClientWrapper):
844 self._client_wrapper = client_wrapper
845
846 async def list(
847 self,
848 *,
849 trigger_id: typing.Optional[ActionTriggerTypeEnum] = None,
850 action_name: typing.Optional[str] = None,
851 deployed: typing.Optional[bool] = None,
852 page: typing.Optional[int] = 0,
853 per_page: typing.Optional[int] = 50,
854 installed: typing.Optional[bool] = None,
855 request_options: typing.Optional[RequestOptions] = None,
856 ) -> AsyncPager[Action, ListActionsPaginatedResponseContent]:
857 """
858 Retrieve all actions.
859
860 Parameters
861 ----------
862 trigger_id : typing.Optional[ActionTriggerTypeEnum]
863 An actions extensibility point.
864
865 action_name : typing.Optional[str]
866 The name of the action to retrieve.
867
868 deployed : typing.Optional[bool]
869 Optional filter to only retrieve actions that are deployed.
870
871 page : typing.Optional[int]
872 Use this field to request a specific page of the list results.
873
874 per_page : typing.Optional[int]
875 The maximum number of results to be returned by the server in single response. 20 by default
876
877 installed : typing.Optional[bool]
878 Optional. When true, return only installed actions. When false, return only custom actions. Returns all actions by default.
879
880 request_options : typing.Optional[RequestOptions]
881 Request-specific configuration.
882
883 Returns
884 -------
885 AsyncPager[Action, ListActionsPaginatedResponseContent]
886 The actions were retrieved.
887 """
888 page = page if page is not None else 0
889
890 _response = await self._client_wrapper.httpx_client.request(
891 "actions/actions",
892 method="GET",
893 params={
894 "triggerId": trigger_id,
895 "actionName": action_name,
896 "deployed": deployed,
897 "page": page,
898 "per_page": per_page,
899 "installed": installed,
900 },
901 request_options=request_options,
902 )
903 try:
904 if 200 <= _response.status_code < 300:
905 _parsed_response = typing.cast(
906 ListActionsPaginatedResponseContent,
907 parse_obj_as(
908 type_=ListActionsPaginatedResponseContent, # type: ignore
909 object_=_response.json(),
910 ),
911 )
912 _items = _parsed_response.actions
913 _has_next = len(_items or []) > 0
914
915 async def _get_next():
916 return await self.list(
917 trigger_id=trigger_id,
918 action_name=action_name,
919 deployed=deployed,
920 page=page + 1,
921 per_page=per_page,
922 installed=installed,
923 request_options=request_options,
924 )
925
926 return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
927 if _response.status_code == 400:
928 raise BadRequestError(
929 headers=dict(_response.headers),
930 body=typing.cast(
931 typing.Any,
932 parse_obj_as(
933 type_=typing.Any, # type: ignore
934 object_=_response.json(),
935 ),
936 ),
937 )
938 if _response.status_code == 401:
939 raise UnauthorizedError(
940 headers=dict(_response.headers),
941 body=typing.cast(
942 typing.Any,
943 parse_obj_as(
944 type_=typing.Any, # type: ignore
945 object_=_response.json(),
946 ),
947 ),
948 )
949 if _response.status_code == 403:
950 raise ForbiddenError(
951 headers=dict(_response.headers),
952 body=typing.cast(
953 typing.Any,
954 parse_obj_as(
955 type_=typing.Any, # type: ignore
956 object_=_response.json(),
957 ),
958 ),
959 )
960 if _response.status_code == 429:
961 raise TooManyRequestsError(
962 headers=dict(_response.headers),
963 body=typing.cast(
964 typing.Any,
965 parse_obj_as(
966 type_=typing.Any, # type: ignore
967 object_=_response.json(),
968 ),
969 ),
970 )
971 _response_json = _response.json()
972 except JSONDecodeError:
973 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
974 except ValidationError as e:
975 raise ParsingError(
976 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
977 )
978 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
979
980 async def create(
981 self,
982 *,
983 name: str,
984 supported_triggers: typing.Sequence[ActionTrigger],
985 code: typing.Optional[str] = OMIT,
986 dependencies: typing.Optional[typing.Sequence[ActionVersionDependency]] = OMIT,
987 runtime: typing.Optional[str] = OMIT,
988 secrets: typing.Optional[typing.Sequence[ActionSecretRequest]] = OMIT,
989 modules: typing.Optional[typing.Sequence[ActionModuleReference]] = OMIT,
990 deploy: typing.Optional[bool] = OMIT,
991 request_options: typing.Optional[RequestOptions] = None,
992 ) -> AsyncHttpResponse[CreateActionResponseContent]:
993 """
994 Create an action. Once an action is created, it must be deployed, and then bound to a trigger before it will be executed as part of a flow.
995
996 Parameters
997 ----------
998 name : str
999 The name of an action.
1000
1001 supported_triggers : typing.Sequence[ActionTrigger]
1002 The list of triggers that this action supports. At this time, an action can only target a single trigger at a time.
1003
1004 code : typing.Optional[str]
1005 The source code of the action.
1006
1007 dependencies : typing.Optional[typing.Sequence[ActionVersionDependency]]
1008 The list of third party npm modules, and their versions, that this action depends on.
1009
1010 runtime : typing.Optional[str]
1011 The Node runtime. For example: `node22`, defaults to `node22`
1012
1013 secrets : typing.Optional[typing.Sequence[ActionSecretRequest]]
1014 The list of secrets that are included in an action or a version of an action.
1015
1016 modules : typing.Optional[typing.Sequence[ActionModuleReference]]
1017 The list of action modules and their versions used by this action.
1018
1019 deploy : typing.Optional[bool]
1020 True if the action should be deployed after creation.
1021
1022 request_options : typing.Optional[RequestOptions]
1023 Request-specific configuration.
1024
1025 Returns
1026 -------
1027 AsyncHttpResponse[CreateActionResponseContent]
1028 Action successfully created.
1029 """
1030 _response = await self._client_wrapper.httpx_client.request(
1031 "actions/actions",
1032 method="POST",
1033 json={
1034 "name": name,
1035 "supported_triggers": convert_and_respect_annotation_metadata(
1036 object_=supported_triggers, annotation=typing.Sequence[ActionTrigger], direction="write"
1037 ),
1038 "code": code,
1039 "dependencies": convert_and_respect_annotation_metadata(
1040 object_=dependencies, annotation=typing.Sequence[ActionVersionDependency], direction="write"
1041 ),
1042 "runtime": runtime,
1043 "secrets": convert_and_respect_annotation_metadata(
1044 object_=secrets, annotation=typing.Sequence[ActionSecretRequest], direction="write"
1045 ),
1046 "modules": convert_and_respect_annotation_metadata(
1047 object_=modules, annotation=typing.Sequence[ActionModuleReference], direction="write"
1048 ),
1049 "deploy": deploy,
1050 },
1051 headers={
1052 "content-type": "application/json",
1053 },
1054 request_options=request_options,
1055 omit=OMIT,
1056 )
1057 try:
1058 if 200 <= _response.status_code < 300:
1059 _data = typing.cast(
1060 CreateActionResponseContent,
1061 parse_obj_as(
1062 type_=CreateActionResponseContent, # type: ignore
1063 object_=_response.json(),
1064 ),
1065 )
1066 return AsyncHttpResponse(response=_response, data=_data)
1067 if _response.status_code == 400:
1068 raise BadRequestError(
1069 headers=dict(_response.headers),
1070 body=typing.cast(
1071 typing.Any,
1072 parse_obj_as(
1073 type_=typing.Any, # type: ignore
1074 object_=_response.json(),
1075 ),
1076 ),
1077 )
1078 if _response.status_code == 401:
1079 raise UnauthorizedError(
1080 headers=dict(_response.headers),
1081 body=typing.cast(
1082 typing.Any,
1083 parse_obj_as(
1084 type_=typing.Any, # type: ignore
1085 object_=_response.json(),
1086 ),
1087 ),
1088 )
1089 if _response.status_code == 403:
1090 raise ForbiddenError(
1091 headers=dict(_response.headers),
1092 body=typing.cast(
1093 typing.Any,
1094 parse_obj_as(
1095 type_=typing.Any, # type: ignore
1096 object_=_response.json(),
1097 ),
1098 ),
1099 )
1100 if _response.status_code == 429:
1101 raise TooManyRequestsError(
1102 headers=dict(_response.headers),
1103 body=typing.cast(
1104 typing.Any,
1105 parse_obj_as(
1106 type_=typing.Any, # type: ignore
1107 object_=_response.json(),
1108 ),
1109 ),
1110 )
1111 _response_json = _response.json()
1112 except JSONDecodeError:
1113 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1114 except ValidationError as e:
1115 raise ParsingError(
1116 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1117 )
1118 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1119
1120 async def get(
1121 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1122 ) -> AsyncHttpResponse[GetActionResponseContent]:
1123 """
1124 Retrieve an action by its ID.
1125
1126 Parameters
1127 ----------
1128 id : str
1129 The ID of the action to retrieve.
1130
1131 request_options : typing.Optional[RequestOptions]
1132 Request-specific configuration.
1133
1134 Returns
1135 -------
1136 AsyncHttpResponse[GetActionResponseContent]
1137 The action was retrieved.
1138 """
1139 _response = await self._client_wrapper.httpx_client.request(
1140 f"actions/actions/{encode_path_param(id)}",
1141 method="GET",
1142 request_options=request_options,
1143 )
1144 try:
1145 if 200 <= _response.status_code < 300:
1146 _data = typing.cast(
1147 GetActionResponseContent,
1148 parse_obj_as(
1149 type_=GetActionResponseContent, # type: ignore
1150 object_=_response.json(),
1151 ),
1152 )
1153 return AsyncHttpResponse(response=_response, data=_data)
1154 if _response.status_code == 400:
1155 raise BadRequestError(
1156 headers=dict(_response.headers),
1157 body=typing.cast(
1158 typing.Any,
1159 parse_obj_as(
1160 type_=typing.Any, # type: ignore
1161 object_=_response.json(),
1162 ),
1163 ),
1164 )
1165 if _response.status_code == 401:
1166 raise UnauthorizedError(
1167 headers=dict(_response.headers),
1168 body=typing.cast(
1169 typing.Any,
1170 parse_obj_as(
1171 type_=typing.Any, # type: ignore
1172 object_=_response.json(),
1173 ),
1174 ),
1175 )
1176 if _response.status_code == 403:
1177 raise ForbiddenError(
1178 headers=dict(_response.headers),
1179 body=typing.cast(
1180 typing.Any,
1181 parse_obj_as(
1182 type_=typing.Any, # type: ignore
1183 object_=_response.json(),
1184 ),
1185 ),
1186 )
1187 if _response.status_code == 404:
1188 raise NotFoundError(
1189 headers=dict(_response.headers),
1190 body=typing.cast(
1191 typing.Any,
1192 parse_obj_as(
1193 type_=typing.Any, # type: ignore
1194 object_=_response.json(),
1195 ),
1196 ),
1197 )
1198 if _response.status_code == 429:
1199 raise TooManyRequestsError(
1200 headers=dict(_response.headers),
1201 body=typing.cast(
1202 typing.Any,
1203 parse_obj_as(
1204 type_=typing.Any, # type: ignore
1205 object_=_response.json(),
1206 ),
1207 ),
1208 )
1209 _response_json = _response.json()
1210 except JSONDecodeError:
1211 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1212 except ValidationError as e:
1213 raise ParsingError(
1214 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1215 )
1216 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1217
1218 async def delete(
1219 self, id: str, *, force: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None
1220 ) -> AsyncHttpResponse[None]:
1221 """
1222 Deletes an action and all of its associated versions. An action must be unbound from all triggers before it can be deleted.
1223
1224 Parameters
1225 ----------
1226 id : str
1227 The ID of the action to delete.
1228
1229 force : typing.Optional[bool]
1230 Force action deletion detaching bindings
1231
1232 request_options : typing.Optional[RequestOptions]
1233 Request-specific configuration.
1234
1235 Returns
1236 -------
1237 AsyncHttpResponse[None]
1238 """
1239 _response = await self._client_wrapper.httpx_client.request(
1240 f"actions/actions/{encode_path_param(id)}",
1241 method="DELETE",
1242 params={
1243 "force": force,
1244 },
1245 request_options=request_options,
1246 )
1247 try:
1248 if 200 <= _response.status_code < 300:
1249 return AsyncHttpResponse(response=_response, data=None)
1250 if _response.status_code == 400:
1251 raise BadRequestError(
1252 headers=dict(_response.headers),
1253 body=typing.cast(
1254 typing.Any,
1255 parse_obj_as(
1256 type_=typing.Any, # type: ignore
1257 object_=_response.json(),
1258 ),
1259 ),
1260 )
1261 if _response.status_code == 401:
1262 raise UnauthorizedError(
1263 headers=dict(_response.headers),
1264 body=typing.cast(
1265 typing.Any,
1266 parse_obj_as(
1267 type_=typing.Any, # type: ignore
1268 object_=_response.json(),
1269 ),
1270 ),
1271 )
1272 if _response.status_code == 403:
1273 raise ForbiddenError(
1274 headers=dict(_response.headers),
1275 body=typing.cast(
1276 typing.Any,
1277 parse_obj_as(
1278 type_=typing.Any, # type: ignore
1279 object_=_response.json(),
1280 ),
1281 ),
1282 )
1283 if _response.status_code == 404:
1284 raise NotFoundError(
1285 headers=dict(_response.headers),
1286 body=typing.cast(
1287 typing.Any,
1288 parse_obj_as(
1289 type_=typing.Any, # type: ignore
1290 object_=_response.json(),
1291 ),
1292 ),
1293 )
1294 if _response.status_code == 429:
1295 raise TooManyRequestsError(
1296 headers=dict(_response.headers),
1297 body=typing.cast(
1298 typing.Any,
1299 parse_obj_as(
1300 type_=typing.Any, # type: ignore
1301 object_=_response.json(),
1302 ),
1303 ),
1304 )
1305 _response_json = _response.json()
1306 except JSONDecodeError:
1307 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1308 except ValidationError as e:
1309 raise ParsingError(
1310 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1311 )
1312 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1313
1314 async def update(
1315 self,
1316 id: str,
1317 *,
1318 name: typing.Optional[str] = OMIT,
1319 supported_triggers: typing.Optional[typing.Sequence[ActionTrigger]] = OMIT,
1320 code: typing.Optional[str] = OMIT,
1321 dependencies: typing.Optional[typing.Sequence[ActionVersionDependency]] = OMIT,
1322 runtime: typing.Optional[str] = OMIT,
1323 secrets: typing.Optional[typing.Sequence[ActionSecretRequest]] = OMIT,
1324 modules: typing.Optional[typing.Sequence[ActionModuleReference]] = OMIT,
1325 request_options: typing.Optional[RequestOptions] = None,
1326 ) -> AsyncHttpResponse[UpdateActionResponseContent]:
1327 """
1328 Update an existing action. If this action is currently bound to a trigger, updating it will **not** affect any user flows until the action is deployed.
1329
1330 Parameters
1331 ----------
1332 id : str
1333 The id of the action to update.
1334
1335 name : typing.Optional[str]
1336 The name of an action.
1337
1338 supported_triggers : typing.Optional[typing.Sequence[ActionTrigger]]
1339 The list of triggers that this action supports. At this time, an action can only target a single trigger at a time.
1340
1341 code : typing.Optional[str]
1342 The source code of the action.
1343
1344 dependencies : typing.Optional[typing.Sequence[ActionVersionDependency]]
1345 The list of third party npm modules, and their versions, that this action depends on.
1346
1347 runtime : typing.Optional[str]
1348 The Node runtime. For example: `node22`, defaults to `node22`
1349
1350 secrets : typing.Optional[typing.Sequence[ActionSecretRequest]]
1351 The list of secrets that are included in an action or a version of an action.
1352
1353 modules : typing.Optional[typing.Sequence[ActionModuleReference]]
1354 The list of action modules and their versions used by this action.
1355
1356 request_options : typing.Optional[RequestOptions]
1357 Request-specific configuration.
1358
1359 Returns
1360 -------
1361 AsyncHttpResponse[UpdateActionResponseContent]
1362 Action successfully updated.
1363 """
1364 _response = await self._client_wrapper.httpx_client.request(
1365 f"actions/actions/{encode_path_param(id)}",
1366 method="PATCH",
1367 json={
1368 "name": name,
1369 "supported_triggers": convert_and_respect_annotation_metadata(
1370 object_=supported_triggers, annotation=typing.Sequence[ActionTrigger], direction="write"
1371 ),
1372 "code": code,
1373 "dependencies": convert_and_respect_annotation_metadata(
1374 object_=dependencies, annotation=typing.Sequence[ActionVersionDependency], direction="write"
1375 ),
1376 "runtime": runtime,
1377 "secrets": convert_and_respect_annotation_metadata(
1378 object_=secrets, annotation=typing.Sequence[ActionSecretRequest], direction="write"
1379 ),
1380 "modules": convert_and_respect_annotation_metadata(
1381 object_=modules, annotation=typing.Sequence[ActionModuleReference], direction="write"
1382 ),
1383 },
1384 headers={
1385 "content-type": "application/json",
1386 },
1387 request_options=request_options,
1388 omit=OMIT,
1389 )
1390 try:
1391 if 200 <= _response.status_code < 300:
1392 _data = typing.cast(
1393 UpdateActionResponseContent,
1394 parse_obj_as(
1395 type_=UpdateActionResponseContent, # type: ignore
1396 object_=_response.json(),
1397 ),
1398 )
1399 return AsyncHttpResponse(response=_response, data=_data)
1400 if _response.status_code == 400:
1401 raise BadRequestError(
1402 headers=dict(_response.headers),
1403 body=typing.cast(
1404 typing.Any,
1405 parse_obj_as(
1406 type_=typing.Any, # type: ignore
1407 object_=_response.json(),
1408 ),
1409 ),
1410 )
1411 if _response.status_code == 401:
1412 raise UnauthorizedError(
1413 headers=dict(_response.headers),
1414 body=typing.cast(
1415 typing.Any,
1416 parse_obj_as(
1417 type_=typing.Any, # type: ignore
1418 object_=_response.json(),
1419 ),
1420 ),
1421 )
1422 if _response.status_code == 403:
1423 raise ForbiddenError(
1424 headers=dict(_response.headers),
1425 body=typing.cast(
1426 typing.Any,
1427 parse_obj_as(
1428 type_=typing.Any, # type: ignore
1429 object_=_response.json(),
1430 ),
1431 ),
1432 )
1433 if _response.status_code == 404:
1434 raise NotFoundError(
1435 headers=dict(_response.headers),
1436 body=typing.cast(
1437 typing.Any,
1438 parse_obj_as(
1439 type_=typing.Any, # type: ignore
1440 object_=_response.json(),
1441 ),
1442 ),
1443 )
1444 if _response.status_code == 429:
1445 raise TooManyRequestsError(
1446 headers=dict(_response.headers),
1447 body=typing.cast(
1448 typing.Any,
1449 parse_obj_as(
1450 type_=typing.Any, # type: ignore
1451 object_=_response.json(),
1452 ),
1453 ),
1454 )
1455 _response_json = _response.json()
1456 except JSONDecodeError:
1457 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1458 except ValidationError as e:
1459 raise ParsingError(
1460 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1461 )
1462 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1463
1464 async def deploy(
1465 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1466 ) -> AsyncHttpResponse[DeployActionResponseContent]:
1467 """
1468 Deploy an action. Deploying an action will create a new immutable version of the action. If the action is currently bound to a trigger, then the system will begin executing the newly deployed version of the action immediately. Otherwise, the action will only be executed as a part of a flow once it is bound to that flow.
1469
1470 Parameters
1471 ----------
1472 id : str
1473 The ID of an action.
1474
1475 request_options : typing.Optional[RequestOptions]
1476 Request-specific configuration.
1477
1478 Returns
1479 -------
1480 AsyncHttpResponse[DeployActionResponseContent]
1481 Request to create action version was accepted.
1482 """
1483 _response = await self._client_wrapper.httpx_client.request(
1484 f"actions/actions/{encode_path_param(id)}/deploy",
1485 method="POST",
1486 request_options=request_options,
1487 )
1488 try:
1489 if 200 <= _response.status_code < 300:
1490 _data = typing.cast(
1491 DeployActionResponseContent,
1492 parse_obj_as(
1493 type_=DeployActionResponseContent, # type: ignore
1494 object_=_response.json(),
1495 ),
1496 )
1497 return AsyncHttpResponse(response=_response, data=_data)
1498 if _response.status_code == 400:
1499 raise BadRequestError(
1500 headers=dict(_response.headers),
1501 body=typing.cast(
1502 typing.Any,
1503 parse_obj_as(
1504 type_=typing.Any, # type: ignore
1505 object_=_response.json(),
1506 ),
1507 ),
1508 )
1509 if _response.status_code == 401:
1510 raise UnauthorizedError(
1511 headers=dict(_response.headers),
1512 body=typing.cast(
1513 typing.Any,
1514 parse_obj_as(
1515 type_=typing.Any, # type: ignore
1516 object_=_response.json(),
1517 ),
1518 ),
1519 )
1520 if _response.status_code == 403:
1521 raise ForbiddenError(
1522 headers=dict(_response.headers),
1523 body=typing.cast(
1524 typing.Any,
1525 parse_obj_as(
1526 type_=typing.Any, # type: ignore
1527 object_=_response.json(),
1528 ),
1529 ),
1530 )
1531 if _response.status_code == 429:
1532 raise TooManyRequestsError(
1533 headers=dict(_response.headers),
1534 body=typing.cast(
1535 typing.Any,
1536 parse_obj_as(
1537 type_=typing.Any, # type: ignore
1538 object_=_response.json(),
1539 ),
1540 ),
1541 )
1542 _response_json = _response.json()
1543 except JSONDecodeError:
1544 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1545 except ValidationError as e:
1546 raise ParsingError(
1547 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1548 )
1549 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1550
1551 async def test(
1552 self, id: str, *, payload: TestActionPayload, request_options: typing.Optional[RequestOptions] = None
1553 ) -> AsyncHttpResponse[TestActionResponseContent]:
1554 """
1555 Test an action. After updating an action, it can be tested prior to being deployed to ensure it behaves as expected.
1556
1557 Parameters
1558 ----------
1559 id : str
1560 The id of the action to test.
1561
1562 payload : TestActionPayload
1563
1564 request_options : typing.Optional[RequestOptions]
1565 Request-specific configuration.
1566
1567 Returns
1568 -------
1569 AsyncHttpResponse[TestActionResponseContent]
1570 Test action version successfully created.
1571 """
1572 _response = await self._client_wrapper.httpx_client.request(
1573 f"actions/actions/{encode_path_param(id)}/test",
1574 method="POST",
1575 json={
1576 "payload": payload,
1577 },
1578 headers={
1579 "content-type": "application/json",
1580 },
1581 request_options=request_options,
1582 omit=OMIT,
1583 )
1584 try:
1585 if 200 <= _response.status_code < 300:
1586 _data = typing.cast(
1587 TestActionResponseContent,
1588 parse_obj_as(
1589 type_=TestActionResponseContent, # type: ignore
1590 object_=_response.json(),
1591 ),
1592 )
1593 return AsyncHttpResponse(response=_response, data=_data)
1594 if _response.status_code == 400:
1595 raise BadRequestError(
1596 headers=dict(_response.headers),
1597 body=typing.cast(
1598 typing.Any,
1599 parse_obj_as(
1600 type_=typing.Any, # type: ignore
1601 object_=_response.json(),
1602 ),
1603 ),
1604 )
1605 if _response.status_code == 401:
1606 raise UnauthorizedError(
1607 headers=dict(_response.headers),
1608 body=typing.cast(
1609 typing.Any,
1610 parse_obj_as(
1611 type_=typing.Any, # type: ignore
1612 object_=_response.json(),
1613 ),
1614 ),
1615 )
1616 if _response.status_code == 403:
1617 raise ForbiddenError(
1618 headers=dict(_response.headers),
1619 body=typing.cast(
1620 typing.Any,
1621 parse_obj_as(
1622 type_=typing.Any, # type: ignore
1623 object_=_response.json(),
1624 ),
1625 ),
1626 )
1627 if _response.status_code == 429:
1628 raise TooManyRequestsError(
1629 headers=dict(_response.headers),
1630 body=typing.cast(
1631 typing.Any,
1632 parse_obj_as(
1633 type_=typing.Any, # type: ignore
1634 object_=_response.json(),
1635 ),
1636 ),
1637 )
1638 _response_json = _response.json()
1639 except JSONDecodeError:
1640 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1641 except ValidationError as e:
1642 raise ParsingError(
1643 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1644 )
1645 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)