8000 feat: trigger in ApplicationIntegrationTools is changed to triggers a… · Syntax404-coder/adk-python@d740b93 · GitHub
[go: up one dir, main page]

Skip to content

Commit d740b93

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: trigger in ApplicationIntegrationTools is changed to triggers and is a list of strings
PiperOrigin-RevId: 758034458
1 parent 2d84b13 commit d740b93

File tree

4 files changed

+138
-74
lines changed

4 files changed

+138
-74
lines changed

src/google/adk/tools/application_integration_tool/application_integration_toolset.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ApplicationIntegrationToolset:
4646
project="test-project",
4747
location="us-central1"
4848
integration="test-integration",
49-
trigger="api_trigger/test_trigger",
49+
triggers=["api_trigger/test_trigger"],
5050
service_account_credentials={...},
5151
)
5252
@@ -80,7 +80,7 @@ def __init__(
8080
project: str,
8181
location: str,
8282
integration: Optional[str] = None,
83-
trigger: Optional[str] = None,
83+
triggers: Optional[List[str]] = None,
8484
connection: Optional[str] = None,
8585
entity_operations: Optional[str] = None,
8686
actions: Optional[str] = None,
@@ -95,10 +95,11 @@ def __init__(
9595
):
9696
"""Args:
9797
98+
Args:
9899
project: The GCP project ID.
99100
location: The GCP location.
100101
integration: The integration name.
101-
trigger: The trigger name.
102+
triggers: The list of trigger names in the integration.
102103
connection: The connection name.
103104
entity_operations: The entity operations supported by the connection.
104105
actions: The actions supported by the connection.
@@ -112,15 +113,17 @@ def __init__(
112113
expose.
113114
114115
Raises:
115-
ValueError: If neither integration and trigger nor connection and
116-
(entity_operations or actions) is provided.
116+
ValueError: If none of the following conditions are met:
117+
- `integration` is provided.
118+
- `connection` is provided and at least one of `entity_operations`
119+
or `actions` is provided.
117120
Exception: If there is an error during the initialization of the
118121
integration or connection client.
119122
"""
120123
self.project = project
121124
self.location = location
122125
self.integration = integration
123-
self.trigger = trigger
126+
self.triggers = triggers
124127
self.connection = connection
125128
self.entity_operations = entity_operations
126129
self.actions = actions
@@ -133,14 +136,14 @@ def __init__(
133136
project,
134137
location,
135138
integration,
136-
trigger,
139+
triggers,
137140
connection,
138141
entity_operations,
139142
actions,
140143
service_account_json,
141144
)
142145
connection_details = {}
143-
if integration and trigger:
146+
if integration:
144147
spec = integration_client.get_openapi_spec_for_integration()
145148
elif connection and (entity_operations or actions):
146149
connections_client = ConnectionsClient(
@@ -153,7 +156,7 @@ def __init__(
153156
)
154157
else:
155158
raise ValueError(
156-
"Either (integration and trigger) or (connection and"
159+
"Invalid request, Either integration or (connection and"
157160
" (entity_operations or actions)) should be provided."
158161
)
159162
self.openapi_toolset = None
@@ -183,7 +186,7 @@ def _parse_spec_to_toolset(self, spec_dict, connection_details):
183186
)
184187
auth_scheme = HTTPBearer(bearerFormat="JWT")
185188

186-
if self.integration and self.trigger:
189+
if self.integration:
187190
self.openapi_toolset = OpenAPIToolset(
188191
spec_dict=spec_dict,
189192
auth_credential=auth_credential,

src/google/adk/tools/application_integration_tool/clients/integration_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import json
16-
from typing import Optional
16+
from typing import List, Optional
1717
from google.adk.tools.application_integration_tool.clients.connections_client import ConnectionsClient
1818
import google.auth
1919
from google.auth import default as default_service_credential
@@ -35,7 +35,7 @@ def __init__(
3535
project: str,
3636
location: str,
3737
integration: Optional[str] = None,
38-
trigger: Optional[str] = None,
38+
triggers: Optional[List[str]] = None,
3939
connection: Optional[str] = None,
4040
entity_operations: Optional[dict[str, list[str]]] = None,
4141
actions: Optional[list[str]] = None,
@@ -47,7 +47,7 @@ def __init__(
4747
project: The Google Cloud project ID.
4848
location: The Google Cloud location (e.g., us-central1).
4949
integration: The integration name.
50-
trigger: The trigger ID for the integration.
50+
triggers: The list of trigger IDs for the integration.
5151
connection: The connection name.
5252
entity_operations: A dictionary mapping entity names to a list of
5353
operations (e.g., LIST, CREATE, UPDATE, DELETE, GET).
@@ -59,7 +59,7 @@ def __init__(
5959
self.project = project
6060
self.location = location
6161
self.integration = integration
62-
self.trigger = trigger
62+
self.triggers = triggers
6363
self.connection = connection
6464
self.entity_operations = (
6565
entity_operations if entity_operations is not None else {}
@@ -88,7 +88,7 @@ def get_openapi_spec_for_integration(self):
8888
"apiTriggerResources": [
8989
{
9090
"integrationResource": self.integration,
91-
"triggerId": [self.trigger],
91+
"triggerId": self.triggers,
9292
},
9393
],
9494
"fileFormat": "JSON",
@@ -109,7 +109,7 @@ def get_openapi_spec_for_integration(self):
109109
raise ValueError(
110110
"Invalid request. Please check the provided values of"
111111
f" project({self.project}), location({self.location}),"
112-
f" integration({self.integration}) and trigger({self.trigger})."
112+
f" integration({self.integration})."
113113
) from e
114114
raise ValueError(f"Request error: {e}") from e
115115
except Exception as e:

0 commit comments

Comments
 (0)
0