-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresources.py
More file actions
68 lines (51 loc) · 1.73 KB
/
resources.py
File metadata and controls
68 lines (51 loc) · 1.73 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from typing import List, Protocol
from ..base import ResourceBase, APIOperation
from .models import Workspace, WorkspaceCreate
class ListWorkspacesCallable(Protocol):
async def __call__(self, *, team_id: int) -> List[Workspace]: ...
class GetWorkspaceCallable(Protocol):
async def __call__(self, *, workspace_id: int) -> Workspace: ...
class CreateWorkspaceCallable(Protocol):
async def __call__(self, *, data: WorkspaceCreate) -> Workspace: ...
class WorkspacesResource(ResourceBase):
"""Manages all API operations for the Workspace resource."""
list_by_team: ListWorkspacesCallable
"""
Lists all workspaces for a specific team.
Args:
team_id (int): The unique identifier for the team.
Returns:
List[Workspace]: A list of Workspace objects associated with the team.
"""
list_by_team = APIOperation(
method="GET",
endpoint_template="/workspaces/team/{team_id}",
response_model=List[Workspace],
)
get: GetWorkspaceCallable
"""
Fetches a single workspace by its ID.
Args:
workspace_id (int): The unique identifier for the workspace.
Returns:
Workspace: The requested Workspace object.
"""
get = APIOperation(
method="GET",
endpoint_template="/workspaces/{workspace_id}",
response_model=Workspace,
)
create: CreateWorkspaceCallable
"""
Creates a new workspace.
Args:
data (WorkspaceCreate): The data payload for the new workspace.
Returns:
Workspace: The newly created Workspace object.
"""
create = APIOperation(
method="POST",
endpoint_template="/workspaces",
input_model=WorkspaceCreate,
response_model=Workspace,
)