|
3 | 3 | import java.util.Collections; |
4 | 4 | import java.util.List; |
5 | 5 | import java.util.Map; |
6 | | -import java.util.UUID; |
7 | 6 |
|
8 | 7 | import io.a2a.client.http.A2ACardResolver; |
9 | | -import io.a2a.client.http.A2AHttpClient; |
10 | | -import io.a2a.client.http.JdkA2AHttpClient; |
| 8 | +import io.a2a.client.http.HttpClient; |
11 | 9 | import io.a2a.spec.A2AClientError; |
12 | 10 | import io.a2a.spec.A2AClientJSONError; |
13 | 11 | import io.a2a.spec.AgentCard; |
@@ -139,51 +137,37 @@ private static Message toMessage(List<Part<?>> parts, Message.Role role, String |
139 | 137 | * @throws A2AClientJSONError f the response body cannot be decoded as JSON or validated against the AgentCard schema |
140 | 138 | */ |
141 | 139 | public static AgentCard getAgentCard(String agentUrl) throws A2AClientError, A2AClientJSONError { |
142 | | - return getAgentCard(new JdkA2AHttpClient(), agentUrl); |
143 | | - } |
144 | | - |
145 | | - /** |
146 | | - * Get the agent card for an A2A agent. |
147 | | - * |
148 | | - * @param httpClient the http client to use |
149 | | - * @param agentUrl the base URL for the agent whose agent card we want to retrieve |
150 | | - * @return the agent card |
151 | | - * @throws A2AClientError If an HTTP error occurs fetching the card |
152 | | - * @throws A2AClientJSONError f the response body cannot be decoded as JSON or validated against the AgentCard schema |
153 | | - */ |
154 | | - public static AgentCard getAgentCard(A2AHttpClient httpClient, String agentUrl) throws A2AClientError, A2AClientJSONError { |
155 | | - return getAgentCard(httpClient, agentUrl, null, null); |
| 140 | + return getAgentCard(HttpClient.createHttpClient(agentUrl), null, null); |
156 | 141 | } |
157 | 142 |
|
158 | 143 | /** |
159 | 144 | * Get the agent card for an A2A agent. |
160 | 145 | * |
161 | 146 | * @param agentUrl the base URL for the agent whose agent card we want to retrieve |
162 | 147 | * @param relativeCardPath optional path to the agent card endpoint relative to the base |
163 | | - * agent URL, defaults to ".well-known/agent-card.json" |
| 148 | + * agent URL, defaults to "/.well-known/agent-card.json" |
164 | 149 | * @param authHeaders the HTTP authentication headers to use |
165 | 150 | * @return the agent card |
166 | 151 | * @throws A2AClientError If an HTTP error occurs fetching the card |
167 | 152 | * @throws A2AClientJSONError f the response body cannot be decoded as JSON or validated against the AgentCard schema |
168 | 153 | */ |
169 | 154 | public static AgentCard getAgentCard(String agentUrl, String relativeCardPath, Map<String, String> authHeaders) throws A2AClientError, A2AClientJSONError { |
170 | | - return getAgentCard(new JdkA2AHttpClient(), agentUrl, relativeCardPath, authHeaders); |
| 155 | + return getAgentCard(HttpClient.createHttpClient(agentUrl), relativeCardPath, authHeaders); |
171 | 156 | } |
172 | 157 |
|
173 | 158 | /** |
174 | 159 | * Get the agent card for an A2A agent. |
175 | 160 | * |
176 | 161 | * @param httpClient the http client to use |
177 | | - * @param agentUrl the base URL for the agent whose agent card we want to retrieve |
178 | 162 | * @param relativeCardPath optional path to the agent card endpoint relative to the base |
179 | | - * agent URL, defaults to ".well-known/agent-card.json" |
| 163 | + * agent URL, defaults to "/.well-known/agent-card.json" |
180 | 164 | * @param authHeaders the HTTP authentication headers to use |
181 | 165 | * @return the agent card |
182 | 166 | * @throws A2AClientError If an HTTP error occurs fetching the card |
183 | 167 | * @throws A2AClientJSONError f the response body cannot be decoded as JSON or validated against the AgentCard schema |
184 | 168 | */ |
185 | | - public static AgentCard getAgentCard(A2AHttpClient httpClient, String agentUrl, String relativeCardPath, Map<String, String> authHeaders) throws A2AClientError, A2AClientJSONError { |
186 | | - A2ACardResolver resolver = new A2ACardResolver(httpClient, agentUrl, relativeCardPath, authHeaders); |
| 169 | + public static AgentCard getAgentCard(HttpClient httpClient, String relativeCardPath, Map<String, String> authHeaders) throws A2AClientError, A2AClientJSONError { |
| 170 | + A2ACardResolver resolver = new A2ACardResolver(httpClient, relativeCardPath, authHeaders); |
187 | 171 | return resolver.getAgentCard(); |
188 | 172 | } |
189 | 173 | } |
0 commit comments