Skip to content

Commit

Permalink
[KYUUBI apache#6045] [REST] Sync the AdminRestApi with the AdminResou…
Browse files Browse the repository at this point in the history
…rce Apis

# 🔍 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 apache#6045 from turboFei/list_op.

Closes apache#6045

ce017b8 [Fei Wang] api

Authored-by: Fei Wang <fwang12@ebay.com>
Signed-off-by: Fei Wang <fwang12@ebay.com>
  • Loading branch information
turboFei authored and zhaohehuhu committed Mar 21, 2024
1 parent d73e022 commit eab026d
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 eab026d

Please sign in to comment.