Debian Codegraph @

src/auth0/management/guardian/factors/sms/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.unauthorized_error import UnauthorizedError
15 from ....types.get_guardian_factor_sms_templates_response_content import GetGuardianFactorSmsTemplatesResponseContent
16 from ....types.get_guardian_factors_provider_sms_response_content import GetGuardianFactorsProviderSmsResponseContent
17 from ....types.get_guardian_factors_provider_sms_twilio_response_content import (
18 GetGuardianFactorsProviderSmsTwilioResponseContent,
19 )
20 from ....types.guardian_factors_provider_sms_provider_enum import GuardianFactorsProviderSmsProviderEnum
21 from ....types.set_guardian_factor_sms_templates_response_content import SetGuardianFactorSmsTemplatesResponseContent
22 from ....types.set_guardian_factors_provider_sms_response_content import SetGuardianFactorsProviderSmsResponseContent
23 from ....types.set_guardian_factors_provider_sms_twilio_response_content import (
24 SetGuardianFactorsProviderSmsTwilioResponseContent,
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 RawSmsClient:
33 def __init__(self, *, client_wrapper: SyncClientWrapper):
34 self._client_wrapper = client_wrapper
35
36 def get_twilio_provider(
37 self, *, request_options: typing.Optional[RequestOptions] = None
38 ) -> HttpResponse[GetGuardianFactorsProviderSmsTwilioResponseContent]:
39 """
40 Retrieve the <a href="https://auth0.com/docs/multifactor-authentication/twilio-configuration">Twilio SMS provider configuration</a> (subscription required).
41
42 A new endpoint is available to retrieve the Twilio configuration related to phone factors (<a href='https://auth0.com/docs/api/management/v2/#!/Guardian/get_twilio'>phone Twilio configuration</a>). It has the same payload as this one. Please use it instead.
43
44 Parameters
45 ----------
46 request_options : typing.Optional[RequestOptions]
47 Request-specific configuration.
48
49 Returns
50 -------
51 HttpResponse[GetGuardianFactorsProviderSmsTwilioResponseContent]
52 Twilio SMS configuration successfully retrieved.
53 """
54 _response = self._client_wrapper.httpx_client.request(
55 "guardian/factors/sms/providers/twilio",
56 method="GET",
57 request_options=request_options,
58 )
59 try:
60 if 200 <= _response.status_code < 300:
61 _data = typing.cast(
62 GetGuardianFactorsProviderSmsTwilioResponseContent,
63 parse_obj_as(
64 type_=GetGuardianFactorsProviderSmsTwilioResponseContent, # type: ignore
65 object_=_response.json(),
66 ),
67 )
68 return HttpResponse(response=_response, data=_data)
69 if _response.status_code == 400:
70 raise BadRequestError(
71 headers=dict(_response.headers),
72 body=typing.cast(
73 typing.Any,
74 parse_obj_as(
75 type_=typing.Any, # type: ignore
76 object_=_response.json(),
77 ),
78 ),
79 )
80 if _response.status_code == 401:
81 raise UnauthorizedError(
82 headers=dict(_response.headers),
83 body=typing.cast(
84 typing.Any,
85 parse_obj_as(
86 type_=typing.Any, # type: ignore
87 object_=_response.json(),
88 ),
89 ),
90 )
91 if _response.status_code == 403:
92 raise ForbiddenError(
93 headers=dict(_response.headers),
94 body=typing.cast(
95 typing.Any,
96 parse_obj_as(
97 type_=typing.Any, # type: ignore
98 object_=_response.json(),
99 ),
100 ),
101 )
102 _response_json = _response.json()
103 except JSONDecodeError:
104 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
105 except ValidationError as e:
106 raise ParsingError(
107 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
108 )
109 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
110
111 def set_twilio_provider(
112 self,
113 *,
114 from_: typing.Optional[str] = OMIT,
115 messaging_service_sid: typing.Optional[str] = OMIT,
116 auth_token: typing.Optional[str] = OMIT,
117 sid: typing.Optional[str] = OMIT,
118 request_options: typing.Optional[RequestOptions] = None,
119 ) -> HttpResponse[SetGuardianFactorsProviderSmsTwilioResponseContent]:
120 """
121 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/put-twilio">Update Twilio phone configuration</a> endpoint.
122
123 <b>Previous functionality</b>: Update the Twilio SMS provider configuration.
124
125 Parameters
126 ----------
127 from_ : typing.Optional[str]
128 From number
129
130 messaging_service_sid : typing.Optional[str]
131 Copilot SID
132
133 auth_token : typing.Optional[str]
134 Twilio Authentication token
135
136 sid : typing.Optional[str]
137 Twilio SID
138
139 request_options : typing.Optional[RequestOptions]
140 Request-specific configuration.
141
142 Returns
143 -------
144 HttpResponse[SetGuardianFactorsProviderSmsTwilioResponseContent]
145 Twilio SMS configuration successfully updated.
146 """
147 _response = self._client_wrapper.httpx_client.request(
148 "guardian/factors/sms/providers/twilio",
149 method="PUT",
150 json={
151 "from": from_,
152 "messaging_service_sid": messaging_service_sid,
153 "auth_token": auth_token,
154 "sid": sid,
155 },
156 headers={
157 "content-type": "application/json",
158 },
159 request_options=request_options,
160 omit=OMIT,
161 )
162 try:
163 if 200 <= _response.status_code < 300:
164 _data = typing.cast(
165 SetGuardianFactorsProviderSmsTwilioResponseContent,
166 parse_obj_as(
167 type_=SetGuardianFactorsProviderSmsTwilioResponseContent, # type: ignore
168 object_=_response.json(),
169 ),
170 )
171 return HttpResponse(response=_response, data=_data)
172 if _response.status_code == 400:
173 raise BadRequestError(
174 headers=dict(_response.headers),
175 body=typing.cast(
176 typing.Any,
177 parse_obj_as(
178 type_=typing.Any, # type: ignore
179 object_=_response.json(),
180 ),
181 ),
182 )
183 if _response.status_code == 401:
184 raise UnauthorizedError(
185 headers=dict(_response.headers),
186 body=typing.cast(
187 typing.Any,
188 parse_obj_as(
189 type_=typing.Any, # type: ignore
190 object_=_response.json(),
191 ),
192 ),
193 )
194 if _response.status_code == 403:
195 raise ForbiddenError(
196 headers=dict(_response.headers),
197 body=typing.cast(
198 typing.Any,
199 parse_obj_as(
200 type_=typing.Any, # type: ignore
201 object_=_response.json(),
202 ),
203 ),
204 )
205 _response_json = _response.json()
206 except JSONDecodeError:
207 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
208 except ValidationError as e:
209 raise ParsingError(
210 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
211 )
212 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
213
214 def get_selected_provider(
215 self, *, request_options: typing.Optional[RequestOptions] = None
216 ) -> HttpResponse[GetGuardianFactorsProviderSmsResponseContent]:
217 """
218 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/get-phone-providers">Retrieve phone configuration</a> endpoint instead.
219
220 <b>Previous functionality</b>: Retrieve details for the multi-factor authentication SMS provider configured for your tenant.
221
222 Parameters
223 ----------
224 request_options : typing.Optional[RequestOptions]
225 Request-specific configuration.
226
227 Returns
228 -------
229 HttpResponse[GetGuardianFactorsProviderSmsResponseContent]
230 Returns selected SMS provider configuration
231 """
232 _response = self._client_wrapper.httpx_client.request(
233 "guardian/factors/sms/selected-provider",
234 method="GET",
235 request_options=request_options,
236 )
237 try:
238 if 200 <= _response.status_code < 300:
239 _data = typing.cast(
240 GetGuardianFactorsProviderSmsResponseContent,
241 parse_obj_as(
242 type_=GetGuardianFactorsProviderSmsResponseContent, # type: ignore
243 object_=_response.json(),
244 ),
245 )
246 return HttpResponse(response=_response, data=_data)
247 if _response.status_code == 400:
248 raise BadRequestError(
249 headers=dict(_response.headers),
250 body=typing.cast(
251 typing.Any,
252 parse_obj_as(
253 type_=typing.Any, # type: ignore
254 object_=_response.json(),
255 ),
256 ),
257 )
258 if _response.status_code == 401:
259 raise UnauthorizedError(
260 headers=dict(_response.headers),
261 body=typing.cast(
262 typing.Any,
263 parse_obj_as(
264 type_=typing.Any, # type: ignore
265 object_=_response.json(),
266 ),
267 ),
268 )
269 if _response.status_code == 403:
270 raise ForbiddenError(
271 headers=dict(_response.headers),
272 body=typing.cast(
273 typing.Any,
274 parse_obj_as(
275 type_=typing.Any, # type: ignore
276 object_=_response.json(),
277 ),
278 ),
279 )
280 _response_json = _response.json()
281 except JSONDecodeError:
282 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
283 except ValidationError as e:
284 raise ParsingError(
285 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
286 )
287 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
288
289 def set_provider(
290 self,
291 *,
292 provider: GuardianFactorsProviderSmsProviderEnum,
293 request_options: typing.Optional[RequestOptions] = None,
294 ) -> HttpResponse[SetGuardianFactorsProviderSmsResponseContent]:
295 """
296 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/put-phone-providers">Update phone configuration</a> endpoint instead.
297
298 <b>Previous functionality</b>: Update the multi-factor authentication SMS provider configuration in your tenant.
299
300 Parameters
301 ----------
302 provider : GuardianFactorsProviderSmsProviderEnum
303
304 request_options : typing.Optional[RequestOptions]
305 Request-specific configuration.
306
307 Returns
308 -------
309 HttpResponse[SetGuardianFactorsProviderSmsResponseContent]
310 Returns selected SMS provider configuration
311 """
312 _response = self._client_wrapper.httpx_client.request(
313 "guardian/factors/sms/selected-provider",
314 method="PUT",
315 json={
316 "provider": provider,
317 },
318 headers={
319 "content-type": "application/json",
320 },
321 request_options=request_options,
322 omit=OMIT,
323 )
324 try:
325 if 200 <= _response.status_code < 300:
326 _data = typing.cast(
327 SetGuardianFactorsProviderSmsResponseContent,
328 parse_obj_as(
329 type_=SetGuardianFactorsProviderSmsResponseContent, # type: ignore
330 object_=_response.json(),
331 ),
332 )
333 return HttpResponse(response=_response, data=_data)
334 if _response.status_code == 400:
335 raise BadRequestError(
336 headers=dict(_response.headers),
337 body=typing.cast(
338 typing.Any,
339 parse_obj_as(
340 type_=typing.Any, # type: ignore
341 object_=_response.json(),
342 ),
343 ),
344 )
345 if _response.status_code == 401:
346 raise UnauthorizedError(
347 headers=dict(_response.headers),
348 body=typing.cast(
349 typing.Any,
350 parse_obj_as(
351 type_=typing.Any, # type: ignore
352 object_=_response.json(),
353 ),
354 ),
355 )
356 if _response.status_code == 403:
357 raise ForbiddenError(
358 headers=dict(_response.headers),
359 body=typing.cast(
360 typing.Any,
361 parse_obj_as(
362 type_=typing.Any, # type: ignore
363 object_=_response.json(),
364 ),
365 ),
366 )
367 _response_json = _response.json()
368 except JSONDecodeError:
369 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
370 except ValidationError as e:
371 raise ParsingError(
372 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
373 )
374 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
375
376 def get_templates(
377 self, *, request_options: typing.Optional[RequestOptions] = None
378 ) -> HttpResponse[typing.Optional[GetGuardianFactorSmsTemplatesResponseContent]]:
379 """
380 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/get-factor-phone-templates">Retrieve enrollment and verification phone templates</a> endpoint instead.
381
382 <b>Previous function</b>: Retrieve details of SMS enrollment and verification templates configured for your tenant.
383
384 Parameters
385 ----------
386 request_options : typing.Optional[RequestOptions]
387 Request-specific configuration.
388
389 Returns
390 -------
391 HttpResponse[typing.Optional[GetGuardianFactorSmsTemplatesResponseContent]]
392 SMS enrollment and verification templates successfully retrieved.
393 """
394 _response = self._client_wrapper.httpx_client.request(
395 "guardian/factors/sms/templates",
396 method="GET",
397 request_options=request_options,
398 )
399 try:
400 if _response is None or not _response.text.strip():
401 return HttpResponse(response=_response, data=None)
402 if 200 <= _response.status_code < 300:
403 _data = typing.cast(
404 typing.Optional[GetGuardianFactorSmsTemplatesResponseContent],
405 parse_obj_as(
406 type_=typing.Optional[GetGuardianFactorSmsTemplatesResponseContent], # type: ignore
407 object_=_response.json(),
408 ),
409 )
410 return HttpResponse(response=_response, data=_data)
411 if _response.status_code == 400:
412 raise BadRequestError(
413 headers=dict(_response.headers),
414 body=typing.cast(
415 typing.Any,
416 parse_obj_as(
417 type_=typing.Any, # type: ignore
418 object_=_response.json(),
419 ),
420 ),
421 )
422 if _response.status_code == 401:
423 raise UnauthorizedError(
424 headers=dict(_response.headers),
425 body=typing.cast(
426 typing.Any,
427 parse_obj_as(
428 type_=typing.Any, # type: ignore
429 object_=_response.json(),
430 ),
431 ),
432 )
433 if _response.status_code == 403:
434 raise ForbiddenError(
435 headers=dict(_response.headers),
436 body=typing.cast(
437 typing.Any,
438 parse_obj_as(
439 type_=typing.Any, # type: ignore
440 object_=_response.json(),
441 ),
442 ),
443 )
444 _response_json = _response.json()
445 except JSONDecodeError:
446 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
447 except ValidationError as e:
448 raise ParsingError(
449 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
450 )
451 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
452
453 def set_templates(
454 self,
455 *,
456 enrollment_message: str,
457 verification_message: str,
458 request_options: typing.Optional[RequestOptions] = None,
459 ) -> HttpResponse[SetGuardianFactorSmsTemplatesResponseContent]:
460 """
461 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/put-factor-phone-templates">Update enrollment and verification phone templates</a> endpoint instead.
462
463 <b>Previous functionality</b>: Customize the messages sent to complete SMS enrollment and verification.
464
465 Parameters
466 ----------
467 enrollment_message : str
468 Message sent to the user when they are invited to enroll with a phone number.
469
470 verification_message : str
471 Message sent to the user when they are prompted to verify their account.
472
473 request_options : typing.Optional[RequestOptions]
474 Request-specific configuration.
475
476 Returns
477 -------
478 HttpResponse[SetGuardianFactorSmsTemplatesResponseContent]
479 SMS enrollment and verification templates successfully updated.
480 """
481 _response = self._client_wrapper.httpx_client.request(
482 "guardian/factors/sms/templates",
483 method="PUT",
484 json={
485 "enrollment_message": enrollment_message,
486 "verification_message": verification_message,
487 },
488 headers={
489 "content-type": "application/json",
490 },
491 request_options=request_options,
492 omit=OMIT,
493 )
494 try:
495 if 200 <= _response.status_code < 300:
496 _data = typing.cast(
497 SetGuardianFactorSmsTemplatesResponseContent,
498 parse_obj_as(
499 type_=SetGuardianFactorSmsTemplatesResponseContent, # type: ignore
500 object_=_response.json(),
501 ),
502 )
503 return HttpResponse(response=_response, data=_data)
504 if _response.status_code == 400:
505 raise BadRequestError(
506 headers=dict(_response.headers),
507 body=typing.cast(
508 typing.Any,
509 parse_obj_as(
510 type_=typing.Any, # type: ignore
511 object_=_response.json(),
512 ),
513 ),
514 )
515 if _response.status_code == 401:
516 raise UnauthorizedError(
517 headers=dict(_response.headers),
518 body=typing.cast(
519 typing.Any,
520 parse_obj_as(
521 type_=typing.Any, # type: ignore
522 object_=_response.json(),
523 ),
524 ),
525 )
526 if _response.status_code == 403:
527 raise ForbiddenError(
528 headers=dict(_response.headers),
529 body=typing.cast(
530 typing.Any,
531 parse_obj_as(
532 type_=typing.Any, # type: ignore
533 object_=_response.json(),
534 ),
535 ),
536 )
537 _response_json = _response.json()
538 except JSONDecodeError:
539 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
540 except ValidationError as e:
541 raise ParsingError(
542 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
543 )
544 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
545
546
547 class AsyncRawSmsClient:
548 def __init__(self, *, client_wrapper: AsyncClientWrapper):
549 self._client_wrapper = client_wrapper
550
551 async def get_twilio_provider(
552 self, *, request_options: typing.Optional[RequestOptions] = None
553 ) -> AsyncHttpResponse[GetGuardianFactorsProviderSmsTwilioResponseContent]:
554 """
555 Retrieve the <a href="https://auth0.com/docs/multifactor-authentication/twilio-configuration">Twilio SMS provider configuration</a> (subscription required).
556
557 A new endpoint is available to retrieve the Twilio configuration related to phone factors (<a href='https://auth0.com/docs/api/management/v2/#!/Guardian/get_twilio'>phone Twilio configuration</a>). It has the same payload as this one. Please use it instead.
558
559 Parameters
560 ----------
561 request_options : typing.Optional[RequestOptions]
562 Request-specific configuration.
563
564 Returns
565 -------
566 AsyncHttpResponse[GetGuardianFactorsProviderSmsTwilioResponseContent]
567 Twilio SMS configuration successfully retrieved.
568 """
569 _response = await self._client_wrapper.httpx_client.request(
570 "guardian/factors/sms/providers/twilio",
571 method="GET",
572 request_options=request_options,
573 )
574 try:
575 if 200 <= _response.status_code < 300:
576 _data = typing.cast(
577 GetGuardianFactorsProviderSmsTwilioResponseContent,
578 parse_obj_as(
579 type_=GetGuardianFactorsProviderSmsTwilioResponseContent, # type: ignore
580 object_=_response.json(),
581 ),
582 )
583 return AsyncHttpResponse(response=_response, data=_data)
584 if _response.status_code == 400:
585 raise BadRequestError(
586 headers=dict(_response.headers),
587 body=typing.cast(
588 typing.Any,
589 parse_obj_as(
590 type_=typing.Any, # type: ignore
591 object_=_response.json(),
592 ),
593 ),
594 )
595 if _response.status_code == 401:
596 raise UnauthorizedError(
597 headers=dict(_response.headers),
598 body=typing.cast(
599 typing.Any,
600 parse_obj_as(
601 type_=typing.Any, # type: ignore
602 object_=_response.json(),
603 ),
604 ),
605 )
606 if _response.status_code == 403:
607 raise ForbiddenError(
608 headers=dict(_response.headers),
609 body=typing.cast(
610 typing.Any,
611 parse_obj_as(
612 type_=typing.Any, # type: ignore
613 object_=_response.json(),
614 ),
615 ),
616 )
617 _response_json = _response.json()
618 except JSONDecodeError:
619 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
620 except ValidationError as e:
621 raise ParsingError(
622 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
623 )
624 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
625
626 async def set_twilio_provider(
627 self,
628 *,
629 from_: typing.Optional[str] = OMIT,
630 messaging_service_sid: typing.Optional[str] = OMIT,
631 auth_token: typing.Optional[str] = OMIT,
632 sid: typing.Optional[str] = OMIT,
633 request_options: typing.Optional[RequestOptions] = None,
634 ) -> AsyncHttpResponse[SetGuardianFactorsProviderSmsTwilioResponseContent]:
635 """
636 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/put-twilio">Update Twilio phone configuration</a> endpoint.
637
638 <b>Previous functionality</b>: Update the Twilio SMS provider configuration.
639
640 Parameters
641 ----------
642 from_ : typing.Optional[str]
643 From number
644
645 messaging_service_sid : typing.Optional[str]
646 Copilot SID
647
648 auth_token : typing.Optional[str]
649 Twilio Authentication token
650
651 sid : typing.Optional[str]
652 Twilio SID
653
654 request_options : typing.Optional[RequestOptions]
655 Request-specific configuration.
656
657 Returns
658 -------
659 AsyncHttpResponse[SetGuardianFactorsProviderSmsTwilioResponseContent]
660 Twilio SMS configuration successfully updated.
661 """
662 _response = await self._client_wrapper.httpx_client.request(
663 "guardian/factors/sms/providers/twilio",
664 method="PUT",
665 json={
666 "from": from_,
667 "messaging_service_sid": messaging_service_sid,
668 "auth_token": auth_token,
669 "sid": sid,
670 },
671 headers={
672 "content-type": "application/json",
673 },
674 request_options=request_options,
675 omit=OMIT,
676 )
677 try:
678 if 200 <= _response.status_code < 300:
679 _data = typing.cast(
680 SetGuardianFactorsProviderSmsTwilioResponseContent,
681 parse_obj_as(
682 type_=SetGuardianFactorsProviderSmsTwilioResponseContent, # type: ignore
683 object_=_response.json(),
684 ),
685 )
686 return AsyncHttpResponse(response=_response, data=_data)
687 if _response.status_code == 400:
688 raise BadRequestError(
689 headers=dict(_response.headers),
690 body=typing.cast(
691 typing.Any,
692 parse_obj_as(
693 type_=typing.Any, # type: ignore
694 object_=_response.json(),
695 ),
696 ),
697 )
698 if _response.status_code == 401:
699 raise UnauthorizedError(
700 headers=dict(_response.headers),
701 body=typing.cast(
702 typing.Any,
703 parse_obj_as(
704 type_=typing.Any, # type: ignore
705 object_=_response.json(),
706 ),
707 ),
708 )
709 if _response.status_code == 403:
710 raise ForbiddenError(
711 headers=dict(_response.headers),
712 body=typing.cast(
713 typing.Any,
714 parse_obj_as(
715 type_=typing.Any, # type: ignore
716 object_=_response.json(),
717 ),
718 ),
719 )
720 _response_json = _response.json()
721 except JSONDecodeError:
722 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
723 except ValidationError as e:
724 raise ParsingError(
725 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
726 )
727 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
728
729 async def get_selected_provider(
730 self, *, request_options: typing.Optional[RequestOptions] = None
731 ) -> AsyncHttpResponse[GetGuardianFactorsProviderSmsResponseContent]:
732 """
733 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/get-phone-providers">Retrieve phone configuration</a> endpoint instead.
734
735 <b>Previous functionality</b>: Retrieve details for the multi-factor authentication SMS provider configured for your tenant.
736
737 Parameters
738 ----------
739 request_options : typing.Optional[RequestOptions]
740 Request-specific configuration.
741
742 Returns
743 -------
744 AsyncHttpResponse[GetGuardianFactorsProviderSmsResponseContent]
745 Returns selected SMS provider configuration
746 """
747 _response = await self._client_wrapper.httpx_client.request(
748 "guardian/factors/sms/selected-provider",
749 method="GET",
750 request_options=request_options,
751 )
752 try:
753 if 200 <= _response.status_code < 300:
754 _data = typing.cast(
755 GetGuardianFactorsProviderSmsResponseContent,
756 parse_obj_as(
757 type_=GetGuardianFactorsProviderSmsResponseContent, # type: ignore
758 object_=_response.json(),
759 ),
760 )
761 return AsyncHttpResponse(response=_response, data=_data)
762 if _response.status_code == 400:
763 raise BadRequestError(
764 headers=dict(_response.headers),
765 body=typing.cast(
766 typing.Any,
767 parse_obj_as(
768 type_=typing.Any, # type: ignore
769 object_=_response.json(),
770 ),
771 ),
772 )
773 if _response.status_code == 401:
774 raise UnauthorizedError(
775 headers=dict(_response.headers),
776 body=typing.cast(
777 typing.Any,
778 parse_obj_as(
779 type_=typing.Any, # type: ignore
780 object_=_response.json(),
781 ),
782 ),
783 )
784 if _response.status_code == 403:
785 raise ForbiddenError(
786 headers=dict(_response.headers),
787 body=typing.cast(
788 typing.Any,
789 parse_obj_as(
790 type_=typing.Any, # type: ignore
791 object_=_response.json(),
792 ),
793 ),
794 )
795 _response_json = _response.json()
796 except JSONDecodeError:
797 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
798 except ValidationError as e:
799 raise ParsingError(
800 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
801 )
802 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
803
804 async def set_provider(
805 self,
806 *,
807 provider: GuardianFactorsProviderSmsProviderEnum,
808 request_options: typing.Optional[RequestOptions] = None,
809 ) -> AsyncHttpResponse[SetGuardianFactorsProviderSmsResponseContent]:
810 """
811 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/put-phone-providers">Update phone configuration</a> endpoint instead.
812
813 <b>Previous functionality</b>: Update the multi-factor authentication SMS provider configuration in your tenant.
814
815 Parameters
816 ----------
817 provider : GuardianFactorsProviderSmsProviderEnum
818
819 request_options : typing.Optional[RequestOptions]
820 Request-specific configuration.
821
822 Returns
823 -------
824 AsyncHttpResponse[SetGuardianFactorsProviderSmsResponseContent]
825 Returns selected SMS provider configuration
826 """
827 _response = await self._client_wrapper.httpx_client.request(
828 "guardian/factors/sms/selected-provider",
829 method="PUT",
830 json={
831 "provider": provider,
832 },
833 headers={
834 "content-type": "application/json",
835 },
836 request_options=request_options,
837 omit=OMIT,
838 )
839 try:
840 if 200 <= _response.status_code < 300:
841 _data = typing.cast(
842 SetGuardianFactorsProviderSmsResponseContent,
843 parse_obj_as(
844 type_=SetGuardianFactorsProviderSmsResponseContent, # type: ignore
845 object_=_response.json(),
846 ),
847 )
848 return AsyncHttpResponse(response=_response, data=_data)
849 if _response.status_code == 400:
850 raise BadRequestError(
851 headers=dict(_response.headers),
852 body=typing.cast(
853 typing.Any,
854 parse_obj_as(
855 type_=typing.Any, # type: ignore
856 object_=_response.json(),
857 ),
858 ),
859 )
860 if _response.status_code == 401:
861 raise UnauthorizedError(
862 headers=dict(_response.headers),
863 body=typing.cast(
864 typing.Any,
865 parse_obj_as(
866 type_=typing.Any, # type: ignore
867 object_=_response.json(),
868 ),
869 ),
870 )
871 if _response.status_code == 403:
872 raise ForbiddenError(
873 headers=dict(_response.headers),
874 body=typing.cast(
875 typing.Any,
876 parse_obj_as(
877 type_=typing.Any, # type: ignore
878 object_=_response.json(),
879 ),
880 ),
881 )
882 _response_json = _response.json()
883 except JSONDecodeError:
884 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
885 except ValidationError as e:
886 raise ParsingError(
887 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
888 )
889 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
890
891 async def get_templates(
892 self, *, request_options: typing.Optional[RequestOptions] = None
893 ) -> AsyncHttpResponse[typing.Optional[GetGuardianFactorSmsTemplatesResponseContent]]:
894 """
895 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/get-factor-phone-templates">Retrieve enrollment and verification phone templates</a> endpoint instead.
896
897 <b>Previous function</b>: Retrieve details of SMS enrollment and verification templates configured for your tenant.
898
899 Parameters
900 ----------
901 request_options : typing.Optional[RequestOptions]
902 Request-specific configuration.
903
904 Returns
905 -------
906 AsyncHttpResponse[typing.Optional[GetGuardianFactorSmsTemplatesResponseContent]]
907 SMS enrollment and verification templates successfully retrieved.
908 """
909 _response = await self._client_wrapper.httpx_client.request(
910 "guardian/factors/sms/templates",
911 method="GET",
912 request_options=request_options,
913 )
914 try:
915 if _response is None or not _response.text.strip():
916 return AsyncHttpResponse(response=_response, data=None)
917 if 200 <= _response.status_code < 300:
918 _data = typing.cast(
919 typing.Optional[GetGuardianFactorSmsTemplatesResponseContent],
920 parse_obj_as(
921 type_=typing.Optional[GetGuardianFactorSmsTemplatesResponseContent], # type: ignore
922 object_=_response.json(),
923 ),
924 )
925 return AsyncHttpResponse(response=_response, data=_data)
926 if _response.status_code == 400:
927 raise BadRequestError(
928 headers=dict(_response.headers),
929 body=typing.cast(
930 typing.Any,
931 parse_obj_as(
932 type_=typing.Any, # type: ignore
933 object_=_response.json(),
934 ),
935 ),
936 )
937 if _response.status_code == 401:
938 raise UnauthorizedError(
939 headers=dict(_response.headers),
940 body=typing.cast(
941 typing.Any,
942 parse_obj_as(
943 type_=typing.Any, # type: ignore
944 object_=_response.json(),
945 ),
946 ),
947 )
948 if _response.status_code == 403:
949 raise ForbiddenError(
950 headers=dict(_response.headers),
951 body=typing.cast(
952 typing.Any,
953 parse_obj_as(
954 type_=typing.Any, # type: ignore
955 object_=_response.json(),
956 ),
957 ),
958 )
959 _response_json = _response.json()
960 except JSONDecodeError:
961 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
962 except ValidationError as e:
963 raise ParsingError(
964 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
965 )
966 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
967
968 async def set_templates(
969 self,
970 *,
971 enrollment_message: str,
972 verification_message: str,
973 request_options: typing.Optional[RequestOptions] = None,
974 ) -> AsyncHttpResponse[SetGuardianFactorSmsTemplatesResponseContent]:
975 """
976 This endpoint has been deprecated. To complete this action, use the <a href="https://auth0.com/docs/api/management/v2/guardian/put-factor-phone-templates">Update enrollment and verification phone templates</a> endpoint instead.
977
978 <b>Previous functionality</b>: Customize the messages sent to complete SMS enrollment and verification.
979
980 Parameters
981 ----------
982 enrollment_message : str
983 Message sent to the user when they are invited to enroll with a phone number.
984
985 verification_message : str
986 Message sent to the user when they are prompted to verify their account.
987
988 request_options : typing.Optional[RequestOptions]
989 Request-specific configuration.
990
991 Returns
992 -------
993 AsyncHttpResponse[SetGuardianFactorSmsTemplatesResponseContent]
994 SMS enrollment and verification templates successfully updated.
995 """
996 _response = await self._client_wrapper.httpx_client.request(
997 "guardian/factors/sms/templates",
998 method="PUT",
999 json={
1000 "enrollment_message": enrollment_message,
1001 "verification_message": verification_message,
1002 },
1003 headers={
1004 "content-type": "application/json",
1005 },
1006 request_options=request_options,
1007 omit=OMIT,
1008 )
1009 try:
1010 if 200 <= _response.status_code < 300:
1011 _data = typing.cast(
1012 SetGuardianFactorSmsTemplatesResponseContent,
1013 parse_obj_as(
1014 type_=SetGuardianFactorSmsTemplatesResponseContent, # type: ignore
1015 object_=_response.json(),
1016 ),
1017 )
1018 return AsyncHttpResponse(response=_response, data=_data)
1019 if _response.status_code == 400:
1020 raise BadRequestError(
1021 headers=dict(_response.headers),
1022 body=typing.cast(
1023 typing.Any,
1024 parse_obj_as(
1025 type_=typing.Any, # type: ignore
1026 object_=_response.json(),
1027 ),
1028 ),
1029 )
1030 if _response.status_code == 401:
1031 raise UnauthorizedError(
1032 headers=dict(_response.headers),
1033 body=typing.cast(
1034 typing.Any,
1035 parse_obj_as(
1036 type_=typing.Any, # type: ignore
1037 object_=_response.json(),
1038 ),
1039 ),
1040 )
1041 if _response.status_code == 403:
1042 raise ForbiddenError(
1043 headers=dict(_response.headers),
1044 body=typing.cast(
1045 typing.Any,
1046 parse_obj_as(
1047 type_=typing.Any, # type: ignore
1048 object_=_response.json(),
1049 ),
1050 ),
1051 )
1052 _response_json = _response.json()
1053 except JSONDecodeError:
1054 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1055 except ValidationError as e:
1056 raise ParsingError(
1057 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1058 )
1059 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)