use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
the class ListAppVersionsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String appName = arguments.get(ArgumentName.APP.toString());
List<String> versions = appClient.listAppVersions(cliConfig.getCurrentNamespace(), appName);
Table table = Table.builder().setHeader("version").setRows(versions, new RowMaker<String>() {
@Override
public List<String> makeRow(String version) {
return Lists.newArrayList(version);
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
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);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
the class StatusProgramsCommand method runBatchCommand.
@Override
protected void runBatchCommand(PrintStream printStream, Args<BatchProgram> args) throws Exception {
List<BatchProgramStatus> results = programClient.getStatus(args.appId.getParent(), args.programs);
Table table = Table.builder().setHeader("name", "type", "status", "error").setRows(results, new RowMaker<BatchProgramStatus>() {
@Override
public List<?> makeRow(BatchProgramStatus result) {
return Lists.newArrayList(result.getProgramId(), result.getProgramType(), result.getStatus(), result.getError());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, printStream, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
the class StopProgramsCommand method runBatchCommand.
@Override
protected void runBatchCommand(PrintStream printStream, Args<BatchProgram> args) throws Exception {
List<BatchProgramResult> results = programClient.stop(args.appId.getParent(), args.programs);
Table table = Table.builder().setHeader("name", "type", "error").setRows(results, new RowMaker<BatchProgramResult>() {
@Override
public List<?> makeRow(BatchProgramResult result) {
return Lists.newArrayList(result.getProgramId(), result.getProgramType(), result.getError());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, printStream, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
the class ListDatasetInstancesCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
List<DatasetSpecificationSummary> datasetMetas = datasetClient.list(cliConfig.getCurrentNamespace());
Table table = Table.builder().setHeader("name", "type", "description").setRows(datasetMetas, new RowMaker<DatasetSpecificationSummary>() {
@Override
public List<?> makeRow(DatasetSpecificationSummary object) {
return Lists.newArrayList(object.getName(), object.getType(), object.getDescription());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Aggregations