-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_workspace.py
More file actions
29 lines (21 loc) · 824 Bytes
/
get_workspace.py
File metadata and controls
29 lines (21 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import asyncio
import logging
from codesphere import CodesphereSDK
logging.basicConfig(level=logging.INFO)
async def main():
async with CodesphereSDK() as sdk:
all_teams = await sdk.teams.list()
if not all_teams:
print("No teams found. Cannot get a workspace.")
return
first_team = all_teams[0]
workspaces = await sdk.workspaces.list_by_team(team_id=first_team.id)
if not workspaces:
print(f"No workspaces found in team '{first_team.name}'.")
return
first_workspace = workspaces[0]
workspace_id_to_fetch = first_workspace.id
workspace = await sdk.workspaces.get(workspace_id=workspace_id_to_fetch)
print(workspace.model_dump_json(indent=2))
if __name__ == "__main__":
asyncio.run(main())