Debian Codegraph @

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