use of io.cdap.cdap.cli.util.RowMaker in project cdap by caskdata.
the class ListArtifactPluginTypesCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String artifactName = arguments.get(ArgumentName.ARTIFACT_NAME.toString());
String artifactVersion = arguments.get(ArgumentName.ARTIFACT_VERSION.toString());
ArtifactId artifactId = cliConfig.getCurrentNamespace().artifact(artifactName, artifactVersion);
List<String> types;
String scopeStr = arguments.getOptional(ArgumentName.SCOPE.toString());
if (scopeStr == null) {
types = artifactClient.getPluginTypes(artifactId);
} else {
types = artifactClient.getPluginTypes(artifactId, ArtifactScope.valueOf(scopeStr.toUpperCase()));
}
Table table = Table.builder().setHeader("plugin type").setRows(types, new RowMaker<String>() {
@Override
public List<?> makeRow(String object) {
return Lists.newArrayList(object);
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by caskdata.
the class ListProgramsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
List<ProgramRecord> programs = appClient.listAllPrograms(cliConfig.getCurrentNamespace(), programType);
Table table = Table.builder().setHeader("app", "id", "description").setRows(programs, new RowMaker<ProgramRecord>() {
@Override
public List<?> makeRow(ProgramRecord object) {
return Lists.newArrayList(object.getApp(), object.getName(), object.getDescription());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by caskdata.
the class ListAllProgramsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
Map<ProgramType, List<ProgramRecord>> allPrograms = appClient.listAllPrograms(cliConfig.getCurrentNamespace());
List<ProgramRecord> allProgramsList = Lists.newArrayList();
for (List<ProgramRecord> subList : allPrograms.values()) {
allProgramsList.addAll(subList);
}
Table table = Table.builder().setHeader("type", "app", "id", "description").setRows(allProgramsList, new RowMaker<ProgramRecord>() {
@Override
public List<?> makeRow(ProgramRecord object) {
return Lists.newArrayList(object.getType().getCategoryName(), object.getApp(), object.getName(), object.getDescription());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by caskdata.
the class DescribeAppCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
ApplicationId appId = parseApplicationId(arguments);
List<ProgramRecord> programsList = applicationClient.listPrograms(appId);
Table table = Table.builder().setHeader("type", "id", "description").setRows(programsList, new RowMaker<ProgramRecord>() {
@Override
public List<?> makeRow(ProgramRecord object) {
return Lists.newArrayList(object.getType().getPrettyName(), object.getName(), object.getDescription());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by caskdata.
the class ListAppsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String artifactNamesStr = arguments.getOptional(ArgumentName.ARTIFACT_NAME.toString());
String artifactVersion = arguments.getOptional(ArgumentName.ARTIFACT_VERSION.toString());
Set<String> artifactNames = new HashSet<>();
if (artifactNamesStr != null) {
for (String name : Splitter.on(',').trimResults().split(artifactNamesStr)) {
artifactNames.add(name);
}
}
Table table = Table.builder().setHeader("id", "appVersion", "description", "artifactName", "artifactVersion", "artifactScope", "principal").setRows(appClient.list(cliConfig.getCurrentNamespace(), artifactNames, artifactVersion), new RowMaker<ApplicationRecord>() {
@Override
public List<?> makeRow(ApplicationRecord object) {
return Lists.newArrayList(object.getName(), object.getAppVersion(), object.getDescription(), object.getArtifact().getName(), object.getArtifact().getVersion(), object.getArtifact().getScope(), object.getOwnerPrincipal());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Aggregations