Debian Codegraph @

src/auth0/management/organizations/discovery_domains/raw_client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 import typing
4 from json.decoder import JSONDecodeError
5
6 from ...core.api_error import ApiError
7 from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8 from ...core.http_response import AsyncHttpResponse, HttpResponse
9 from ...core.jsonable_encoder import encode_path_param
10 from ...core.pagination import AsyncPager, SyncPager
11 from ...core.parse_error import ParsingError
12 from ...core.pydantic_utilities import parse_obj_as
13 from ...core.request_options import RequestOptions
14 from ...errors.bad_request_error import BadRequestError
15 from ...errors.conflict_error import ConflictError
16 from ...errors.forbidden_error import ForbiddenError
17 from ...errors.not_found_error import NotFoundError
18 from ...errors.too_many_requests_error import TooManyRequestsError
19 from ...errors.unauthorized_error import UnauthorizedError
20 from ...types.create_organization_discovery_domain_response_content import (
21 CreateOrganizationDiscoveryDomainResponseContent,
22 )
23 from ...types.get_organization_discovery_domain_by_name_response_content import (
24 GetOrganizationDiscoveryDomainByNameResponseContent,
25 )
26 from ...types.get_organization_discovery_domain_response_content import GetOrganizationDiscoveryDomainResponseContent
27 from ...types.list_organization_discovery_domains_response_content import (
28 ListOrganizationDiscoveryDomainsResponseContent,
29 )
30 from ...types.organization_discovery_domain import OrganizationDiscoveryDomain
31 from ...types.organization_discovery_domain_status import OrganizationDiscoveryDomainStatus
32 from ...types.update_organization_discovery_domain_response_content import (
33 UpdateOrganizationDiscoveryDomainResponseContent,
34 )
35 from pydantic import ValidationError
36
37 # this is used as the default value for optional parameters
38 OMIT = typing.cast(typing.Any, ...)
39
40
41 class RawDiscoveryDomainsClient:
42 def __init__(self, *, client_wrapper: SyncClientWrapper):
43 self._client_wrapper = client_wrapper
44
45 def list(
46 self,
47 id: str,
48 *,
49 from_: typing.Optional[str] = None,
50 take: typing.Optional[int] = 50,
51 request_options: typing.Optional[RequestOptions] = None,
52 ) -> SyncPager[OrganizationDiscoveryDomain, ListOrganizationDiscoveryDomainsResponseContent]:
53 """
54 Retrieve list of all organization discovery domains associated with the specified organization.
55 This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response.
56
57 Parameters
58 ----------
59 id : str
60 ID of the organization.
61
62 from_ : typing.Optional[str]
63 Optional Id from which to start selection.
64
65 take : typing.Optional[int]
66 Number of results per page. Defaults to 50.
67
68 request_options : typing.Optional[RequestOptions]
69 Request-specific configuration.
70
71 Returns
72 -------
73 SyncPager[OrganizationDiscoveryDomain, ListOrganizationDiscoveryDomainsResponseContent]
74 Organization discovery domains retrieved successfully.
75 """
76 _response = self._client_wrapper.httpx_client.request(
77 f"organizations/{encode_path_param(id)}/discovery-domains",
78 method="GET",
79 params={
80 "from": from_,
81 "take": take,
82 },
83 request_options=request_options,
84 )
85 try:
86 if 200 <= _response.status_code < 300:
87 _parsed_response = typing.cast(
88 ListOrganizationDiscoveryDomainsResponseContent,
89 parse_obj_as(
90 type_=ListOrganizationDiscoveryDomainsResponseContent, # type: ignore
91 object_=_response.json(),
92 ),
93 )
94 _items = _parsed_response.domains
95 _parsed_next = _parsed_response.next
96 _has_next = _parsed_next is not None and _parsed_next != ""
97 _get_next = lambda: self.list(
98 id,
99 from_=_parsed_next,
100 take=take,
101 request_options=request_options,
102 )
103 return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
104 if _response.status_code == 400:
105 raise BadRequestError(
106 headers=dict(_response.headers),
107 body=typing.cast(
108 typing.Any,
109 parse_obj_as(
110 type_=typing.Any, # type: ignore
111 object_=_response.json(),
112 ),
113 ),
114 )
115 if _response.status_code == 401:
116 raise UnauthorizedError(
117 headers=dict(_response.headers),
118 body=typing.cast(
119 typing.Any,
120 parse_obj_as(
121 type_=typing.Any, # type: ignore
122 object_=_response.json(),
123 ),
124 ),
125 )
126 if _response.status_code == 403:
127 raise ForbiddenError(
128 headers=dict(_response.headers),
129 body=typing.cast(
130 typing.Any,
131 parse_obj_as(
132 type_=typing.Any, # type: ignore
133 object_=_response.json(),
134 ),
135 ),
136 )
137 if _response.status_code == 404:
138 raise NotFoundError(
139 headers=dict(_response.headers),
140 body=typing.cast(
141 typing.Any,
142 parse_obj_as(
143 type_=typing.Any, # type: ignore
144 object_=_response.json(),
145 ),
146 ),
147 )
148 if _response.status_code == 429:
149 raise TooManyRequestsError(
150 headers=dict(_response.headers),
151 body=typing.cast(
152 typing.Any,
153 parse_obj_as(
154 type_=typing.Any, # type: ignore
155 object_=_response.json(),
156 ),
157 ),
158 )
159 _response_json = _response.json()
160 except JSONDecodeError:
161 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
162 except ValidationError as e:
163 raise ParsingError(
164 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
165 )
166 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
167
168 def create(
169 self,
170 id: str,
171 *,
172 domain: str,
173 status: typing.Optional[OrganizationDiscoveryDomainStatus] = OMIT,
174 use_for_organization_discovery: typing.Optional[bool] = OMIT,
175 request_options: typing.Optional[RequestOptions] = None,
176 ) -> HttpResponse[CreateOrganizationDiscoveryDomainResponseContent]:
177 """
178 Create a new discovery domain for an organization.
179
180 Parameters
181 ----------
182 id : str
183 ID of the organization.
184
185 domain : str
186 The domain name to associate with the organization e.g. acme.com.
187
188 status : typing.Optional[OrganizationDiscoveryDomainStatus]
189
190 use_for_organization_discovery : typing.Optional[bool]
191 Indicates whether this domain should be used for organization discovery.
192
193 request_options : typing.Optional[RequestOptions]
194 Request-specific configuration.
195
196 Returns
197 -------
198 HttpResponse[CreateOrganizationDiscoveryDomainResponseContent]
199 Organization discovery domain successfully created.
200 """
201 _response = self._client_wrapper.httpx_client.request(
202 f"organizations/{encode_path_param(id)}/discovery-domains",
203 method="POST",
204 json={
205 "domain": domain,
206 "status": status,
207 "use_for_organization_discovery": use_for_organization_discovery,
208 },
209 headers={
210 "content-type": "application/json",
211 },
212 request_options=request_options,
213 omit=OMIT,
214 )
215 try:
216 if 200 <= _response.status_code < 300:
217 _data = typing.cast(
218 CreateOrganizationDiscoveryDomainResponseContent,
219 parse_obj_as(
220 type_=CreateOrganizationDiscoveryDomainResponseContent, # type: ignore
221 object_=_response.json(),
222 ),
223 )
224 return HttpResponse(response=_response, data=_data)
225 if _response.status_code == 400:
226 raise BadRequestError(
227 headers=dict(_response.headers),
228 body=typing.cast(
229 typing.Any,
230 parse_obj_as(
231 type_=typing.Any, # type: ignore
232 object_=_response.json(),
233 ),
234 ),
235 )
236 if _response.status_code == 401:
237 raise UnauthorizedError(
238 headers=dict(_response.headers),
239 body=typing.cast(
240 typing.Any,
241 parse_obj_as(
242 type_=typing.Any, # type: ignore
243 object_=_response.json(),
244 ),
245 ),
246 )
247 if _response.status_code == 403:
248 raise ForbiddenError(
249 headers=dict(_response.headers),
250 body=typing.cast(
251 typing.Any,
252 parse_obj_as(
253 type_=typing.Any, # type: ignore
254 object_=_response.json(),
255 ),
256 ),
257 )
258 if _response.status_code == 404:
259 raise NotFoundError(
260 headers=dict(_response.headers),
261 body=typing.cast(
262 typing.Any,
263 parse_obj_as(
264 type_=typing.Any, # type: ignore
265 object_=_response.json(),
266 ),
267 ),
268 )
269 if _response.status_code == 409:
270 raise ConflictError(
271 headers=dict(_response.headers),
272 body=typing.cast(
273 typing.Any,
274 parse_obj_as(
275 type_=typing.Any, # type: ignore
276 object_=_response.json(),
277 ),
278 ),
279 )
280 if _response.status_code == 429:
281 raise TooManyRequestsError(
282 headers=dict(_response.headers),
283 body=typing.cast(
284 typing.Any,
285 parse_obj_as(
286 type_=typing.Any, # type: ignore
287 object_=_response.json(),
288 ),
289 ),
290 )
291 _response_json = _response.json()
292 except JSONDecodeError:
293 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
294 except ValidationError as e:
295 raise ParsingError(
296 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
297 )
298 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
299
300 def get_by_name(
301 self, id: str, discovery_domain: str, *, request_options: typing.Optional[RequestOptions] = None
302 ) -> HttpResponse[GetOrganizationDiscoveryDomainByNameResponseContent]:
303 """
304 Retrieve details about a single organization discovery domain specified by domain name.
305 This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response.
306
307 Parameters
308 ----------
309 id : str
310 ID of the organization.
311
312 discovery_domain : str
313 Domain name of the discovery domain.
314
315 request_options : typing.Optional[RequestOptions]
316 Request-specific configuration.
317
318 Returns
319 -------
320 HttpResponse[GetOrganizationDiscoveryDomainByNameResponseContent]
321 Organization discovery domain successfully retrieved.
322 """
323 _response = self._client_wrapper.httpx_client.request(
324 f"organizations/{encode_path_param(id)}/discovery-domains/name/{encode_path_param(discovery_domain)}",
325 method="GET",
326 request_options=request_options,
327 )
328 try:
329 if 200 <= _response.status_code < 300:
330 _data = typing.cast(
331 GetOrganizationDiscoveryDomainByNameResponseContent,
332 parse_obj_as(
333 type_=GetOrganizationDiscoveryDomainByNameResponseContent, # type: ignore
334 object_=_response.json(),
335 ),
336 )
337 return HttpResponse(response=_response, data=_data)
338 if _response.status_code == 400:
339 raise BadRequestError(
340 headers=dict(_response.headers),
341 body=typing.cast(
342 typing.Any,
343 parse_obj_as(
344 type_=typing.Any, # type: ignore
345 object_=_response.json(),
346 ),
347 ),
348 )
349 if _response.status_code == 401:
350 raise UnauthorizedError(
351 headers=dict(_response.headers),
352 body=typing.cast(
353 typing.Any,
354 parse_obj_as(
355 type_=typing.Any, # type: ignore
356 object_=_response.json(),
357 ),
358 ),
359 )
360 if _response.status_code == 403:
361 raise ForbiddenError(
362 headers=dict(_response.headers),
363 body=typing.cast(
364 typing.Any,
365 parse_obj_as(
366 type_=typing.Any, # type: ignore
367 object_=_response.json(),
368 ),
369 ),
370 )
371 if _response.status_code == 404:
372 raise NotFoundError(
373 headers=dict(_response.headers),
374 body=typing.cast(
375 typing.Any,
376 parse_obj_as(
377 type_=typing.Any, # type: ignore
378 object_=_response.json(),
379 ),
380 ),
381 )
382 if _response.status_code == 429:
383 raise TooManyRequestsError(
384 headers=dict(_response.headers),
385 body=typing.cast(
386 typing.Any,
387 parse_obj_as(
388 type_=typing.Any, # type: ignore
389 object_=_response.json(),
390 ),
391 ),
392 )
393 _response_json = _response.json()
394 except JSONDecodeError:
395 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
396 except ValidationError as e:
397 raise ParsingError(
398 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
399 )
400 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
401
402 def get(
403 self, id: str, discovery_domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
404 ) -> HttpResponse[GetOrganizationDiscoveryDomainResponseContent]:
405 """
406 Retrieve details about a single organization discovery domain specified by ID.
407 This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response.
408
409 Parameters
410 ----------
411 id : str
412 ID of the organization.
413
414 discovery_domain_id : str
415 ID of the discovery domain.
416
417 request_options : typing.Optional[RequestOptions]
418 Request-specific configuration.
419
420 Returns
421 -------
422 HttpResponse[GetOrganizationDiscoveryDomainResponseContent]
423 Organization discovery domain successfully retrieved.
424 """
425 _response = self._client_wrapper.httpx_client.request(
426 f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}",
427 method="GET",
428 request_options=request_options,
429 )
430 try:
431 if 200 <= _response.status_code < 300:
432 _data = typing.cast(
433 GetOrganizationDiscoveryDomainResponseContent,
434 parse_obj_as(
435 type_=GetOrganizationDiscoveryDomainResponseContent, # type: ignore
436 object_=_response.json(),
437 ),
438 )
439 return HttpResponse(response=_response, data=_data)
440 if _response.status_code == 400:
441 raise BadRequestError(
442 headers=dict(_response.headers),
443 body=typing.cast(
444 typing.Any,
445 parse_obj_as(
446 type_=typing.Any, # type: ignore
447 object_=_response.json(),
448 ),
449 ),
450 )
451 if _response.status_code == 401:
452 raise UnauthorizedError(
453 headers=dict(_response.headers),
454 body=typing.cast(
455 typing.Any,
456 parse_obj_as(
457 type_=typing.Any, # type: ignore
458 object_=_response.json(),
459 ),
460 ),
461 )
462 if _response.status_code == 403:
463 raise ForbiddenError(
464 headers=dict(_response.headers),
465 body=typing.cast(
466 typing.Any,
467 parse_obj_as(
468 type_=typing.Any, # type: ignore
469 object_=_response.json(),
470 ),
471 ),
472 )
473 if _response.status_code == 404:
474 raise NotFoundError(
475 headers=dict(_response.headers),
476 body=typing.cast(
477 typing.Any,
478 parse_obj_as(
479 type_=typing.Any, # type: ignore
480 object_=_response.json(),
481 ),
482 ),
483 )
484 if _response.status_code == 429:
485 raise TooManyRequestsError(
486 headers=dict(_response.headers),
487 body=typing.cast(
488 typing.Any,
489 parse_obj_as(
490 type_=typing.Any, # type: ignore
491 object_=_response.json(),
492 ),
493 ),
494 )
495 _response_json = _response.json()
496 except JSONDecodeError:
497 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
498 except ValidationError as e:
499 raise ParsingError(
500 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
501 )
502 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
503
504 def delete(
505 self, id: str, discovery_domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
506 ) -> HttpResponse[None]:
507 """
508 Remove a discovery domain from an organization. This action cannot be undone.
509
510 Parameters
511 ----------
512 id : str
513 ID of the organization.
514
515 discovery_domain_id : str
516 ID of the discovery domain.
517
518 request_options : typing.Optional[RequestOptions]
519 Request-specific configuration.
520
521 Returns
522 -------
523 HttpResponse[None]
524 """
525 _response = self._client_wrapper.httpx_client.request(
526 f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}",
527 method="DELETE",
528 request_options=request_options,
529 )
530 try:
531 if 200 <= _response.status_code < 300:
532 return HttpResponse(response=_response, data=None)
533 if _response.status_code == 401:
534 raise UnauthorizedError(
535 headers=dict(_response.headers),
536 body=typing.cast(
537 typing.Any,
538 parse_obj_as(
539 type_=typing.Any, # type: ignore
540 object_=_response.json(),
541 ),
542 ),
543 )
544 if _response.status_code == 403:
545 raise ForbiddenError(
546 headers=dict(_response.headers),
547 body=typing.cast(
548 typing.Any,
549 parse_obj_as(
550 type_=typing.Any, # type: ignore
551 object_=_response.json(),
552 ),
553 ),
554 )
555 if _response.status_code == 404:
556 raise NotFoundError(
557 headers=dict(_response.headers),
558 body=typing.cast(
559 typing.Any,
560 parse_obj_as(
561 type_=typing.Any, # type: ignore
562 object_=_response.json(),
563 ),
564 ),
565 )
566 if _response.status_code == 429:
567 raise TooManyRequestsError(
568 headers=dict(_response.headers),
569 body=typing.cast(
570 typing.Any,
571 parse_obj_as(
572 type_=typing.Any, # type: ignore
573 object_=_response.json(),
574 ),
575 ),
576 )
577 _response_json = _response.json()
578 except JSONDecodeError:
579 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
580 except ValidationError as e:
581 raise ParsingError(
582 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
583 )
584 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
585
586 def update(
587 self,
588 id: str,
589 discovery_domain_id: str,
590 *,
591 status: typing.Optional[OrganizationDiscoveryDomainStatus] = OMIT,
592 use_for_organization_discovery: typing.Optional[bool] = OMIT,
593 request_options: typing.Optional[RequestOptions] = None,
594 ) -> HttpResponse[UpdateOrganizationDiscoveryDomainResponseContent]:
595 """
596 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`).
597
598 Parameters
599 ----------
600 id : str
601 ID of the organization.
602
603 discovery_domain_id : str
604 ID of the discovery domain to update.
605
606 status : typing.Optional[OrganizationDiscoveryDomainStatus]
607
608 use_for_organization_discovery : typing.Optional[bool]
609 Indicates whether this domain should be used for organization discovery.
610
611 request_options : typing.Optional[RequestOptions]
612 Request-specific configuration.
613
614 Returns
615 -------
616 HttpResponse[UpdateOrganizationDiscoveryDomainResponseContent]
617 Organization discovery domain successfully updated.
618 """
619 _response = self._client_wrapper.httpx_client.request(
620 f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}",
621 method="PATCH",
622 json={
623 "status": status,
624 "use_for_organization_discovery": use_for_organization_discovery,
625 },
626 headers={
627 "content-type": "application/json",
628 },
629 request_options=request_options,
630 omit=OMIT,
631 )
632 try:
633 if 200 <= _response.status_code < 300:
634 _data = typing.cast(
635 UpdateOrganizationDiscoveryDomainResponseContent,
636 parse_obj_as(
637 type_=UpdateOrganizationDiscoveryDomainResponseContent, # type: ignore
638 object_=_response.json(),
639 ),
640 )
641 return HttpResponse(response=_response, data=_data)
642 if _response.status_code == 400:
643 raise BadRequestError(
644 headers=dict(_response.headers),
645 body=typing.cast(
646 typing.Any,
647 parse_obj_as(
648 type_=typing.Any, # type: ignore
649 object_=_response.json(),
650 ),
651 ),
652 )
653 if _response.status_code == 404:
654 raise NotFoundError(
655 headers=dict(_response.headers),
656 body=typing.cast(
657 typing.Any,
658 parse_obj_as(
659 type_=typing.Any, # type: ignore
660 object_=_response.json(),
661 ),
662 ),
663 )
664 _response_json = _response.json()
665 except JSONDecodeError:
666 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
667 except ValidationError as e:
668 raise ParsingError(
669 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
670 )
671 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
672
673
674 class AsyncRawDiscoveryDomainsClient:
675 def __init__(self, *, client_wrapper: AsyncClientWrapper):
676 self._client_wrapper = client_wrapper
677
678 async def list(
679 self,
680 id: str,
681 *,
682 from_: typing.Optional[str] = None,
683 take: typing.Optional[int] = 50,
684 request_options: typing.Optional[RequestOptions] = None,
685 ) -> AsyncPager[OrganizationDiscoveryDomain, ListOrganizationDiscoveryDomainsResponseContent]:
686 """
687 Retrieve list of all organization discovery domains associated with the specified organization.
688 This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response.
689
690 Parameters
691 ----------
692 id : str
693 ID of the organization.
694
695 from_ : typing.Optional[str]
696 Optional Id from which to start selection.
697
698 take : typing.Optional[int]
699 Number of results per page. Defaults to 50.
700
701 request_options : typing.Optional[RequestOptions]
702 Request-specific configuration.
703
704 Returns
705 -------
706 AsyncPager[OrganizationDiscoveryDomain, ListOrganizationDiscoveryDomainsResponseContent]
707 Organization discovery domains retrieved successfully.
708 """
709 _response = await self._client_wrapper.httpx_client.request(
710 f"organizations/{encode_path_param(id)}/discovery-domains",
711 method="GET",
712 params={
713 "from": from_,
714 "take": take,
715 },
716 request_options=request_options,
717 )
718 try:
719 if 200 <= _response.status_code < 300:
720 _parsed_response = typing.cast(
721 ListOrganizationDiscoveryDomainsResponseContent,
722 parse_obj_as(
723 type_=ListOrganizationDiscoveryDomainsResponseContent, # type: ignore
724 object_=_response.json(),
725 ),
726 )
727 _items = _parsed_response.domains
728 _parsed_next = _parsed_response.next
729 _has_next = _parsed_next is not None and _parsed_next != ""
730
731 async def _get_next():
732 return await self.list(
733 id,
734 from_=_parsed_next,
735 take=take,
736 request_options=request_options,
737 )
738
739 return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
740 if _response.status_code == 400:
741 raise BadRequestError(
742 headers=dict(_response.headers),
743 body=typing.cast(
744 typing.Any,
745 parse_obj_as(
746 type_=typing.Any, # type: ignore
747 object_=_response.json(),
748 ),
749 ),
750 )
751 if _response.status_code == 401:
752 raise UnauthorizedError(
753 headers=dict(_response.headers),
754 body=typing.cast(
755 typing.Any,
756 parse_obj_as(
757 type_=typing.Any, # type: ignore
758 object_=_response.json(),
759 ),
760 ),
761 )
762 if _response.status_code == 403:
763 raise ForbiddenError(
764 headers=dict(_response.headers),
765 body=typing.cast(
766 typing.Any,
767 parse_obj_as(
768 type_=typing.Any, # type: ignore
769 object_=_response.json(),
770 ),
771 ),
772 )
773 if _response.status_code == 404:
774 raise NotFoundError(
775 headers=dict(_response.headers),
776 body=typing.cast(
777 typing.Any,
778 parse_obj_as(
779 type_=typing.Any, # type: ignore
780 object_=_response.json(),
781 ),
782 ),
783 )
784 if _response.status_code == 429:
785 raise TooManyRequestsError(
786 headers=dict(_response.headers),
787 body=typing.cast(
788 typing.Any,
789 parse_obj_as(
790 type_=typing.Any, # type: ignore
791 object_=_response.json(),
792 ),
793 ),
794 )
795 _response_json = _response.json()
796 except JSONDecodeError:
797 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
798 except ValidationError as e:
799 raise ParsingError(
800 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
801 )
802 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
803
804 async def create(
805 self,
806 id: str,
807 *,
808 domain: str,
809 status: typing.Optional[OrganizationDiscoveryDomainStatus] = OMIT,
810 use_for_organization_discovery: typing.Optional[bool] = OMIT,
811 request_options: typing.Optional[RequestOptions] = None,
812 ) -> AsyncHttpResponse[CreateOrganizationDiscoveryDomainResponseContent]:
813 """
814 Create a new discovery domain for an organization.
815
816 Parameters
817 ----------
818 id : str
819 ID of the organization.
820
821 domain : str
822 The domain name to associate with the organization e.g. acme.com.
823
824 status : typing.Optional[OrganizationDiscoveryDomainStatus]
825
826 use_for_organization_discovery : typing.Optional[bool]
827 Indicates whether this domain should be used for organization discovery.
828
829 request_options : typing.Optional[RequestOptions]
830 Request-specific configuration.
831
832 Returns
833 -------
834 AsyncHttpResponse[CreateOrganizationDiscoveryDomainResponseContent]
835 Organization discovery domain successfully created.
836 """
837 _response = await self._client_wrapper.httpx_client.request(
838 f"organizations/{encode_path_param(id)}/discovery-domains",
839 method="POST",
840 json={
841 "domain": domain,
842 "status": status,
843 "use_for_organization_discovery": use_for_organization_discovery,
844 },
845 headers={
846 "content-type": "application/json",
847 },
848 request_options=request_options,
849 omit=OMIT,
850 )
851 try:
852 if 200 <= _response.status_code < 300:
853 _data = typing.cast(
854 CreateOrganizationDiscoveryDomainResponseContent,
855 parse_obj_as(
856 type_=CreateOrganizationDiscoveryDomainResponseContent, # type: ignore
857 object_=_response.json(),
858 ),
859 )
860 return AsyncHttpResponse(response=_response, data=_data)
861 if _response.status_code == 400:
862 raise BadRequestError(
863 headers=dict(_response.headers),
864 body=typing.cast(
865 typing.Any,
866 parse_obj_as(
867 type_=typing.Any, # type: ignore
868 object_=_response.json(),
869 ),
870 ),
871 )
872 if _response.status_code == 401:
873 raise UnauthorizedError(
874 headers=dict(_response.headers),
875 body=typing.cast(
876 typing.Any,
877 parse_obj_as(
878 type_=typing.Any, # type: ignore
879 object_=_response.json(),
880 ),
881 ),
882 )
883 if _response.status_code == 403:
884 raise ForbiddenError(
885 headers=dict(_response.headers),
886 body=typing.cast(
887 typing.Any,
888 parse_obj_as(
889 type_=typing.Any, # type: ignore
890 object_=_response.json(),
891 ),
892 ),
893 )
894 if _response.status_code == 404:
895 raise NotFoundError(
896 headers=dict(_response.headers),
897 body=typing.cast(
898 typing.Any,
899 parse_obj_as(
900 type_=typing.Any, # type: ignore
901 object_=_response.json(),
902 ),
903 ),
904 )
905 if _response.status_code == 409:
906 raise ConflictError(
907 headers=dict(_response.headers),
908 body=typing.cast(
909 typing.Any,
910 parse_obj_as(
911 type_=typing.Any, # type: ignore
912 object_=_response.json(),
913 ),
914 ),
915 )
916 if _response.status_code == 429:
917 raise TooManyRequestsError(
918 headers=dict(_response.headers),
919 body=typing.cast(
920 typing.Any,
921 parse_obj_as(
922 type_=typing.Any, # type: ignore
923 object_=_response.json(),
924 ),
925 ),
926 )
927 _response_json = _response.json()
928 except JSONDecodeError:
929 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
930 except ValidationError as e:
931 raise ParsingError(
932 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
933 )
934 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
935
936 async def get_by_name(
937 self, id: str, discovery_domain: str, *, request_options: typing.Optional[RequestOptions] = None
938 ) -> AsyncHttpResponse[GetOrganizationDiscoveryDomainByNameResponseContent]:
939 """
940 Retrieve details about a single organization discovery domain specified by domain name.
941 This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response.
942
943 Parameters
944 ----------
945 id : str
946 ID of the organization.
947
948 discovery_domain : str
949 Domain name of the discovery domain.
950
951 request_options : typing.Optional[RequestOptions]
952 Request-specific configuration.
953
954 Returns
955 -------
956 AsyncHttpResponse[GetOrganizationDiscoveryDomainByNameResponseContent]
957 Organization discovery domain successfully retrieved.
958 """
959 _response = await self._client_wrapper.httpx_client.request(
960 f"organizations/{encode_path_param(id)}/discovery-domains/name/{encode_path_param(discovery_domain)}",
961 method="GET",
962 request_options=request_options,
963 )
964 try:
965 if 200 <= _response.status_code < 300:
966 _data = typing.cast(
967 GetOrganizationDiscoveryDomainByNameResponseContent,
968 parse_obj_as(
969 type_=GetOrganizationDiscoveryDomainByNameResponseContent, # type: ignore
970 object_=_response.json(),
971 ),
972 )
973 return AsyncHttpResponse(response=_response, data=_data)
974 if _response.status_code == 400:
975 raise BadRequestError(
976 headers=dict(_response.headers),
977 body=typing.cast(
978 typing.Any,
979 parse_obj_as(
980 type_=typing.Any, # type: ignore
981 object_=_response.json(),
982 ),
983 ),
984 )
985 if _response.status_code == 401:
986 raise UnauthorizedError(
987 headers=dict(_response.headers),
988 body=typing.cast(
989 typing.Any,
990 parse_obj_as(
991 type_=typing.Any, # type: ignore
992 object_=_response.json(),
993 ),
994 ),
995 )
996 if _response.status_code == 403:
997 raise ForbiddenError(
998 headers=dict(_response.headers),
999 body=typing.cast(
1000 typing.Any,
1001 parse_obj_as(
1002 type_=typing.Any, # type: ignore
1003 object_=_response.json(),
1004 ),
1005 ),
1006 )
1007 if _response.status_code == 404:
1008 raise NotFoundError(
1009 headers=dict(_response.headers),
1010 body=typing.cast(
1011 typing.Any,
1012 parse_obj_as(
1013 type_=typing.Any, # type: ignore
1014 object_=_response.json(),
1015 ),
1016 ),
1017 )
1018 if _response.status_code == 429:
1019 raise TooManyRequestsError(
1020 headers=dict(_response.headers),
1021 body=typing.cast(
1022 typing.Any,
1023 parse_obj_as(
1024 type_=typing.Any, # type: ignore
1025 object_=_response.json(),
1026 ),
1027 ),
1028 )
1029 _response_json = _response.json()
1030 except JSONDecodeError:
1031 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1032 except ValidationError as e:
1033 raise ParsingError(
1034 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1035 )
1036 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1037
1038 async def get(
1039 self, id: str, discovery_domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
1040 ) -> AsyncHttpResponse[GetOrganizationDiscoveryDomainResponseContent]:
1041 """
1042 Retrieve details about a single organization discovery domain specified by ID.
1043 This endpoint is subject to eventual consistency; newly created, updated, or deleted discovery domains may not immediately appear in the response.
1044
1045 Parameters
1046 ----------
1047 id : str
1048 ID of the organization.
1049
1050 discovery_domain_id : str
1051 ID of the discovery domain.
1052
1053 request_options : typing.Optional[RequestOptions]
1054 Request-specific configuration.
1055
1056 Returns
1057 -------
1058 AsyncHttpResponse[GetOrganizationDiscoveryDomainResponseContent]
1059 Organization discovery domain successfully retrieved.
1060 """
1061 _response = await self._client_wrapper.httpx_client.request(
1062 f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}",
1063 method="GET",
1064 request_options=request_options,
1065 )
1066 try:
1067 if 200 <= _response.status_code < 300:
1068 _data = typing.cast(
1069 GetOrganizationDiscoveryDomainResponseContent,
1070 parse_obj_as(
1071 type_=GetOrganizationDiscoveryDomainResponseContent, # type: ignore
1072 object_=_response.json(),
1073 ),
1074 )
1075 return AsyncHttpResponse(response=_response, data=_data)
1076 if _response.status_code == 400:
1077 raise BadRequestError(
1078 headers=dict(_response.headers),
1079 body=typing.cast(
1080 typing.Any,
1081 parse_obj_as(
1082 type_=typing.Any, # type: ignore
1083 object_=_response.json(),
1084 ),
1085 ),
1086 )
1087 if _response.status_code == 401:
1088 raise UnauthorizedError(
1089 headers=dict(_response.headers),
1090 body=typing.cast(
1091 typing.Any,
1092 parse_obj_as(
1093 type_=typing.Any, # type: ignore
1094 object_=_response.json(),
1095 ),
1096 ),
1097 )
1098 if _response.status_code == 403:
1099 raise ForbiddenError(
1100 headers=dict(_response.headers),
1101 body=typing.cast(
1102 typing.Any,
1103 parse_obj_as(
1104 type_=typing.Any, # type: ignore
1105 object_=_response.json(),
1106 ),
1107 ),
1108 )
1109 if _response.status_code == 404:
1110 raise NotFoundError(
1111 headers=dict(_response.headers),
1112 body=typing.cast(
1113 typing.Any,
1114 parse_obj_as(
1115 type_=typing.Any, # type: ignore
1116 object_=_response.json(),
1117 ),
1118 ),
1119 )
1120 if _response.status_code == 429:
1121 raise TooManyRequestsError(
1122 headers=dict(_response.headers),
1123 body=typing.cast(
1124 typing.Any,
1125 parse_obj_as(
1126 type_=typing.Any, # type: ignore
1127 object_=_response.json(),
1128 ),
1129 ),
1130 )
1131 _response_json = _response.json()
1132 except JSONDecodeError:
1133 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1134 except ValidationError as e:
1135 raise ParsingError(
1136 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1137 )
1138 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1139
1140 async def delete(
1141 self, id: str, discovery_domain_id: str, *, request_options: typing.Optional[RequestOptions] = None
1142 ) -> AsyncHttpResponse[None]:
1143 """
1144 Remove a discovery domain from an organization. This action cannot be undone.
1145
1146 Parameters
1147 ----------
1148 id : str
1149 ID of the organization.
1150
1151 discovery_domain_id : str
1152 ID of the discovery domain.
1153
1154 request_options : typing.Optional[RequestOptions]
1155 Request-specific configuration.
1156
1157 Returns
1158 -------
1159 AsyncHttpResponse[None]
1160 """
1161 _response = await self._client_wrapper.httpx_client.request(
1162 f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}",
1163 method="DELETE",
1164 request_options=request_options,
1165 )
1166 try:
1167 if 200 <= _response.status_code < 300:
1168 return AsyncHttpResponse(response=_response, data=None)
1169 if _response.status_code == 401:
1170 raise UnauthorizedError(
1171 headers=dict(_response.headers),
1172 body=typing.cast(
1173 typing.Any,
1174 parse_obj_as(
1175 type_=typing.Any, # type: ignore
1176 object_=_response.json(),
1177 ),
1178 ),
1179 )
1180 if _response.status_code == 403:
1181 raise ForbiddenError(
1182 headers=dict(_response.headers),
1183 body=typing.cast(
1184 typing.Any,
1185 parse_obj_as(
1186 type_=typing.Any, # type: ignore
1187 object_=_response.json(),
1188 ),
1189 ),
1190 )
1191 if _response.status_code == 404:
1192 raise NotFoundError(
1193 headers=dict(_response.headers),
1194 body=typing.cast(
1195 typing.Any,
1196 parse_obj_as(
1197 type_=typing.Any, # type: ignore
1198 object_=_response.json(),
1199 ),
1200 ),
1201 )
1202 if _response.status_code == 429:
1203 raise TooManyRequestsError(
1204 headers=dict(_response.headers),
1205 body=typing.cast(
1206 typing.Any,
1207 parse_obj_as(
1208 type_=typing.Any, # type: ignore
1209 object_=_response.json(),
1210 ),
1211 ),
1212 )
1213 _response_json = _response.json()
1214 except JSONDecodeError:
1215 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1216 except ValidationError as e:
1217 raise ParsingError(
1218 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1219 )
1220 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1221
1222 async def update(
1223 self,
1224 id: str,
1225 discovery_domain_id: str,
1226 *,
1227 status: typing.Optional[OrganizationDiscoveryDomainStatus] = OMIT,
1228 use_for_organization_discovery: typing.Optional[bool] = OMIT,
1229 request_options: typing.Optional[RequestOptions] = None,
1230 ) -> AsyncHttpResponse[UpdateOrganizationDiscoveryDomainResponseContent]:
1231 """
1232 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`).
1233
1234 Parameters
1235 ----------
1236 id : str
1237 ID of the organization.
1238
1239 discovery_domain_id : str
1240 ID of the discovery domain to update.
1241
1242 status : typing.Optional[OrganizationDiscoveryDomainStatus]
1243
1244 use_for_organization_discovery : typing.Optional[bool]
1245 Indicates whether this domain should be used for organization discovery.
1246
1247 request_options : typing.Optional[RequestOptions]
1248 Request-specific configuration.
1249
1250 Returns
1251 -------
1252 AsyncHttpResponse[UpdateOrganizationDiscoveryDomainResponseContent]
1253 Organization discovery domain successfully updated.
1254 """
1255 _response = await self._client_wrapper.httpx_client.request(
1256 f"organizations/{encode_path_param(id)}/discovery-domains/{encode_path_param(discovery_domain_id)}",
1257 method="PATCH",
1258 json={
1259 "status": status,
1260 "use_for_organization_discovery": use_for_organization_discovery,
1261 },
1262 headers={
1263 "content-type": "application/json",
1264 },
1265 request_options=request_options,
1266 omit=OMIT,
1267 )
1268 try:
1269 if 200 <= _response.status_code < 300:
1270 _data = typing.cast(
1271 UpdateOrganizationDiscoveryDomainResponseContent,
1272 parse_obj_as(
1273 type_=UpdateOrganizationDiscoveryDomainResponseContent, # type: ignore
1274 object_=_response.json(),
1275 ),
1276 )
1277 return AsyncHttpResponse(response=_response, data=_data)
1278 if _response.status_code == 400:
1279 raise BadRequestError(
1280 headers=dict(_response.headers),
1281 body=typing.cast(
1282 typing.Any,
1283 parse_obj_as(
1284 type_=typing.Any, # type: ignore
1285 object_=_response.json(),
1286 ),
1287 ),
1288 )
1289 if _response.status_code == 404:
1290 raise NotFoundError(
1291 headers=dict(_response.headers),
1292 body=typing.cast(
1293 typing.Any,
1294 parse_obj_as(
1295 type_=typing.Any, # type: ignore
1296 object_=_response.json(),
1297 ),
1298 ),
1299 )
1300 _response_json = _response.json()
1301 except JSONDecodeError:
1302 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1303 except ValidationError as e:
1304 raise ParsingError(
1305 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1306 )
1307 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)