1+ from typing import Optional , Protocol
2+ from workos ._client_configuration import ClientConfiguration
3+ from workos .types .organization_domains import OrganizationDomain
4+ from workos .typing .sync_or_async import SyncOrAsync
5+ from workos .utils .http_client import AsyncHTTPClient , SyncHTTPClient
6+ from workos .utils .request_helper import (
7+ REQUEST_METHOD_DELETE ,
8+ REQUEST_METHOD_GET ,
9+ REQUEST_METHOD_POST ,
10+ RequestHelper ,
11+ )
12+
13+
14+ class OrganizationDomainsModule (Protocol ):
15+ """Offers methods for managing organization domains."""
16+
17+ _client_configuration : ClientConfiguration
18+
19+ def get_organization_domain (
20+ self , organization_domain_id : str
21+ ) -> SyncOrAsync [OrganizationDomain ]:
22+ """Gets a single Organization Domain
23+
24+ Args:
25+ organization_domain_id (str): Organization Domain unique identifier
26+
27+ Returns:
28+ OrganizationDomain: Organization Domain response from WorkOS
29+ """
30+ ...
31+
32+ def create_organization_domain (
33+ self ,
34+ organization_id : str ,
35+ domain : str ,
36+ ) -> SyncOrAsync [OrganizationDomain ]:
37+ """Creates an Organization Domain
38+
39+ Args:
40+ organization_id (str): Organization unique identifier
41+ domain (str): Domain to be added to the organization
42+
43+ Returns:
44+ OrganizationDomain: Organization Domain response from WorkOS
45+ """
46+ ...
47+
48+ def verify_organization_domain (
49+ self , organization_domain_id : str
50+ ) -> SyncOrAsync [OrganizationDomain ]:
51+ """Verifies an Organization Domain
52+
53+ Args:
54+ organization_domain_id (str): Organization Domain unique identifier
55+
56+ Returns:
57+ OrganizationDomain: Organization Domain response from WorkOS
58+ """
59+ ...
60+
61+ def delete_organization_domain (
62+ self , organization_domain_id : str
63+ ) -> SyncOrAsync [None ]:
64+ """Deletes a single Organization Domain
65+
66+ Args:
67+ organization_domain_id (str): Organization Domain unique identifier
68+
69+ Returns:
70+ None
71+ """
72+ ...
73+
74+
75+ class OrganizationDomains :
76+ """Offers methods for managing organization domains."""
77+
78+ _http_client : SyncHTTPClient
79+ _client_configuration : ClientConfiguration
80+
81+ def __init__ (
82+ self ,
83+ http_client : SyncHTTPClient ,
84+ client_configuration : ClientConfiguration ,
85+ ):
86+ self ._http_client = http_client
87+ self ._client_configuration = client_configuration
88+
89+ def get_organization_domain (
90+ self , organization_domain_id : str
91+ ) -> OrganizationDomain :
92+ response = self ._http_client .request (
93+ f"organization_domains/{ organization_domain_id } " ,
94+ method = REQUEST_METHOD_GET ,
95+ )
96+
97+ return OrganizationDomain .model_validate (response )
98+
99+ def create_organization_domain (
100+ self ,
101+ organization_id : str ,
102+ domain : str ,
103+ ) -> OrganizationDomain :
104+ response = self ._http_client .request (
105+ "organization_domains" ,
106+ method = REQUEST_METHOD_POST ,
107+ json = {"organization_id" : organization_id , "domain" : domain },
108+ )
109+
110+ return OrganizationDomain .model_validate (response )
111+
112+ def verify_organization_domain (
113+ self , organization_domain_id : str
114+ ) -> OrganizationDomain :
115+ response = self ._http_client .request (
116+ f"organization_domains/{ organization_domain_id } /verify" ,
117+ method = REQUEST_METHOD_POST ,
118+ )
119+
120+ return OrganizationDomain .model_validate (response )
121+
122+ def delete_organization_domain (self , organization_domain_id : str ) -> None :
123+ self ._http_client .request (
124+ f"organization_domains/{ organization_domain_id } " ,
125+ method = REQUEST_METHOD_DELETE ,
126+ )
127+
128+
129+ class AsyncOrganizationDomains :
130+ """Offers async methods for managing organization domains."""
131+
132+ _http_client : AsyncHTTPClient
133+ _client_configuration : ClientConfiguration
134+
135+ def __init__ (
136+ self ,
137+ http_client : AsyncHTTPClient ,
138+ client_configuration : ClientConfiguration ,
139+ ):
140+ self ._http_client = http_client
141+ self ._client_configuration = client_configuration
142+
143+ async def get_organization_domain (
144+ self , organization_domain_id : str
145+ ) -> OrganizationDomain :
146+ response = await self ._http_client .request (
147+ f"organization_domains/{ organization_domain_id } " ,
148+ method = REQUEST_METHOD_GET ,
149+ )
150+
151+ return OrganizationDomain .model_validate (response )
152+
153+ async def create_organization_domain (
154+ self ,
155+ organization_id : str ,
156+ domain : str ,
157+ ) -> OrganizationDomain :
158+ response = await self ._http_client .request (
159+ "organization_domains" ,
160+ method = REQUEST_METHOD_POST ,
161+ json = {"organization_id" : organization_id , "domain" : domain },
162+ )
163+
164+ return OrganizationDomain .model_validate (response )
165+
166+ async def verify_organization_domain (
167+ self , organization_domain_id : str
168+ ) -> OrganizationDomain :
169+ response = await self ._http_client .request (
170+ f"organization_domains/{ organization_domain_id } /verify" ,
171+ method = REQUEST_METHOD_POST ,
172+ )
173+
174+ return OrganizationDomain .model_validate (response )
175+
176+ async def delete_organization_domain (self , organization_domain_id : str ) -> None :
177+ await self ._http_client .request (
178+ f"organization_domains/{ organization_domain_id } " ,
179+ method = REQUEST_METHOD_DELETE ,
180+ )
0 commit comments