# 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.create_branding_phone_provider_response_content import CreateBrandingPhoneProviderResponseContent from ....types.create_phone_provider_send_test_response_content import CreatePhoneProviderSendTestResponseContent from ....types.get_branding_phone_provider_response_content import GetBrandingPhoneProviderResponseContent from ....types.list_branding_phone_providers_response_content import ListBrandingPhoneProvidersResponseContent from ....types.phone_provider_configuration import PhoneProviderConfiguration from ....types.phone_provider_credentials import PhoneProviderCredentials from ....types.phone_provider_delivery_method_enum import PhoneProviderDeliveryMethodEnum from ....types.phone_provider_name_enum import PhoneProviderNameEnum from ....types.update_branding_phone_provider_response_content import UpdateBrandingPhoneProviderResponseContent from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class RawProvidersClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def list( self, *, disabled: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[ListBrandingPhoneProvidersResponseContent]: """ Retrieve a list of [phone providers](https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers) details set for a Tenant. A list of fields to include or exclude may also be specified. Parameters ---------- disabled : typing.Optional[bool] Whether the provider is enabled (false) or disabled (true). request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[ListBrandingPhoneProvidersResponseContent] Phone providers have been successfully retrieved. """ _response = self._client_wrapper.httpx_client.request( "branding/phone/providers", method="GET", params={ "disabled": disabled, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( ListBrandingPhoneProvidersResponseContent, parse_obj_as( type_=ListBrandingPhoneProvidersResponseContent, # 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 == 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 create( self, *, name: PhoneProviderNameEnum, credentials: PhoneProviderCredentials, disabled: typing.Optional[bool] = OMIT, configuration: typing.Optional[PhoneProviderConfiguration] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[CreateBrandingPhoneProviderResponseContent]: """ Create a [phone provider](https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers). The `credentials` object requires different properties depending on the phone provider (which is specified using the `name` property). Parameters ---------- name : PhoneProviderNameEnum credentials : PhoneProviderCredentials disabled : typing.Optional[bool] Whether the provider is enabled (false) or disabled (true). configuration : typing.Optional[PhoneProviderConfiguration] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[CreateBrandingPhoneProviderResponseContent] Phone notification provider successfully created. """ _response = self._client_wrapper.httpx_client.request( "branding/phone/providers", method="POST", json={ "name": name, "disabled": disabled, "configuration": convert_and_respect_annotation_metadata( object_=configuration, annotation=PhoneProviderConfiguration, direction="write" ), "credentials": convert_and_respect_annotation_metadata( object_=credentials, annotation=PhoneProviderCredentials, direction="write" ), }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateBrandingPhoneProviderResponseContent, parse_obj_as( type_=CreateBrandingPhoneProviderResponseContent, # 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( self, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[GetBrandingPhoneProviderResponseContent]: """ Retrieve [phone provider](https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers) details. A list of fields to include or exclude may also be specified. Parameters ---------- id : str request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[GetBrandingPhoneProviderResponseContent] Phone provider successfully retrieved. """ _response = self._client_wrapper.httpx_client.request( f"branding/phone/providers/{encode_path_param(id)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetBrandingPhoneProviderResponseContent, parse_obj_as( type_=GetBrandingPhoneProviderResponseContent, # 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) def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: """ Delete the configured phone provider. Parameters ---------- id : str request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[None] """ _response = self._client_wrapper.httpx_client.request( f"branding/phone/providers/{encode_path_param(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, id: str, *, name: typing.Optional[PhoneProviderNameEnum] = OMIT, disabled: typing.Optional[bool] = OMIT, credentials: typing.Optional[PhoneProviderCredentials] = OMIT, configuration: typing.Optional[PhoneProviderConfiguration] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[UpdateBrandingPhoneProviderResponseContent]: """ Update a [phone provider](https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers). The `credentials` object requires different properties depending on the phone provider (which is specified using the `name` property). Parameters ---------- id : str name : typing.Optional[PhoneProviderNameEnum] disabled : typing.Optional[bool] Whether the provider is enabled (false) or disabled (true). credentials : typing.Optional[PhoneProviderCredentials] configuration : typing.Optional[PhoneProviderConfiguration] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[UpdateBrandingPhoneProviderResponseContent] Phone provider successfully updated. """ _response = self._client_wrapper.httpx_client.request( f"branding/phone/providers/{encode_path_param(id)}", method="PATCH", json={ "name": name, "disabled": disabled, "credentials": convert_and_respect_annotation_metadata( object_=credentials, annotation=PhoneProviderCredentials, direction="write" ), "configuration": convert_and_respect_annotation_metadata( object_=configuration, annotation=PhoneProviderConfiguration, direction="write" ), }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( UpdateBrandingPhoneProviderResponseContent, parse_obj_as( type_=UpdateBrandingPhoneProviderResponseContent, # 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 == 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 test( self, id: str, *, to: str, delivery_method: typing.Optional[PhoneProviderDeliveryMethodEnum] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[CreatePhoneProviderSendTestResponseContent]: """ Parameters ---------- id : str to : str The recipient phone number to receive a given notification. delivery_method : typing.Optional[PhoneProviderDeliveryMethodEnum] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[CreatePhoneProviderSendTestResponseContent] Phone notification sent. """ _response = self._client_wrapper.httpx_client.request( f"branding/phone/providers/{encode_path_param(id)}/try", method="POST", json={ "to": to, "delivery_method": delivery_method, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreatePhoneProviderSendTestResponseContent, parse_obj_as( type_=CreatePhoneProviderSendTestResponseContent, # 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 == 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) class AsyncRawProvidersClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def list( self, *, disabled: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[ListBrandingPhoneProvidersResponseContent]: """ Retrieve a list of [phone providers](https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers) details set for a Tenant. A list of fields to include or exclude may also be specified. Parameters ---------- disabled : typing.Optional[bool] Whether the provider is enabled (false) or disabled (true). request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[ListBrandingPhoneProvidersResponseContent] Phone providers have been successfully retrieved. """ _response = await self._client_wrapper.httpx_client.request( "branding/phone/providers", method="GET", params={ "disabled": disabled, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( ListBrandingPhoneProvidersResponseContent, parse_obj_as( type_=ListBrandingPhoneProvidersResponseContent, # 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 == 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 create( self, *, name: PhoneProviderNameEnum, credentials: PhoneProviderCredentials, disabled: typing.Optional[bool] = OMIT, configuration: typing.Optional[PhoneProviderConfiguration] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[CreateBrandingPhoneProviderResponseContent]: """ Create a [phone provider](https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers). The `credentials` object requires different properties depending on the phone provider (which is specified using the `name` property). Parameters ---------- name : PhoneProviderNameEnum credentials : PhoneProviderCredentials disabled : typing.Optional[bool] Whether the provider is enabled (false) or disabled (true). configuration : typing.Optional[PhoneProviderConfiguration] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[CreateBrandingPhoneProviderResponseContent] Phone notification provider successfully created. """ _response = await self._client_wrapper.httpx_client.request( "branding/phone/providers", method="POST", json={ "name": name, "disabled": disabled, "configuration": convert_and_respect_annotation_metadata( object_=configuration, annotation=PhoneProviderConfiguration, direction="write" ), "credentials": convert_and_respect_annotation_metadata( object_=credentials, annotation=PhoneProviderCredentials, direction="write" ), }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateBrandingPhoneProviderResponseContent, parse_obj_as( type_=CreateBrandingPhoneProviderResponseContent, # 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( self, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[GetBrandingPhoneProviderResponseContent]: """ Retrieve [phone provider](https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers) details. A list of fields to include or exclude may also be specified. Parameters ---------- id : str request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[GetBrandingPhoneProviderResponseContent] Phone provider successfully retrieved. """ _response = await self._client_wrapper.httpx_client.request( f"branding/phone/providers/{encode_path_param(id)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetBrandingPhoneProviderResponseContent, parse_obj_as( type_=GetBrandingPhoneProviderResponseContent, # 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) async def delete( self, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[None]: """ Delete the configured phone provider. Parameters ---------- id : str request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[None] """ _response = await self._client_wrapper.httpx_client.request( f"branding/phone/providers/{encode_path_param(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, id: str, *, name: typing.Optional[PhoneProviderNameEnum] = OMIT, disabled: typing.Optional[bool] = OMIT, credentials: typing.Optional[PhoneProviderCredentials] = OMIT, configuration: typing.Optional[PhoneProviderConfiguration] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[UpdateBrandingPhoneProviderResponseContent]: """ Update a [phone provider](https://auth0.com/docs/customize/phone-messages/configure-phone-messaging-providers). The `credentials` object requires different properties depending on the phone provider (which is specified using the `name` property). Parameters ---------- id : str name : typing.Optional[PhoneProviderNameEnum] disabled : typing.Optional[bool] Whether the provider is enabled (false) or disabled (true). credentials : typing.Optional[PhoneProviderCredentials] configuration : typing.Optional[PhoneProviderConfiguration] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[UpdateBrandingPhoneProviderResponseContent] Phone provider successfully updated. """ _response = await self._client_wrapper.httpx_client.request( f"branding/phone/providers/{encode_path_param(id)}", method="PATCH", json={ "name": name, "disabled": disabled, "credentials": convert_and_respect_annotation_metadata( object_=credentials, annotation=PhoneProviderCredentials, direction="write" ), "configuration": convert_and_respect_annotation_metadata( object_=configuration, annotation=PhoneProviderConfiguration, direction="write" ), }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( UpdateBrandingPhoneProviderResponseContent, parse_obj_as( type_=UpdateBrandingPhoneProviderResponseContent, # 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 == 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 test( self, id: str, *, to: str, delivery_method: typing.Optional[PhoneProviderDeliveryMethodEnum] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[CreatePhoneProviderSendTestResponseContent]: """ Parameters ---------- id : str to : str The recipient phone number to receive a given notification. delivery_method : typing.Optional[PhoneProviderDeliveryMethodEnum] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[CreatePhoneProviderSendTestResponseContent] Phone notification sent. """ _response = await self._client_wrapper.httpx_client.request( f"branding/phone/providers/{encode_path_param(id)}/try", method="POST", json={ "to": to, "delivery_method": delivery_method, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreatePhoneProviderSendTestResponseContent, parse_obj_as( type_=CreatePhoneProviderSendTestResponseContent, # 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 == 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)