|
1 | 1 | import asyncio |
2 | | -import pprint |
3 | | -from codesphere import CodesphereSDK |
| 2 | +import logging |
| 3 | +from codesphere import CodesphereSDK, EnvVar |
| 4 | + |
| 5 | +logging.basicConfig(level=logging.INFO) |
4 | 6 |
|
5 | 7 |
|
6 | 8 | async def main(): |
7 | | - """Fetches a team and lists all workspaces within it.""" |
8 | 9 | async with CodesphereSDK() as sdk: |
9 | 10 | teams = await sdk.teams.list() |
10 | 11 | workspaces = await sdk.workspaces.list_by_team(team_id=teams[0].id) |
11 | | - |
12 | 12 | workspace = workspaces[0] |
13 | 13 |
|
14 | | - envs = await workspace.get_env_vars() |
15 | | - print("Current Environment Variables:") |
16 | | - pprint.pprint(envs) |
| 14 | + new_vars = [ |
| 15 | + EnvVar(name="MY_NEW_VAR", value="hello_world"), |
| 16 | + EnvVar(name="ANOTHER_VAR", value="123456"), |
| 17 | + ] |
17 | 18 |
|
18 | | - envs[0].value = "new_value" # Modify an environment variable |
19 | | - await workspace.set_env_vars(envs) # Update the environment variables |
| 19 | + await workspace.env_vars.set(new_vars) |
20 | 20 |
|
21 | | - print("Updated Environment Variables:") |
22 | | - updated_envs = await workspace.get_env_vars() |
23 | | - pprint.pprint(updated_envs) |
| 21 | + print("\n--- Verifying new list ---") |
| 22 | + current_vars = await workspace.env_vars.get() |
| 23 | + for env in current_vars: |
| 24 | + print(env.model_dump_json(indent=2)) |
24 | 25 |
|
25 | 26 |
|
26 | 27 | if __name__ == "__main__": |
|
0 commit comments