88import com .google .adk .agents .ReadonlyContext ;
99import com .google .adk .tools .BaseTool ;
1010import com .google .adk .tools .BaseToolset ;
11- import com .google .adk .tools .applicationintegrationtoolset .IntegrationConnectorTool .DefaultHttpExecutor ;
12- import com .google .adk .tools .applicationintegrationtoolset .IntegrationConnectorTool .HttpExecutor ;
1311import io .reactivex .rxjava3 .core .Flowable ;
12+ import java .net .http .HttpClient ;
1413import java .util .ArrayList ;
1514import java .util .Iterator ;
1615import java .util .List ;
@@ -30,7 +29,8 @@ public class ApplicationIntegrationToolset implements BaseToolset {
3029 @ Nullable String toolNamePrefix ;
3130 @ Nullable String toolInstructions ;
3231 public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper ();
33- HttpExecutor httpExecutor ;
32+ private final HttpClient httpClient ;
33+ private final CredentialsHelper credentialsHelper ;
3434
3535 /**
3636 * ApplicationIntegrationToolset generates tools from a given Application Integration resource.
@@ -85,7 +85,8 @@ public ApplicationIntegrationToolset(
8585 serviceAccountJson ,
8686 toolNamePrefix ,
8787 toolInstructions ,
88- new DefaultHttpExecutor ().createExecutor (serviceAccountJson ));
88+ HttpClient .newHttpClient (),
89+ new GoogleCredentialsHelper ());
8990 }
9091
9192 ApplicationIntegrationToolset (
@@ -99,7 +100,8 @@ public ApplicationIntegrationToolset(
99100 String serviceAccountJson ,
100101 String toolNamePrefix ,
101102 String toolInstructions ,
102- HttpExecutor httpExecutor ) {
103+ HttpClient httpClient ,
104+ CredentialsHelper credentialsHelper ) {
103105 this .project = project ;
104106 this .location = location ;
105107 this .integration = integration ;
@@ -110,7 +112,8 @@ public ApplicationIntegrationToolset(
110112 this .serviceAccountJson = serviceAccountJson ;
111113 this .toolNamePrefix = toolNamePrefix ;
112114 this .toolInstructions = toolInstructions ;
113- this .httpExecutor = httpExecutor ;
115+ this .httpClient = httpClient ;
116+ this .credentialsHelper = credentialsHelper ;
114117 }
115118
116119 List <String > getPathUrl (String openApiSchemaString ) throws Exception {
@@ -145,7 +148,9 @@ private List<BaseTool> getAllTools() throws Exception {
145148 null ,
146149 null ,
147150 null ,
148- this .httpExecutor );
151+ this .serviceAccountJson ,
152+ this .httpClient ,
153+ this .credentialsHelper );
149154 openApiSchemaString = integrationClient .generateOpenApiSpec ();
150155 List <String > pathUrls = getPathUrl (openApiSchemaString );
151156 for (String pathUrl : pathUrls ) {
@@ -161,7 +166,8 @@ private List<BaseTool> getAllTools() throws Exception {
161166 null ,
162167 null ,
163168 this .serviceAccountJson ,
164- this .httpExecutor ));
169+ this .httpClient ,
170+ this .credentialsHelper ));
165171 }
166172 }
167173 } else if (!isNullOrEmpty (this .connection )
@@ -175,7 +181,9 @@ private List<BaseTool> getAllTools() throws Exception {
175181 this .connection ,
176182 this .entityOperations ,
177183 this .actions ,
178- this .httpExecutor );
184+ this .serviceAccountJson ,
185+ this .httpClient ,
186+ this .credentialsHelper );
179187 ObjectNode parentOpenApiSpec = OBJECT_MAPPER .createObjectNode ();
180188 ObjectNode openApiSpec =
181189 integrationClient .getOpenApiSpecForConnection (toolNamePrefix , toolInstructions );
@@ -188,7 +196,14 @@ private List<BaseTool> getAllTools() throws Exception {
188196 if (!isNullOrEmpty (toolName )) {
189197 ConnectionsClient connectionsClient =
190198 new ConnectionsClient (
191- this .project , this .location , this .connection , this .httpExecutor , OBJECT_MAPPER );
199+ this .project ,
200+ this .location ,
201+ this .connection ,
202+ this .serviceAccountJson ,
203+ this .httpClient ,
204+ this .credentialsHelper ,
205+ OBJECT_MAPPER );
206+
192207 ConnectionsClient .ConnectionDetails connectionDetails =
193208 connectionsClient .getConnectionDetails ();
194209
@@ -202,7 +217,8 @@ private List<BaseTool> getAllTools() throws Exception {
202217 connectionDetails .serviceName ,
203218 connectionDetails .host ,
204219 this .serviceAccountJson ,
205- this .httpExecutor ));
220+ this .httpClient ,
221+ this .credentialsHelper ));
206222 }
207223 }
208224 } else {
0 commit comments