Skip to content

Commit 084aca1

Browse files
Add util method to extract Task ID and Push Notification Config ID from request
Both `GetTaskPushNotificationConfigRequest` and `DeleteTaskPushNotificationConfigRequest` have a `name` field that has the same format: `tasks/{task_id}/pushNotificationConfigs/{config_id}`. Adding here a utility to extract the Task ID and Config ID. Can't output a `types.TaskPushNotificationConfig` as the `PushNotificationConfig` requires a url.
1 parent aa159f3 commit 084aca1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/a2a/utils/proto_utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,26 @@ def task_push_notification_config(
366366
),
367367
)
368368

369+
@classmethod
370+
def task_push_notification_config_params(
371+
cls,
372+
request: (
373+
a2a_pb2.GetTaskPushNotificationConfigRequest
374+
| a2a_pb2.DeleteTaskPushNotificationConfigRequest
375+
),
376+
) -> tuple[str, str]:
377+
m = _TASK_PUSH_CONFIG_NAME_MATCH.match(request.name)
378+
if not m:
379+
raise ServerError(
380+
error=types.InvalidParamsError(
381+
message=f'No task or config id for {request.name}'
382+
)
383+
)
384+
return (
385+
m.group(1),
386+
m.group(2),
387+
)
388+
369389
@classmethod
370390
def agent_card(
371391
cls,

0 commit comments

Comments
 (0)