Debian Codegraph @

src/auth0/management/actions/executions/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.parse_error import ParsingError
11 from ...core.pydantic_utilities import parse_obj_as
12 from ...core.request_options import RequestOptions
13 from ...errors.bad_request_error import BadRequestError
14 from ...errors.forbidden_error import ForbiddenError
15 from ...errors.not_found_error import NotFoundError
16 from ...errors.too_many_requests_error import TooManyRequestsError
17 from ...errors.unauthorized_error import UnauthorizedError
18 from ...types.get_action_execution_response_content import GetActionExecutionResponseContent
19 from pydantic import ValidationError
20
21
22 class RawExecutionsClient:
23 def __init__(self, *, client_wrapper: SyncClientWrapper):
24 self._client_wrapper = client_wrapper
25
26 def get(
27 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
28 ) -> HttpResponse[GetActionExecutionResponseContent]:
29 """
30 Retrieve information about a specific execution of a trigger. Relevant execution IDs will be included in tenant logs generated as part of that authentication flow. Executions will only be stored for 10 days after their creation.
31
32 Parameters
33 ----------
34 id : str
35 The ID of the execution to retrieve.
36
37 request_options : typing.Optional[RequestOptions]
38 Request-specific configuration.
39
40 Returns
41 -------
42 HttpResponse[GetActionExecutionResponseContent]
43 The execution was retrieved.
44 """
45 _response = self._client_wrapper.httpx_client.request(
46 f"actions/executions/{encode_path_param(id)}",
47 method="GET",
48 request_options=request_options,
49 )
50 try:
51 if 200 <= _response.status_code < 300:
52 _data = typing.cast(
53 GetActionExecutionResponseContent,
54 parse_obj_as(
55 type_=GetActionExecutionResponseContent, # type: ignore
56 object_=_response.json(),
57 ),
58 )
59 return HttpResponse(response=_response, data=_data)
60 if _response.status_code == 400:
61 raise BadRequestError(
62 headers=dict(_response.headers),
63 body=typing.cast(
64 typing.Any,
65 parse_obj_as(
66 type_=typing.Any, # type: ignore
67 object_=_response.json(),
68 ),
69 ),
70 )
71 if _response.status_code == 401:
72 raise UnauthorizedError(
73 headers=dict(_response.headers),
74 body=typing.cast(
75 typing.Any,
76 parse_obj_as(
77 type_=typing.Any, # type: ignore
78 object_=_response.json(),
79 ),
80 ),
81 )
82 if _response.status_code == 403:
83 raise ForbiddenError(
84 headers=dict(_response.headers),
85 body=typing.cast(
86 typing.Any,
87 parse_obj_as(
88 type_=typing.Any, # type: ignore
89 object_=_response.json(),
90 ),
91 ),
92 )
93 if _response.status_code == 404:
94 raise NotFoundError(
95 headers=dict(_response.headers),
96 body=typing.cast(
97 typing.Any,
98 parse_obj_as(
99 type_=typing.Any, # type: ignore
100 object_=_response.json(),
101 ),
102 ),
103 )
104 if _response.status_code == 429:
105 raise TooManyRequestsError(
106 headers=dict(_response.headers),
107 body=typing.cast(
108 typing.Any,
109 parse_obj_as(
110 type_=typing.Any, # type: ignore
111 object_=_response.json(),
112 ),
113 ),
114 )
115 _response_json = _response.json()
116 except JSONDecodeError:
117 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
118 except ValidationError as e:
119 raise ParsingError(
120 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
121 )
122 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
123
124
125 class AsyncRawExecutionsClient:
126 def __init__(self, *, client_wrapper: AsyncClientWrapper):
127 self._client_wrapper = client_wrapper
128
129 async def get(
130 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
131 ) -> AsyncHttpResponse[GetActionExecutionResponseContent]:
132 """
133 Retrieve information about a specific execution of a trigger. Relevant execution IDs will be included in tenant logs generated as part of that authentication flow. Executions will only be stored for 10 days after their creation.
134
135 Parameters
136 ----------
137 id : str
138 The ID of the execution to retrieve.
139
140 request_options : typing.Optional[RequestOptions]
141 Request-specific configuration.
142
143 Returns
144 -------
145 AsyncHttpResponse[GetActionExecutionResponseContent]
146 The execution was retrieved.
147 """
148 _response = await self._client_wrapper.httpx_client.request(
149 f"actions/executions/{encode_path_param(id)}",
150 method="GET",
151 request_options=request_options,
152 )
153 try:
154 if 200 <= _response.status_code < 300:
155 _data = typing.cast(
156 GetActionExecutionResponseContent,
157 parse_obj_as(
158 type_=GetActionExecutionResponseContent, # type: ignore
159 object_=_response.json(),
160 ),
161 )
162 return AsyncHttpResponse(response=_response, data=_data)
163 if _response.status_code == 400:
164 raise BadRequestError(
165 headers=dict(_response.headers),
166 body=typing.cast(
167 typing.Any,
168 parse_obj_as(
169 type_=typing.Any, # type: ignore
170 object_=_response.json(),
171 ),
172 ),
173 )
174 if _response.status_code == 401:
175 raise UnauthorizedError(
176 headers=dict(_response.headers),
177 body=typing.cast(
178 typing.Any,
179 parse_obj_as(
180 type_=typing.Any, # type: ignore
181 object_=_response.json(),
182 ),
183 ),
184 )
185 if _response.status_code == 403:
186 raise ForbiddenError(
187 headers=dict(_response.headers),
188 body=typing.cast(
189 typing.Any,
190 parse_obj_as(
191 type_=typing.Any, # type: ignore
192 object_=_response.json(),
193 ),
194 ),
195 )
196 if _response.status_code == 404:
197 raise NotFoundError(
198 headers=dict(_response.headers),
199 body=typing.cast(
200 typing.Any,
201 parse_obj_as(
202 type_=typing.Any, # type: ignore
203 object_=_response.json(),
204 ),
205 ),
206 )
207 if _response.status_code == 429:
208 raise TooManyRequestsError(
209 headers=dict(_response.headers),
210 body=typing.cast(
211 typing.Any,
212 parse_obj_as(
213 type_=typing.Any, # type: ignore
214 object_=_response.json(),
215 ),
216 ),
217 )
218 _response_json = _response.json()
219 except JSONDecodeError:
220 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
221 except ValidationError as e:
222 raise ParsingError(
223 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
224 )
225 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)