Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit f01c6c6

Browse files
authored
Merge pull request #12 from seamapi/andrii-workspaces-list
2 parents 1591dd0 + a695d5e commit f01c6c6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

seamapi/workspaces.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,18 @@ class Workspaces(AbstractWorkspaces):
99
def __init__(self, seam: Seam):
1010
self.seam = seam
1111

12-
def list(self) -> List[Workspace]:
13-
raise NotImplementedError
12+
def list(self, workspace_id: Optional[str] = None) -> List[Workspace]:
13+
res = requests.get(
14+
f"{self.seam.api_url}/workspaces/list",
15+
params={"workspace_id": workspace_id},
16+
headers={"Authorization": f"Bearer {self.seam.api_key}"},
17+
)
18+
if res.status_code == 404:
19+
raise Exception("workspaces not found") # TODO custom exception
20+
if res.status_code != 200:
21+
raise Exception(res.text)
22+
res_json = res.json()
23+
return res_json['workspaces']
1424

1525
def get(self, workspace_id: Optional[str] = None) -> Workspace:
1626
res = requests.get(

tests/workspaces/test_workspaces.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ def test_workspaces(seam: Seam):
1111
reset_sandbox_result = seam.workspaces.reset_sandbox()
1212
assert reset_sandbox_result is None
1313

14-
# seam.workspaces.list() - not implemented
14+
ws_list = seam.workspaces.list()
15+
assert len(ws_list) > 0

0 commit comments

Comments
 (0)