File tree Expand file tree Collapse file tree 19 files changed +600
-559
lines changed
Expand file tree Collapse file tree 19 files changed +600
-559
lines changed Original file line number Diff line number Diff line change 1+ CS_TOKEN = " secret_token"
Original file line number Diff line number Diff line change @@ -16,5 +16,6 @@ wheels/
1616.venv /
1717venv /
1818env /
19+ * .env
1920
2021.pytest_cache
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ install: ## Sets up the development environment
1212 @echo " 2. Installing all dependencies (including 'dev')..."
1313 uv pip install -e ' .[dev]'
1414 @echo " 3. Installing git hooks with pre-commit..."
15- pre-commit install --hook-type commit-msg --hook-type pre-commit --hook-type pre-push
15+ uv run pre-commit install --hook-type commit-msg --hook-type pre-commit --hook-type pre-push
1616 @echo " \n\033[0;32mSetup complete! Please activate the virtual environment with 'source .venv/bin/activate'.\033[0m"
1717
1818commit : # # Starts Commitizen for a guided commit message
Original file line number Diff line number Diff line change 11import asyncio
2- import pprint
32from codesphere import CodesphereSDK
43
54
65async def main ():
76 """Fetches datacenters."""
87 async with CodesphereSDK () as sdk :
98 datacenters = await sdk .metadata .datacenters ()
10-
119 for datacenter in datacenters :
12- pprint .pprint (datacenter .name )
13- pprint .pprint (datacenter .city )
14- pprint .pprint (datacenter .countryCode )
15- pprint .pprint (datacenter .id )
10+ print (datacenter .model_dump_json (indent = 2 ))
11+
1612
1713if __name__ == "__main__" :
1814 asyncio .run (main ())
Original file line number Diff line number Diff line change 11import asyncio
2- import pprint
32from codesphere import CodesphereSDK
43
54
65async def main ():
76 """Fetches base images."""
87 async with CodesphereSDK () as sdk :
98 images = await sdk .metadata .images ()
10-
119 for image in images :
12- pprint .pprint (image .id )
13- pprint .pprint (image .name )
14- pprint .pprint (image .supportedUntil )
10+ print (image .model_dump_json (indent = 2 ))
11+
1512
1613if __name__ == "__main__" :
1714 asyncio .run (main ())
Original file line number Diff line number Diff line change 11import asyncio
2- import pprint
32from codesphere import CodesphereSDK
43
54
@@ -9,18 +8,8 @@ async def main():
98 plans = await sdk .metadata .plans ()
109
1110 for plan in plans :
12- pprint .pprint (plan .id )
13- pprint .pprint (plan .title )
14- pprint .pprint (plan .priceUsd )
15- pprint .pprint (plan .deprecated )
16- pprint .pprint (plan .characteristics .id )
17- pprint .pprint (plan .characteristics .CPU )
18- pprint .pprint (plan .characteristics .GPU )
19- pprint .pprint (plan .characteristics .RAM )
20- pprint .pprint (plan .characteristics .SSD )
21- pprint .pprint (plan .characteristics .TempStorage )
22- pprint .pprint (plan .characteristics .onDemand )
23- pprint .pprint (plan .maxReplicas )
11+ print (plan .model_dump_json (indent = 2 ))
12+
2413
2514if __name__ == "__main__" :
2615 asyncio .run (main ())
Original file line number Diff line number Diff line change 11import asyncio
2- import pprint
3-
4- from codesphere import CodesphereSDK
2+ from codesphere import CodesphereSDK , TeamCreate
53
64
75async def main ():
86 try :
97 async with CodesphereSDK () as sdk :
10- created_team = await sdk .teams .create (name = "hello" , dc = 2 )
8+ newTeam = TeamCreate (name = "test" , dc = 2 )
9+ created_team = await sdk .teams .create (data = newTeam )
1110 print ("\n --- Details for the created team ---" )
12- pprint .pprint (created_team .model_dump ())
13-
14- print (f"Team ID: { created_team .id } , Name: { created_team .name } " )
15-
11+ print (created_team .model_dump_json (indent = 2 ))
1612 except Exception as e :
1713 print (f"An error occurred: { e } " )
1814
Original file line number Diff line number Diff line change 11import asyncio
2- import pprint
3-
42from codesphere import CodesphereSDK
53
64
@@ -9,7 +7,7 @@ async def main():
97 async with CodesphereSDK () as sdk :
108 team_to_delete = await sdk .teams .get (team_id = "<id>" )
119 print ("\n --- Details of the team to be deleted ---" )
12- pprint . pprint (team_to_delete .model_dump ( ))
10+ print (team_to_delete .model_dump_json ( indent = 2 ))
1311 await team_to_delete .delete ()
1412 print (f"Team with ID { team_to_delete .id } was successfully deleted." )
1513
Original file line number Diff line number Diff line change 11import asyncio
2- import pprint
32
43from codesphere import CodesphereSDK
54
@@ -8,9 +7,10 @@ async def main():
87 try :
98 async with CodesphereSDK () as sdk :
109 teams = await sdk .teams .list ()
10+ print (teams [0 ].model_dump_json (indent = 2 ))
1111 first_team = await sdk .teams .get (team_id = teams [0 ].id )
1212 print ("\n --- Details for the first team ---" )
13- pprint . pprint (first_team .model_dump ( ))
13+ print (first_team .model_dump_json ( indent = 2 ))
1414
1515 except Exception as e :
1616 print (f"An error occurred: { e } " )
Original file line number Diff line number Diff line change @@ -7,9 +7,8 @@ async def main():
77 try :
88 async with CodesphereSDK () as sdk :
99 teams = await sdk .teams .list ()
10- print (f"Found { len (teams )} teams:" )
1110 for team in teams :
12- print (f"Team ID: { team .id } , Name: { team . name } " )
11+ print (team .model_dump_json ( indent = 2 ) )
1312
1413 except Exception as e :
1514 print (f"An error occurred: { e } " )
You can’t perform that action at this time.
0 commit comments