Skip to content

Commit 6ffa7c8

Browse files
authored
Add lookup_key support (#278)
* Add `lookup_key` support * format
1 parent daf4a2b commit 6ffa7c8

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

tests/test_organizations.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ def test_get_organization(self, mock_organization, mock_request_method):
185185

186186
assert organization == mock_organization
187187

188+
def test_get_organization_by_lookup_key(
189+
self, mock_organization, mock_request_method
190+
):
191+
mock_request_method("get", mock_organization, 200)
192+
193+
organization = self.organizations.get_organization_by_lookup_key(
194+
lookup_key="test"
195+
)
196+
197+
assert organization == mock_organization
198+
188199
def test_create_organization_with_domain_data(
189200
self, mock_organization, mock_request_method
190201
):

tests/utils/fixtures/mock_organization.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ def __init__(self, id):
2626
"created_at",
2727
"updated_at",
2828
"domains",
29+
"lookup_key",
2930
]

workos/organizations.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,21 @@ def get_organization(self, organization):
169169

170170
return WorkOSOrganization.construct_from_response(response).to_dict()
171171

172+
def get_organization_by_lookup_key(self, lookup_key):
173+
"""Gets details for a single Organization by lookup key
174+
Args:
175+
lookup_key (str): Organization's lookup key
176+
Returns:
177+
dict: Organization response from WorkOS
178+
"""
179+
response = self.request_helper.request(
180+
"organizations/by_lookup_key/{lookup_key}".format(lookup_key=lookup_key),
181+
method=REQUEST_METHOD_GET,
182+
token=workos.api_key,
183+
)
184+
185+
return WorkOSOrganization.construct_from_response(response).to_dict()
186+
172187
def create_organization(self, organization, idempotency_key=None):
173188
"""Create an organization
174189
@@ -222,6 +237,7 @@ def update_organization(
222237
allow_profiles_outside_organization=None,
223238
domains=None,
224239
domain_data=None,
240+
lookup_key=None,
225241
):
226242
"""Update an organization
227243
@@ -262,6 +278,9 @@ def update_organization(
262278
if domain_data is not None:
263279
params["domain_data"] = domain_data
264280

281+
if lookup_key is not None:
282+
params["lookup_key"] = lookup_key
283+
265284
response = self.request_helper.request(
266285
"organizations/{organization}".format(organization=organization),
267286
method=REQUEST_METHOD_PUT,

workos/resources/organizations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class WorkOSOrganization(WorkOSBaseResource):
1616
"created_at",
1717
"updated_at",
1818
"domains",
19+
"lookup_key",
1920
]
2021

2122
@classmethod

0 commit comments

Comments
 (0)