Debian Codegraph @

src/auth0/management/prompts/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.get_settings_response_content import GetSettingsResponseContent
17 from ..types.universal_login_experience_enum import UniversalLoginExperienceEnum
18 from ..types.update_settings_response_content import UpdateSettingsResponseContent
19 from pydantic import ValidationError
20
21 # this is used as the default value for optional parameters
22 OMIT = typing.cast(typing.Any, ...)
23
24
25 class RawPromptsClient:
26 def __init__(self, *, client_wrapper: SyncClientWrapper):
27 self._client_wrapper = client_wrapper
28
29 def get_settings(
30 self, *, request_options: typing.Optional[RequestOptions] = None
31 ) -> HttpResponse[GetSettingsResponseContent]:
32 """
33 Retrieve details of the Universal Login configuration of your tenant. This includes the <a href="https://auth0.com/docs/authenticate/login/auth0-universal-login/identifier-first">Identifier First Authentication</a> and <a href="https://auth0.com/docs/secure/multi-factor-authentication/fido-authentication-with-webauthn/configure-webauthn-device-biometrics-for-mfa">WebAuthn with Device Biometrics for MFA</a> features.
34
35 Parameters
36 ----------
37 request_options : typing.Optional[RequestOptions]
38 Request-specific configuration.
39
40 Returns
41 -------
42 HttpResponse[GetSettingsResponseContent]
43 Prompt settings successfully retrieved.
44 """
45 _response = self._client_wrapper.httpx_client.request(
46 "prompts",
47 method="GET",
48 request_options=request_options,
49 )
50 try:
51 if 200 <= _response.status_code < 300:
52 _data = typing.cast(
53 GetSettingsResponseContent,
54 parse_obj_as(
55 type_=GetSettingsResponseContent, # type: ignore
56 object_=_response.json(),
57 ),
58 )
59 return HttpResponse(response=_response, data=_data)
60 if _response.status_code == 401:
61 raise UnauthorizedError(
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 == 403:
72 raise ForbiddenError(
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 == 429:
83 raise TooManyRequestsError(
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 _response_json = _response.json()
94 except JSONDecodeError:
95 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
96 except ValidationError as e:
97 raise ParsingError(
98 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
99 )
100 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
101
102 def update_settings(
103 self,
104 *,
105 universal_login_experience: typing.Optional[UniversalLoginExperienceEnum] = OMIT,
106 identifier_first: typing.Optional[bool] = OMIT,
107 webauthn_platform_first_factor: typing.Optional[bool] = OMIT,
108 request_options: typing.Optional[RequestOptions] = None,
109 ) -> HttpResponse[UpdateSettingsResponseContent]:
110 """
111 Update the Universal Login configuration of your tenant. This includes the <a href="https://auth0.com/docs/authenticate/login/auth0-universal-login/identifier-first">Identifier First Authentication</a> and <a href="https://auth0.com/docs/secure/multi-factor-authentication/fido-authentication-with-webauthn/configure-webauthn-device-biometrics-for-mfa">WebAuthn with Device Biometrics for MFA</a> features.
112
113 Parameters
114 ----------
115 universal_login_experience : typing.Optional[UniversalLoginExperienceEnum]
116
117 identifier_first : typing.Optional[bool]
118 Whether identifier first is enabled or not
119
120 webauthn_platform_first_factor : typing.Optional[bool]
121 Use WebAuthn with Device Biometrics as the first authentication factor
122
123 request_options : typing.Optional[RequestOptions]
124 Request-specific configuration.
125
126 Returns
127 -------
128 HttpResponse[UpdateSettingsResponseContent]
129 Prompts settings successfully updated.
130 """
131 _response = self._client_wrapper.httpx_client.request(
132 "prompts",
133 method="PATCH",
134 json={
135 "universal_login_experience": universal_login_experience,
136 "identifier_first": identifier_first,
137 "webauthn_platform_first_factor": webauthn_platform_first_factor,
138 },
139 headers={
140 "content-type": "application/json",
141 },
142 request_options=request_options,
143 omit=OMIT,
144 )
145 try:
146 if 200 <= _response.status_code < 300:
147 _data = typing.cast(
148 UpdateSettingsResponseContent,
149 parse_obj_as(
150 type_=UpdateSettingsResponseContent, # type: ignore
151 object_=_response.json(),
152 ),
153 )
154 return HttpResponse(response=_response, data=_data)
155 if _response.status_code == 400:
156 raise BadRequestError(
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 == 401:
167 raise UnauthorizedError(
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 == 403:
178 raise ForbiddenError(
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 if _response.status_code == 429:
189 raise TooManyRequestsError(
190 headers=dict(_response.headers),
191 body=typing.cast(
192 typing.Any,
193 parse_obj_as(
194 type_=typing.Any, # type: ignore
195 object_=_response.json(),
196 ),
197 ),
198 )
199 _response_json = _response.json()
200 except JSONDecodeError:
201 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
202 except ValidationError as e:
203 raise ParsingError(
204 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
205 )
206 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
207
208
209 class AsyncRawPromptsClient:
210 def __init__(self, *, client_wrapper: AsyncClientWrapper):
211 self._client_wrapper = client_wrapper
212
213 async def get_settings(
214 self, *, request_options: typing.Optional[RequestOptions] = None
215 ) -> AsyncHttpResponse[GetSettingsResponseContent]:
216 """
217 Retrieve details of the Universal Login configuration of your tenant. This includes the <a href="https://auth0.com/docs/authenticate/login/auth0-universal-login/identifier-first">Identifier First Authentication</a> and <a href="https://auth0.com/docs/secure/multi-factor-authentication/fido-authentication-with-webauthn/configure-webauthn-device-biometrics-for-mfa">WebAuthn with Device Biometrics for MFA</a> features.
218
219 Parameters
220 ----------
221 request_options : typing.Optional[RequestOptions]
222 Request-specific configuration.
223
224 Returns
225 -------
226 AsyncHttpResponse[GetSettingsResponseContent]
227 Prompt settings successfully retrieved.
228 """
229 _response = await self._client_wrapper.httpx_client.request(
230 "prompts",
231 method="GET",
232 request_options=request_options,
233 )
234 try:
235 if 200 <= _response.status_code < 300:
236 _data = typing.cast(
237 GetSettingsResponseContent,
238 parse_obj_as(
239 type_=GetSettingsResponseContent, # type: ignore
240 object_=_response.json(),
241 ),
242 )
243 return AsyncHttpResponse(response=_response, data=_data)
244 if _response.status_code == 401:
245 raise UnauthorizedError(
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 == 403:
256 raise ForbiddenError(
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 async def update_settings(
287 self,
288 *,
289 universal_login_experience: typing.Optional[UniversalLoginExperienceEnum] = OMIT,
290 identifier_first: typing.Optional[bool] = OMIT,
291 webauthn_platform_first_factor: typing.Optional[bool] = OMIT,
292 request_options: typing.Optional[RequestOptions] = None,
293 ) -> AsyncHttpResponse[UpdateSettingsResponseContent]:
294 """
295 Update the Universal Login configuration of your tenant. This includes the <a href="https://auth0.com/docs/authenticate/login/auth0-universal-login/identifier-first">Identifier First Authentication</a> and <a href="https://auth0.com/docs/secure/multi-factor-authentication/fido-authentication-with-webauthn/configure-webauthn-device-biometrics-for-mfa">WebAuthn with Device Biometrics for MFA</a> features.
296
297 Parameters
298 ----------
299 universal_login_experience : typing.Optional[UniversalLoginExperienceEnum]
300
301 identifier_first : typing.Optional[bool]
302 Whether identifier first is enabled or not
303
304 webauthn_platform_first_factor : typing.Optional[bool]
305 Use WebAuthn with Device Biometrics as the first authentication factor
306
307 request_options : typing.Optional[RequestOptions]
308 Request-specific configuration.
309
310 Returns
311 -------
312 AsyncHttpResponse[UpdateSettingsResponseContent]
313 Prompts settings successfully updated.
314 """
315 _response = await self._client_wrapper.httpx_client.request(
316 "prompts",
317 method="PATCH",
318 json={
319 "universal_login_experience": universal_login_experience,
320 "identifier_first": identifier_first,
321 "webauthn_platform_first_factor": webauthn_platform_first_factor,
322 },
323 headers={
324 "content-type": "application/json",
325 },
326 request_options=request_options,
327 omit=OMIT,
328 )
329 try:
330 if 200 <= _response.status_code < 300:
331 _data = typing.cast(
332 UpdateSettingsResponseContent,
333 parse_obj_as(
334 type_=UpdateSettingsResponseContent, # type: ignore
335 object_=_response.json(),
336 ),
337 )
338 return AsyncHttpResponse(response=_response, data=_data)
339 if _response.status_code == 400:
340 raise BadRequestError(
341 headers=dict(_response.headers),
342 body=typing.cast(
343 typing.Any,
344 parse_obj_as(
345 type_=typing.Any, # type: ignore
346 object_=_response.json(),
347 ),
348 ),
349 )
350 if _response.status_code == 401:
351 raise UnauthorizedError(
352 headers=dict(_response.headers),
353 body=typing.cast(
354 typing.Any,
355 parse_obj_as(
356 type_=typing.Any, # type: ignore
357 object_=_response.json(),
358 ),
359 ),
360 )
361 if _response.status_code == 403:
362 raise ForbiddenError(
363 headers=dict(_response.headers),
364 body=typing.cast(
365 typing.Any,
366 parse_obj_as(
367 type_=typing.Any, # type: ignore
368 object_=_response.json(),
369 ),
370 ),
371 )
372 if _response.status_code == 429:
373 raise TooManyRequestsError(
374 headers=dict(_response.headers),
375 body=typing.cast(
376 typing.Any,
377 parse_obj_as(
378 type_=typing.Any, # type: ignore
379 object_=_response.json(),
380 ),
381 ),
382 )
383 _response_json = _response.json()
384 except JSONDecodeError:
385 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
386 except ValidationError as e:
387 raise ParsingError(
388 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
389 )
390 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)