use of org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse in project incubator-inlong by apache.
the class InnerInlongManagerClient method listGroups.
public PageInfo<InlongGroupListResponse> listGroups(String keyword, int status, int pageNum, int pageSize) {
if (pageNum <= 0) {
pageNum = 1;
}
JSONObject groupQuery = new JSONObject();
groupQuery.put("keyWord", pageNum);
groupQuery.put("status", status);
groupQuery.put("pageNum", pageNum);
groupQuery.put("pageSize", pageSize);
String operationData = GsonUtil.toJson(groupQuery);
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), operationData);
String path = HTTP_PATH + "/group/list";
final String url = formatUrl(path);
Request request = new Request.Builder().get().url(url).method("POST", requestBody).build();
Call call = httpClient.newCall(request);
try {
Response response = call.execute();
assert response.body() != null;
String body = response.body().string();
AssertUtil.isTrue(response.isSuccessful(), String.format("Inlong request failed: %s", body));
org.apache.inlong.manager.common.beans.Response responseBody = InlongParser.parseResponse(body);
if (responseBody.getErrMsg() != null) {
if (responseBody.getErrMsg().contains("Inlong group does not exist")) {
return null;
} else {
throw new RuntimeException(responseBody.getErrMsg());
}
} else {
return InlongParser.parseGroupList(responseBody);
}
} catch (Exception e) {
throw new RuntimeException(String.format("Inlong group get failed: %s", e.getMessage()), e);
}
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse in project incubator-inlong by apache.
the class InlongClientImpl method listGroup.
@Override
public List<InlongGroup> listGroup(String expr, int status, int pageNum, int pageSize) throws Exception {
InnerInlongManagerClient managerClient = new InnerInlongManagerClient(this);
PageInfo<InlongGroupListResponse> responsePageInfo = managerClient.listGroups(expr, status, pageNum, pageSize);
if (CollectionUtils.isEmpty(responsePageInfo.getList())) {
return Lists.newArrayList();
} else {
return responsePageInfo.getList().stream().map(response -> {
String groupId = response.getInlongGroupId();
InlongGroupResponse groupResponse = managerClient.getGroupInfo(groupId);
InlongGroupConf groupConf = InlongGroupTransfer.parseGroupResponse(groupResponse);
return new InlongGroupImpl(groupConf, this);
}).collect(Collectors.toList());
}
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse in project incubator-inlong by apache.
the class InlongParser method parseGroupList.
public static PageInfo<InlongGroupListResponse> parseGroupList(Response response) {
Object data = response.getData();
String pageInfoJson = GsonUtil.toJson(data);
return GsonUtil.fromJson(pageInfoJson, new TypeToken<PageInfo<InlongGroupListResponse>>() {
}.getType());
}
Aggregations