Skip to content

Commit 55b87ee

Browse files
google-genai-botcopybara-github
authored andcommitted
fix: operation should be added irrespective of actions or entities
PiperOrigin-RevId: 784199909
1 parent 403ace1 commit 55b87ee

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

core/src/main/java/com/google/adk/tools/applicationintegrationtoolset/IntegrationConnectorTool.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@ public Single<Map<String, Object>> runAsync(Map<String, Object> args, ToolContex
159159
args.put("connectionName", this.connectionName);
160160
args.put("serviceName", this.serviceName);
161161
args.put("host", this.host);
162-
if (!isNullOrEmpty(this.entity) && !isNullOrEmpty(this.operation)) {
162+
if (!isNullOrEmpty(this.entity)) {
163163
args.put("entity", this.entity);
164-
args.put("operation", this.operation);
165164
} else if (!isNullOrEmpty(this.action)) {
166165
args.put("action", this.action);
167166
}
167+
if (!isNullOrEmpty(this.operation)) {
168+
args.put("operation", this.operation);
169+
}
168170
}
169171

170172
return Single.fromCallable(
@@ -237,10 +239,12 @@ String getOperationIdFromPathUrl(String openApiSchemaString, String pathUrl) thr
237239
this.action = "";
238240
if (operationNode.has("x-entity")) {
239241
this.entity = operationNode.path("x-entity").asText();
240-
this.operation = operationNode.path("x-operation").asText();
241242
} else if (operationNode.has("x-action")) {
242243
this.action = operationNode.path("x-action").asText();
243244
}
245+
if (operationNode.has("x-operation")) {
246+
this.operation = operationNode.path("x-operation").asText();
247+
}
244248
// Get the operationId from the operationNode
245249
if (operationNode.has("operationId")) {
246250
return operationNode.path("operationId").asText();

core/src/test/java/com/google/adk/tools/applicationintegrationtoolset/IntegrationConnectorToolTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public final class IntegrationConnectorToolTest {
7272
+ " for Executing"
7373
+ " Action\\\"},\\\"paths\\\":{\\\"/v2/projects/test-project/locations/test-region/integrations/ExecuteConnection:execute\\\":{\\\"post\\\":{\\\"summary\\\":\\\"Execute"
7474
+ " a custom"
75-
+ " action\\\",\\\"operationId\\\":\\\"execute_custom_action\\\",\\\"x-action\\\":\\\"CUSTOM_ACTION\\\",\\\"requestBody\\\":{\\\"required\\\":true,\\\"content\\\":{\\\"application/json\\\":{\\\"schema\\\":{\\\"$ref\\\":\\\"#/components/schemas/ActionRequest\\\"}}}}}}},\\\"components\\\":{\\\"schemas\\\":{\\\"ActionRequest\\\":{\\\"type\\\":\\\"object\\\",\\\"required\\\":[\\\"connectionName\\\",\\\"action\\\",\\\"payload\\\"],\\\"properties\\\":{\\\"connectionName\\\":{\\\"type\\\":\\\"string\\\"},\\\"action\\\":{\\\"type\\\":\\\"string\\\"},\\\"payload\\\":{\\\"type\\\":\\\"string\\\"}}}}}}\"}";
75+
+ " action\\\",\\\"operationId\\\":\\\"execute_custom_action\\\",\\\"x-action\\\":\\\"CUSTOM_ACTION\\\",\\\"x-operation\\\":\\\"EXECUTE_ACTION\\\",\\\"requestBody\\\":{\\\"required\\\":true,\\\"content\\\":{\\\"application/json\\\":{\\\"schema\\\":{\\\"$ref\\\":\\\"#/components/schemas/ActionRequest\\\"}}}}}}},\\\"components\\\":{\\\"schemas\\\":{\\\"ActionRequest\\\":{\\\"type\\\":\\\"object\\\",\\\"required\\\":[\\\"connectionName\\\",\\\"action\\\",\\\"operation\\\"],\\\"properties\\\":{\\\"connectionName\\\":{\\\"type\\\":\\\"string\\\"},\\\"serviceName\\\":{\\\"type\\\":\\\"string\\\"},\\\"host\\\":{\\\"type\\\":\\\"string\\\"},\\\"action\\\":{\\\"type\\\":\\\"string\\\"},\\\"operation\\\":{\\\"type\\\":\\\"string\\\"}}}}}}\"}";
7676

7777
@Before
7878
public void setUp() {
@@ -242,8 +242,8 @@ public void connectorToolWithAction_runAsync_success() throws Exception {
242242
assertThat(inputArgs).containsEntry("serviceName", "test-service-action");
243243
assertThat(inputArgs).containsEntry("host", "test-host-action");
244244
assertThat(inputArgs).containsEntry("action", "CUSTOM_ACTION");
245+
assertThat(inputArgs).containsEntry("operation", "EXECUTE_ACTION");
245246
assertThat(inputArgs).doesNotContainKey("entity");
246-
assertThat(inputArgs).doesNotContainKey("operation");
247247
}
248248

249249
@Test

0 commit comments

Comments
 (0)