Debian Codegraph @

src/auth0/management/branding/themes/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 ...core.serialization import convert_and_respect_annotation_metadata
14 from ...errors.bad_request_error import BadRequestError
15 from ...errors.conflict_error import ConflictError
16 from ...errors.forbidden_error import ForbiddenError
17 from ...errors.not_found_error import NotFoundError
18 from ...errors.too_many_requests_error import TooManyRequestsError
19 from ...errors.unauthorized_error import UnauthorizedError
20 from ...types.branding_theme_borders import BrandingThemeBorders
21 from ...types.branding_theme_colors import BrandingThemeColors
22 from ...types.branding_theme_fonts import BrandingThemeFonts
23 from ...types.branding_theme_identifiers import BrandingThemeIdentifiers
24 from ...types.branding_theme_page_background import BrandingThemePageBackground
25 from ...types.branding_theme_widget import BrandingThemeWidget
26 from ...types.create_branding_theme_response_content import CreateBrandingThemeResponseContent
27 from ...types.get_branding_default_theme_response_content import GetBrandingDefaultThemeResponseContent
28 from ...types.get_branding_theme_response_content import GetBrandingThemeResponseContent
29 from ...types.update_branding_theme_response_content import UpdateBrandingThemeResponseContent
30 from pydantic import ValidationError
31
32 # this is used as the default value for optional parameters
33 OMIT = typing.cast(typing.Any, ...)
34
35
36 class RawThemesClient:
37 def __init__(self, *, client_wrapper: SyncClientWrapper):
38 self._client_wrapper = client_wrapper
39
40 def create(
41 self,
42 *,
43 borders: BrandingThemeBorders,
44 colors: BrandingThemeColors,
45 fonts: BrandingThemeFonts,
46 page_background: BrandingThemePageBackground,
47 widget: BrandingThemeWidget,
48 display_name: typing.Optional[str] = OMIT,
49 identifiers: typing.Optional[BrandingThemeIdentifiers] = OMIT,
50 request_options: typing.Optional[RequestOptions] = None,
51 ) -> HttpResponse[CreateBrandingThemeResponseContent]:
52 """
53 Create branding theme.
54
55 Parameters
56 ----------
57 borders : BrandingThemeBorders
58
59 colors : BrandingThemeColors
60
61 fonts : BrandingThemeFonts
62
63 page_background : BrandingThemePageBackground
64
65 widget : BrandingThemeWidget
66
67 display_name : typing.Optional[str]
68 Display Name
69
70 identifiers : typing.Optional[BrandingThemeIdentifiers]
71
72 request_options : typing.Optional[RequestOptions]
73 Request-specific configuration.
74
75 Returns
76 -------
77 HttpResponse[CreateBrandingThemeResponseContent]
78 Branding settings successfully updated.
79 """
80 _response = self._client_wrapper.httpx_client.request(
81 "branding/themes",
82 method="POST",
83 json={
84 "borders": convert_and_respect_annotation_metadata(
85 object_=borders, annotation=BrandingThemeBorders, direction="write"
86 ),
87 "colors": convert_and_respect_annotation_metadata(
88 object_=colors, annotation=BrandingThemeColors, direction="write"
89 ),
90 "displayName": display_name,
91 "fonts": convert_and_respect_annotation_metadata(
92 object_=fonts, annotation=BrandingThemeFonts, direction="write"
93 ),
94 "identifiers": convert_and_respect_annotation_metadata(
95 object_=identifiers, annotation=BrandingThemeIdentifiers, direction="write"
96 ),
97 "page_background": convert_and_respect_annotation_metadata(
98 object_=page_background, annotation=BrandingThemePageBackground, direction="write"
99 ),
100 "widget": convert_and_respect_annotation_metadata(
101 object_=widget, annotation=BrandingThemeWidget, direction="write"
102 ),
103 },
104 headers={
105 "content-type": "application/json",
106 },
107 request_options=request_options,
108 omit=OMIT,
109 )
110 try:
111 if 200 <= _response.status_code < 300:
112 _data = typing.cast(
113 CreateBrandingThemeResponseContent,
114 parse_obj_as(
115 type_=CreateBrandingThemeResponseContent, # type: ignore
116 object_=_response.json(),
117 ),
118 )
119 return HttpResponse(response=_response, data=_data)
120 if _response.status_code == 400:
121 raise BadRequestError(
122 headers=dict(_response.headers),
123 body=typing.cast(
124 typing.Any,
125 parse_obj_as(
126 type_=typing.Any, # type: ignore
127 object_=_response.json(),
128 ),
129 ),
130 )
131 if _response.status_code == 401:
132 raise UnauthorizedError(
133 headers=dict(_response.headers),
134 body=typing.cast(
135 typing.Any,
136 parse_obj_as(
137 type_=typing.Any, # type: ignore
138 object_=_response.json(),
139 ),
140 ),
141 )
142 if _response.status_code == 403:
143 raise ForbiddenError(
144 headers=dict(_response.headers),
145 body=typing.cast(
146 typing.Any,
147 parse_obj_as(
148 type_=typing.Any, # type: ignore
149 object_=_response.json(),
150 ),
151 ),
152 )
153 if _response.status_code == 409:
154 raise ConflictError(
155 headers=dict(_response.headers),
156 body=typing.cast(
157 typing.Any,
158 parse_obj_as(
159 type_=typing.Any, # type: ignore
160 object_=_response.json(),
161 ),
162 ),
163 )
164 if _response.status_code == 429:
165 raise TooManyRequestsError(
166 headers=dict(_response.headers),
167 body=typing.cast(
168 typing.Any,
169 parse_obj_as(
170 type_=typing.Any, # type: ignore
171 object_=_response.json(),
172 ),
173 ),
174 )
175 _response_json = _response.json()
176 except JSONDecodeError:
177 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
178 except ValidationError as e:
179 raise ParsingError(
180 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
181 )
182 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
183
184 def get_default(
185 self, *, request_options: typing.Optional[RequestOptions] = None
186 ) -> HttpResponse[GetBrandingDefaultThemeResponseContent]:
187 """
188 Retrieve default branding theme.
189
190 Parameters
191 ----------
192 request_options : typing.Optional[RequestOptions]
193 Request-specific configuration.
194
195 Returns
196 -------
197 HttpResponse[GetBrandingDefaultThemeResponseContent]
198 Branding theme successfully retrieved.
199 """
200 _response = self._client_wrapper.httpx_client.request(
201 "branding/themes/default",
202 method="GET",
203 request_options=request_options,
204 )
205 try:
206 if 200 <= _response.status_code < 300:
207 _data = typing.cast(
208 GetBrandingDefaultThemeResponseContent,
209 parse_obj_as(
210 type_=GetBrandingDefaultThemeResponseContent, # type: ignore
211 object_=_response.json(),
212 ),
213 )
214 return HttpResponse(response=_response, data=_data)
215 if _response.status_code == 401:
216 raise UnauthorizedError(
217 headers=dict(_response.headers),
218 body=typing.cast(
219 typing.Any,
220 parse_obj_as(
221 type_=typing.Any, # type: ignore
222 object_=_response.json(),
223 ),
224 ),
225 )
226 if _response.status_code == 403:
227 raise ForbiddenError(
228 headers=dict(_response.headers),
229 body=typing.cast(
230 typing.Any,
231 parse_obj_as(
232 type_=typing.Any, # type: ignore
233 object_=_response.json(),
234 ),
235 ),
236 )
237 if _response.status_code == 404:
238 raise NotFoundError(
239 headers=dict(_response.headers),
240 body=typing.cast(
241 typing.Any,
242 parse_obj_as(
243 type_=typing.Any, # type: ignore
244 object_=_response.json(),
245 ),
246 ),
247 )
248 if _response.status_code == 429:
249 raise TooManyRequestsError(
250 headers=dict(_response.headers),
251 body=typing.cast(
252 typing.Any,
253 parse_obj_as(
254 type_=typing.Any, # type: ignore
255 object_=_response.json(),
256 ),
257 ),
258 )
259 _response_json = _response.json()
260 except JSONDecodeError:
261 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
262 except ValidationError as e:
263 raise ParsingError(
264 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
265 )
266 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
267
268 def get(
269 self, theme_id: str, *, request_options: typing.Optional[RequestOptions] = None
270 ) -> HttpResponse[GetBrandingThemeResponseContent]:
271 """
272 Retrieve branding theme.
273
274 Parameters
275 ----------
276 theme_id : str
277 The ID of the theme
278
279 request_options : typing.Optional[RequestOptions]
280 Request-specific configuration.
281
282 Returns
283 -------
284 HttpResponse[GetBrandingThemeResponseContent]
285 Branding theme successfully retrieved.
286 """
287 _response = self._client_wrapper.httpx_client.request(
288 f"branding/themes/{encode_path_param(theme_id)}",
289 method="GET",
290 request_options=request_options,
291 )
292 try:
293 if 200 <= _response.status_code < 300:
294 _data = typing.cast(
295 GetBrandingThemeResponseContent,
296 parse_obj_as(
297 type_=GetBrandingThemeResponseContent, # type: ignore
298 object_=_response.json(),
299 ),
300 )
301 return HttpResponse(response=_response, data=_data)
302 if _response.status_code == 401:
303 raise UnauthorizedError(
304 headers=dict(_response.headers),
305 body=typing.cast(
306 typing.Any,
307 parse_obj_as(
308 type_=typing.Any, # type: ignore
309 object_=_response.json(),
310 ),
311 ),
312 )
313 if _response.status_code == 403:
314 raise ForbiddenError(
315 headers=dict(_response.headers),
316 body=typing.cast(
317 typing.Any,
318 parse_obj_as(
319 type_=typing.Any, # type: ignore
320 object_=_response.json(),
321 ),
322 ),
323 )
324 if _response.status_code == 404:
325 raise NotFoundError(
326 headers=dict(_response.headers),
327 body=typing.cast(
328 typing.Any,
329 parse_obj_as(
330 type_=typing.Any, # type: ignore
331 object_=_response.json(),
332 ),
333 ),
334 )
335 if _response.status_code == 429:
336 raise TooManyRequestsError(
337 headers=dict(_response.headers),
338 body=typing.cast(
339 typing.Any,
340 parse_obj_as(
341 type_=typing.Any, # type: ignore
342 object_=_response.json(),
343 ),
344 ),
345 )
346 _response_json = _response.json()
347 except JSONDecodeError:
348 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
349 except ValidationError as e:
350 raise ParsingError(
351 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
352 )
353 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
354
355 def delete(self, theme_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
356 """
357 Delete branding theme.
358
359 Parameters
360 ----------
361 theme_id : str
362 The ID of the theme
363
364 request_options : typing.Optional[RequestOptions]
365 Request-specific configuration.
366
367 Returns
368 -------
369 HttpResponse[None]
370 """
371 _response = self._client_wrapper.httpx_client.request(
372 f"branding/themes/{encode_path_param(theme_id)}",
373 method="DELETE",
374 request_options=request_options,
375 )
376 try:
377 if 200 <= _response.status_code < 300:
378 return HttpResponse(response=_response, data=None)
379 if _response.status_code == 401:
380 raise UnauthorizedError(
381 headers=dict(_response.headers),
382 body=typing.cast(
383 typing.Any,
384 parse_obj_as(
385 type_=typing.Any, # type: ignore
386 object_=_response.json(),
387 ),
388 ),
389 )
390 if _response.status_code == 403:
391 raise ForbiddenError(
392 headers=dict(_response.headers),
393 body=typing.cast(
394 typing.Any,
395 parse_obj_as(
396 type_=typing.Any, # type: ignore
397 object_=_response.json(),
398 ),
399 ),
400 )
401 if _response.status_code == 404:
402 raise NotFoundError(
403 headers=dict(_response.headers),
404 body=typing.cast(
405 typing.Any,
406 parse_obj_as(
407 type_=typing.Any, # type: ignore
408 object_=_response.json(),
409 ),
410 ),
411 )
412 if _response.status_code == 429:
413 raise TooManyRequestsError(
414 headers=dict(_response.headers),
415 body=typing.cast(
416 typing.Any,
417 parse_obj_as(
418 type_=typing.Any, # type: ignore
419 object_=_response.json(),
420 ),
421 ),
422 )
423 _response_json = _response.json()
424 except JSONDecodeError:
425 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
426 except ValidationError as e:
427 raise ParsingError(
428 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
429 )
430 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
431
432 def update(
433 self,
434 theme_id: str,
435 *,
436 borders: BrandingThemeBorders,
437 colors: BrandingThemeColors,
438 fonts: BrandingThemeFonts,
439 page_background: BrandingThemePageBackground,
440 widget: BrandingThemeWidget,
441 display_name: typing.Optional[str] = OMIT,
442 identifiers: typing.Optional[BrandingThemeIdentifiers] = OMIT,
443 request_options: typing.Optional[RequestOptions] = None,
444 ) -> HttpResponse[UpdateBrandingThemeResponseContent]:
445 """
446 Update branding theme.
447
448 Parameters
449 ----------
450 theme_id : str
451 The ID of the theme
452
453 borders : BrandingThemeBorders
454
455 colors : BrandingThemeColors
456
457 fonts : BrandingThemeFonts
458
459 page_background : BrandingThemePageBackground
460
461 widget : BrandingThemeWidget
462
463 display_name : typing.Optional[str]
464 Display Name
465
466 identifiers : typing.Optional[BrandingThemeIdentifiers]
467
468 request_options : typing.Optional[RequestOptions]
469 Request-specific configuration.
470
471 Returns
472 -------
473 HttpResponse[UpdateBrandingThemeResponseContent]
474 Branding settings successfully updated.
475 """
476 _response = self._client_wrapper.httpx_client.request(
477 f"branding/themes/{encode_path_param(theme_id)}",
478 method="PATCH",
479 json={
480 "borders": convert_and_respect_annotation_metadata(
481 object_=borders, annotation=BrandingThemeBorders, direction="write"
482 ),
483 "colors": convert_and_respect_annotation_metadata(
484 object_=colors, annotation=BrandingThemeColors, direction="write"
485 ),
486 "displayName": display_name,
487 "fonts": convert_and_respect_annotation_metadata(
488 object_=fonts, annotation=BrandingThemeFonts, direction="write"
489 ),
490 "identifiers": convert_and_respect_annotation_metadata(
491 object_=identifiers, annotation=BrandingThemeIdentifiers, direction="write"
492 ),
493 "page_background": convert_and_respect_annotation_metadata(
494 object_=page_background, annotation=BrandingThemePageBackground, direction="write"
495 ),
496 "widget": convert_and_respect_annotation_metadata(
497 object_=widget, annotation=BrandingThemeWidget, direction="write"
498 ),
499 },
500 headers={
501 "content-type": "application/json",
502 },
503 request_options=request_options,
504 omit=OMIT,
505 )
506 try:
507 if 200 <= _response.status_code < 300:
508 _data = typing.cast(
509 UpdateBrandingThemeResponseContent,
510 parse_obj_as(
511 type_=UpdateBrandingThemeResponseContent, # type: ignore
512 object_=_response.json(),
513 ),
514 )
515 return HttpResponse(response=_response, data=_data)
516 if _response.status_code == 400:
517 raise BadRequestError(
518 headers=dict(_response.headers),
519 body=typing.cast(
520 typing.Any,
521 parse_obj_as(
522 type_=typing.Any, # type: ignore
523 object_=_response.json(),
524 ),
525 ),
526 )
527 if _response.status_code == 401:
528 raise UnauthorizedError(
529 headers=dict(_response.headers),
530 body=typing.cast(
531 typing.Any,
532 parse_obj_as(
533 type_=typing.Any, # type: ignore
534 object_=_response.json(),
535 ),
536 ),
537 )
538 if _response.status_code == 403:
539 raise ForbiddenError(
540 headers=dict(_response.headers),
541 body=typing.cast(
542 typing.Any,
543 parse_obj_as(
544 type_=typing.Any, # type: ignore
545 object_=_response.json(),
546 ),
547 ),
548 )
549 if _response.status_code == 404:
550 raise NotFoundError(
551 headers=dict(_response.headers),
552 body=typing.cast(
553 typing.Any,
554 parse_obj_as(
555 type_=typing.Any, # type: ignore
556 object_=_response.json(),
557 ),
558 ),
559 )
560 if _response.status_code == 429:
561 raise TooManyRequestsError(
562 headers=dict(_response.headers),
563 body=typing.cast(
564 typing.Any,
565 parse_obj_as(
566 type_=typing.Any, # type: ignore
567 object_=_response.json(),
568 ),
569 ),
570 )
571 _response_json = _response.json()
572 except JSONDecodeError:
573 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
574 except ValidationError as e:
575 raise ParsingError(
576 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
577 )
578 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
579
580
581 class AsyncRawThemesClient:
582 def __init__(self, *, client_wrapper: AsyncClientWrapper):
583 self._client_wrapper = client_wrapper
584
585 async def create(
586 self,
587 *,
588 borders: BrandingThemeBorders,
589 colors: BrandingThemeColors,
590 fonts: BrandingThemeFonts,
591 page_background: BrandingThemePageBackground,
592 widget: BrandingThemeWidget,
593 display_name: typing.Optional[str] = OMIT,
594 identifiers: typing.Optional[BrandingThemeIdentifiers] = OMIT,
595 request_options: typing.Optional[RequestOptions] = None,
596 ) -> AsyncHttpResponse[CreateBrandingThemeResponseContent]:
597 """
598 Create branding theme.
599
600 Parameters
601 ----------
602 borders : BrandingThemeBorders
603
604 colors : BrandingThemeColors
605
606 fonts : BrandingThemeFonts
607
608 page_background : BrandingThemePageBackground
609
610 widget : BrandingThemeWidget
611
612 display_name : typing.Optional[str]
613 Display Name
614
615 identifiers : typing.Optional[BrandingThemeIdentifiers]
616
617 request_options : typing.Optional[RequestOptions]
618 Request-specific configuration.
619
620 Returns
621 -------
622 AsyncHttpResponse[CreateBrandingThemeResponseContent]
623 Branding settings successfully updated.
624 """
625 _response = await self._client_wrapper.httpx_client.request(
626 "branding/themes",
627 method="POST",
628 json={
629 "borders": convert_and_respect_annotation_metadata(
630 object_=borders, annotation=BrandingThemeBorders, direction="write"
631 ),
632 "colors": convert_and_respect_annotation_metadata(
633 object_=colors, annotation=BrandingThemeColors, direction="write"
634 ),
635 "displayName": display_name,
636 "fonts": convert_and_respect_annotation_metadata(
637 object_=fonts, annotation=BrandingThemeFonts, direction="write"
638 ),
639 "identifiers": convert_and_respect_annotation_metadata(
640 object_=identifiers, annotation=BrandingThemeIdentifiers, direction="write"
641 ),
642 "page_background": convert_and_respect_annotation_metadata(
643 object_=page_background, annotation=BrandingThemePageBackground, direction="write"
644 ),
645 "widget": convert_and_respect_annotation_metadata(
646 object_=widget, annotation=BrandingThemeWidget, direction="write"
647 ),
648 },
649 headers={
650 "content-type": "application/json",
651 },
652 request_options=request_options,
653 omit=OMIT,
654 )
655 try:
656 if 200 <= _response.status_code < 300:
657 _data = typing.cast(
658 CreateBrandingThemeResponseContent,
659 parse_obj_as(
660 type_=CreateBrandingThemeResponseContent, # type: ignore
661 object_=_response.json(),
662 ),
663 )
664 return AsyncHttpResponse(response=_response, data=_data)
665 if _response.status_code == 400:
666 raise BadRequestError(
667 headers=dict(_response.headers),
668 body=typing.cast(
669 typing.Any,
670 parse_obj_as(
671 type_=typing.Any, # type: ignore
672 object_=_response.json(),
673 ),
674 ),
675 )
676 if _response.status_code == 401:
677 raise UnauthorizedError(
678 headers=dict(_response.headers),
679 body=typing.cast(
680 typing.Any,
681 parse_obj_as(
682 type_=typing.Any, # type: ignore
683 object_=_response.json(),
684 ),
685 ),
686 )
687 if _response.status_code == 403:
688 raise ForbiddenError(
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 == 409:
699 raise ConflictError(
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 == 429:
710 raise TooManyRequestsError(
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_default(
730 self, *, request_options: typing.Optional[RequestOptions] = None
731 ) -> AsyncHttpResponse[GetBrandingDefaultThemeResponseContent]:
732 """
733 Retrieve default branding theme.
734
735 Parameters
736 ----------
737 request_options : typing.Optional[RequestOptions]
738 Request-specific configuration.
739
740 Returns
741 -------
742 AsyncHttpResponse[GetBrandingDefaultThemeResponseContent]
743 Branding theme successfully retrieved.
744 """
745 _response = await self._client_wrapper.httpx_client.request(
746 "branding/themes/default",
747 method="GET",
748 request_options=request_options,
749 )
750 try:
751 if 200 <= _response.status_code < 300:
752 _data = typing.cast(
753 GetBrandingDefaultThemeResponseContent,
754 parse_obj_as(
755 type_=GetBrandingDefaultThemeResponseContent, # type: ignore
756 object_=_response.json(),
757 ),
758 )
759 return AsyncHttpResponse(response=_response, data=_data)
760 if _response.status_code == 401:
761 raise UnauthorizedError(
762 headers=dict(_response.headers),
763 body=typing.cast(
764 typing.Any,
765 parse_obj_as(
766 type_=typing.Any, # type: ignore
767 object_=_response.json(),
768 ),
769 ),
770 )
771 if _response.status_code == 403:
772 raise ForbiddenError(
773 headers=dict(_response.headers),
774 body=typing.cast(
775 typing.Any,
776 parse_obj_as(
777 type_=typing.Any, # type: ignore
778 object_=_response.json(),
779 ),
780 ),
781 )
782 if _response.status_code == 404:
783 raise NotFoundError(
784 headers=dict(_response.headers),
785 body=typing.cast(
786 typing.Any,
787 parse_obj_as(
788 type_=typing.Any, # type: ignore
789 object_=_response.json(),
790 ),
791 ),
792 )
793 if _response.status_code == 429:
794 raise TooManyRequestsError(
795 headers=dict(_response.headers),
796 body=typing.cast(
797 typing.Any,
798 parse_obj_as(
799 type_=typing.Any, # type: ignore
800 object_=_response.json(),
801 ),
802 ),
803 )
804 _response_json = _response.json()
805 except JSONDecodeError:
806 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
807 except ValidationError as e:
808 raise ParsingError(
809 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
810 )
811 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
812
813 async def get(
814 self, theme_id: str, *, request_options: typing.Optional[RequestOptions] = None
815 ) -> AsyncHttpResponse[GetBrandingThemeResponseContent]:
816 """
817 Retrieve branding theme.
818
819 Parameters
820 ----------
821 theme_id : str
822 The ID of the theme
823
824 request_options : typing.Optional[RequestOptions]
825 Request-specific configuration.
826
827 Returns
828 -------
829 AsyncHttpResponse[GetBrandingThemeResponseContent]
830 Branding theme successfully retrieved.
831 """
832 _response = await self._client_wrapper.httpx_client.request(
833 f"branding/themes/{encode_path_param(theme_id)}",
834 method="GET",
835 request_options=request_options,
836 )
837 try:
838 if 200 <= _response.status_code < 300:
839 _data = typing.cast(
840 GetBrandingThemeResponseContent,
841 parse_obj_as(
842 type_=GetBrandingThemeResponseContent, # type: ignore
843 object_=_response.json(),
844 ),
845 )
846 return AsyncHttpResponse(response=_response, data=_data)
847 if _response.status_code == 401:
848 raise UnauthorizedError(
849 headers=dict(_response.headers),
850 body=typing.cast(
851 typing.Any,
852 parse_obj_as(
853 type_=typing.Any, # type: ignore
854 object_=_response.json(),
855 ),
856 ),
857 )
858 if _response.status_code == 403:
859 raise ForbiddenError(
860 headers=dict(_response.headers),
861 body=typing.cast(
862 typing.Any,
863 parse_obj_as(
864 type_=typing.Any, # type: ignore
865 object_=_response.json(),
866 ),
867 ),
868 )
869 if _response.status_code == 404:
870 raise NotFoundError(
871 headers=dict(_response.headers),
872 body=typing.cast(
873 typing.Any,
874 parse_obj_as(
875 type_=typing.Any, # type: ignore
876 object_=_response.json(),
877 ),
878 ),
879 )
880 if _response.status_code == 429:
881 raise TooManyRequestsError(
882 headers=dict(_response.headers),
883 body=typing.cast(
884 typing.Any,
885 parse_obj_as(
886 type_=typing.Any, # type: ignore
887 object_=_response.json(),
888 ),
889 ),
890 )
891 _response_json = _response.json()
892 except JSONDecodeError:
893 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
894 except ValidationError as e:
895 raise ParsingError(
896 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
897 )
898 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
899
900 async def delete(
901 self, theme_id: str, *, request_options: typing.Optional[RequestOptions] = None
902 ) -> AsyncHttpResponse[None]:
903 """
904 Delete branding theme.
905
906 Parameters
907 ----------
908 theme_id : str
909 The ID of the theme
910
911 request_options : typing.Optional[RequestOptions]
912 Request-specific configuration.
913
914 Returns
915 -------
916 AsyncHttpResponse[None]
917 """
918 _response = await self._client_wrapper.httpx_client.request(
919 f"branding/themes/{encode_path_param(theme_id)}",
920 method="DELETE",
921 request_options=request_options,
922 )
923 try:
924 if 200 <= _response.status_code < 300:
925 return AsyncHttpResponse(response=_response, data=None)
926 if _response.status_code == 401:
927 raise UnauthorizedError(
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 == 403:
938 raise ForbiddenError(
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 == 404:
949 raise NotFoundError(
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 if _response.status_code == 429:
960 raise TooManyRequestsError(
961 headers=dict(_response.headers),
962 body=typing.cast(
963 typing.Any,
964 parse_obj_as(
965 type_=typing.Any, # type: ignore
966 object_=_response.json(),
967 ),
968 ),
969 )
970 _response_json = _response.json()
971 except JSONDecodeError:
972 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
973 except ValidationError as e:
974 raise ParsingError(
975 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
976 )
977 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
978
979 async def update(
980 self,
981 theme_id: str,
982 *,
983 borders: BrandingThemeBorders,
984 colors: BrandingThemeColors,
985 fonts: BrandingThemeFonts,
986 page_background: BrandingThemePageBackground,
987 widget: BrandingThemeWidget,
988 display_name: typing.Optional[str] = OMIT,
989 identifiers: typing.Optional[BrandingThemeIdentifiers] = OMIT,
990 request_options: typing.Optional[RequestOptions] = None,
991 ) -> AsyncHttpResponse[UpdateBrandingThemeResponseContent]:
992 """
993 Update branding theme.
994
995 Parameters
996 ----------
997 theme_id : str
998 The ID of the theme
999
1000 borders : BrandingThemeBorders
1001
1002 colors : BrandingThemeColors
1003
1004 fonts : BrandingThemeFonts
1005
1006 page_background : BrandingThemePageBackground
1007
1008 widget : BrandingThemeWidget
1009
1010 display_name : typing.Optional[str]
1011 Display Name
1012
1013 identifiers : typing.Optional[BrandingThemeIdentifiers]
1014
1015 request_options : typing.Optional[RequestOptions]
1016 Request-specific configuration.
1017
1018 Returns
1019 -------
1020 AsyncHttpResponse[UpdateBrandingThemeResponseContent]
1021 Branding settings successfully updated.
1022 """
1023 _response = await self._client_wrapper.httpx_client.request(
1024 f"branding/themes/{encode_path_param(theme_id)}",
1025 method="PATCH",
1026 json={
1027 "borders": convert_and_respect_annotation_metadata(
1028 object_=borders, annotation=BrandingThemeBorders, direction="write"
1029 ),
1030 "colors": convert_and_respect_annotation_metadata(
1031 object_=colors, annotation=BrandingThemeColors, direction="write"
1032 ),
1033 "displayName": display_name,
1034 "fonts": convert_and_respect_annotation_metadata(
1035 object_=fonts, annotation=BrandingThemeFonts, direction="write"
1036 ),
1037 "identifiers": convert_and_respect_annotation_metadata(
1038 object_=identifiers, annotation=BrandingThemeIdentifiers, direction="write"
1039 ),
1040 "page_background": convert_and_respect_annotation_metadata(
1041 object_=page_background, annotation=BrandingThemePageBackground, direction="write"
1042 ),
1043 "widget": convert_and_respect_annotation_metadata(
1044 object_=widget, annotation=BrandingThemeWidget, direction="write"
1045 ),
1046 },
1047 headers={
1048 "content-type": "application/json",
1049 },
1050 request_options=request_options,
1051 omit=OMIT,
1052 )
1053 try:
1054 if 200 <= _response.status_code < 300:
1055 _data = typing.cast(
1056 UpdateBrandingThemeResponseContent,
1057 parse_obj_as(
1058 type_=UpdateBrandingThemeResponseContent, # type: ignore
1059 object_=_response.json(),
1060 ),
1061 )
1062 return AsyncHttpResponse(response=_response, data=_data)
1063 if _response.status_code == 400:
1064 raise BadRequestError(
1065 headers=dict(_response.headers),
1066 body=typing.cast(
1067 typing.Any,
1068 parse_obj_as(
1069 type_=typing.Any, # type: ignore
1070 object_=_response.json(),
1071 ),
1072 ),
1073 )
1074 if _response.status_code == 401:
1075 raise UnauthorizedError(
1076 headers=dict(_response.headers),
1077 body=typing.cast(
1078 typing.Any,
1079 parse_obj_as(
1080 type_=typing.Any, # type: ignore
1081 object_=_response.json(),
1082 ),
1083 ),
1084 )
1085 if _response.status_code == 403:
1086 raise ForbiddenError(
1087 headers=dict(_response.headers),
1088 body=typing.cast(
1089 typing.Any,
1090 parse_obj_as(
1091 type_=typing.Any, # type: ignore
1092 object_=_response.json(),
1093 ),
1094 ),
1095 )
1096 if _response.status_code == 404:
1097 raise NotFoundError(
1098 headers=dict(_response.headers),
1099 body=typing.cast(
1100 typing.Any,
1101 parse_obj_as(
1102 type_=typing.Any, # type: ignore
1103 object_=_response.json(),
1104 ),
1105 ),
1106 )
1107 if _response.status_code == 429:
1108 raise TooManyRequestsError(
1109 headers=dict(_response.headers),
1110 body=typing.cast(
1111 typing.Any,
1112 parse_obj_as(
1113 type_=typing.Any, # type: ignore
1114 object_=_response.json(),
1115 ),
1116 ),
1117 )
1118 _response_json = _response.json()
1119 except JSONDecodeError:
1120 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1121 except ValidationError as e:
1122 raise ParsingError(
1123 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1124 )
1125 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)