Skip to content

Commit 98ce81f

Browse files
committed
BatchRestApi
1 parent fba1f94 commit 98ce81f

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/BatchRestApi.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ public CloseBatchResponse deleteBatch(String batchId, Map<String, String> header
174174
.delete(path, null, CloseBatchResponse.class, client.getAuthHeader(), headers);
175175
}
176176

177+
public ReassignBatchResponse reassignBatch(ReassignBatchRequest request) {
178+
String path = String.format("%s/reassign", API_BASE_PATH);
179+
String requestBody = JsonUtils.toJson(request);
180+
return this.getClient()
181+
.post(path, requestBody, ReassignBatchResponse.class, client.getAuthHeader());
182+
}
183+
177184
private IRestClient getClient() {
178185
return this.client.getHttpClient();
179186
}

kyuubi-rest-client/src/test/java/org/apache/kyuubi/client/BatchRestClientTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.apache.kyuubi.client.api.v1.dto.CloseBatchResponse;
2727
import org.apache.kyuubi.client.api.v1.dto.GetBatchesResponse;
2828
import org.apache.kyuubi.client.api.v1.dto.OperationLog;
29+
import org.apache.kyuubi.client.api.v1.dto.ReassignBatchRequest;
30+
import org.apache.kyuubi.client.api.v1.dto.ReassignBatchResponse;
2931
import org.apache.kyuubi.client.exception.KyuubiRestException;
3032
import org.junit.After;
3133
import org.junit.Before;
@@ -276,4 +278,19 @@ public void deleteBatchTest() {
276278
response = basicBatchRestApi.deleteBatch("71535");
277279
assertTrue(response.isSuccess());
278280
}
281+
282+
@Test
283+
public void reassignBatchTest() {
284+
// test spnego auth
285+
BatchTestServlet.setAuthSchema(NEGOTIATE_AUTH);
286+
ReassignBatchRequest request = new ReassignBatchRequest("http://127.0.0.1:10012");
287+
ReassignBatchResponse response = spnegoBatchRestApi.reassignBatch(request);
288+
assertTrue(response.getBatchIds().isEmpty());
289+
290+
// test basic auth
291+
BatchTestServlet.setAuthSchema(BASIC_AUTH);
292+
BatchTestServlet.allowAnonymous(false);
293+
response = basicBatchRestApi.reassignBatch(request);
294+
assertTrue(response.getBatchIds().isEmpty());
295+
}
279296
}

kyuubi-rest-client/src/test/java/org/apache/kyuubi/client/BatchTestServlet.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.kyuubi.client.api.v1.dto.CloseBatchResponse;
2929
import org.apache.kyuubi.client.api.v1.dto.GetBatchesResponse;
3030
import org.apache.kyuubi.client.api.v1.dto.OperationLog;
31+
import org.apache.kyuubi.client.api.v1.dto.ReassignBatchResponse;
3132
import org.apache.kyuubi.client.util.JsonUtils;
3233

3334
public class BatchTestServlet extends HttpServlet {
@@ -81,6 +82,11 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I
8182
Batch batch = generateTestBatch();
8283
resp.getWriter().write(JsonUtils.toJson(batch));
8384
resp.getWriter().flush();
85+
} else if (req.getPathInfo().equalsIgnoreCase("/api/v1/batches/reassign")) {
86+
resp.setStatus(HttpServletResponse.SC_OK);
87+
88+
resp.getWriter().write(JsonUtils.toJson(new ReassignBatchResponse()));
89+
resp.getWriter().flush();
8490
} else {
8591
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
8692
}

0 commit comments

Comments
 (0)