@@ -111,6 +111,9 @@ async def _handle_request(
111111 request : Request ,
112112 ) -> Response :
113113 call_context = self ._context_builder .build (request )
114+ if 'tenant' in request .path_params :
115+ call_context .tenant = request .path_params ['tenant' ]
116+
114117 response = await method (request , call_context )
115118 return JSONResponse (content = response )
116119
@@ -131,6 +134,8 @@ async def _handle_streaming_request(
131134 ) from e
132135
133136 call_context = self ._context_builder .build (request )
137+ if 'tenant' in request .path_params :
138+ call_context .tenant = request .path_params ['tenant' ]
134139
135140 async def event_generator (
136141 stream : AsyncIterable [Any ],
@@ -250,10 +255,59 @@ def routes(self) -> dict[tuple[str, str], Callable[[Request], Any]]:
250255 ('/tasks' , 'GET' ): functools .partial (
251256 self ._handle_request , self .handler .list_tasks
252257 ),
258+ # Tenant prefixed routes
259+ ('/{tenant}/message:send' , 'POST' ): functools .partial (
260+ self ._handle_request ,
261+ self .handler .on_message_send ,
262+ ),
263+ ('/{tenant}/message:stream' , 'POST' ): functools .partial (
264+ self ._handle_streaming_request ,
265+ self .handler .on_message_send_stream ,
266+ ),
267+ ('/{tenant}/tasks/{id}:cancel' , 'POST' ): functools .partial (
268+ self ._handle_request , self .handler .on_cancel_task
269+ ),
270+ ('/{tenant}/tasks/{id}:subscribe' , 'GET' ): functools .partial (
271+ self ._handle_streaming_request ,
272+ self .handler .on_subscribe_to_task ,
273+ ),
274+ ('/{tenant}/tasks/{id}' , 'GET' ): functools .partial (
275+ self ._handle_request , self .handler .on_get_task
276+ ),
277+ (
278+ '/{tenant}/tasks/{id}/pushNotificationConfigs/{push_id}' ,
279+ 'GET' ,
280+ ): functools .partial (
281+ self ._handle_request , self .handler .get_push_notification
282+ ),
283+ (
284+ '/{tenant}/tasks/{id}/pushNotificationConfigs/{push_id}' ,
285+ 'DELETE' ,
286+ ): functools .partial (
287+ self ._handle_request , self .handler .delete_push_notification
288+ ),
289+ (
290+ '/{tenant}/tasks/{id}/pushNotificationConfigs' ,
291+ 'POST' ,
292+ ): functools .partial (
293+ self ._handle_request , self .handler .set_push_notification
294+ ),
295+ (
296+ '/{tenant}/tasks/{id}/pushNotificationConfigs' ,
297+ 'GET' ,
298+ ): functools .partial (
299+ self ._handle_request , self .handler .list_push_notifications
300+ ),
301+ ('/{tenant}/tasks' , 'GET' ): functools .partial (
302+ self ._handle_request , self .handler .list_tasks
303+ ),
253304 }
254305 if self .agent_card .capabilities .extended_agent_card :
255306 routes [('/extendedAgentCard' , 'GET' )] = functools .partial (
256307 self ._handle_request , self .handle_authenticated_agent_card
257308 )
309+ routes [('/{tenant}/extendedAgentCard' , 'GET' )] = functools .partial (
310+ self ._handle_request , self .handle_authenticated_agent_card
311+ )
258312
259313 return routes
0 commit comments