# This file was auto-generated by Fern from our API Definition. import typing from json.decoder import JSONDecodeError from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.http_response import AsyncHttpResponse, HttpResponse from ...core.jsonable_encoder import encode_path_param from ...core.parse_error import ParsingError from ...core.pydantic_utilities import parse_obj_as from ...core.request_options import RequestOptions from ...core.serialization import convert_and_respect_annotation_metadata from ...errors.bad_request_error import BadRequestError from ...errors.conflict_error import ConflictError from ...errors.forbidden_error import ForbiddenError from ...errors.not_found_error import NotFoundError from ...errors.too_many_requests_error import TooManyRequestsError from ...errors.unauthorized_error import UnauthorizedError from ...types.branding_theme_borders import BrandingThemeBorders from ...types.branding_theme_colors import BrandingThemeColors from ...types.branding_theme_fonts import BrandingThemeFonts from ...types.branding_theme_identifiers import BrandingThemeIdentifiers from ...types.branding_theme_page_background import BrandingThemePageBackground from ...types.branding_theme_widget import BrandingThemeWidget from ...types.create_branding_theme_response_content import CreateBrandingThemeResponseContent from ...types.get_branding_default_theme_response_content import GetBrandingDefaultThemeResponseContent from ...types.get_branding_theme_response_content import GetBrandingThemeResponseContent from ...types.update_branding_theme_response_content import UpdateBrandingThemeResponseContent from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class RawThemesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( self, *, borders: BrandingThemeBorders, colors: BrandingThemeColors, fonts: BrandingThemeFonts, page_background: BrandingThemePageBackground, widget: BrandingThemeWidget, display_name: typing.Optional[str] = OMIT, identifiers: typing.Optional[BrandingThemeIdentifiers] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[CreateBrandingThemeResponseContent]: """ Create branding theme. Parameters ---------- borders : BrandingThemeBorders colors : BrandingThemeColors fonts : BrandingThemeFonts page_background : BrandingThemePageBackground widget : BrandingThemeWidget display_name : typing.Optional[str] Display Name identifiers : typing.Optional[BrandingThemeIdentifiers] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[CreateBrandingThemeResponseContent] Branding settings successfully updated. """ _response = self._client_wrapper.httpx_client.request( "branding/themes", method="POST", json={ "borders": convert_and_respect_annotation_metadata( object_=borders, annotation=BrandingThemeBorders, direction="write" ), "colors": convert_and_respect_annotation_metadata( object_=colors, annotation=BrandingThemeColors, direction="write" ), "displayName": display_name, "fonts": convert_and_respect_annotation_metadata( object_=fonts, annotation=BrandingThemeFonts, direction="write" ), "identifiers": convert_and_respect_annotation_metadata( object_=identifiers, annotation=BrandingThemeIdentifiers, direction="write" ), "page_background": convert_and_respect_annotation_metadata( object_=page_background, annotation=BrandingThemePageBackground, direction="write" ), "widget": convert_and_respect_annotation_metadata( object_=widget, annotation=BrandingThemeWidget, direction="write" ), }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateBrandingThemeResponseContent, parse_obj_as( type_=CreateBrandingThemeResponseContent, # type: ignore object_=_response.json(), ), ) return HttpResponse(response=_response, data=_data) if _response.status_code == 400: raise BadRequestError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def get_default( self, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[GetBrandingDefaultThemeResponseContent]: """ Retrieve default branding theme. Parameters ---------- request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[GetBrandingDefaultThemeResponseContent] Branding theme successfully retrieved. """ _response = self._client_wrapper.httpx_client.request( "branding/themes/default", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetBrandingDefaultThemeResponseContent, parse_obj_as( type_=GetBrandingDefaultThemeResponseContent, # type: ignore object_=_response.json(), ), ) return HttpResponse(response=_response, data=_data) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def get( self, theme_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[GetBrandingThemeResponseContent]: """ Retrieve branding theme. Parameters ---------- theme_id : str The ID of the theme request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[GetBrandingThemeResponseContent] Branding theme successfully retrieved. """ _response = self._client_wrapper.httpx_client.request( f"branding/themes/{encode_path_param(theme_id)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetBrandingThemeResponseContent, parse_obj_as( type_=GetBrandingThemeResponseContent, # type: ignore object_=_response.json(), ), ) return HttpResponse(response=_response, data=_data) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete(self, theme_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: """ Delete branding theme. Parameters ---------- theme_id : str The ID of the theme request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[None] """ _response = self._client_wrapper.httpx_client.request( f"branding/themes/{encode_path_param(theme_id)}", method="DELETE", request_options=request_options, ) try: if 200 <= _response.status_code < 300: return HttpResponse(response=_response, data=None) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update( self, theme_id: str, *, borders: BrandingThemeBorders, colors: BrandingThemeColors, fonts: BrandingThemeFonts, page_background: BrandingThemePageBackground, widget: BrandingThemeWidget, display_name: typing.Optional[str] = OMIT, identifiers: typing.Optional[BrandingThemeIdentifiers] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[UpdateBrandingThemeResponseContent]: """ Update branding theme. Parameters ---------- theme_id : str The ID of the theme borders : BrandingThemeBorders colors : BrandingThemeColors fonts : BrandingThemeFonts page_background : BrandingThemePageBackground widget : BrandingThemeWidget display_name : typing.Optional[str] Display Name identifiers : typing.Optional[BrandingThemeIdentifiers] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[UpdateBrandingThemeResponseContent] Branding settings successfully updated. """ _response = self._client_wrapper.httpx_client.request( f"branding/themes/{encode_path_param(theme_id)}", method="PATCH", json={ "borders": convert_and_respect_annotation_metadata( object_=borders, annotation=BrandingThemeBorders, direction="write" ), "colors": convert_and_respect_annotation_metadata( object_=colors, annotation=BrandingThemeColors, direction="write" ), "displayName": display_name, "fonts": convert_and_respect_annotation_metadata( object_=fonts, annotation=BrandingThemeFonts, direction="write" ), "identifiers": convert_and_respect_annotation_metadata( object_=identifiers, annotation=BrandingThemeIdentifiers, direction="write" ), "page_background": convert_and_respect_annotation_metadata( object_=page_background, annotation=BrandingThemePageBackground, direction="write" ), "widget": convert_and_respect_annotation_metadata( object_=widget, annotation=BrandingThemeWidget, direction="write" ), }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( UpdateBrandingThemeResponseContent, parse_obj_as( type_=UpdateBrandingThemeResponseContent, # type: ignore object_=_response.json(), ), ) return HttpResponse(response=_response, data=_data) if _response.status_code == 400: raise BadRequestError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) class AsyncRawThemesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( self, *, borders: BrandingThemeBorders, colors: BrandingThemeColors, fonts: BrandingThemeFonts, page_background: BrandingThemePageBackground, widget: BrandingThemeWidget, display_name: typing.Optional[str] = OMIT, identifiers: typing.Optional[BrandingThemeIdentifiers] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[CreateBrandingThemeResponseContent]: """ Create branding theme. Parameters ---------- borders : BrandingThemeBorders colors : BrandingThemeColors fonts : BrandingThemeFonts page_background : BrandingThemePageBackground widget : BrandingThemeWidget display_name : typing.Optional[str] Display Name identifiers : typing.Optional[BrandingThemeIdentifiers] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[CreateBrandingThemeResponseContent] Branding settings successfully updated. """ _response = await self._client_wrapper.httpx_client.request( "branding/themes", method="POST", json={ "borders": convert_and_respect_annotation_metadata( object_=borders, annotation=BrandingThemeBorders, direction="write" ), "colors": convert_and_respect_annotation_metadata( object_=colors, annotation=BrandingThemeColors, direction="write" ), "displayName": display_name, "fonts": convert_and_respect_annotation_metadata( object_=fonts, annotation=BrandingThemeFonts, direction="write" ), "identifiers": convert_and_respect_annotation_metadata( object_=identifiers, annotation=BrandingThemeIdentifiers, direction="write" ), "page_background": convert_and_respect_annotation_metadata( object_=page_background, annotation=BrandingThemePageBackground, direction="write" ), "widget": convert_and_respect_annotation_metadata( object_=widget, annotation=BrandingThemeWidget, direction="write" ), }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateBrandingThemeResponseContent, parse_obj_as( type_=CreateBrandingThemeResponseContent, # type: ignore object_=_response.json(), ), ) return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 400: raise BadRequestError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 409: raise ConflictError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def get_default( self, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[GetBrandingDefaultThemeResponseContent]: """ Retrieve default branding theme. Parameters ---------- request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[GetBrandingDefaultThemeResponseContent] Branding theme successfully retrieved. """ _response = await self._client_wrapper.httpx_client.request( "branding/themes/default", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetBrandingDefaultThemeResponseContent, parse_obj_as( type_=GetBrandingDefaultThemeResponseContent, # type: ignore object_=_response.json(), ), ) return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def get( self, theme_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[GetBrandingThemeResponseContent]: """ Retrieve branding theme. Parameters ---------- theme_id : str The ID of the theme request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[GetBrandingThemeResponseContent] Branding theme successfully retrieved. """ _response = await self._client_wrapper.httpx_client.request( f"branding/themes/{encode_path_param(theme_id)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetBrandingThemeResponseContent, parse_obj_as( type_=GetBrandingThemeResponseContent, # type: ignore object_=_response.json(), ), ) return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete( self, theme_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[None]: """ Delete branding theme. Parameters ---------- theme_id : str The ID of the theme request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[None] """ _response = await self._client_wrapper.httpx_client.request( f"branding/themes/{encode_path_param(theme_id)}", method="DELETE", request_options=request_options, ) try: if 200 <= _response.status_code < 300: return AsyncHttpResponse(response=_response, data=None) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update( self, theme_id: str, *, borders: BrandingThemeBorders, colors: BrandingThemeColors, fonts: BrandingThemeFonts, page_background: BrandingThemePageBackground, widget: BrandingThemeWidget, display_name: typing.Optional[str] = OMIT, identifiers: typing.Optional[BrandingThemeIdentifiers] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[UpdateBrandingThemeResponseContent]: """ Update branding theme. Parameters ---------- theme_id : str The ID of the theme borders : BrandingThemeBorders colors : BrandingThemeColors fonts : BrandingThemeFonts page_background : BrandingThemePageBackground widget : BrandingThemeWidget display_name : typing.Optional[str] Display Name identifiers : typing.Optional[BrandingThemeIdentifiers] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[UpdateBrandingThemeResponseContent] Branding settings successfully updated. """ _response = await self._client_wrapper.httpx_client.request( f"branding/themes/{encode_path_param(theme_id)}", method="PATCH", json={ "borders": convert_and_respect_annotation_metadata( object_=borders, annotation=BrandingThemeBorders, direction="write" ), "colors": convert_and_respect_annotation_metadata( object_=colors, annotation=BrandingThemeColors, direction="write" ), "displayName": display_name, "fonts": convert_and_respect_annotation_metadata( object_=fonts, annotation=BrandingThemeFonts, direction="write" ), "identifiers": convert_and_respect_annotation_metadata( object_=identifiers, annotation=BrandingThemeIdentifiers, direction="write" ), "page_background": convert_and_respect_annotation_metadata( object_=page_background, annotation=BrandingThemePageBackground, direction="write" ), "widget": convert_and_respect_annotation_metadata( object_=widget, annotation=BrandingThemeWidget, direction="write" ), }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( UpdateBrandingThemeResponseContent, parse_obj_as( type_=UpdateBrandingThemeResponseContent, # type: ignore object_=_response.json(), ), ) return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 400: raise BadRequestError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 401: raise UnauthorizedError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 403: raise ForbiddenError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 404: raise NotFoundError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) if _response.status_code == 429: raise TooManyRequestsError( headers=dict(_response.headers), body=typing.cast( typing.Any, parse_obj_as( type_=typing.Any, # type: ignore object_=_response.json(), ), ), ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) except ValidationError as e: raise ParsingError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)