You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-03-30 10:57:20 -07:00
feat: Allow overriding connection template
PiperOrigin-RevId: 841984336
This commit is contained in:
committed by
Copybara-Service
parent
82e6623fa9
commit
cde7f7c243
@@ -83,6 +83,7 @@ class ApplicationIntegrationToolset(BaseToolset):
|
||||
self,
|
||||
project: str,
|
||||
location: str,
|
||||
connection_template_override: Optional[str] = None,
|
||||
integration: Optional[str] = None,
|
||||
triggers: Optional[List[str]] = None,
|
||||
connection: Optional[str] = None,
|
||||
@@ -104,6 +105,8 @@ class ApplicationIntegrationToolset(BaseToolset):
|
||||
Args:
|
||||
project: The GCP project ID.
|
||||
location: The GCP location.
|
||||
connection_template_override: Overrides `ExecuteConnection` default
|
||||
integration name.
|
||||
integration: The integration name.
|
||||
triggers: The list of trigger names in the integration.
|
||||
connection: The connection name.
|
||||
@@ -129,6 +132,7 @@ class ApplicationIntegrationToolset(BaseToolset):
|
||||
super().__init__(tool_filter=tool_filter)
|
||||
self.project = project
|
||||
self.location = location
|
||||
self._connection_template_override = connection_template_override
|
||||
self._integration = integration
|
||||
self._triggers = triggers
|
||||
self._connection = connection
|
||||
@@ -142,6 +146,7 @@ class ApplicationIntegrationToolset(BaseToolset):
|
||||
integration_client = IntegrationClient(
|
||||
project,
|
||||
location,
|
||||
connection_template_override,
|
||||
integration,
|
||||
triggers,
|
||||
connection,
|
||||
|
||||
@@ -38,6 +38,7 @@ class IntegrationClient:
|
||||
self,
|
||||
project: str,
|
||||
location: str,
|
||||
connection_template_override: Optional[str] = None,
|
||||
integration: Optional[str] = None,
|
||||
triggers: Optional[List[str]] = None,
|
||||
connection: Optional[str] = None,
|
||||
@@ -50,6 +51,8 @@ class IntegrationClient:
|
||||
Args:
|
||||
project: The Google Cloud project ID.
|
||||
location: The Google Cloud location (e.g., us-central1).
|
||||
connection_template_override: Overrides `ExecuteConnection` default
|
||||
integration name.
|
||||
integration: The integration name.
|
||||
triggers: The list of trigger IDs for the integration.
|
||||
connection: The connection name.
|
||||
@@ -62,6 +65,7 @@ class IntegrationClient:
|
||||
"""
|
||||
self.project = project
|
||||
self.location = location
|
||||
self.connection_template_override = connection_template_override
|
||||
self.integration = integration
|
||||
self.triggers = triggers
|
||||
self.connection = connection
|
||||
@@ -130,7 +134,7 @@ class IntegrationClient:
|
||||
Exception: For any other unexpected errors.
|
||||
"""
|
||||
# Application Integration needs to be provisioned in the same region as connection and an integration with name "ExecuteConnection" and trigger "api_trigger/ExecuteConnection" should be created as per the documentation.
|
||||
integration_name = "ExecuteConnection"
|
||||
integration_name = self.connection_template_override or "ExecuteConnection"
|
||||
connections_client = ConnectionsClient(
|
||||
self.project,
|
||||
self.location,
|
||||
|
||||
+49
-6
@@ -192,7 +192,15 @@ async def test_initialization_with_integration_and_trigger(
|
||||
project, location, integration=integration_name, triggers=triggers
|
||||
)
|
||||
mock_integration_client.assert_called_once_with(
|
||||
project, location, integration_name, triggers, None, None, None, None
|
||||
project,
|
||||
location,
|
||||
None,
|
||||
integration_name,
|
||||
triggers,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
mock_integration_client.return_value.get_openapi_spec_for_integration.assert_called_once()
|
||||
mock_connections_client.assert_not_called()
|
||||
@@ -218,6 +226,7 @@ async def test_initialization_with_integration_and_list_of_triggers(
|
||||
mock_integration_client.assert_called_once_with(
|
||||
project,
|
||||
location,
|
||||
None,
|
||||
integration_name,
|
||||
triggers,
|
||||
None,
|
||||
@@ -247,7 +256,7 @@ async def test_initialization_with_integration_and_empty_trigger_list(
|
||||
project, location, integration=integration_name
|
||||
)
|
||||
mock_integration_client.assert_called_once_with(
|
||||
project, location, integration_name, None, None, None, None, None
|
||||
project, location, None, integration_name, None, None, None, None, None
|
||||
)
|
||||
mock_integration_client.return_value.get_openapi_spec_for_integration.assert_called_once()
|
||||
mock_connections_client.assert_not_called()
|
||||
@@ -287,6 +296,7 @@ async def test_initialization_with_connection_and_entity_operations(
|
||||
location,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
connection_name,
|
||||
entity_operations_list,
|
||||
None,
|
||||
@@ -335,7 +345,15 @@ async def test_initialization_with_connection_and_actions(
|
||||
tool_instructions=tool_instructions,
|
||||
)
|
||||
mock_integration_client.assert_called_once_with(
|
||||
project, location, None, None, connection_name, None, actions_list, None
|
||||
project,
|
||||
location,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
connection_name,
|
||||
None,
|
||||
actions_list,
|
||||
None,
|
||||
)
|
||||
mock_connections_client.assert_called_once_with(
|
||||
project, location, connection_name, None
|
||||
@@ -414,6 +432,7 @@ def test_initialization_with_service_account_credentials(
|
||||
mock_integration_client.assert_called_once_with(
|
||||
project,
|
||||
location,
|
||||
None,
|
||||
integration_name,
|
||||
triggers,
|
||||
None,
|
||||
@@ -441,7 +460,15 @@ def test_initialization_without_explicit_service_account_credentials(
|
||||
project, location, integration=integration_name, triggers=triggers
|
||||
)
|
||||
mock_integration_client.assert_called_once_with(
|
||||
project, location, integration_name, triggers, None, None, None, None
|
||||
project,
|
||||
location,
|
||||
None,
|
||||
integration_name,
|
||||
triggers,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
mock_openapi_toolset.assert_called_once()
|
||||
_, kwargs = mock_openapi_toolset.call_args
|
||||
@@ -542,7 +569,15 @@ async def test_init_with_connection_and_custom_auth(
|
||||
auth_credential=auth_credential,
|
||||
)
|
||||
mock_integration_client.assert_called_once_with(
|
||||
project, location, None, None, connection_name, None, actions_list, None
|
||||
project,
|
||||
location,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
connection_name,
|
||||
None,
|
||||
actions_list,
|
||||
None,
|
||||
)
|
||||
mock_connections_client.assert_called_once_with(
|
||||
project, location, connection_name, None
|
||||
@@ -611,7 +646,15 @@ async def test_init_with_connection_with_auth_override_disabled_and_custom_auth(
|
||||
auth_credential=auth_credential,
|
||||
)
|
||||
mock_integration_client.assert_called_once_with(
|
||||
project, location, None, None, connection_name, None, actions_list, None
|
||||
project,
|
||||
location,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
connection_name,
|
||||
None,
|
||||
actions_list,
|
||||
None,
|
||||
)
|
||||
mock_connections_client.assert_called_once_with(
|
||||
project, location, connection_name, None
|
||||
|
||||
Reference in New Issue
Block a user