-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresources.py
More file actions
60 lines (47 loc) · 1.36 KB
/
resources.py
File metadata and controls
60 lines (47 loc) · 1.36 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
from typing import Awaitable, Callable, List, Protocol
from ..base import ResourceBase, APIOperation
from .models import Team, TeamCreate
class GetTeamCallable(Protocol):
async def __call__(self, *, team_id: int) -> Team: ...
class CreateTeamCallable(Protocol):
async def __call__(self, *, data: TeamCreate) -> Team: ...
class TeamsResource(ResourceBase):
"""Contains all API operations for team ressources."""
list: Callable[[], Awaitable[List[Team]]]
"""
Fetches all teams.
"""
list = APIOperation(
method="GET",
endpoint_template="/teams",
input_model=None,
response_model=List[Team],
)
get: GetTeamCallable
"""
Fetches a single team by its ID.
Args:
team_id (int): The unique identifier for the team.
Returns:
Team: The requested Team object.
"""
get = APIOperation(
method="GET",
endpoint_template="/teams/{team_id}",
input_model=None,
response_model=Team,
)
create: CreateTeamCallable
"""
Creates a new team.
Args:
data (TeamCreate): The data payload for the new team.
Returns:
Team: The newly created Team object.
"""
create = APIOperation(
method="POST",
endpoint_template="/teams",
input_model=TeamCreate,
response_model=Team,
)