|
1 | | -from typing import List |
| 1 | +from typing import List, Protocol |
2 | 2 | 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: ... |
4 | 16 |
|
5 | 17 |
|
6 | 18 | class WorkspacesResource(ResourceBase): |
7 | 19 | """Manages all API operations for the Workspace resource.""" |
8 | 20 |
|
| 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 | + """ |
9 | 31 | list_by_team = APIOperation( |
10 | 32 | method="GET", |
11 | 33 | endpoint_template="/workspaces/team/{team_id}", |
12 | 34 | response_model=List[Workspace], |
13 | 35 | ) |
14 | 36 |
|
| 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 | + """ |
15 | 47 | get = APIOperation( |
16 | 48 | method="GET", |
17 | 49 | endpoint_template="/workspaces/{workspace_id}", |
18 | 50 | response_model=Workspace, |
19 | 51 | ) |
20 | 52 |
|
| 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 | + """ |
21 | 63 | create = APIOperation( |
22 | 64 | method="POST", |
23 | 65 | endpoint_template="/workspaces", |
24 | 66 | input_model=WorkspaceCreate, |
25 | 67 | response_model=Workspace, |
26 | 68 | ) |
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