# 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 ..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.client_grant_allow_any_organization_enum import ClientGrantAllowAnyOrganizationEnum from ..types.client_grant_default_for_enum import ClientGrantDefaultForEnum from ..types.client_grant_organization_nullable_usage_enum import ClientGrantOrganizationNullableUsageEnum from ..types.client_grant_organization_usage_enum import ClientGrantOrganizationUsageEnum from ..types.client_grant_response_content import ClientGrantResponseContent from ..types.client_grant_subject_type_enum import ClientGrantSubjectTypeEnum from ..types.create_client_grant_response_content import CreateClientGrantResponseContent from ..types.get_client_grant_response_content import GetClientGrantResponseContent from ..types.list_client_grant_paginated_response_content import ListClientGrantPaginatedResponseContent from ..types.update_client_grant_response_content import UpdateClientGrantResponseContent from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class RawClientGrantsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def list( self, *, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, audience: typing.Optional[str] = None, client_id: typing.Optional[str] = None, allow_any_organization: typing.Optional[ClientGrantAllowAnyOrganizationEnum] = None, subject_type: typing.Optional[ClientGrantSubjectTypeEnum] = None, default_for: typing.Optional[ClientGrantDefaultForEnum] = None, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[ClientGrantResponseContent, ListClientGrantPaginatedResponseContent]: """ Retrieve a list of [client grants](https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants), including the scopes associated with the application/API pair. Parameters ---------- from_ : typing.Optional[str] Optional Id from which to start selection. take : typing.Optional[int] Number of results per page. Defaults to 50. audience : typing.Optional[str] Optional filter on audience. client_id : typing.Optional[str] Optional filter on client_id. allow_any_organization : typing.Optional[ClientGrantAllowAnyOrganizationEnum] Optional filter on allow_any_organization. subject_type : typing.Optional[ClientGrantSubjectTypeEnum] The type of application access the client grant allows. default_for : typing.Optional[ClientGrantDefaultForEnum] Applies this client grant as the default for all clients in the specified group. The only accepted value is `third_party_clients`, which applies the grant to all third-party clients. Per-client grants for the same audience take precedence. Mutually exclusive with `client_id`. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- SyncPager[ClientGrantResponseContent, ListClientGrantPaginatedResponseContent] Client grants successfully retrieved. """ _response = self._client_wrapper.httpx_client.request( "client-grants", method="GET", params={ "from": from_, "take": take, "audience": audience, "client_id": client_id, "allow_any_organization": allow_any_organization, "subject_type": subject_type, "default_for": default_for, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _parsed_response = typing.cast( ListClientGrantPaginatedResponseContent, parse_obj_as( type_=ListClientGrantPaginatedResponseContent, # type: ignore object_=_response.json(), ), ) _items = _parsed_response.client_grants _parsed_next = _parsed_response.next _has_next = _parsed_next is not None and _parsed_next != "" _get_next = lambda: self.list( from_=_parsed_next, take=take, audience=audience, client_id=client_id, allow_any_organization=allow_any_organization, subject_type=subject_type, default_for=default_for, request_options=request_options, ) return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) 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, *, audience: str, client_id: typing.Optional[str] = OMIT, default_for: typing.Optional[ClientGrantDefaultForEnum] = OMIT, organization_usage: typing.Optional[ClientGrantOrganizationUsageEnum] = OMIT, allow_any_organization: typing.Optional[bool] = OMIT, scope: typing.Optional[typing.Sequence[str]] = OMIT, subject_type: typing.Optional[ClientGrantSubjectTypeEnum] = OMIT, authorization_details_types: typing.Optional[typing.Sequence[str]] = OMIT, allow_all_scopes: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[CreateClientGrantResponseContent]: """ Create a client grant for a machine-to-machine login flow. To learn more, read [Client Credential Flow](https://www.auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow). Parameters ---------- audience : str The audience (API identifier) of this client grant client_id : typing.Optional[str] ID of the client. default_for : typing.Optional[ClientGrantDefaultForEnum] organization_usage : typing.Optional[ClientGrantOrganizationUsageEnum] allow_any_organization : typing.Optional[bool] If enabled, any organization can be used with this grant. If disabled (default), the grant must be explicitly assigned to the desired organizations. scope : typing.Optional[typing.Sequence[str]] Scopes allowed for this client grant. subject_type : typing.Optional[ClientGrantSubjectTypeEnum] authorization_details_types : typing.Optional[typing.Sequence[str]] Types of authorization_details allowed for this client grant. allow_all_scopes : typing.Optional[bool] If enabled, all scopes configured on the resource server are allowed for this grant. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[CreateClientGrantResponseContent] Client grant successfully created. """ _response = self._client_wrapper.httpx_client.request( "client-grants", method="POST", json={ "client_id": client_id, "audience": audience, "default_for": default_for, "organization_usage": organization_usage, "allow_any_organization": allow_any_organization, "scope": scope, "subject_type": subject_type, "authorization_details_types": authorization_details_types, "allow_all_scopes": allow_all_scopes, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateClientGrantResponseContent, parse_obj_as( type_=CreateClientGrantResponseContent, # 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 get( self, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[GetClientGrantResponseContent]: """ Retrieve a single [client grant](https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants), including the scopes associated with the application/API pair. Parameters ---------- id : str The ID of the client grant to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[GetClientGrantResponseContent] Client grant successfully retrieved. """ _response = self._client_wrapper.httpx_client.request( f"client-grants/{encode_path_param(id)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetClientGrantResponseContent, parse_obj_as( type_=GetClientGrantResponseContent, # 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, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: """ Delete the [Client Credential Flow](https://www.auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow) from your machine-to-machine application. Parameters ---------- id : str ID of the client grant to delete. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[None] """ _response = self._client_wrapper.httpx_client.request( f"client-grants/{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 == 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 update( self, id: str, *, scope: typing.Optional[typing.Sequence[str]] = OMIT, organization_usage: typing.Optional[ClientGrantOrganizationNullableUsageEnum] = OMIT, allow_any_organization: typing.Optional[bool] = OMIT, authorization_details_types: typing.Optional[typing.Sequence[str]] = OMIT, allow_all_scopes: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[UpdateClientGrantResponseContent]: """ Update a client grant. Parameters ---------- id : str ID of the client grant to update. scope : typing.Optional[typing.Sequence[str]] Scopes allowed for this client grant. organization_usage : typing.Optional[ClientGrantOrganizationNullableUsageEnum] allow_any_organization : typing.Optional[bool] Controls allowing any organization to be used with this grant authorization_details_types : typing.Optional[typing.Sequence[str]] Types of authorization_details allowed for this client grant. allow_all_scopes : typing.Optional[bool] If enabled, all scopes configured on the resource server are allowed for this grant. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[UpdateClientGrantResponseContent] Client grant successfully updated. """ _response = self._client_wrapper.httpx_client.request( f"client-grants/{encode_path_param(id)}", method="PATCH", json={ "scope": scope, "organization_usage": organization_usage, "allow_any_organization": allow_any_organization, "authorization_details_types": authorization_details_types, "allow_all_scopes": allow_all_scopes, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( UpdateClientGrantResponseContent, parse_obj_as( type_=UpdateClientGrantResponseContent, # 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 AsyncRawClientGrantsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def list( self, *, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, audience: typing.Optional[str] = None, client_id: typing.Optional[str] = None, allow_any_organization: typing.Optional[ClientGrantAllowAnyOrganizationEnum] = None, subject_type: typing.Optional[ClientGrantSubjectTypeEnum] = None, default_for: typing.Optional[ClientGrantDefaultForEnum] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[ClientGrantResponseContent, ListClientGrantPaginatedResponseContent]: """ Retrieve a list of [client grants](https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants), including the scopes associated with the application/API pair. Parameters ---------- from_ : typing.Optional[str] Optional Id from which to start selection. take : typing.Optional[int] Number of results per page. Defaults to 50. audience : typing.Optional[str] Optional filter on audience. client_id : typing.Optional[str] Optional filter on client_id. allow_any_organization : typing.Optional[ClientGrantAllowAnyOrganizationEnum] Optional filter on allow_any_organization. subject_type : typing.Optional[ClientGrantSubjectTypeEnum] The type of application access the client grant allows. default_for : typing.Optional[ClientGrantDefaultForEnum] Applies this client grant as the default for all clients in the specified group. The only accepted value is `third_party_clients`, which applies the grant to all third-party clients. Per-client grants for the same audience take precedence. Mutually exclusive with `client_id`. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncPager[ClientGrantResponseContent, ListClientGrantPaginatedResponseContent] Client grants successfully retrieved. """ _response = await self._client_wrapper.httpx_client.request( "client-grants", method="GET", params={ "from": from_, "take": take, "audience": audience, "client_id": client_id, "allow_any_organization": allow_any_organization, "subject_type": subject_type, "default_for": default_for, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _parsed_response = typing.cast( ListClientGrantPaginatedResponseContent, parse_obj_as( type_=ListClientGrantPaginatedResponseContent, # type: ignore object_=_response.json(), ), ) _items = _parsed_response.client_grants _parsed_next = _parsed_response.next _has_next = _parsed_next is not None and _parsed_next != "" async def _get_next(): return await self.list( from_=_parsed_next, take=take, audience=audience, client_id=client_id, allow_any_organization=allow_any_organization, subject_type=subject_type, default_for=default_for, request_options=request_options, ) return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) 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, *, audience: str, client_id: typing.Optional[str] = OMIT, default_for: typing.Optional[ClientGrantDefaultForEnum] = OMIT, organization_usage: typing.Optional[ClientGrantOrganizationUsageEnum] = OMIT, allow_any_organization: typing.Optional[bool] = OMIT, scope: typing.Optional[typing.Sequence[str]] = OMIT, subject_type: typing.Optional[ClientGrantSubjectTypeEnum] = OMIT, authorization_details_types: typing.Optional[typing.Sequence[str]] = OMIT, allow_all_scopes: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[CreateClientGrantResponseContent]: """ Create a client grant for a machine-to-machine login flow. To learn more, read [Client Credential Flow](https://www.auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow). Parameters ---------- audience : str The audience (API identifier) of this client grant client_id : typing.Optional[str] ID of the client. default_for : typing.Optional[ClientGrantDefaultForEnum] organization_usage : typing.Optional[ClientGrantOrganizationUsageEnum] allow_any_organization : typing.Optional[bool] If enabled, any organization can be used with this grant. If disabled (default), the grant must be explicitly assigned to the desired organizations. scope : typing.Optional[typing.Sequence[str]] Scopes allowed for this client grant. subject_type : typing.Optional[ClientGrantSubjectTypeEnum] authorization_details_types : typing.Optional[typing.Sequence[str]] Types of authorization_details allowed for this client grant. allow_all_scopes : typing.Optional[bool] If enabled, all scopes configured on the resource server are allowed for this grant. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[CreateClientGrantResponseContent] Client grant successfully created. """ _response = await self._client_wrapper.httpx_client.request( "client-grants", method="POST", json={ "client_id": client_id, "audience": audience, "default_for": default_for, "organization_usage": organization_usage, "allow_any_organization": allow_any_organization, "scope": scope, "subject_type": subject_type, "authorization_details_types": authorization_details_types, "allow_all_scopes": allow_all_scopes, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateClientGrantResponseContent, parse_obj_as( type_=CreateClientGrantResponseContent, # 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 get( self, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[GetClientGrantResponseContent]: """ Retrieve a single [client grant](https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants), including the scopes associated with the application/API pair. Parameters ---------- id : str The ID of the client grant to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[GetClientGrantResponseContent] Client grant successfully retrieved. """ _response = await self._client_wrapper.httpx_client.request( f"client-grants/{encode_path_param(id)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetClientGrantResponseContent, parse_obj_as( type_=GetClientGrantResponseContent, # 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, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[None]: """ Delete the [Client Credential Flow](https://www.auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow) from your machine-to-machine application. Parameters ---------- id : str ID of the client grant to delete. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[None] """ _response = await self._client_wrapper.httpx_client.request( f"client-grants/{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 == 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 update( self, id: str, *, scope: typing.Optional[typing.Sequence[str]] = OMIT, organization_usage: typing.Optional[ClientGrantOrganizationNullableUsageEnum] = OMIT, allow_any_organization: typing.Optional[bool] = OMIT, authorization_details_types: typing.Optional[typing.Sequence[str]] = OMIT, allow_all_scopes: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[UpdateClientGrantResponseContent]: """ Update a client grant. Parameters ---------- id : str ID of the client grant to update. scope : typing.Optional[typing.Sequence[str]] Scopes allowed for this client grant. organization_usage : typing.Optional[ClientGrantOrganizationNullableUsageEnum] allow_any_organization : typing.Optional[bool] Controls allowing any organization to be used with this grant authorization_details_types : typing.Optional[typing.Sequence[str]] Types of authorization_details allowed for this client grant. allow_all_scopes : typing.Optional[bool] If enabled, all scopes configured on the resource server are allowed for this grant. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[UpdateClientGrantResponseContent] Client grant successfully updated. """ _response = await self._client_wrapper.httpx_client.request( f"client-grants/{encode_path_param(id)}", method="PATCH", json={ "scope": scope, "organization_usage": organization_usage, "allow_any_organization": allow_any_organization, "authorization_details_types": authorization_details_types, "allow_all_scopes": allow_all_scopes, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( UpdateClientGrantResponseContent, parse_obj_as( type_=UpdateClientGrantResponseContent, # 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)