Skip to content

Commit 17b8372

Browse files
authored
chore(test): bla bla (#28)
Co-authored-by: JD <>
1 parent 28af131 commit 17b8372

File tree

5 files changed

+88
-30
lines changed

5 files changed

+88
-30
lines changed

examples/workspaces/create_workspace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def main():
2121
created_workspace = await sdk.workspaces.create(data=workspace_data)
2222

2323
print("\n--- Details of successfully created workspace ---")
24-
pprint.pprint(created_workspace.model_dump())
24+
pprint.pprint(created_workspace.model_dump_json())
2525

2626

2727
if __name__ == "__main__":
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import asyncio
2+
from codesphere import CodesphereSDK
3+
4+
5+
async def main():
6+
"""Fetches a workspace within a Team."""
7+
async with CodesphereSDK() as sdk:
8+
pass
9+
10+
11+
if __name__ == "__main__":
12+
asyncio.run(main())

src/codesphere/resources/team/resources.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from asyncio import Protocol
2-
from typing import Awaitable, Callable, List
1+
from typing import Awaitable, Callable, List, Protocol
32
from ..base import ResourceBase, APIOperation
43
from .models import Team, TeamCreate
54

@@ -12,14 +11,13 @@ class CreateTeamCallable(Protocol):
1211
async def __call__(self, *, data: TeamCreate) -> Team: ...
1312

1413

15-
class DeleteTeamCallable(Protocol):
16-
async def __call__(self, *, team_id: int) -> None: ...
17-
18-
1914
class TeamsResource(ResourceBase):
2015
"""Contains all API operations for team ressources."""
2116

2217
list: Callable[[], Awaitable[List[Team]]]
18+
"""
19+
Fetches all teams.
20+
"""
2321
list = APIOperation(
2422
method="GET",
2523
endpoint_template="/teams",
@@ -28,6 +26,15 @@ class TeamsResource(ResourceBase):
2826
)
2927

3028
get: GetTeamCallable
29+
"""
30+
Fetches a single team by its ID.
31+
32+
Args:
33+
team_id (int): The unique identifier for the team.
34+
35+
Returns:
36+
Team: The requested Team object.
37+
"""
3138
get = APIOperation(
3239
method="GET",
3340
endpoint_template="/teams/{team_id}",
@@ -36,17 +43,18 @@ class TeamsResource(ResourceBase):
3643
)
3744

3845
create: CreateTeamCallable
46+
"""
47+
Creates a new team.
48+
49+
Args:
50+
data (TeamCreate): The data payload for the new team.
51+
52+
Returns:
53+
Team: The newly created Team object.
54+
"""
3955
create = APIOperation(
4056
method="POST",
4157
endpoint_template="/teams",
4258
input_model=TeamCreate,
4359
response_model=Team,
4460
)
45-
46-
delete: DeleteTeamCallable
47-
delete = APIOperation(
48-
method="DELETE",
49-
endpoint_template="/teams/{team_id}",
50-
input_model=None,
51-
response_model=None,
52-
)

src/codesphere/resources/workspace/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,12 @@ async def delete_env_vars(
132132
payload = var_names
133133

134134
await self._http_client.delete(f"/workspaces/{self.id}/env-vars", json=payload)
135+
136+
async def execute_command():
137+
pass
138+
139+
async def git_pull():
140+
pass
141+
142+
async def git_head():
143+
pass

src/codesphere/resources/workspace/resources.py

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,68 @@
1-
from typing import List
1+
from typing import List, Protocol
22
from ..base import ResourceBase, APIOperation
3-
from .models import Workspace, WorkspaceCreate, WorkspaceUpdate
3+
from .models import Workspace, WorkspaceCreate
4+
5+
6+
class ListWorkspacesCallable(Protocol):
7+
async def __call__(self, *, team_id: int) -> List[Workspace]: ...
8+
9+
10+
class GetWorkspaceCallable(Protocol):
11+
async def __call__(self, *, workspace_id: int) -> Workspace: ...
12+
13+
14+
class CreateWorkspaceCallable(Protocol):
15+
async def __call__(self, *, data: WorkspaceCreate) -> Workspace: ...
416

517

618
class WorkspacesResource(ResourceBase):
719
"""Manages all API operations for the Workspace resource."""
820

21+
list_by_team: ListWorkspacesCallable
22+
"""
23+
Lists all workspaces for a specific team.
24+
25+
Args:
26+
team_id (int): The unique identifier for the team.
27+
28+
Returns:
29+
List[Workspace]: A list of Workspace objects associated with the team.
30+
"""
931
list_by_team = APIOperation(
1032
method="GET",
1133
endpoint_template="/workspaces/team/{team_id}",
1234
response_model=List[Workspace],
1335
)
1436

37+
get: GetWorkspaceCallable
38+
"""
39+
Fetches a single workspace by its ID.
40+
41+
Args:
42+
workspace_id (int): The unique identifier for the workspace.
43+
44+
Returns:
45+
Workspace: The requested Workspace object.
46+
"""
1547
get = APIOperation(
1648
method="GET",
1749
endpoint_template="/workspaces/{workspace_id}",
1850
response_model=Workspace,
1951
)
2052

53+
create: CreateWorkspaceCallable
54+
"""
55+
Creates a new workspace.
56+
57+
Args:
58+
data (WorkspaceCreate): The data payload for the new workspace.
59+
60+
Returns:
61+
Workspace: The newly created Workspace object.
62+
"""
2163
create = APIOperation(
2264
method="POST",
2365
endpoint_template="/workspaces",
2466
input_model=WorkspaceCreate,
2567
response_model=Workspace,
2668
)
27-
28-
update = APIOperation(
29-
method="PATCH",
30-
endpoint_template="/workspaces/{workspace_id}",
31-
input_model=WorkspaceUpdate,
32-
response_model=None,
33-
)
34-
35-
delete = APIOperation(
36-
method="DELETE",
37-
endpoint_template="/workspaces/{workspace_id}",
38-
response_model=None,
39-
)

0 commit comments

Comments
 (0)