Debian Codegraph @

src/auth0/management/guardian/factors/client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 from __future__ import annotations
4
5 import typing
6
7 from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8 from ...core.request_options import RequestOptions
9 from ...types.guardian_factor import GuardianFactor
10 from ...types.guardian_factor_name_enum import GuardianFactorNameEnum
11 from ...types.set_guardian_factor_response_content import SetGuardianFactorResponseContent
12 from .raw_client import AsyncRawFactorsClient, RawFactorsClient
13
14 if typing.TYPE_CHECKING:
15 from .duo.client import AsyncDuoClient, DuoClient
16 from .phone.client import AsyncPhoneClient, PhoneClient
17 from .push_notification.client import AsyncPushNotificationClient, PushNotificationClient
18 from .sms.client import AsyncSmsClient, SmsClient
19 # this is used as the default value for optional parameters
20 OMIT = typing.cast(typing.Any, ...)
21
22
23 class FactorsClient:
24 def __init__(self, *, client_wrapper: SyncClientWrapper):
25 self._raw_client = RawFactorsClient(client_wrapper=client_wrapper)
26 self._client_wrapper = client_wrapper
27 self._phone: typing.Optional[PhoneClient] = None
28 self._push_notification: typing.Optional[PushNotificationClient] = None
29 self._sms: typing.Optional[SmsClient] = None
30 self._duo: typing.Optional[DuoClient] = None
31
32 @property
33 def with_raw_response(self) -> RawFactorsClient:
34 """
35 Retrieves a raw implementation of this client that returns raw responses.
36
37 Returns
38 -------
39 RawFactorsClient
40 """
41 return self._raw_client
42
43 def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[GuardianFactor]:
44 """
45 Retrieve details of all <a href="https://auth0.com/docs/secure/multi-factor-authentication/multi-factor-authentication-factors">multi-factor authentication factors</a> associated with your tenant.
46
47 Parameters
48 ----------
49 request_options : typing.Optional[RequestOptions]
50 Request-specific configuration.
51
52 Returns
53 -------
54 typing.List[GuardianFactor]
55 Factors successfully retrieved.
56
57 Examples
58 --------
59 from auth0 import Auth0
60
61 client = Auth0(
62 token="YOUR_TOKEN",
63 )
64 client.guardian.factors.list()
65 """
66 _response = self._raw_client.list(request_options=request_options)
67 return _response.data
68
69 def set(
70 self, name: GuardianFactorNameEnum, *, enabled: bool, request_options: typing.Optional[RequestOptions] = None
71 ) -> SetGuardianFactorResponseContent:
72 """
73 Update the status (i.e., enabled or disabled) of a specific multi-factor authentication factor.
74
75 Parameters
76 ----------
77 name : GuardianFactorNameEnum
78 Factor name. Can be `sms`, `push-notification`, `email`, `duo` `otp` `webauthn-roaming`, `webauthn-platform`, or `recovery-code`.
79
80 enabled : bool
81 Whether this factor is enabled (true) or disabled (false).
82
83 request_options : typing.Optional[RequestOptions]
84 Request-specific configuration.
85
86 Returns
87 -------
88 SetGuardianFactorResponseContent
89 Factor updated successfully.
90
91 Examples
92 --------
93 from auth0 import Auth0
94
95 client = Auth0(
96 token="YOUR_TOKEN",
97 )
98 client.guardian.factors.set(
99 name="push-notification",
100 enabled=True,
101 )
102 """
103 _response = self._raw_client.set(name, enabled=enabled, request_options=request_options)
104 return _response.data
105
106 @property
107 def phone(self):
108 if self._phone is None:
109 from .phone.client import PhoneClient # noqa: E402
110
111 self._phone = PhoneClient(client_wrapper=self._client_wrapper)
112 return self._phone
113
114 @property
115 def push_notification(self):
116 if self._push_notification is None:
117 from .push_notification.client import PushNotificationClient # noqa: E402
118
119 self._push_notification = PushNotificationClient(client_wrapper=self._client_wrapper)
120 return self._push_notification
121
122 @property
123 def sms(self):
124 if self._sms is None:
125 from .sms.client import SmsClient # noqa: E402
126
127 self._sms = SmsClient(client_wrapper=self._client_wrapper)
128 return self._sms
129
130 @property
131 def duo(self):
132 if self._duo is None:
133 from .duo.client import DuoClient # noqa: E402
134
135 self._duo = DuoClient(client_wrapper=self._client_wrapper)
136 return self._duo
137
138
139 class AsyncFactorsClient:
140 def __init__(self, *, client_wrapper: AsyncClientWrapper):
141 self._raw_client = AsyncRawFactorsClient(client_wrapper=client_wrapper)
142 self._client_wrapper = client_wrapper
143 self._phone: typing.Optional[AsyncPhoneClient] = None
144 self._push_notification: typing.Optional[AsyncPushNotificationClient] = None
145 self._sms: typing.Optional[AsyncSmsClient] = None
146 self._duo: typing.Optional[AsyncDuoClient] = None
147
148 @property
149 def with_raw_response(self) -> AsyncRawFactorsClient:
150 """
151 Retrieves a raw implementation of this client that returns raw responses.
152
153 Returns
154 -------
155 AsyncRawFactorsClient
156 """
157 return self._raw_client
158
159 async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[GuardianFactor]:
160 """
161 Retrieve details of all <a href="https://auth0.com/docs/secure/multi-factor-authentication/multi-factor-authentication-factors">multi-factor authentication factors</a> associated with your tenant.
162
163 Parameters
164 ----------
165 request_options : typing.Optional[RequestOptions]
166 Request-specific configuration.
167
168 Returns
169 -------
170 typing.List[GuardianFactor]
171 Factors successfully retrieved.
172
173 Examples
174 --------
175 import asyncio
176
177 from auth0 import AsyncAuth0
178
179 client = AsyncAuth0(
180 token="YOUR_TOKEN",
181 )
182
183
184 async def main() -> None:
185 await client.guardian.factors.list()
186
187
188 asyncio.run(main())
189 """
190 _response = await self._raw_client.list(request_options=request_options)
191 return _response.data
192
193 async def set(
194 self, name: GuardianFactorNameEnum, *, enabled: bool, request_options: typing.Optional[RequestOptions] = None
195 ) -> SetGuardianFactorResponseContent:
196 """
197 Update the status (i.e., enabled or disabled) of a specific multi-factor authentication factor.
198
199 Parameters
200 ----------
201 name : GuardianFactorNameEnum
202 Factor name. Can be `sms`, `push-notification`, `email`, `duo` `otp` `webauthn-roaming`, `webauthn-platform`, or `recovery-code`.
203
204 enabled : bool
205 Whether this factor is enabled (true) or disabled (false).
206
207 request_options : typing.Optional[RequestOptions]
208 Request-specific configuration.
209
210 Returns
211 -------
212 SetGuardianFactorResponseContent
213 Factor updated successfully.
214
215 Examples
216 --------
217 import asyncio
218
219 from auth0 import AsyncAuth0
220
221 client = AsyncAuth0(
222 token="YOUR_TOKEN",
223 )
224
225
226 async def main() -> None:
227 await client.guardian.factors.set(
228 name="push-notification",
229 enabled=True,
230 )
231
232
233 asyncio.run(main())
234 """
235 _response = await self._raw_client.set(name, enabled=enabled, request_options=request_options)
236 return _response.data
237
238 @property
239 def phone(self):
240 if self._phone is None:
241 from .phone.client import AsyncPhoneClient # noqa: E402
242
243 self._phone = AsyncPhoneClient(client_wrapper=self._client_wrapper)
244 return self._phone
245
246 @property
247 def push_notification(self):
248 if self._push_notification is None:
249 from .push_notification.client import AsyncPushNotificationClient # noqa: E402
250
251 self._push_notification = AsyncPushNotificationClient(client_wrapper=self._client_wrapper)
252 return self._push_notification
253
254 @property
255 def sms(self):
256 if self._sms is None:
257 from .sms.client import AsyncSmsClient # noqa: E402
258
259 self._sms = AsyncSmsClient(client_wrapper=self._client_wrapper)
260 return self._sms
261
262 @property
263 def duo(self):
264 if self._duo is None:
265 from .duo.client import AsyncDuoClient # noqa: E402
266
267 self._duo = AsyncDuoClient(client_wrapper=self._client_wrapper)
268 return self._duo