You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2023/10/09 06:35:00 UTC

[kyuubi] branch master updated: [KYUUBI #4498][FOLLOWUP] Support to list sessions with conditions in AdminRestApi

This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 6444c82d2 [KYUUBI #4498][FOLLOWUP] Support to list sessions with conditions in AdminRestApi
6444c82d2 is described below

commit 6444c82d2ed59a90e31ce65461e66e01cac13380
Author: fwang12 <fw...@ebay.com>
AuthorDate: Mon Oct 9 14:34:51 2023 +0800

    [KYUUBI #4498][FOLLOWUP] Support to list sessions with conditions in AdminRestApi
    
    ### _Why are the changes needed?_
    
    Followup #4498
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [ ] [Run test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests) locally before make a pull request
    
    ### _Was this patch authored or co-authored using generative AI tooling?_
    
    No
    
    Closes #5354 from turboFei/list_sessions.
    
    Closes #4498
    
    5a3020ac2 [fwang12] list users sessions
    
    Authored-by: fwang12 <fw...@ebay.com>
    Signed-off-by: fwang12 <fw...@ebay.com>
---
 .../main/java/org/apache/kyuubi/client/AdminRestApi.java  | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/AdminRestApi.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/AdminRestApi.java
index 3b220cbc2..904ecb6c9 100644
--- a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/AdminRestApi.java
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/AdminRestApi.java
@@ -17,10 +17,7 @@
 
 package org.apache.kyuubi.client;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 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;
@@ -87,9 +84,17 @@ public class AdminRestApi {
   }
 
   public List<SessionData> listSessions() {
+    return listSessions(Collections.emptyList());
+  }
+
+  public List<SessionData> listSessions(List<String> users) {
+    Map<String, Object> params = new HashMap<>();
+    if (users != null && !users.isEmpty()) {
+      params.put("users", String.join(",", users));
+    }
     SessionData[] result =
         this.getClient()
-            .get(API_BASE_PATH + "/sessions", null, SessionData[].class, client.getAuthHeader());
+            .get(API_BASE_PATH + "/sessions", params, SessionData[].class, client.getAuthHeader());
     return Arrays.asList(result);
   }