Skip to content

Commit 145eb30

Browse files
committed
Update proto_utils.py based on new tests
1 parent 64648c9 commit 145eb30

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/a2a/utils/proto_utils.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,16 @@ def authentication_info(
143143
def push_notification_config(
144144
cls, config: types.PushNotificationConfig
145145
) -> a2a_pb2.PushNotificationConfig:
146+
auth_info = (
147+
ToProto.authentication_info(config.authentication)
148+
if config.authentication
149+
else None
150+
)
146151
return a2a_pb2.PushNotificationConfig(
147152
id=config.id or '',
148153
url=config.url,
149154
token=config.token,
150-
authentication=ToProto.authentication_info(config.authentication),
155+
authentication=auth_info,
151156
)
152157

153158
@classmethod
@@ -185,7 +190,9 @@ def message_send_configuration(
185190
accepted_output_modes=list(config.acceptedOutputModes),
186191
push_notification=ToProto.push_notification_config(
187192
config.pushNotificationConfig
188-
),
193+
)
194+
if config.pushNotificationConfig
195+
else None,
189196
history_length=config.historyLength,
190197
blocking=config.blocking or False,
191198
)
@@ -252,7 +259,7 @@ def task_push_notification_config(
252259
cls, config: types.TaskPushNotificationConfig
253260
) -> a2a_pb2.TaskPushNotificationConfig:
254261
return a2a_pb2.TaskPushNotificationConfig(
255-
name=f'tasks/{config.taskId}/pushNotifications/{config.taskId}',
262+
name=f'tasks/{config.taskId}/pushNotifications/{config.pushNotificationConfig.id}',
256263
push_notification_config=cls.push_notification_config(
257264
config.pushNotificationConfig,
258265
),
@@ -548,7 +555,9 @@ def push_notification_config(
548555
id=config.id,
549556
url=config.url,
550557
token=config.token,
551-
authentication=FromProto.authentication_info(config.authentication),
558+
authentication=FromProto.authentication_info(config.authentication)
559+
if config.HasField('authentication')
560+
else None,
552561
)
553562

554563
@classmethod
@@ -568,7 +577,9 @@ def message_send_configuration(
568577
acceptedOutputModes=list(config.accepted_output_modes),
569578
pushNotificationConfig=FromProto.push_notification_config(
570579
config.push_notification
571-
),
580+
)
581+
if config.HasField('push_notification')
582+
else None,
572583
historyLength=config.history_length,
573584
blocking=config.blocking,
574585
)
@@ -720,7 +731,7 @@ def security_scheme(
720731
root=types.APIKeySecurityScheme(
721732
description=scheme.api_key_security_scheme.description,
722733
name=scheme.api_key_security_scheme.name,
723-
in_=scheme.api_key_security_scheme.location, # type: ignore[call-arg]
734+
in_=types.In(scheme.api_key_security_scheme.location), # type: ignore[call-arg]
724735
)
725736
)
726737
if scheme.HasField('http_auth_security_scheme'):

0 commit comments

Comments
 (0)