use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class GetWorkflowTokenCommand method getWorkflowToken.
private Table getWorkflowToken(ProgramRunId runId, WorkflowToken.Scope workflowTokenScope, String key) throws UnauthenticatedException, IOException, NotFoundException, UnauthorizedException {
WorkflowTokenDetail workflowToken = workflowClient.getWorkflowToken(runId, workflowTokenScope, key);
List<Map.Entry<String, List<WorkflowTokenDetail.NodeValueDetail>>> tokenKeys = new ArrayList<>();
tokenKeys.addAll(workflowToken.getTokenData().entrySet());
return Table.builder().setHeader("token key", "token value").setRows(tokenKeys, new RowMaker<Map.Entry<String, List<WorkflowTokenDetail.NodeValueDetail>>>() {
@Override
public List<?> makeRow(Map.Entry<String, List<WorkflowTokenDetail.NodeValueDetail>> object) {
return Lists.newArrayList(object.getKey(), GSON.toJson(object.getValue()));
}
}).build();
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class ListDatasetModulesCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
List<DatasetModuleMeta> modules = client.list(cliConfig.getCurrentNamespace());
Table table = Table.builder().setHeader("name", "className").setRows(modules, new RowMaker<DatasetModuleMeta>() {
@Override
public List<?> makeRow(DatasetModuleMeta object) {
return Lists.newArrayList(object.getName(), object.getClassName());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class CLIMainTest method testNamespacesOutput.
private static void testNamespacesOutput(CLI cli, String command, final List<NamespaceMeta> expected) throws Exception {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintStream output = new PrintStream(outputStream);
Table table = Table.builder().setHeader("name", "description", "config").setRows(expected, new RowMaker<NamespaceMeta>() {
@Override
public List<?> makeRow(NamespaceMeta object) {
return Lists.newArrayList(object.getName(), object.getDescription(), NamespaceCommandUtils.prettyPrintNamespaceConfigCLI(object.getConfig()));
}
}).build();
cliMain.getTableRenderer().render(cliConfig, output, table);
final String expectedOutput = outputStream.toString();
testCommand(cli, command, new Function<String, Void>() {
@Nullable
@Override
public Void apply(@Nullable String output) {
Assert.assertNotNull(output);
Assert.assertEquals(expectedOutput, output);
return null;
}
});
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class DescribeStreamViewCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString()));
ViewDetail detail = client.get(streamId.view(arguments.get(ArgumentName.VIEW.toString())));
Table table = Table.builder().setHeader("id", "format", "table", "schema", "settings").setRows(Collections.singletonList(detail), new RowMaker<ViewDetail>() {
@Override
public List<?> makeRow(ViewDetail object) {
return Lists.newArrayList(object.getId(), object.getFormat().getName(), object.getTableName(), GSON.toJson(object.getFormat().getSchema()), GSON.toJson(object.getFormat().getSettings()));
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.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);
}
Aggregations