1+ """API endpoints for client management operations."""
2+
13import uuid
24from typing import Annotated
35
@@ -18,6 +20,22 @@ async def create_client(
1820 data : models .CreateClient ,
1921 token : Annotated [models .DecodedClientToken , Depends (services .require_scope ("clients" , "create" ))],
2022):
23+ """Create a new client with specified name and scopes.
24+
25+ Creates a new authorized client that can access the pub/sub API
26+ based on their granted scopes. Returns the client ID and generated secret.
27+
28+ Args:
29+ data: Client creation data including name, scopes, and active status.
30+ token: Decoded client token with 'clients:create' scope.
31+
32+ Returns:
33+ CreateClientResult containing the new client ID and secret.
34+
35+ Raises:
36+ AlreadyExistsError: If a client with the same ID already exists.
37+ InvalidClient: If the requesting client lacks 'clients:create' scope.
38+ """
2139 return await services .create_client (data )
2240
2341
@@ -32,6 +50,22 @@ async def get_client(
3250 id : uuid .UUID ,
3351 token : Annotated [models .DecodedClientToken , Depends (services .require_scope ("clients" , "read" ))],
3452):
53+ """Retrieve a client by ID.
54+
55+ Returns the full details of an existing client including ID, name,
56+ scopes, status, and timestamps.
57+
58+ Args:
59+ id: UUID of the client to retrieve.
60+ token: Decoded client token with 'clients:read' scope.
61+
62+ Returns:
63+ Client model with full client details.
64+
65+ Raises:
66+ NotFoundError: If no client with the given ID exists.
67+ InvalidClient: If the requesting client lacks 'clients:read' scope.
68+ """
3569 return await services .get_client (id )
3670
3771
@@ -47,6 +81,23 @@ async def update_client(
4781 data : models .UpdateClient ,
4882 token : Annotated [models .DecodedClientToken , Depends (services .require_scope ("clients" , "update" ))],
4983):
84+ """Update an existing client's name, scopes, or active status.
85+
86+ Modifies the properties of an existing client. Only the fields
87+ provided in the update data will be modified.
88+
89+ Args:
90+ id: UUID of the client to update.
91+ data: Updated client data including name, scopes, and/or active status.
92+ token: Decoded client token with 'clients:update' scope.
93+
94+ Returns:
95+ Client model with updated details.
96+
97+ Raises:
98+ NotFoundError: If no client with the given ID exists.
99+ InvalidClient: If the requesting client lacks 'clients:update' scope.
100+ """
50101 return await services .update_client (id , data )
51102
52103
@@ -61,6 +112,21 @@ async def list_client(
61112 offset : int = Query (default = 0 , ge = 0 ),
62113 limit : int = Query (default = 10 , ge = 1 , le = 100 ),
63114):
115+ """List clients with pagination support.
116+
117+ Returns a paginated list of all clients in the system.
118+
119+ Args:
120+ token: Decoded client token with 'clients:read' scope.
121+ offset: Number of items to skip (for pagination).
122+ limit: Maximum number of items to return (1-100).
123+
124+ Returns:
125+ ListClientAPI containing the list of clients.
126+
127+ Raises:
128+ InvalidClient: If the requesting client lacks 'clients:read' scope.
129+ """
64130 clients = await services .list_client (offset , limit )
65131 return models .ListClientAPI (data = clients )
66132
@@ -75,6 +141,18 @@ async def delete_client(
75141 id : uuid .UUID ,
76142 token : Annotated [models .DecodedClientToken , Depends (services .require_scope ("clients" , "delete" ))],
77143):
144+ """Delete a client by ID.
145+
146+ Permanently removes a client from the system. This action cannot be undone.
147+
148+ Args:
149+ id: UUID of the client to delete.
150+ token: Decoded client token with 'clients:delete' scope.
151+
152+ Raises:
153+ NotFoundError: If no client with the given ID exists.
154+ InvalidClient: If the requesting client lacks 'clients:delete' scope.
155+ """
78156 await services .delete_client (id )
79157
80158
@@ -85,4 +163,20 @@ async def delete_client(
85163 summary = "Issue a new client token" ,
86164)
87165async def issue_client_token (data : models .IssueClientToken ):
166+ """Issue a new JWT access token for a client.
167+
168+ Generates a new access token that the client can use for authentication
169+ in subsequent API requests. The token includes the client's scopes
170+ and has an expiration time.
171+
172+ Args:
173+ data: Client credentials including ID and secret for authentication.
174+
175+ Returns:
176+ ClientToken containing the access token, type, expiration, and scopes.
177+
178+ Raises:
179+ InvalidClient: If client ID or secret is invalid.
180+ ServiceUnavailable: If token generation service is unavailable.
181+ """
88182 return await services .issue_jwt_client_token (client_id = data .client_id , client_secret = data .client_secret )
0 commit comments