Debian Codegraph @

src/auth0/management/self_service_profiles/custom_text/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.forbidden_error import ForbiddenError
14 from ...errors.not_found_error import NotFoundError
15 from ...errors.too_many_requests_error import TooManyRequestsError
16 from ...errors.unauthorized_error import UnauthorizedError
17 from ...types.list_self_service_profile_custom_text_response_content import (
18 ListSelfServiceProfileCustomTextResponseContent,
19 )
20 from ...types.self_service_profile_custom_text_language_enum import SelfServiceProfileCustomTextLanguageEnum
21 from ...types.self_service_profile_custom_text_page_enum import SelfServiceProfileCustomTextPageEnum
22 from ...types.set_self_service_profile_custom_text_request_content import SetSelfServiceProfileCustomTextRequestContent
23 from ...types.set_self_service_profile_custom_text_response_content import (
24 SetSelfServiceProfileCustomTextResponseContent,
25 )
26 from pydantic import ValidationError
27
28 # this is used as the default value for optional parameters
29 OMIT = typing.cast(typing.Any, ...)
30
31
32 class RawCustomTextClient:
33 def __init__(self, *, client_wrapper: SyncClientWrapper):
34 self._client_wrapper = client_wrapper
35
36 def list(
37 self,
38 id: str,
39 language: SelfServiceProfileCustomTextLanguageEnum,
40 page: SelfServiceProfileCustomTextPageEnum,
41 *,
42 request_options: typing.Optional[RequestOptions] = None,
43 ) -> HttpResponse[ListSelfServiceProfileCustomTextResponseContent]:
44 """
45 Retrieves text customizations for a given self-service profile, language and Self-Service Enterprise Configuration flow page.
46
47 Parameters
48 ----------
49 id : str
50 The id of the self-service profile.
51
52 language : SelfServiceProfileCustomTextLanguageEnum
53 The language of the custom text.
54
55 page : SelfServiceProfileCustomTextPageEnum
56 The page where the custom text is shown.
57
58 request_options : typing.Optional[RequestOptions]
59 Request-specific configuration.
60
61 Returns
62 -------
63 HttpResponse[ListSelfServiceProfileCustomTextResponseContent]
64 Retrieved custom text.
65 """
66 _response = self._client_wrapper.httpx_client.request(
67 f"self-service-profiles/{encode_path_param(id)}/custom-text/{encode_path_param(language)}/{encode_path_param(page)}",
68 method="GET",
69 request_options=request_options,
70 )
71 try:
72 if 200 <= _response.status_code < 300:
73 _data = typing.cast(
74 ListSelfServiceProfileCustomTextResponseContent,
75 parse_obj_as(
76 type_=ListSelfServiceProfileCustomTextResponseContent, # type: ignore
77 object_=_response.json(),
78 ),
79 )
80 return HttpResponse(response=_response, data=_data)
81 if _response.status_code == 401:
82 raise UnauthorizedError(
83 headers=dict(_response.headers),
84 body=typing.cast(
85 typing.Any,
86 parse_obj_as(
87 type_=typing.Any, # type: ignore
88 object_=_response.json(),
89 ),
90 ),
91 )
92 if _response.status_code == 403:
93 raise ForbiddenError(
94 headers=dict(_response.headers),
95 body=typing.cast(
96 typing.Any,
97 parse_obj_as(
98 type_=typing.Any, # type: ignore
99 object_=_response.json(),
100 ),
101 ),
102 )
103 if _response.status_code == 404:
104 raise NotFoundError(
105 headers=dict(_response.headers),
106 body=typing.cast(
107 typing.Any,
108 parse_obj_as(
109 type_=typing.Any, # type: ignore
110 object_=_response.json(),
111 ),
112 ),
113 )
114 if _response.status_code == 429:
115 raise TooManyRequestsError(
116 headers=dict(_response.headers),
117 body=typing.cast(
118 typing.Any,
119 parse_obj_as(
120 type_=typing.Any, # type: ignore
121 object_=_response.json(),
122 ),
123 ),
124 )
125 _response_json = _response.json()
126 except JSONDecodeError:
127 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
128 except ValidationError as e:
129 raise ParsingError(
130 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
131 )
132 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
133
134 def set(
135 self,
136 id: str,
137 language: SelfServiceProfileCustomTextLanguageEnum,
138 page: SelfServiceProfileCustomTextPageEnum,
139 *,
140 request: SetSelfServiceProfileCustomTextRequestContent,
141 request_options: typing.Optional[RequestOptions] = None,
142 ) -> HttpResponse[SetSelfServiceProfileCustomTextResponseContent]:
143 """
144 Updates text customizations for a given self-service profile, language and Self-Service Enterprise Configuration flow page.
145
146 Parameters
147 ----------
148 id : str
149 The id of the self-service profile.
150
151 language : SelfServiceProfileCustomTextLanguageEnum
152 The language of the custom text.
153
154 page : SelfServiceProfileCustomTextPageEnum
155 The page where the custom text is shown.
156
157 request : SetSelfServiceProfileCustomTextRequestContent
158
159 request_options : typing.Optional[RequestOptions]
160 Request-specific configuration.
161
162 Returns
163 -------
164 HttpResponse[SetSelfServiceProfileCustomTextResponseContent]
165 Updated custom text.
166 """
167 _response = self._client_wrapper.httpx_client.request(
168 f"self-service-profiles/{encode_path_param(id)}/custom-text/{encode_path_param(language)}/{encode_path_param(page)}",
169 method="PUT",
170 json=request,
171 request_options=request_options,
172 omit=OMIT,
173 )
174 try:
175 if 200 <= _response.status_code < 300:
176 _data = typing.cast(
177 SetSelfServiceProfileCustomTextResponseContent,
178 parse_obj_as(
179 type_=SetSelfServiceProfileCustomTextResponseContent, # type: ignore
180 object_=_response.json(),
181 ),
182 )
183 return HttpResponse(response=_response, data=_data)
184 if _response.status_code == 401:
185 raise UnauthorizedError(
186 headers=dict(_response.headers),
187 body=typing.cast(
188 typing.Any,
189 parse_obj_as(
190 type_=typing.Any, # type: ignore
191 object_=_response.json(),
192 ),
193 ),
194 )
195 if _response.status_code == 403:
196 raise ForbiddenError(
197 headers=dict(_response.headers),
198 body=typing.cast(
199 typing.Any,
200 parse_obj_as(
201 type_=typing.Any, # type: ignore
202 object_=_response.json(),
203 ),
204 ),
205 )
206 if _response.status_code == 404:
207 raise NotFoundError(
208 headers=dict(_response.headers),
209 body=typing.cast(
210 typing.Any,
211 parse_obj_as(
212 type_=typing.Any, # type: ignore
213 object_=_response.json(),
214 ),
215 ),
216 )
217 if _response.status_code == 429:
218 raise TooManyRequestsError(
219 headers=dict(_response.headers),
220 body=typing.cast(
221 typing.Any,
222 parse_obj_as(
223 type_=typing.Any, # type: ignore
224 object_=_response.json(),
225 ),
226 ),
227 )
228 _response_json = _response.json()
229 except JSONDecodeError:
230 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
231 except ValidationError as e:
232 raise ParsingError(
233 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
234 )
235 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
236
237
238 class AsyncRawCustomTextClient:
239 def __init__(self, *, client_wrapper: AsyncClientWrapper):
240 self._client_wrapper = client_wrapper
241
242 async def list(
243 self,
244 id: str,
245 language: SelfServiceProfileCustomTextLanguageEnum,
246 page: SelfServiceProfileCustomTextPageEnum,
247 *,
248 request_options: typing.Optional[RequestOptions] = None,
249 ) -> AsyncHttpResponse[ListSelfServiceProfileCustomTextResponseContent]:
250 """
251 Retrieves text customizations for a given self-service profile, language and Self-Service Enterprise Configuration flow page.
252
253 Parameters
254 ----------
255 id : str
256 The id of the self-service profile.
257
258 language : SelfServiceProfileCustomTextLanguageEnum
259 The language of the custom text.
260
261 page : SelfServiceProfileCustomTextPageEnum
262 The page where the custom text is shown.
263
264 request_options : typing.Optional[RequestOptions]
265 Request-specific configuration.
266
267 Returns
268 -------
269 AsyncHttpResponse[ListSelfServiceProfileCustomTextResponseContent]
270 Retrieved custom text.
271 """
272 _response = await self._client_wrapper.httpx_client.request(
273 f"self-service-profiles/{encode_path_param(id)}/custom-text/{encode_path_param(language)}/{encode_path_param(page)}",
274 method="GET",
275 request_options=request_options,
276 )
277 try:
278 if 200 <= _response.status_code < 300:
279 _data = typing.cast(
280 ListSelfServiceProfileCustomTextResponseContent,
281 parse_obj_as(
282 type_=ListSelfServiceProfileCustomTextResponseContent, # type: ignore
283 object_=_response.json(),
284 ),
285 )
286 return AsyncHttpResponse(response=_response, data=_data)
287 if _response.status_code == 401:
288 raise UnauthorizedError(
289 headers=dict(_response.headers),
290 body=typing.cast(
291 typing.Any,
292 parse_obj_as(
293 type_=typing.Any, # type: ignore
294 object_=_response.json(),
295 ),
296 ),
297 )
298 if _response.status_code == 403:
299 raise ForbiddenError(
300 headers=dict(_response.headers),
301 body=typing.cast(
302 typing.Any,
303 parse_obj_as(
304 type_=typing.Any, # type: ignore
305 object_=_response.json(),
306 ),
307 ),
308 )
309 if _response.status_code == 404:
310 raise NotFoundError(
311 headers=dict(_response.headers),
312 body=typing.cast(
313 typing.Any,
314 parse_obj_as(
315 type_=typing.Any, # type: ignore
316 object_=_response.json(),
317 ),
318 ),
319 )
320 if _response.status_code == 429:
321 raise TooManyRequestsError(
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 _response_json = _response.json()
332 except JSONDecodeError:
333 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
334 except ValidationError as e:
335 raise ParsingError(
336 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
337 )
338 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
339
340 async def set(
341 self,
342 id: str,
343 language: SelfServiceProfileCustomTextLanguageEnum,
344 page: SelfServiceProfileCustomTextPageEnum,
345 *,
346 request: SetSelfServiceProfileCustomTextRequestContent,
347 request_options: typing.Optional[RequestOptions] = None,
348 ) -> AsyncHttpResponse[SetSelfServiceProfileCustomTextResponseContent]:
349 """
350 Updates text customizations for a given self-service profile, language and Self-Service Enterprise Configuration flow page.
351
352 Parameters
353 ----------
354 id : str
355 The id of the self-service profile.
356
357 language : SelfServiceProfileCustomTextLanguageEnum
358 The language of the custom text.
359
360 page : SelfServiceProfileCustomTextPageEnum
361 The page where the custom text is shown.
362
363 request : SetSelfServiceProfileCustomTextRequestContent
364
365 request_options : typing.Optional[RequestOptions]
366 Request-specific configuration.
367
368 Returns
369 -------
370 AsyncHttpResponse[SetSelfServiceProfileCustomTextResponseContent]
371 Updated custom text.
372 """
373 _response = await self._client_wrapper.httpx_client.request(
374 f"self-service-profiles/{encode_path_param(id)}/custom-text/{encode_path_param(language)}/{encode_path_param(page)}",
375 method="PUT",
376 json=request,
377 request_options=request_options,
378 omit=OMIT,
379 )
380 try:
381 if 200 <= _response.status_code < 300:
382 _data = typing.cast(
383 SetSelfServiceProfileCustomTextResponseContent,
384 parse_obj_as(
385 type_=SetSelfServiceProfileCustomTextResponseContent, # type: ignore
386 object_=_response.json(),
387 ),
388 )
389 return AsyncHttpResponse(response=_response, data=_data)
390 if _response.status_code == 401:
391 raise UnauthorizedError(
392 headers=dict(_response.headers),
393 body=typing.cast(
394 typing.Any,
395 parse_obj_as(
396 type_=typing.Any, # type: ignore
397 object_=_response.json(),
398 ),
399 ),
400 )
401 if _response.status_code == 403:
402 raise ForbiddenError(
403 headers=dict(_response.headers),
404 body=typing.cast(
405 typing.Any,
406 parse_obj_as(
407 type_=typing.Any, # type: ignore
408 object_=_response.json(),
409 ),
410 ),
411 )
412 if _response.status_code == 404:
413 raise NotFoundError(
414 headers=dict(_response.headers),
415 body=typing.cast(
416 typing.Any,
417 parse_obj_as(
418 type_=typing.Any, # type: ignore
419 object_=_response.json(),
420 ),
421 ),
422 )
423 if _response.status_code == 429:
424 raise TooManyRequestsError(
425 headers=dict(_response.headers),
426 body=typing.cast(
427 typing.Any,
428 parse_obj_as(
429 type_=typing.Any, # type: ignore
430 object_=_response.json(),
431 ),
432 ),
433 )
434 _response_json = _response.json()
435 except JSONDecodeError:
436 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
437 except ValidationError as e:
438 raise ParsingError(
439 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
440 )
441 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)