|
14 | 14 | import io.reactivex.rxjava3.core.Single; |
15 | 15 | import java.io.IOException; |
16 | 16 | import java.io.UncheckedIOException; |
| 17 | +import java.net.URLEncoder; |
| 18 | +import java.nio.charset.StandardCharsets; |
17 | 19 | import java.util.HashMap; |
18 | 20 | import java.util.List; |
19 | 21 | import java.util.Map; |
@@ -103,40 +105,53 @@ private Completable pollOperation(String operationId, int attempt) { |
103 | 105 | }); |
104 | 106 | } |
105 | 107 |
|
| 108 | + private static String encodeParam(String value) { |
| 109 | + return URLEncoder.encode(value, StandardCharsets.UTF_8); |
| 110 | + } |
| 111 | + |
106 | 112 | Maybe<JsonNode> listSessions(String reasoningEngineId, String userId) { |
107 | 113 | return performApiRequest( |
108 | 114 | "GET", |
109 | | - "reasoningEngines/" + reasoningEngineId + "/sessions?filter=user_id=" + userId, |
| 115 | + "reasoningEngines/" + reasoningEngineId |
| 116 | + + "/sessions?filter=user_id=" + encodeParam(userId), |
110 | 117 | "") |
111 | 118 | .flatMapMaybe(VertexAiClient::getJsonResponse); |
112 | 119 | } |
113 | 120 |
|
114 | 121 | Maybe<JsonNode> listEvents(String reasoningEngineId, String sessionId) { |
115 | 122 | return performApiRequest( |
116 | 123 | "GET", |
117 | | - "reasoningEngines/" + reasoningEngineId + "/sessions/" + sessionId + "/events", |
| 124 | + "reasoningEngines/" + reasoningEngineId |
| 125 | + + "/sessions/" + encodeParam(sessionId) + "/events", |
118 | 126 | "") |
119 | 127 | .doOnSuccess(apiResponse -> logger.debug("List events response {}", apiResponse)) |
120 | 128 | .flatMapMaybe(VertexAiClient::getJsonResponse); |
121 | 129 | } |
122 | 130 |
|
123 | 131 | Maybe<JsonNode> getSession(String reasoningEngineId, String sessionId) { |
124 | 132 | return performApiRequest( |
125 | | - "GET", "reasoningEngines/" + reasoningEngineId + "/sessions/" + sessionId, "") |
| 133 | + "GET", |
| 134 | + "reasoningEngines/" + reasoningEngineId |
| 135 | + + "/sessions/" + encodeParam(sessionId), |
| 136 | + "") |
126 | 137 | .flatMapMaybe(apiResponse -> getJsonResponse(apiResponse)); |
127 | 138 | } |
128 | 139 |
|
129 | 140 | Completable deleteSession(String reasoningEngineId, String sessionId) { |
130 | 141 | return performApiRequest( |
131 | | - "DELETE", "reasoningEngines/" + reasoningEngineId + "/sessions/" + sessionId, "") |
| 142 | + "DELETE", |
| 143 | + "reasoningEngines/" + reasoningEngineId |
| 144 | + + "/sessions/" + encodeParam(sessionId), |
| 145 | + "") |
132 | 146 | .doOnSuccess(ApiResponse::close) |
133 | 147 | .ignoreElement(); |
134 | 148 | } |
135 | 149 |
|
136 | 150 | Completable appendEvent(String reasoningEngineId, String sessionId, String eventJson) { |
137 | 151 | return performApiRequest( |
138 | 152 | "POST", |
139 | | - "reasoningEngines/" + reasoningEngineId + "/sessions/" + sessionId + ":appendEvent", |
| 153 | + "reasoningEngines/" + reasoningEngineId |
| 154 | + + "/sessions/" + encodeParam(sessionId) + ":appendEvent", |
140 | 155 | eventJson) |
141 | 156 | .flatMapCompletable( |
142 | 157 | response -> { |
|
0 commit comments