# 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.pagination import AsyncPager, SyncPager 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.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.app_metadata import AppMetadata from ...types.create_organization_invitation_response_content import CreateOrganizationInvitationResponseContent from ...types.get_organization_invitation_response_content import GetOrganizationInvitationResponseContent from ...types.list_organization_invitations_offset_paginated_response_content import ( ListOrganizationInvitationsOffsetPaginatedResponseContent, ) from ...types.organization_invitation import OrganizationInvitation from ...types.organization_invitation_invitee import OrganizationInvitationInvitee from ...types.organization_invitation_inviter import OrganizationInvitationInviter from ...types.user_metadata import UserMetadata from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class RawInvitationsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def list( self, id: str, *, page: typing.Optional[int] = 0, per_page: typing.Optional[int] = 50, include_totals: typing.Optional[bool] = True, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, sort: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[OrganizationInvitation, ListOrganizationInvitationsOffsetPaginatedResponseContent]: """ Retrieve a detailed list of invitations sent to users for a specific Organization. The list includes details such as inviter and invitee information, invitation URLs, and dates of creation and expiration. To learn more about Organization invitations, review [Invite Organization Members](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members). Parameters ---------- id : str Organization identifier. page : typing.Optional[int] Page index of the results to return. First page is 0. per_page : typing.Optional[int] Number of results per page. Defaults to 50. include_totals : typing.Optional[bool] When true, return results inside an object that also contains the start and limit. When false (default), a direct array of results is returned. We do not yet support returning the total invitations count. fields : typing.Optional[str] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). Defaults to true. sort : typing.Optional[str] Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- SyncPager[OrganizationInvitation, ListOrganizationInvitationsOffsetPaginatedResponseContent] Invitations successfully retrieved. """ page = page if page is not None else 0 _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/invitations", method="GET", params={ "page": page, "per_page": per_page, "include_totals": include_totals, "fields": fields, "include_fields": include_fields, "sort": sort, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _parsed_response = typing.cast( ListOrganizationInvitationsOffsetPaginatedResponseContent, parse_obj_as( type_=ListOrganizationInvitationsOffsetPaginatedResponseContent, # type: ignore object_=_response.json(), ), ) _items = _parsed_response.invitations _has_next = len(_items or []) > 0 _get_next = lambda: self.list( id, page=page + 1, per_page=per_page, include_totals=include_totals, fields=fields, include_fields=include_fields, sort=sort, request_options=request_options, ) return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) 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 create( self, id: str, *, inviter: OrganizationInvitationInviter, invitee: OrganizationInvitationInvitee, client_id: str, connection_id: typing.Optional[str] = OMIT, app_metadata: typing.Optional[AppMetadata] = OMIT, user_metadata: typing.Optional[UserMetadata] = OMIT, ttl_sec: typing.Optional[int] = OMIT, roles: typing.Optional[typing.Sequence[str]] = OMIT, send_invitation_email: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[CreateOrganizationInvitationResponseContent]: """ Create a user invitation for a specific Organization. Upon creation, the listed user receives an email inviting them to join the Organization. To learn more about Organization invitations, review [Invite Organization Members](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members). Parameters ---------- id : str Organization identifier. inviter : OrganizationInvitationInviter invitee : OrganizationInvitationInvitee client_id : str Auth0 client ID. Used to resolve the application's login initiation endpoint. connection_id : typing.Optional[str] The id of the connection to force invitee to authenticate with. app_metadata : typing.Optional[AppMetadata] user_metadata : typing.Optional[UserMetadata] ttl_sec : typing.Optional[int] Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Max value: 2592000 seconds (30 days). roles : typing.Optional[typing.Sequence[str]] List of roles IDs to associated with the user. send_invitation_email : typing.Optional[bool] Whether the user will receive an invitation email (true) or no email (false), true by default request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[CreateOrganizationInvitationResponseContent] Invitation successfully created. """ _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/invitations", method="POST", json={ "inviter": convert_and_respect_annotation_metadata( object_=inviter, annotation=OrganizationInvitationInviter, direction="write" ), "invitee": convert_and_respect_annotation_metadata( object_=invitee, annotation=OrganizationInvitationInvitee, direction="write" ), "client_id": client_id, "connection_id": connection_id, "app_metadata": app_metadata, "user_metadata": user_metadata, "ttl_sec": ttl_sec, "roles": roles, "send_invitation_email": send_invitation_email, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateOrganizationInvitationResponseContent, parse_obj_as( type_=CreateOrganizationInvitationResponseContent, # 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 get( self, id: str, invitation_id: str, *, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[GetOrganizationInvitationResponseContent]: """ Parameters ---------- id : str Organization identifier. invitation_id : str The id of the user invitation. fields : typing.Optional[str] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). Defaults to true. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[GetOrganizationInvitationResponseContent] Invitation successfully retrieved. """ _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/invitations/{encode_path_param(invitation_id)}", method="GET", params={ "fields": fields, "include_fields": include_fields, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetOrganizationInvitationResponseContent, parse_obj_as( type_=GetOrganizationInvitationResponseContent, # 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, invitation_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[None]: """ Parameters ---------- id : str Organization identifier. invitation_id : str The id of the user invitation. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[None] """ _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/invitations/{encode_path_param(invitation_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) class AsyncRawInvitationsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def list( self, id: str, *, page: typing.Optional[int] = 0, per_page: typing.Optional[int] = 50, include_totals: typing.Optional[bool] = True, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, sort: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[OrganizationInvitation, ListOrganizationInvitationsOffsetPaginatedResponseContent]: """ Retrieve a detailed list of invitations sent to users for a specific Organization. The list includes details such as inviter and invitee information, invitation URLs, and dates of creation and expiration. To learn more about Organization invitations, review [Invite Organization Members](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members). Parameters ---------- id : str Organization identifier. page : typing.Optional[int] Page index of the results to return. First page is 0. per_page : typing.Optional[int] Number of results per page. Defaults to 50. include_totals : typing.Optional[bool] When true, return results inside an object that also contains the start and limit. When false (default), a direct array of results is returned. We do not yet support returning the total invitations count. fields : typing.Optional[str] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). Defaults to true. sort : typing.Optional[str] Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncPager[OrganizationInvitation, ListOrganizationInvitationsOffsetPaginatedResponseContent] Invitations successfully retrieved. """ page = page if page is not None else 0 _response = await self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/invitations", method="GET", params={ "page": page, "per_page": per_page, "include_totals": include_totals, "fields": fields, "include_fields": include_fields, "sort": sort, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _parsed_response = typing.cast( ListOrganizationInvitationsOffsetPaginatedResponseContent, parse_obj_as( type_=ListOrganizationInvitationsOffsetPaginatedResponseContent, # type: ignore object_=_response.json(), ), ) _items = _parsed_response.invitations _has_next = len(_items or []) > 0 async def _get_next(): return await self.list( id, page=page + 1, per_page=per_page, include_totals=include_totals, fields=fields, include_fields=include_fields, sort=sort, request_options=request_options, ) return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) 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 create( self, id: str, *, inviter: OrganizationInvitationInviter, invitee: OrganizationInvitationInvitee, client_id: str, connection_id: typing.Optional[str] = OMIT, app_metadata: typing.Optional[AppMetadata] = OMIT, user_metadata: typing.Optional[UserMetadata] = OMIT, ttl_sec: typing.Optional[int] = OMIT, roles: typing.Optional[typing.Sequence[str]] = OMIT, send_invitation_email: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[CreateOrganizationInvitationResponseContent]: """ Create a user invitation for a specific Organization. Upon creation, the listed user receives an email inviting them to join the Organization. To learn more about Organization invitations, review [Invite Organization Members](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members). Parameters ---------- id : str Organization identifier. inviter : OrganizationInvitationInviter invitee : OrganizationInvitationInvitee client_id : str Auth0 client ID. Used to resolve the application's login initiation endpoint. connection_id : typing.Optional[str] The id of the connection to force invitee to authenticate with. app_metadata : typing.Optional[AppMetadata] user_metadata : typing.Optional[UserMetadata] ttl_sec : typing.Optional[int] Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Max value: 2592000 seconds (30 days). roles : typing.Optional[typing.Sequence[str]] List of roles IDs to associated with the user. send_invitation_email : typing.Optional[bool] Whether the user will receive an invitation email (true) or no email (false), true by default request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[CreateOrganizationInvitationResponseContent] Invitation successfully created. """ _response = await self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/invitations", method="POST", json={ "inviter": convert_and_respect_annotation_metadata( object_=inviter, annotation=OrganizationInvitationInviter, direction="write" ), "invitee": convert_and_respect_annotation_metadata( object_=invitee, annotation=OrganizationInvitationInvitee, direction="write" ), "client_id": client_id, "connection_id": connection_id, "app_metadata": app_metadata, "user_metadata": user_metadata, "ttl_sec": ttl_sec, "roles": roles, "send_invitation_email": send_invitation_email, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateOrganizationInvitationResponseContent, parse_obj_as( type_=CreateOrganizationInvitationResponseContent, # 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 get( self, id: str, invitation_id: str, *, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[GetOrganizationInvitationResponseContent]: """ Parameters ---------- id : str Organization identifier. invitation_id : str The id of the user invitation. fields : typing.Optional[str] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). Defaults to true. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[GetOrganizationInvitationResponseContent] Invitation successfully retrieved. """ _response = await self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/invitations/{encode_path_param(invitation_id)}", method="GET", params={ "fields": fields, "include_fields": include_fields, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetOrganizationInvitationResponseContent, parse_obj_as( type_=GetOrganizationInvitationResponseContent, # 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, invitation_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[None]: """ Parameters ---------- id : str Organization identifier. invitation_id : str The id of the user invitation. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[None] """ _response = await self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/invitations/{encode_path_param(invitation_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)