|
34 | 34 | TaskPushNotificationConfig, |
35 | 35 | TaskResubscriptionRequest, |
36 | 36 | TaskStatusUpdateEvent, |
| 37 | + ListTaskPushNotificationConfigRequest, |
| 38 | + ListTaskPushNotificationConfigResponse, |
| 39 | + ListTaskPushNotificationConfigSuccessResponse, |
| 40 | + DeleteTaskPushNotificationConfigRequest, |
| 41 | + DeleteTaskPushNotificationConfigResponse, |
| 42 | + DeleteTaskPushNotificationConfigSuccessResponse |
37 | 43 | ) |
38 | 44 | from a2a.utils.errors import ServerError |
39 | 45 | from a2a.utils.helpers import validate |
@@ -214,7 +220,7 @@ async def on_resubscribe_to_task( |
214 | 220 | ) |
215 | 221 | ) |
216 | 222 |
|
217 | | - async def get_push_notification( |
| 223 | + async def get_push_notification_config( |
218 | 224 | self, |
219 | 225 | request: GetTaskPushNotificationConfigRequest, |
220 | 226 | context: ServerCallContext | None = None, |
@@ -252,7 +258,7 @@ async def get_push_notification( |
252 | 258 | lambda self: self.agent_card.capabilities.pushNotifications, |
253 | 259 | 'Push notifications are not supported by the agent', |
254 | 260 | ) |
255 | | - async def set_push_notification( |
| 261 | + async def set_push_notification_config( |
256 | 262 | self, |
257 | 263 | request: SetTaskPushNotificationConfigRequest, |
258 | 264 | context: ServerCallContext | None = None, |
@@ -325,3 +331,69 @@ async def on_get_task( |
325 | 331 | id=request.id, error=e.error if e.error else InternalError() |
326 | 332 | ) |
327 | 333 | ) |
| 334 | + |
| 335 | + async def list_push_notification_config( |
| 336 | + self, |
| 337 | + request: ListTaskPushNotificationConfigRequest, |
| 338 | + context: ServerCallContext | None = None, |
| 339 | + ) -> ListTaskPushNotificationConfigResponse: |
| 340 | + """Handles the 'tasks/pushNotificationConfig/list' JSON-RPC method. |
| 341 | +
|
| 342 | + Args: |
| 343 | + request: The incoming `ListTaskPushNotificationConfigRequest` object. |
| 344 | + context: Context provided by the server. |
| 345 | +
|
| 346 | + Returns: |
| 347 | + A `ListTaskPushNotificationConfigResponse` object containing the config or a JSON-RPC error. |
| 348 | + """ |
| 349 | + try: |
| 350 | + config = ( |
| 351 | + await self.request_handler.on_list_task_push_notification_config( |
| 352 | + request.params, context |
| 353 | + ) |
| 354 | + ) |
| 355 | + return prepare_response_object( |
| 356 | + request.id, |
| 357 | + config, |
| 358 | + (list,), |
| 359 | + ListTaskPushNotificationConfigSuccessResponse, |
| 360 | + ListTaskPushNotificationConfigResponse, |
| 361 | + ) |
| 362 | + except ServerError as e: |
| 363 | + return ListTaskPushNotificationConfigResponse( |
| 364 | + root=JSONRPCErrorResponse( |
| 365 | + id=request.id, error=e.error if e.error else InternalError() |
| 366 | + ) |
| 367 | + ) |
| 368 | + |
| 369 | + async def delete_push_notification_config( |
| 370 | + self, |
| 371 | + request: DeleteTaskPushNotificationConfigRequest, |
| 372 | + context: ServerCallContext | None = None, |
| 373 | + ) -> DeleteTaskPushNotificationConfigResponse: |
| 374 | + """Handles the 'tasks/pushNotificationConfig/list' JSON-RPC method. |
| 375 | +
|
| 376 | + Args: |
| 377 | + request: The incoming `DeleteTaskPushNotificationConfigRequest` object. |
| 378 | + context: Context provided by the server. |
| 379 | +
|
| 380 | + Returns: |
| 381 | + A `DeleteTaskPushNotificationConfigResponse` object containing the config or a JSON-RPC error. |
| 382 | + """ |
| 383 | + try: |
| 384 | + ( |
| 385 | + await self.request_handler.on_delete_task_push_notification_config( |
| 386 | + request.params, context |
| 387 | + ) |
| 388 | + ) |
| 389 | + return DeleteTaskPushNotificationConfigResponse( |
| 390 | + root=DeleteTaskPushNotificationConfigSuccessResponse( |
| 391 | + id=request.id, result=None |
| 392 | + ) |
| 393 | + ) |
| 394 | + except ServerError as e: |
| 395 | + return DeleteTaskPushNotificationConfigResponse( |
| 396 | + root=JSONRPCErrorResponse( |
| 397 | + id=request.id, error=e.error if e.error else InternalError() |
| 398 | + ) |
| 399 | + ) |
0 commit comments