Debian Codegraph @

src/auth0/management/branding/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 ..core.serialization import convert_and_respect_annotation_metadata
13 from ..errors.bad_request_error import BadRequestError
14 from ..errors.forbidden_error import ForbiddenError
15 from ..errors.too_many_requests_error import TooManyRequestsError
16 from ..errors.unauthorized_error import UnauthorizedError
17 from ..types.get_branding_response_content import GetBrandingResponseContent
18 from ..types.update_branding_colors import UpdateBrandingColors
19 from ..types.update_branding_font import UpdateBrandingFont
20 from ..types.update_branding_response_content import UpdateBrandingResponseContent
21 from pydantic import ValidationError
22
23 # this is used as the default value for optional parameters
24 OMIT = typing.cast(typing.Any, ...)
25
26
27 class RawBrandingClient:
28 def __init__(self, *, client_wrapper: SyncClientWrapper):
29 self._client_wrapper = client_wrapper
30
31 def get(
32 self, *, request_options: typing.Optional[RequestOptions] = None
33 ) -> HttpResponse[GetBrandingResponseContent]:
34 """
35 Retrieve branding settings.
36
37 Parameters
38 ----------
39 request_options : typing.Optional[RequestOptions]
40 Request-specific configuration.
41
42 Returns
43 -------
44 HttpResponse[GetBrandingResponseContent]
45 Branding settings successfully retrieved.
46 """
47 _response = self._client_wrapper.httpx_client.request(
48 "branding",
49 method="GET",
50 request_options=request_options,
51 )
52 try:
53 if 200 <= _response.status_code < 300:
54 _data = typing.cast(
55 GetBrandingResponseContent,
56 parse_obj_as(
57 type_=GetBrandingResponseContent, # type: ignore
58 object_=_response.json(),
59 ),
60 )
61 return HttpResponse(response=_response, data=_data)
62 if _response.status_code == 401:
63 raise UnauthorizedError(
64 headers=dict(_response.headers),
65 body=typing.cast(
66 typing.Any,
67 parse_obj_as(
68 type_=typing.Any, # type: ignore
69 object_=_response.json(),
70 ),
71 ),
72 )
73 if _response.status_code == 403:
74 raise ForbiddenError(
75 headers=dict(_response.headers),
76 body=typing.cast(
77 typing.Any,
78 parse_obj_as(
79 type_=typing.Any, # type: ignore
80 object_=_response.json(),
81 ),
82 ),
83 )
84 if _response.status_code == 429:
85 raise TooManyRequestsError(
86 headers=dict(_response.headers),
87 body=typing.cast(
88 typing.Any,
89 parse_obj_as(
90 type_=typing.Any, # type: ignore
91 object_=_response.json(),
92 ),
93 ),
94 )
95 _response_json = _response.json()
96 except JSONDecodeError:
97 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
98 except ValidationError as e:
99 raise ParsingError(
100 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
101 )
102 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
103
104 def update(
105 self,
106 *,
107 colors: typing.Optional[UpdateBrandingColors] = OMIT,
108 favicon_url: typing.Optional[str] = OMIT,
109 logo_url: typing.Optional[str] = OMIT,
110 font: typing.Optional[UpdateBrandingFont] = OMIT,
111 request_options: typing.Optional[RequestOptions] = None,
112 ) -> HttpResponse[UpdateBrandingResponseContent]:
113 """
114 Update branding settings.
115
116 Parameters
117 ----------
118 colors : typing.Optional[UpdateBrandingColors]
119
120 favicon_url : typing.Optional[str]
121 URL for the favicon. Must use HTTPS.
122
123 logo_url : typing.Optional[str]
124 URL for the logo. Must use HTTPS.
125
126 font : typing.Optional[UpdateBrandingFont]
127
128 request_options : typing.Optional[RequestOptions]
129 Request-specific configuration.
130
131 Returns
132 -------
133 HttpResponse[UpdateBrandingResponseContent]
134 Branding settings successfully updated.
135 """
136 _response = self._client_wrapper.httpx_client.request(
137 "branding",
138 method="PATCH",
139 json={
140 "colors": convert_and_respect_annotation_metadata(
141 object_=colors, annotation=typing.Optional[UpdateBrandingColors], direction="write"
142 ),
143 "favicon_url": favicon_url,
144 "logo_url": logo_url,
145 "font": convert_and_respect_annotation_metadata(
146 object_=font, annotation=typing.Optional[UpdateBrandingFont], direction="write"
147 ),
148 },
149 headers={
150 "content-type": "application/json",
151 },
152 request_options=request_options,
153 omit=OMIT,
154 )
155 try:
156 if 200 <= _response.status_code < 300:
157 _data = typing.cast(
158 UpdateBrandingResponseContent,
159 parse_obj_as(
160 type_=UpdateBrandingResponseContent, # type: ignore
161 object_=_response.json(),
162 ),
163 )
164 return HttpResponse(response=_response, data=_data)
165 if _response.status_code == 400:
166 raise BadRequestError(
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 == 401:
177 raise UnauthorizedError(
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 if _response.status_code == 403:
188 raise ForbiddenError(
189 headers=dict(_response.headers),
190 body=typing.cast(
191 typing.Any,
192 parse_obj_as(
193 type_=typing.Any, # type: ignore
194 object_=_response.json(),
195 ),
196 ),
197 )
198 if _response.status_code == 429:
199 raise TooManyRequestsError(
200 headers=dict(_response.headers),
201 body=typing.cast(
202 typing.Any,
203 parse_obj_as(
204 type_=typing.Any, # type: ignore
205 object_=_response.json(),
206 ),
207 ),
208 )
209 _response_json = _response.json()
210 except JSONDecodeError:
211 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
212 except ValidationError as e:
213 raise ParsingError(
214 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
215 )
216 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
217
218
219 class AsyncRawBrandingClient:
220 def __init__(self, *, client_wrapper: AsyncClientWrapper):
221 self._client_wrapper = client_wrapper
222
223 async def get(
224 self, *, request_options: typing.Optional[RequestOptions] = None
225 ) -> AsyncHttpResponse[GetBrandingResponseContent]:
226 """
227 Retrieve branding settings.
228
229 Parameters
230 ----------
231 request_options : typing.Optional[RequestOptions]
232 Request-specific configuration.
233
234 Returns
235 -------
236 AsyncHttpResponse[GetBrandingResponseContent]
237 Branding settings successfully retrieved.
238 """
239 _response = await self._client_wrapper.httpx_client.request(
240 "branding",
241 method="GET",
242 request_options=request_options,
243 )
244 try:
245 if 200 <= _response.status_code < 300:
246 _data = typing.cast(
247 GetBrandingResponseContent,
248 parse_obj_as(
249 type_=GetBrandingResponseContent, # type: ignore
250 object_=_response.json(),
251 ),
252 )
253 return AsyncHttpResponse(response=_response, data=_data)
254 if _response.status_code == 401:
255 raise UnauthorizedError(
256 headers=dict(_response.headers),
257 body=typing.cast(
258 typing.Any,
259 parse_obj_as(
260 type_=typing.Any, # type: ignore
261 object_=_response.json(),
262 ),
263 ),
264 )
265 if _response.status_code == 403:
266 raise ForbiddenError(
267 headers=dict(_response.headers),
268 body=typing.cast(
269 typing.Any,
270 parse_obj_as(
271 type_=typing.Any, # type: ignore
272 object_=_response.json(),
273 ),
274 ),
275 )
276 if _response.status_code == 429:
277 raise TooManyRequestsError(
278 headers=dict(_response.headers),
279 body=typing.cast(
280 typing.Any,
281 parse_obj_as(
282 type_=typing.Any, # type: ignore
283 object_=_response.json(),
284 ),
285 ),
286 )
287 _response_json = _response.json()
288 except JSONDecodeError:
289 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
290 except ValidationError as e:
291 raise ParsingError(
292 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
293 )
294 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
295
296 async def update(
297 self,
298 *,
299 colors: typing.Optional[UpdateBrandingColors] = OMIT,
300 favicon_url: typing.Optional[str] = OMIT,
301 logo_url: typing.Optional[str] = OMIT,
302 font: typing.Optional[UpdateBrandingFont] = OMIT,
303 request_options: typing.Optional[RequestOptions] = None,
304 ) -> AsyncHttpResponse[UpdateBrandingResponseContent]:
305 """
306 Update branding settings.
307
308 Parameters
309 ----------
310 colors : typing.Optional[UpdateBrandingColors]
311
312 favicon_url : typing.Optional[str]
313 URL for the favicon. Must use HTTPS.
314
315 logo_url : typing.Optional[str]
316 URL for the logo. Must use HTTPS.
317
318 font : typing.Optional[UpdateBrandingFont]
319
320 request_options : typing.Optional[RequestOptions]
321 Request-specific configuration.
322
323 Returns
324 -------
325 AsyncHttpResponse[UpdateBrandingResponseContent]
326 Branding settings successfully updated.
327 """
328 _response = await self._client_wrapper.httpx_client.request(
329 "branding",
330 method="PATCH",
331 json={
332 "colors": convert_and_respect_annotation_metadata(
333 object_=colors, annotation=typing.Optional[UpdateBrandingColors], direction="write"
334 ),
335 "favicon_url": favicon_url,
336 "logo_url": logo_url,
337 "font": convert_and_respect_annotation_metadata(
338 object_=font, annotation=typing.Optional[UpdateBrandingFont], direction="write"
339 ),
340 },
341 headers={
342 "content-type": "application/json",
343 },
344 request_options=request_options,
345 omit=OMIT,
346 )
347 try:
348 if 200 <= _response.status_code < 300:
349 _data = typing.cast(
350 UpdateBrandingResponseContent,
351 parse_obj_as(
352 type_=UpdateBrandingResponseContent, # type: ignore
353 object_=_response.json(),
354 ),
355 )
356 return AsyncHttpResponse(response=_response, data=_data)
357 if _response.status_code == 400:
358 raise BadRequestError(
359 headers=dict(_response.headers),
360 body=typing.cast(
361 typing.Any,
362 parse_obj_as(
363 type_=typing.Any, # type: ignore
364 object_=_response.json(),
365 ),
366 ),
367 )
368 if _response.status_code == 401:
369 raise UnauthorizedError(
370 headers=dict(_response.headers),
371 body=typing.cast(
372 typing.Any,
373 parse_obj_as(
374 type_=typing.Any, # type: ignore
375 object_=_response.json(),
376 ),
377 ),
378 )
379 if _response.status_code == 403:
380 raise ForbiddenError(
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 == 429:
391 raise TooManyRequestsError(
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 _response_json = _response.json()
402 except JSONDecodeError:
403 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
404 except ValidationError as e:
405 raise ParsingError(
406 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
407 )
408 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)