# 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.create_organization_discovery_domain_response_content import ( CreateOrganizationDiscoveryDomainResponseContent, ) from ...types.get_organization_discovery_domain_by_name_response_content import ( GetOrganizationDiscoveryDomainByNameResponseContent, ) from ...types.get_organization_discovery_domain_response_content import GetOrganizationDiscoveryDomainResponseContent from ...types.list_organization_discovery_domains_response_content import ( ListOrganizationDiscoveryDomainsResponseContent, ) from ...types.organization_discovery_domain import OrganizationDiscoveryDomain from ...types.organization_discovery_domain_status import OrganizationDiscoveryDomainStatus from ...types.update_organization_discovery_domain_response_content import ( UpdateOrganizationDiscoveryDomainResponseContent, ) from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class RawDiscoveryDomainsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def list( self, id: str, *, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[OrganizationDiscoveryDomain, ListOrganizationDiscoveryDomainsResponseContent]: """ Retrieve list of all organization discovery domains associated with the specified organization. This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response. Parameters ---------- id : str ID of the organization. from_ : typing.Optional[str] Optional Id from which to start selection. take : typing.Optional[int] Number of results per page. Defaults to 50. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- SyncPager[OrganizationDiscoveryDomain, ListOrganizationDiscoveryDomainsResponseContent] Organization discovery domains retrieved successfully. """ _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains", method="GET", params={ "from": from_, "take": take, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _parsed_response = typing.cast( ListOrganizationDiscoveryDomainsResponseContent, parse_obj_as( type_=ListOrganizationDiscoveryDomainsResponseContent, # type: ignore object_=_response.json(), ), ) _items = _parsed_response.domains _parsed_next = _parsed_response.next _has_next = _parsed_next is not None and _parsed_next != "" _get_next = lambda: self.list( id, from_=_parsed_next, take=take, 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, *, domain: str, status: typing.Optional[OrganizationDiscoveryDomainStatus] = OMIT, use_for_organization_discovery: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[CreateOrganizationDiscoveryDomainResponseContent]: """ Create a new discovery domain for an organization. Parameters ---------- id : str ID of the organization. domain : str The domain name to associate with the organization e.g. acme.com. status : typing.Optional[OrganizationDiscoveryDomainStatus] use_for_organization_discovery : typing.Optional[bool] Indicates whether this domain should be used for organization discovery. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[CreateOrganizationDiscoveryDomainResponseContent] Organization discovery domain successfully created. """ _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains", method="POST", json={ "domain": domain, "status": status, "use_for_organization_discovery": use_for_organization_discovery, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateOrganizationDiscoveryDomainResponseContent, parse_obj_as( type_=CreateOrganizationDiscoveryDomainResponseContent, # 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_by_name( self, id: str, discovery_domain: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[GetOrganizationDiscoveryDomainByNameResponseContent]: """ Retrieve details about a single organization discovery domain specified by domain name. This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response. Parameters ---------- id : str ID of the organization. discovery_domain : str Domain name of the discovery domain. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[GetOrganizationDiscoveryDomainByNameResponseContent] Organization discovery domain successfully retrieved. """ _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains/name/{encode_path_param(discovery_domain)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetOrganizationDiscoveryDomainByNameResponseContent, parse_obj_as( type_=GetOrganizationDiscoveryDomainByNameResponseContent, # 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, discovery_domain_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[GetOrganizationDiscoveryDomainResponseContent]: """ Retrieve details about a single organization discovery domain specified by ID. This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response. Parameters ---------- id : str ID of the organization. discovery_domain_id : str ID of the discovery domain. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[GetOrganizationDiscoveryDomainResponseContent] Organization discovery domain successfully retrieved. """ _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetOrganizationDiscoveryDomainResponseContent, parse_obj_as( type_=GetOrganizationDiscoveryDomainResponseContent, # 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, discovery_domain_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[None]: """ Remove a discovery domain from an organization. This action cannot be undone. Parameters ---------- id : str ID of the organization. discovery_domain_id : str ID of the discovery domain. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[None] """ _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_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, discovery_domain_id: str, *, status: typing.Optional[OrganizationDiscoveryDomainStatus] = OMIT, use_for_organization_discovery: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[UpdateOrganizationDiscoveryDomainResponseContent]: """ Update the verification status and/or use_for_organization_discovery for an organization discovery domain. The `status` field must be either `pending` or `verified`. The `use_for_organization_discovery` field can be `true` or `false` (default: `true`). Parameters ---------- id : str ID of the organization. discovery_domain_id : str ID of the discovery domain to update. status : typing.Optional[OrganizationDiscoveryDomainStatus] use_for_organization_discovery : typing.Optional[bool] Indicates whether this domain should be used for organization discovery. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- HttpResponse[UpdateOrganizationDiscoveryDomainResponseContent] Organization discovery domain successfully updated. """ _response = self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}", method="PATCH", json={ "status": status, "use_for_organization_discovery": use_for_organization_discovery, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( UpdateOrganizationDiscoveryDomainResponseContent, parse_obj_as( type_=UpdateOrganizationDiscoveryDomainResponseContent, # 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 == 404: raise NotFoundError( 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 AsyncRawDiscoveryDomainsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def list( self, id: str, *, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[OrganizationDiscoveryDomain, ListOrganizationDiscoveryDomainsResponseContent]: """ Retrieve list of all organization discovery domains associated with the specified organization. This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response. Parameters ---------- id : str ID of the organization. from_ : typing.Optional[str] Optional Id from which to start selection. take : typing.Optional[int] Number of results per page. Defaults to 50. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncPager[OrganizationDiscoveryDomain, ListOrganizationDiscoveryDomainsResponseContent] Organization discovery domains retrieved successfully. """ _response = await self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains", method="GET", params={ "from": from_, "take": take, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: _parsed_response = typing.cast( ListOrganizationDiscoveryDomainsResponseContent, parse_obj_as( type_=ListOrganizationDiscoveryDomainsResponseContent, # type: ignore object_=_response.json(), ), ) _items = _parsed_response.domains _parsed_next = _parsed_response.next _has_next = _parsed_next is not None and _parsed_next != "" async def _get_next(): return await self.list( id, from_=_parsed_next, take=take, 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, *, domain: str, status: typing.Optional[OrganizationDiscoveryDomainStatus] = OMIT, use_for_organization_discovery: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[CreateOrganizationDiscoveryDomainResponseContent]: """ Create a new discovery domain for an organization. Parameters ---------- id : str ID of the organization. domain : str The domain name to associate with the organization e.g. acme.com. status : typing.Optional[OrganizationDiscoveryDomainStatus] use_for_organization_discovery : typing.Optional[bool] Indicates whether this domain should be used for organization discovery. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[CreateOrganizationDiscoveryDomainResponseContent] Organization discovery domain successfully created. """ _response = await self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains", method="POST", json={ "domain": domain, "status": status, "use_for_organization_discovery": use_for_organization_discovery, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( CreateOrganizationDiscoveryDomainResponseContent, parse_obj_as( type_=CreateOrganizationDiscoveryDomainResponseContent, # 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_by_name( self, id: str, discovery_domain: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[GetOrganizationDiscoveryDomainByNameResponseContent]: """ Retrieve details about a single organization discovery domain specified by domain name. This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response. Parameters ---------- id : str ID of the organization. discovery_domain : str Domain name of the discovery domain. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[GetOrganizationDiscoveryDomainByNameResponseContent] Organization discovery domain successfully retrieved. """ _response = await self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains/name/{encode_path_param(discovery_domain)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetOrganizationDiscoveryDomainByNameResponseContent, parse_obj_as( type_=GetOrganizationDiscoveryDomainByNameResponseContent, # 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, discovery_domain_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[GetOrganizationDiscoveryDomainResponseContent]: """ Retrieve details about a single organization discovery domain specified by ID. This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response. Parameters ---------- id : str ID of the organization. discovery_domain_id : str ID of the discovery domain. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[GetOrganizationDiscoveryDomainResponseContent] Organization discovery domain successfully retrieved. """ _response = await self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( GetOrganizationDiscoveryDomainResponseContent, parse_obj_as( type_=GetOrganizationDiscoveryDomainResponseContent, # 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, discovery_domain_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[None]: """ Remove a discovery domain from an organization. This action cannot be undone. Parameters ---------- id : str ID of the organization. discovery_domain_id : str ID of the discovery domain. 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)}/discovery-domains/{encode_path_param(discovery_domain_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, discovery_domain_id: str, *, status: typing.Optional[OrganizationDiscoveryDomainStatus] = OMIT, use_for_organization_discovery: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[UpdateOrganizationDiscoveryDomainResponseContent]: """ Update the verification status and/or use_for_organization_discovery for an organization discovery domain. The `status` field must be either `pending` or `verified`. The `use_for_organization_discovery` field can be `true` or `false` (default: `true`). Parameters ---------- id : str ID of the organization. discovery_domain_id : str ID of the discovery domain to update. status : typing.Optional[OrganizationDiscoveryDomainStatus] use_for_organization_discovery : typing.Optional[bool] Indicates whether this domain should be used for organization discovery. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncHttpResponse[UpdateOrganizationDiscoveryDomainResponseContent] Organization discovery domain successfully updated. """ _response = await self._client_wrapper.httpx_client.request( f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}", method="PATCH", json={ "status": status, "use_for_organization_discovery": use_for_organization_discovery, }, headers={ "content-type": "application/json", }, request_options=request_options, omit=OMIT, ) try: if 200 <= _response.status_code < 300: _data = typing.cast( UpdateOrganizationDiscoveryDomainResponseContent, parse_obj_as( type_=UpdateOrganizationDiscoveryDomainResponseContent, # 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 == 404: raise NotFoundError( 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)