Skip to content

Commit

Permalink
[KYUUBI #6045] [REST] Sync the AdminRestApi with the AdminResource Apis
Browse files Browse the repository at this point in the history
# 🔍 Description
## Issue References 🔗

https://github.com/apache/kyuubi/blob/f67140e650d4fb335b43a65eb2678192c9b0b29a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala#L196-L198

Support to filter operations with users and sessionHandle in AdminRestApi
This pull request fixes #

## Describe Your Solution 🔧

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

## Types of changes 🔖

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests

---

# Checklist 📝

- [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

**Be nice. Be informative.**

Closes #6045 from turboFei/list_op.

Closes #6045

ce017b8 [Fei Wang] api

Authored-by: Fei Wang <[email protected]>
Signed-off-by: Fei Wang <[email protected]>
(cherry picked from commit 5ef4390)
Signed-off-by: Fei Wang <[email protected]>
  • Loading branch information
turboFei committed Feb 5, 2024
1 parent 054db88 commit 7c927f5
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.kyuubi.client;

import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.kyuubi.client.api.v1.dto.Engine;
import org.apache.kyuubi.client.api.v1.dto.OperationData;
import org.apache.kyuubi.client.api.v1.dto.ServerData;
Expand Down Expand Up @@ -103,10 +104,24 @@ public String closeSession(String sessionHandleStr) {
}

public List<OperationData> listOperations() {
return listOperations(Collections.emptyList(), null);
}

public List<OperationData> listOperations(List<String> users, String sessionHandleStr) {
Map<String, Object> params = new HashMap<>();
if (users != null && !users.isEmpty()) {
params.put("users", String.join(",", users));
}
if (StringUtils.isNotBlank(sessionHandleStr)) {
params.put("sessionHandle", sessionHandleStr);
}
OperationData[] result =
this.getClient()
.get(
API_BASE_PATH + "/operations", null, OperationData[].class, client.getAuthHeader());
API_BASE_PATH + "/operations",
params,
OperationData[].class,
client.getAuthHeader());
return Arrays.asList(result);
}

Expand Down

0 comments on commit 7c927f5

Please sign in to comment.