Debian Codegraph @

src/auth0/management/guardian/factors/duo/settings/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_duo_settings_response_content import GetGuardianFactorDuoSettingsResponseContent
16 from .....types.set_guardian_factor_duo_settings_response_content import SetGuardianFactorDuoSettingsResponseContent
17 from .....types.update_guardian_factor_duo_settings_response_content import (
18 UpdateGuardianFactorDuoSettingsResponseContent,
19 )
20 from pydantic import ValidationError
21
22 # this is used as the default value for optional parameters
23 OMIT = typing.cast(typing.Any, ...)
24
25
26 class RawSettingsClient:
27 def __init__(self, *, client_wrapper: SyncClientWrapper):
28 self._client_wrapper = client_wrapper
29
30 def get(
31 self, *, request_options: typing.Optional[RequestOptions] = None
32 ) -> HttpResponse[GetGuardianFactorDuoSettingsResponseContent]:
33 """
34 Retrieves the DUO account and factor configuration.
35
36 Parameters
37 ----------
38 request_options : typing.Optional[RequestOptions]
39 Request-specific configuration.
40
41 Returns
42 -------
43 HttpResponse[GetGuardianFactorDuoSettingsResponseContent]
44 DUO settings successfully retrieved.
45 """
46 _response = self._client_wrapper.httpx_client.request(
47 "guardian/factors/duo/settings",
48 method="GET",
49 request_options=request_options,
50 )
51 try:
52 if 200 <= _response.status_code < 300:
53 _data = typing.cast(
54 GetGuardianFactorDuoSettingsResponseContent,
55 parse_obj_as(
56 type_=GetGuardianFactorDuoSettingsResponseContent, # type: ignore
57 object_=_response.json(),
58 ),
59 )
60 return HttpResponse(response=_response, data=_data)
61 if _response.status_code == 400:
62 raise BadRequestError(
63 headers=dict(_response.headers),
64 body=typing.cast(
65 typing.Any,
66 parse_obj_as(
67 type_=typing.Any, # type: ignore
68 object_=_response.json(),
69 ),
70 ),
71 )
72 if _response.status_code == 401:
73 raise UnauthorizedError(
74 headers=dict(_response.headers),
75 body=typing.cast(
76 typing.Any,
77 parse_obj_as(
78 type_=typing.Any, # type: ignore
79 object_=_response.json(),
80 ),
81 ),
82 )
83 if _response.status_code == 403:
84 raise ForbiddenError(
85 headers=dict(_response.headers),
86 body=typing.cast(
87 typing.Any,
88 parse_obj_as(
89 type_=typing.Any, # type: ignore
90 object_=_response.json(),
91 ),
92 ),
93 )
94 _response_json = _response.json()
95 except JSONDecodeError:
96 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
97 except ValidationError as e:
98 raise ParsingError(
99 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
100 )
101 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
102
103 def set(
104 self,
105 *,
106 ikey: typing.Optional[str] = OMIT,
107 skey: typing.Optional[str] = OMIT,
108 host: typing.Optional[str] = OMIT,
109 request_options: typing.Optional[RequestOptions] = None,
110 ) -> HttpResponse[SetGuardianFactorDuoSettingsResponseContent]:
111 """
112 Set the DUO account configuration and other properties specific to this factor.
113
114 Parameters
115 ----------
116 ikey : typing.Optional[str]
117
118 skey : typing.Optional[str]
119
120 host : typing.Optional[str]
121
122 request_options : typing.Optional[RequestOptions]
123 Request-specific configuration.
124
125 Returns
126 -------
127 HttpResponse[SetGuardianFactorDuoSettingsResponseContent]
128 DUO settings successfully updated.
129 """
130 _response = self._client_wrapper.httpx_client.request(
131 "guardian/factors/duo/settings",
132 method="PUT",
133 json={
134 "ikey": ikey,
135 "skey": skey,
136 "host": host,
137 },
138 headers={
139 "content-type": "application/json",
140 },
141 request_options=request_options,
142 omit=OMIT,
143 )
144 try:
145 if 200 <= _response.status_code < 300:
146 _data = typing.cast(
147 SetGuardianFactorDuoSettingsResponseContent,
148 parse_obj_as(
149 type_=SetGuardianFactorDuoSettingsResponseContent, # type: ignore
150 object_=_response.json(),
151 ),
152 )
153 return HttpResponse(response=_response, data=_data)
154 if _response.status_code == 400:
155 raise BadRequestError(
156 headers=dict(_response.headers),
157 body=typing.cast(
158 typing.Any,
159 parse_obj_as(
160 type_=typing.Any, # type: ignore
161 object_=_response.json(),
162 ),
163 ),
164 )
165 if _response.status_code == 401:
166 raise UnauthorizedError(
167 headers=dict(_response.headers),
168 body=typing.cast(
169 typing.Any,
170 parse_obj_as(
171 type_=typing.Any, # type: ignore
172 object_=_response.json(),
173 ),
174 ),
175 )
176 if _response.status_code == 403:
177 raise ForbiddenError(
178 headers=dict(_response.headers),
179 body=typing.cast(
180 typing.Any,
181 parse_obj_as(
182 type_=typing.Any, # type: ignore
183 object_=_response.json(),
184 ),
185 ),
186 )
187 _response_json = _response.json()
188 except JSONDecodeError:
189 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
190 except ValidationError as e:
191 raise ParsingError(
192 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
193 )
194 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
195
196 def update(
197 self,
198 *,
199 ikey: typing.Optional[str] = OMIT,
200 skey: typing.Optional[str] = OMIT,
201 host: typing.Optional[str] = OMIT,
202 request_options: typing.Optional[RequestOptions] = None,
203 ) -> HttpResponse[UpdateGuardianFactorDuoSettingsResponseContent]:
204 """
205 Parameters
206 ----------
207 ikey : typing.Optional[str]
208
209 skey : typing.Optional[str]
210
211 host : typing.Optional[str]
212
213 request_options : typing.Optional[RequestOptions]
214 Request-specific configuration.
215
216 Returns
217 -------
218 HttpResponse[UpdateGuardianFactorDuoSettingsResponseContent]
219 DUO settings successfully updated.
220 """
221 _response = self._client_wrapper.httpx_client.request(
222 "guardian/factors/duo/settings",
223 method="PATCH",
224 json={
225 "ikey": ikey,
226 "skey": skey,
227 "host": host,
228 },
229 headers={
230 "content-type": "application/json",
231 },
232 request_options=request_options,
233 omit=OMIT,
234 )
235 try:
236 if 200 <= _response.status_code < 300:
237 _data = typing.cast(
238 UpdateGuardianFactorDuoSettingsResponseContent,
239 parse_obj_as(
240 type_=UpdateGuardianFactorDuoSettingsResponseContent, # type: ignore
241 object_=_response.json(),
242 ),
243 )
244 return HttpResponse(response=_response, data=_data)
245 if _response.status_code == 400:
246 raise BadRequestError(
247 headers=dict(_response.headers),
248 body=typing.cast(
249 typing.Any,
250 parse_obj_as(
251 type_=typing.Any, # type: ignore
252 object_=_response.json(),
253 ),
254 ),
255 )
256 if _response.status_code == 401:
257 raise UnauthorizedError(
258 headers=dict(_response.headers),
259 body=typing.cast(
260 typing.Any,
261 parse_obj_as(
262 type_=typing.Any, # type: ignore
263 object_=_response.json(),
264 ),
265 ),
266 )
267 if _response.status_code == 403:
268 raise ForbiddenError(
269 headers=dict(_response.headers),
270 body=typing.cast(
271 typing.Any,
272 parse_obj_as(
273 type_=typing.Any, # type: ignore
274 object_=_response.json(),
275 ),
276 ),
277 )
278 _response_json = _response.json()
279 except JSONDecodeError:
280 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
281 except ValidationError as e:
282 raise ParsingError(
283 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
284 )
285 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
286
287
288 class AsyncRawSettingsClient:
289 def __init__(self, *, client_wrapper: AsyncClientWrapper):
290 self._client_wrapper = client_wrapper
291
292 async def get(
293 self, *, request_options: typing.Optional[RequestOptions] = None
294 ) -> AsyncHttpResponse[GetGuardianFactorDuoSettingsResponseContent]:
295 """
296 Retrieves the DUO account and factor configuration.
297
298 Parameters
299 ----------
300 request_options : typing.Optional[RequestOptions]
301 Request-specific configuration.
302
303 Returns
304 -------
305 AsyncHttpResponse[GetGuardianFactorDuoSettingsResponseContent]
306 DUO settings successfully retrieved.
307 """
308 _response = await self._client_wrapper.httpx_client.request(
309 "guardian/factors/duo/settings",
310 method="GET",
311 request_options=request_options,
312 )
313 try:
314 if 200 <= _response.status_code < 300:
315 _data = typing.cast(
316 GetGuardianFactorDuoSettingsResponseContent,
317 parse_obj_as(
318 type_=GetGuardianFactorDuoSettingsResponseContent, # type: ignore
319 object_=_response.json(),
320 ),
321 )
322 return AsyncHttpResponse(response=_response, data=_data)
323 if _response.status_code == 400:
324 raise BadRequestError(
325 headers=dict(_response.headers),
326 body=typing.cast(
327 typing.Any,
328 parse_obj_as(
329 type_=typing.Any, # type: ignore
330 object_=_response.json(),
331 ),
332 ),
333 )
334 if _response.status_code == 401:
335 raise UnauthorizedError(
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 == 403:
346 raise ForbiddenError(
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 _response_json = _response.json()
357 except JSONDecodeError:
358 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
359 except ValidationError as e:
360 raise ParsingError(
361 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
362 )
363 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
364
365 async def set(
366 self,
367 *,
368 ikey: typing.Optional[str] = OMIT,
369 skey: typing.Optional[str] = OMIT,
370 host: typing.Optional[str] = OMIT,
371 request_options: typing.Optional[RequestOptions] = None,
372 ) -> AsyncHttpResponse[SetGuardianFactorDuoSettingsResponseContent]:
373 """
374 Set the DUO account configuration and other properties specific to this factor.
375
376 Parameters
377 ----------
378 ikey : typing.Optional[str]
379
380 skey : typing.Optional[str]
381
382 host : typing.Optional[str]
383
384 request_options : typing.Optional[RequestOptions]
385 Request-specific configuration.
386
387 Returns
388 -------
389 AsyncHttpResponse[SetGuardianFactorDuoSettingsResponseContent]
390 DUO settings successfully updated.
391 """
392 _response = await self._client_wrapper.httpx_client.request(
393 "guardian/factors/duo/settings",
394 method="PUT",
395 json={
396 "ikey": ikey,
397 "skey": skey,
398 "host": host,
399 },
400 headers={
401 "content-type": "application/json",
402 },
403 request_options=request_options,
404 omit=OMIT,
405 )
406 try:
407 if 200 <= _response.status_code < 300:
408 _data = typing.cast(
409 SetGuardianFactorDuoSettingsResponseContent,
410 parse_obj_as(
411 type_=SetGuardianFactorDuoSettingsResponseContent, # type: ignore
412 object_=_response.json(),
413 ),
414 )
415 return AsyncHttpResponse(response=_response, data=_data)
416 if _response.status_code == 400:
417 raise BadRequestError(
418 headers=dict(_response.headers),
419 body=typing.cast(
420 typing.Any,
421 parse_obj_as(
422 type_=typing.Any, # type: ignore
423 object_=_response.json(),
424 ),
425 ),
426 )
427 if _response.status_code == 401:
428 raise UnauthorizedError(
429 headers=dict(_response.headers),
430 body=typing.cast(
431 typing.Any,
432 parse_obj_as(
433 type_=typing.Any, # type: ignore
434 object_=_response.json(),
435 ),
436 ),
437 )
438 if _response.status_code == 403:
439 raise ForbiddenError(
440 headers=dict(_response.headers),
441 body=typing.cast(
442 typing.Any,
443 parse_obj_as(
444 type_=typing.Any, # type: ignore
445 object_=_response.json(),
446 ),
447 ),
448 )
449 _response_json = _response.json()
450 except JSONDecodeError:
451 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
452 except ValidationError as e:
453 raise ParsingError(
454 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
455 )
456 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
457
458 async def update(
459 self,
460 *,
461 ikey: typing.Optional[str] = OMIT,
462 skey: typing.Optional[str] = OMIT,
463 host: typing.Optional[str] = OMIT,
464 request_options: typing.Optional[RequestOptions] = None,
465 ) -> AsyncHttpResponse[UpdateGuardianFactorDuoSettingsResponseContent]:
466 """
467 Parameters
468 ----------
469 ikey : typing.Optional[str]
470
471 skey : typing.Optional[str]
472
473 host : typing.Optional[str]
474
475 request_options : typing.Optional[RequestOptions]
476 Request-specific configuration.
477
478 Returns
479 -------
480 AsyncHttpResponse[UpdateGuardianFactorDuoSettingsResponseContent]
481 DUO settings successfully updated.
482 """
483 _response = await self._client_wrapper.httpx_client.request(
484 "guardian/factors/duo/settings",
485 method="PATCH",
486 json={
487 "ikey": ikey,
488 "skey": skey,
489 "host": host,
490 },
491 headers={
492 "content-type": "application/json",
493 },
494 request_options=request_options,
495 omit=OMIT,
496 )
497 try:
498 if 200 <= _response.status_code < 300:
499 _data = typing.cast(
500 UpdateGuardianFactorDuoSettingsResponseContent,
501 parse_obj_as(
502 type_=UpdateGuardianFactorDuoSettingsResponseContent, # type: ignore
503 object_=_response.json(),
504 ),
505 )
506 return AsyncHttpResponse(response=_response, data=_data)
507 if _response.status_code == 400:
508 raise BadRequestError(
509 headers=dict(_response.headers),
510 body=typing.cast(
511 typing.Any,
512 parse_obj_as(
513 type_=typing.Any, # type: ignore
514 object_=_response.json(),
515 ),
516 ),
517 )
518 if _response.status_code == 401:
519 raise UnauthorizedError(
520 headers=dict(_response.headers),
521 body=typing.cast(
522 typing.Any,
523 parse_obj_as(
524 type_=typing.Any, # type: ignore
525 object_=_response.json(),
526 ),
527 ),
528 )
529 if _response.status_code == 403:
530 raise ForbiddenError(
531 headers=dict(_response.headers),
532 body=typing.cast(
533 typing.Any,
534 parse_obj_as(
535 type_=typing.Any, # type: ignore
536 object_=_response.json(),
537 ),
538 ),
539 )
540 _response_json = _response.json()
541 except JSONDecodeError:
542 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
543 except ValidationError as e:
544 raise ParsingError(
545 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
546 )
547 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)