Debian Codegraph @

src/auth0/management/actions/triggers/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.parse_error import ParsingError
10 from ...core.pydantic_utilities import parse_obj_as
11 from ...core.request_options import RequestOptions
12 from ...errors.bad_request_error import BadRequestError
13 from ...errors.forbidden_error import ForbiddenError
14 from ...errors.too_many_requests_error import TooManyRequestsError
15 from ...errors.unauthorized_error import UnauthorizedError
16 from ...types.list_action_triggers_response_content import ListActionTriggersResponseContent
17 from pydantic import ValidationError
18
19
20 class RawTriggersClient:
21 def __init__(self, *, client_wrapper: SyncClientWrapper):
22 self._client_wrapper = client_wrapper
23
24 def list(
25 self, *, request_options: typing.Optional[RequestOptions] = None
26 ) -> HttpResponse[ListActionTriggersResponseContent]:
27 """
28 Retrieve the set of triggers currently available within actions. A trigger is an extensibility point to which actions can be bound.
29
30 Parameters
31 ----------
32 request_options : typing.Optional[RequestOptions]
33 Request-specific configuration.
34
35 Returns
36 -------
37 HttpResponse[ListActionTriggersResponseContent]
38 The triggers were retrieved.
39 """
40 _response = self._client_wrapper.httpx_client.request(
41 "actions/triggers",
42 method="GET",
43 request_options=request_options,
44 )
45 try:
46 if 200 <= _response.status_code < 300:
47 _data = typing.cast(
48 ListActionTriggersResponseContent,
49 parse_obj_as(
50 type_=ListActionTriggersResponseContent, # type: ignore
51 object_=_response.json(),
52 ),
53 )
54 return HttpResponse(response=_response, data=_data)
55 if _response.status_code == 400:
56 raise BadRequestError(
57 headers=dict(_response.headers),
58 body=typing.cast(
59 typing.Any,
60 parse_obj_as(
61 type_=typing.Any, # type: ignore
62 object_=_response.json(),
63 ),
64 ),
65 )
66 if _response.status_code == 401:
67 raise UnauthorizedError(
68 headers=dict(_response.headers),
69 body=typing.cast(
70 typing.Any,
71 parse_obj_as(
72 type_=typing.Any, # type: ignore
73 object_=_response.json(),
74 ),
75 ),
76 )
77 if _response.status_code == 403:
78 raise ForbiddenError(
79 headers=dict(_response.headers),
80 body=typing.cast(
81 typing.Any,
82 parse_obj_as(
83 type_=typing.Any, # type: ignore
84 object_=_response.json(),
85 ),
86 ),
87 )
88 if _response.status_code == 429:
89 raise TooManyRequestsError(
90 headers=dict(_response.headers),
91 body=typing.cast(
92 typing.Any,
93 parse_obj_as(
94 type_=typing.Any, # type: ignore
95 object_=_response.json(),
96 ),
97 ),
98 )
99 _response_json = _response.json()
100 except JSONDecodeError:
101 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
102 except ValidationError as e:
103 raise ParsingError(
104 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
105 )
106 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
107
108
109 class AsyncRawTriggersClient:
110 def __init__(self, *, client_wrapper: AsyncClientWrapper):
111 self._client_wrapper = client_wrapper
112
113 async def list(
114 self, *, request_options: typing.Optional[RequestOptions] = None
115 ) -> AsyncHttpResponse[ListActionTriggersResponseContent]:
116 """
117 Retrieve the set of triggers currently available within actions. A trigger is an extensibility point to which actions can be bound.
118
119 Parameters
120 ----------
121 request_options : typing.Optional[RequestOptions]
122 Request-specific configuration.
123
124 Returns
125 -------
126 AsyncHttpResponse[ListActionTriggersResponseContent]
127 The triggers were retrieved.
128 """
129 _response = await self._client_wrapper.httpx_client.request(
130 "actions/triggers",
131 method="GET",
132 request_options=request_options,
133 )
134 try:
135 if 200 <= _response.status_code < 300:
136 _data = typing.cast(
137 ListActionTriggersResponseContent,
138 parse_obj_as(
139 type_=ListActionTriggersResponseContent, # type: ignore
140 object_=_response.json(),
141 ),
142 )
143 return AsyncHttpResponse(response=_response, data=_data)
144 if _response.status_code == 400:
145 raise BadRequestError(
146 headers=dict(_response.headers),
147 body=typing.cast(
148 typing.Any,
149 parse_obj_as(
150 type_=typing.Any, # type: ignore
151 object_=_response.json(),
152 ),
153 ),
154 )
155 if _response.status_code == 401:
156 raise UnauthorizedError(
157 headers=dict(_response.headers),
158 body=typing.cast(
159 typing.Any,
160 parse_obj_as(
161 type_=typing.Any, # type: ignore
162 object_=_response.json(),
163 ),
164 ),
165 )
166 if _response.status_code == 403:
167 raise ForbiddenError(
168 headers=dict(_response.headers),
169 body=typing.cast(
170 typing.Any,
171 parse_obj_as(
172 type_=typing.Any, # type: ignore
173 object_=_response.json(),
174 ),
175 ),
176 )
177 if _response.status_code == 429:
178 raise TooManyRequestsError(
179 headers=dict(_response.headers),
180 body=typing.cast(
181 typing.Any,
182 parse_obj_as(
183 type_=typing.Any, # type: ignore
184 object_=_response.json(),
185 ),
186 ),
187 )
188 _response_json = _response.json()
189 except JSONDecodeError:
190 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
191 except ValidationError as e:
192 raise ParsingError(
193 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
194 )
195 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)