Skip to content

Commit daf4a2b

Browse files
authored
Deprecate allow_profiles_outside_organization parameter (#279)
* Mark `allow_profiles_outside_organization` as deprecated * Only serialize params if a value is passed * Run `black` * Run correct version of `black` * Check with `is not None` instead
1 parent 3d1f52b commit daf4a2b

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

workos/organizations.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ def create_organization(self, organization, idempotency_key=None):
175175
Args:
176176
organization (dict) - An organization object
177177
organization[name] (str) - A unique, descriptive name for the organization
178-
organization[allow_profiles_outside_organization] (boolean) - Whether Connections
178+
organization[allow_profiles_outside_organization] (boolean) - [Deprecated] Whether Connections
179179
within the Organization allow profiles that are outside of the Organization's
180180
configured User Email Domains. (Optional)
181+
organization[domains] (list[dict]) - [Deprecated] Use domain_data instead. List of domains that
182+
belong to the organization. (Optional)
181183
organization[domain_data] (list[dict]) - List of domains that belong to the organization.
182184
organization[domain_data][][domain] - The domain of the organization.
183185
organization[domain_data][][state] - The state of the domain: either 'verified' or 'pending'.
@@ -196,6 +198,13 @@ def create_organization(self, organization, idempotency_key=None):
196198
DeprecationWarning,
197199
)
198200

201+
if "allow_profiles_outside_organization" in organization:
202+
warn(
203+
"The `allow_profiles_outside_organization` parameter for `create_orgnaization` is deprecated. "
204+
"If you need to allow sign-ins from any email domain, contact [email protected].",
205+
DeprecationWarning,
206+
)
207+
199208
response = self.request_helper.request(
200209
ORGANIZATIONS_PATH,
201210
method=REQUEST_METHOD_POST,
@@ -219,7 +228,7 @@ def update_organization(
219228
Args:
220229
organization(str) - Organization's unique identifier.
221230
name (str) - A unique, descriptive name for the organization.
222-
allow_profiles_outside_organization (boolean) - Whether Connections
231+
allow_profiles_outside_organization (boolean) - [Deprecated] Whether Connections
223232
within the Organization allow profiles that are outside of the Organization's
224233
configured User Email Domains. (Optional)
225234
domains (list) - [Deprecated] Use domain_data instead. List of domains that belong to the organization. (Optional)
@@ -230,18 +239,29 @@ def update_organization(
230239
Returns:
231240
dict: Updated Organization response from WorkOS.
232241
"""
233-
if domains:
242+
243+
params = {"name": name}
244+
245+
if domains is not None:
234246
warn(
235247
"The 'domains' parameter for 'update_organization' is deprecated. Please use 'domain_data' instead.",
236248
DeprecationWarning,
237249
)
250+
params["domains"] = domains
251+
252+
if allow_profiles_outside_organization is not None:
253+
warn(
254+
"The `allow_profiles_outside_organization` parameter for `create_orgnaization` is deprecated. "
255+
"If you need to allow sign-ins from any email domain, contact [email protected].",
256+
DeprecationWarning,
257+
)
258+
params[
259+
"allow_profiles_outside_organization"
260+
] = allow_profiles_outside_organization
261+
262+
if domain_data is not None:
263+
params["domain_data"] = domain_data
238264

239-
params = {
240-
"name": name,
241-
"domains": domains,
242-
"domain_data": domain_data,
243-
"allow_profiles_outside_organization": allow_profiles_outside_organization,
244-
}
245265
response = self.request_helper.request(
246266
"organizations/{organization}".format(organization=organization),
247267
method=REQUEST_METHOD_PUT,

0 commit comments

Comments
 (0)