in bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/tools/functions/StackFunctions.java [66:100]
public Map<ToolSpecification, ToolExecutor> getServiceByName() {
ToolSpecification toolSpecification = ToolSpecification.builder()
.name("getServiceByName")
.description("Get service information and configs based on service name")
.addParameter(
"serviceName",
JsonSchemaProperty.STRING,
JsonSchemaProperty.description("Lowercase service name"))
.build();
ToolExecutor toolExecutor = (toolExecutionRequest, memoryId) -> {
Map<String, Object> arguments = JsonUtils.readFromString(toolExecutionRequest.arguments());
String serviceName = arguments.get("serviceName").toString();
for (StackVO stackVO : stackService.list()) {
for (ServiceVO serviceVO : stackVO.getServices()) {
if (serviceVO.getName().equals(serviceName)) {
for (ServiceConfigVO serviceConfigVO : serviceVO.getConfigs()) {
for (PropertyVO propertyVO : serviceConfigVO.getProperties()) {
if (propertyVO.getName().equals("content")) {
propertyVO.setValue(null);
}
if (propertyVO.getAttrs() != null
&& propertyVO.getAttrs().getType().equals("longtext")) {
propertyVO.setValue(null);
}
}
}
return JsonUtils.indentWriteAsString(serviceVO);
}
}
}
return "Service not found";
};
return Map.of(toolSpecification, toolExecutor);
}