Skip to content

Commit

Permalink
Fix methods missing _id for unique IDs. (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgd authored Jul 30, 2024
1 parent 1c1c6e9 commit 7b46a5b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
8 changes: 5 additions & 3 deletions tests/test_organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_get_organization(self, mock_organization, mock_http_client_with_respons
mock_http_client_with_response(self.http_client, mock_organization, 200)

organization = self.organizations.get_organization(
organization="organization_id"
organization_id="organization_id"
)

assert organization.dict() == mock_organization
Expand Down Expand Up @@ -140,7 +140,7 @@ def test_update_organization_with_domain_data(
mock_http_client_with_response(self.http_client, mock_organization_updated, 201)

updated_organization = self.organizations.update_organization(
organization="org_01EHT88Z8J8795GZNQ4ZP1J81T",
organization_id="org_01EHT88Z8J8795GZNQ4ZP1J81T",
name="Example Organization",
domain_data=[{"domain": "example.io", "state": "verified"}],
)
Expand All @@ -162,7 +162,9 @@ def test_delete_organization(self, setup, mock_http_client_with_response):
headers={"content-type": "text/plain; charset=utf-8"},
)

response = self.organizations.delete_organization(organization="connection_id")
response = self.organizations.delete_organization(
organization_id="connection_id"
)

assert response is None

Expand Down
4 changes: 2 additions & 2 deletions workos/directory_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def list_directories(
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
before: Optional[str] = None,
after: Optional[str] = None,
organization: Optional[str] = None,
organization_id: Optional[str] = None,
order: PaginationOrder = "desc",
) -> SyncOrAsyncListResource: ...

Expand Down Expand Up @@ -485,7 +485,7 @@ async def list_directories(
Args:
domain (str): Domain of a Directory. (Optional)
organization: ID of an Organization (Optional)
organization_id: ID of an Organization (Optional)
search (str): Searchable text for a Directory. (Optional)
limit (int): Maximum number of records to return. (Optional)
before (str): Pagination cursor to receive records before a provided Directory ID. (Optional)
Expand Down
4 changes: 2 additions & 2 deletions workos/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def list_events(
self,
events: List[EventType],
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
organization: Optional[str] = None,
organization_id: Optional[str] = None,
after: Optional[str] = None,
range_start: Optional[str] = None,
range_end: Optional[str] = None,
Expand All @@ -76,7 +76,7 @@ def list_events(
"events": events,
"limit": limit,
"after": after,
"organization_id": organization,
"organization_id": organization_id,
"range_start": range_start,
"range_end": range_end,
}
Expand Down
30 changes: 15 additions & 15 deletions workos/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def list_organizations(
order: PaginationOrder = "desc",
) -> WorkOsListResource[Organization, OrganizationListFilters, ListMetadata]: ...

def get_organization(self, organization: str) -> Organization: ...
def get_organization(self, organization_id: str) -> Organization: ...

def get_organization_by_lookup_key(self, lookup_key: str) -> Organization: ...

Expand All @@ -46,12 +46,12 @@ def create_organization(

def update_organization(
self,
organization: str,
organization_id: str,
name: str,
domain_data: Optional[List[DomainDataInput]] = None,
) -> Organization: ...

def delete_organization(self, organization: str) -> None: ...
def delete_organization(self, organization_id: str) -> None: ...


class Organizations(OrganizationsModule):
Expand Down Expand Up @@ -101,18 +101,18 @@ def list_organizations(
return WorkOsListResource[Organization, OrganizationListFilters, ListMetadata](
list_method=self.list_organizations,
list_args=list_params,
**ListPage[Organization](**response).model_dump()
**ListPage[Organization](**response).model_dump(),
)

def get_organization(self, organization: str) -> Organization:
def get_organization(self, organization_id: str) -> Organization:
"""Gets details for a single Organization
Args:
organization (str): Organization's unique identifier
organization_id (str): Organization's unique identifier
Returns:
dict: Organization response from WorkOS
Organization: Organization response from WorkOS
"""
response = self._http_client.request(
"organizations/{organization}".format(organization=organization),
f"organizations/{organization_id}",
method=REQUEST_METHOD_GET,
token=workos.api_key,
)
Expand Down Expand Up @@ -163,32 +163,32 @@ def create_organization(

def update_organization(
self,
organization: str,
organization_id: str,
name: str,
domain_data: Optional[List[DomainDataInput]] = None,
):
) -> Organization:
params = {
"name": name,
"domain_data": domain_data,
}

response = self._http_client.request(
"organizations/{organization}".format(organization=organization),
f"organizations/{organization_id}",
method=REQUEST_METHOD_PUT,
params=params,
token=workos.api_key,
)

return Organization.model_validate(response)

def delete_organization(self, organization: str):
def delete_organization(self, organization_id: str) -> None:
"""Deletes a single Organization
Args:
organization (str): Organization unique identifier
organization_id (str): Organization unique identifier
"""
return self._http_client.request(
"organizations/{organization}".format(organization=organization),
self._http_client.request(
f"organizations/{organization_id}",
method=REQUEST_METHOD_DELETE,
token=workos.api_key,
)

0 comments on commit 7b46a5b

Please sign in to comment.