Debian Codegraph @

src/auth0/management/users/multifactor/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.user_multifactor_provider_enum import UserMultifactorProviderEnum
19 from pydantic import ValidationError
20
21
22 class RawMultifactorClient:
23 def __init__(self, *, client_wrapper: SyncClientWrapper):
24 self._client_wrapper = client_wrapper
25
26 def invalidate_remember_browser(
27 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
28 ) -> HttpResponse[None]:
29 """
30 Invalidate all remembered browsers across all [authentication factors](https://auth0.com/docs/multifactor-authentication) for a user.
31
32 Parameters
33 ----------
34 id : str
35 ID of the user to invalidate all remembered browsers and authentication factors for.
36
37 request_options : typing.Optional[RequestOptions]
38 Request-specific configuration.
39
40 Returns
41 -------
42 HttpResponse[None]
43 """
44 _response = self._client_wrapper.httpx_client.request(
45 f"users/{encode_path_param(id)}/multifactor/actions/invalidate-remember-browser",
46 method="POST",
47 request_options=request_options,
48 )
49 try:
50 if 200 <= _response.status_code < 300:
51 return HttpResponse(response=_response, data=None)
52 if _response.status_code == 400:
53 raise BadRequestError(
54 headers=dict(_response.headers),
55 body=typing.cast(
56 typing.Any,
57 parse_obj_as(
58 type_=typing.Any, # type: ignore
59 object_=_response.json(),
60 ),
61 ),
62 )
63 if _response.status_code == 401:
64 raise UnauthorizedError(
65 headers=dict(_response.headers),
66 body=typing.cast(
67 typing.Any,
68 parse_obj_as(
69 type_=typing.Any, # type: ignore
70 object_=_response.json(),
71 ),
72 ),
73 )
74 if _response.status_code == 403:
75 raise ForbiddenError(
76 headers=dict(_response.headers),
77 body=typing.cast(
78 typing.Any,
79 parse_obj_as(
80 type_=typing.Any, # type: ignore
81 object_=_response.json(),
82 ),
83 ),
84 )
85 _response_json = _response.json()
86 except JSONDecodeError:
87 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
88 except ValidationError as e:
89 raise ParsingError(
90 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
91 )
92 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
93
94 def delete_provider(
95 self, id: str, provider: UserMultifactorProviderEnum, *, request_options: typing.Optional[RequestOptions] = None
96 ) -> HttpResponse[None]:
97 """
98 Remove a [multifactor](https://auth0.com/docs/multifactor-authentication) authentication configuration from a user's account. This forces the user to manually reconfigure the multi-factor provider.
99
100 Parameters
101 ----------
102 id : str
103 ID of the user to remove a multifactor configuration from.
104
105 provider : UserMultifactorProviderEnum
106 The multi-factor provider. Supported values 'duo' or 'google-authenticator'
107
108 request_options : typing.Optional[RequestOptions]
109 Request-specific configuration.
110
111 Returns
112 -------
113 HttpResponse[None]
114 """
115 _response = self._client_wrapper.httpx_client.request(
116 f"users/{encode_path_param(id)}/multifactor/{encode_path_param(provider)}",
117 method="DELETE",
118 request_options=request_options,
119 )
120 try:
121 if 200 <= _response.status_code < 300:
122 return HttpResponse(response=_response, data=None)
123 if _response.status_code == 400:
124 raise BadRequestError(
125 headers=dict(_response.headers),
126 body=typing.cast(
127 typing.Any,
128 parse_obj_as(
129 type_=typing.Any, # type: ignore
130 object_=_response.json(),
131 ),
132 ),
133 )
134 if _response.status_code == 401:
135 raise UnauthorizedError(
136 headers=dict(_response.headers),
137 body=typing.cast(
138 typing.Any,
139 parse_obj_as(
140 type_=typing.Any, # type: ignore
141 object_=_response.json(),
142 ),
143 ),
144 )
145 if _response.status_code == 403:
146 raise ForbiddenError(
147 headers=dict(_response.headers),
148 body=typing.cast(
149 typing.Any,
150 parse_obj_as(
151 type_=typing.Any, # type: ignore
152 object_=_response.json(),
153 ),
154 ),
155 )
156 if _response.status_code == 404:
157 raise NotFoundError(
158 headers=dict(_response.headers),
159 body=typing.cast(
160 typing.Any,
161 parse_obj_as(
162 type_=typing.Any, # type: ignore
163 object_=_response.json(),
164 ),
165 ),
166 )
167 if _response.status_code == 429:
168 raise TooManyRequestsError(
169 headers=dict(_response.headers),
170 body=typing.cast(
171 typing.Any,
172 parse_obj_as(
173 type_=typing.Any, # type: ignore
174 object_=_response.json(),
175 ),
176 ),
177 )
178 _response_json = _response.json()
179 except JSONDecodeError:
180 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
181 except ValidationError as e:
182 raise ParsingError(
183 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
184 )
185 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
186
187
188 class AsyncRawMultifactorClient:
189 def __init__(self, *, client_wrapper: AsyncClientWrapper):
190 self._client_wrapper = client_wrapper
191
192 async def invalidate_remember_browser(
193 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
194 ) -> AsyncHttpResponse[None]:
195 """
196 Invalidate all remembered browsers across all [authentication factors](https://auth0.com/docs/multifactor-authentication) for a user.
197
198 Parameters
199 ----------
200 id : str
201 ID of the user to invalidate all remembered browsers and authentication factors for.
202
203 request_options : typing.Optional[RequestOptions]
204 Request-specific configuration.
205
206 Returns
207 -------
208 AsyncHttpResponse[None]
209 """
210 _response = await self._client_wrapper.httpx_client.request(
211 f"users/{encode_path_param(id)}/multifactor/actions/invalidate-remember-browser",
212 method="POST",
213 request_options=request_options,
214 )
215 try:
216 if 200 <= _response.status_code < 300:
217 return AsyncHttpResponse(response=_response, data=None)
218 if _response.status_code == 400:
219 raise BadRequestError(
220 headers=dict(_response.headers),
221 body=typing.cast(
222 typing.Any,
223 parse_obj_as(
224 type_=typing.Any, # type: ignore
225 object_=_response.json(),
226 ),
227 ),
228 )
229 if _response.status_code == 401:
230 raise UnauthorizedError(
231 headers=dict(_response.headers),
232 body=typing.cast(
233 typing.Any,
234 parse_obj_as(
235 type_=typing.Any, # type: ignore
236 object_=_response.json(),
237 ),
238 ),
239 )
240 if _response.status_code == 403:
241 raise ForbiddenError(
242 headers=dict(_response.headers),
243 body=typing.cast(
244 typing.Any,
245 parse_obj_as(
246 type_=typing.Any, # type: ignore
247 object_=_response.json(),
248 ),
249 ),
250 )
251 _response_json = _response.json()
252 except JSONDecodeError:
253 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
254 except ValidationError as e:
255 raise ParsingError(
256 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
257 )
258 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
259
260 async def delete_provider(
261 self, id: str, provider: UserMultifactorProviderEnum, *, request_options: typing.Optional[RequestOptions] = None
262 ) -> AsyncHttpResponse[None]:
263 """
264 Remove a [multifactor](https://auth0.com/docs/multifactor-authentication) authentication configuration from a user's account. This forces the user to manually reconfigure the multi-factor provider.
265
266 Parameters
267 ----------
268 id : str
269 ID of the user to remove a multifactor configuration from.
270
271 provider : UserMultifactorProviderEnum
272 The multi-factor provider. Supported values 'duo' or 'google-authenticator'
273
274 request_options : typing.Optional[RequestOptions]
275 Request-specific configuration.
276
277 Returns
278 -------
279 AsyncHttpResponse[None]
280 """
281 _response = await self._client_wrapper.httpx_client.request(
282 f"users/{encode_path_param(id)}/multifactor/{encode_path_param(provider)}",
283 method="DELETE",
284 request_options=request_options,
285 )
286 try:
287 if 200 <= _response.status_code < 300:
288 return AsyncHttpResponse(response=_response, data=None)
289 if _response.status_code == 400:
290 raise BadRequestError(
291 headers=dict(_response.headers),
292 body=typing.cast(
293 typing.Any,
294 parse_obj_as(
295 type_=typing.Any, # type: ignore
296 object_=_response.json(),
297 ),
298 ),
299 )
300 if _response.status_code == 401:
301 raise UnauthorizedError(
302 headers=dict(_response.headers),
303 body=typing.cast(
304 typing.Any,
305 parse_obj_as(
306 type_=typing.Any, # type: ignore
307 object_=_response.json(),
308 ),
309 ),
310 )
311 if _response.status_code == 403:
312 raise ForbiddenError(
313 headers=dict(_response.headers),
314 body=typing.cast(
315 typing.Any,
316 parse_obj_as(
317 type_=typing.Any, # type: ignore
318 object_=_response.json(),
319 ),
320 ),
321 )
322 if _response.status_code == 404:
323 raise NotFoundError(
324 headers=dict(_response.headers),
325 body=typing.cast(
326 typing.Any,
327 parse_obj_as(
328 type_=typing.Any, # type: ignore
329 object_=_response.json(),
330 ),
331 ),
332 )
333 if _response.status_code == 429:
334 raise TooManyRequestsError(
335 headers=dict(_response.headers),
336 body=typing.cast(
337 typing.Any,
338 parse_obj_as(
339 type_=typing.Any, # type: ignore
340 object_=_response.json(),
341 ),
342 ),
343 )
344 _response_json = _response.json()
345 except JSONDecodeError:
346 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
347 except ValidationError as e:
348 raise ParsingError(
349 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
350 )
351 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)