mirror of
https://github.com/yanlongqi/jhinno-openapi-java-sdk.git
synced 2026-03-22 06:15:10 +08:00
查询会话列表
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.jhinno.sdk.openapi.api.app;
|
||||
|
||||
/**
|
||||
* 关于会话请求路径的path
|
||||
*
|
||||
* @author yanlongqi
|
||||
* @date 2024/2/1 16:27
|
||||
*/
|
||||
@@ -10,4 +12,9 @@ public class AppPathConstant {
|
||||
* 申请会话
|
||||
*/
|
||||
public static final String APPS_START_PATH = "/ws/api/apps/{appId}/start";
|
||||
|
||||
/**
|
||||
* 查询会列表
|
||||
*/
|
||||
public static final String APPS_SESSIONS_ALL_PATH = "/ws/api/apps/sessions/all";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.jhinno.sdk.openapi.api.app;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 启动会话的请求参数
|
||||
@@ -21,7 +23,7 @@ public class AppStartRequest {
|
||||
|
||||
|
||||
/**
|
||||
* 工作路径
|
||||
* 工作路径(会话启动的路径)
|
||||
*/
|
||||
private String cwd;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.jhinno.sdk.openapi.client.JHApiClient;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yanlongqi
|
||||
@@ -48,4 +49,37 @@ public class JHAppApiExecution extends JHApiExecution {
|
||||
return data.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用默认参数启动应用
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param appId 应用id
|
||||
* @return JHClient协议链接
|
||||
*/
|
||||
public AppStartedInfo desktopStart(String username, String appId) {
|
||||
return this.desktopStart(username, appId, new AppStartRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户的会话列表(管理员则查看所有用户的会话)
|
||||
* <p>
|
||||
* 注:开启密集后,仅能查看自己的会话和比自己密级低的会话
|
||||
* </p>
|
||||
*
|
||||
* @return 会话列表
|
||||
*/
|
||||
public List<Map<String, Object>> getDesktopList(String username) {
|
||||
ResponseResult<List<Map<String, Object>>> result = jhApiClient.get(
|
||||
AppPathConstant.APPS_SESSIONS_ALL_PATH,
|
||||
getHeaders(username),
|
||||
new TypeReference<ResponseResult<List<Map<String, Object>>>>() {
|
||||
});
|
||||
if (StringUtils.equals(result.getResult(), CommonConstant.FAILED)) {
|
||||
throw new ServiceException(AppPathConstant.APPS_SESSIONS_ALL_PATH, result.getCode(), result.getMessage());
|
||||
}
|
||||
return result.getData();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.jhinno.sdk.openapi.api.app.JHAppApiExecution;
|
||||
import com.jhinno.sdk.openapi.client.JHApiClient;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 会话启动相关单元测试
|
||||
*
|
||||
@@ -15,17 +18,44 @@ import org.junit.Test;
|
||||
|
||||
public class AppApiTest {
|
||||
|
||||
public static final JHApiClient client = JHApiClient.build("https://192.168.87.25/appform");
|
||||
/**
|
||||
* 初始化JHApi客户端
|
||||
*/
|
||||
public static final JHApiClient client = JHApiClient.build("https://192.168.87.25/appform");
|
||||
|
||||
|
||||
/**
|
||||
* 测试获取"jhadmin"的Linux桌面会话的JHClient链接
|
||||
* 获得一个调用应用接口的执行器
|
||||
*/
|
||||
public static final JHAppApiExecution jhAppApiExecution = new JHAppApiExecution(client);
|
||||
|
||||
/**
|
||||
* 测测试使用自定义的参数启动jhadmin的Linux桌面
|
||||
*/
|
||||
@Test
|
||||
public void testStartApp() {
|
||||
JHAppApiExecution jhAppApiExecution = new JHAppApiExecution(client);
|
||||
AppStartedInfo appStartedInfo = jhAppApiExecution.desktopStart("jhadmin", "linux_desktop", new AppStartRequest());
|
||||
AppStartRequest appStartRequest = new AppStartRequest();
|
||||
appStartRequest.setStartNew(true);
|
||||
AppStartedInfo appStartedInfo = jhAppApiExecution.desktopStart("jhadmin", "linux_desktop", appStartRequest);
|
||||
System.out.println(appStartedInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试使用默认的参数启动jhadmin的Linux桌面
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultParamsStartApp() {
|
||||
AppStartedInfo appStartedInfo = jhAppApiExecution.desktopStart("jhadmin", "linux_desktop");
|
||||
System.out.println(appStartedInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试获取用户jhadmin的会话列表
|
||||
*/
|
||||
@Test
|
||||
public void testGetSessionsList() {
|
||||
List<Map<String, Object>> desktopList = jhAppApiExecution.getDesktopList("jhadmin");
|
||||
System.out.println(desktopList);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user