Search in sources :

Example 16 with RowMaker

use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.

the class ListDatasetTypesCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    List<DatasetTypeMeta> datasetTypeMetas = datasetTypeClient.list(cliConfig.getCurrentNamespace());
    Table table = Table.builder().setHeader("name", "modules").setRows(datasetTypeMetas, new RowMaker<DatasetTypeMeta>() {

        @Override
        public List<?> makeRow(DatasetTypeMeta object) {
            List<String> modulesStrings = Lists.newArrayList();
            for (DatasetModuleMeta module : object.getModules()) {
                modulesStrings.add(module.getName());
            }
            return Lists.newArrayList(object.getName(), Joiner.on(", ").join(modulesStrings));
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : Table(co.cask.cdap.cli.util.table.Table) DatasetModuleMeta(co.cask.cdap.proto.DatasetModuleMeta) RowMaker(co.cask.cdap.cli.util.RowMaker) DatasetTypeMeta(co.cask.cdap.proto.DatasetTypeMeta)

Example 17 with RowMaker

use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.

the class ListNamespacesCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    Table table = Table.builder().setHeader("name", "description", "config").setRows(namespaceClient.list(), new RowMaker<NamespaceMeta>() {

        @Override
        public List<?> makeRow(NamespaceMeta object) {
            return Lists.newArrayList(object.getName(), object.getDescription(), NamespaceCommandUtils.prettyPrintNamespaceConfigCLI(object.getConfig()));
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : Table(co.cask.cdap.cli.util.table.Table) RowMaker(co.cask.cdap.cli.util.RowMaker) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta)

Example 18 with RowMaker

use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.

the class StartProgramsCommand method runBatchCommand.

@Override
protected void runBatchCommand(PrintStream printStream, Args<BatchProgramStart> args) throws Exception {
    List<BatchProgramResult> results = programClient.start(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);
}
Also used : Table(co.cask.cdap.cli.util.table.Table) RowMaker(co.cask.cdap.cli.util.RowMaker) BatchProgramResult(co.cask.cdap.proto.BatchProgramResult)

Example 19 with RowMaker

use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.

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);
}
Also used : BatchProgramStatus(co.cask.cdap.proto.BatchProgramStatus) Table(co.cask.cdap.cli.util.table.Table) RowMaker(co.cask.cdap.cli.util.RowMaker)

Example 20 with RowMaker

use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.

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);
}
Also used : Table(co.cask.cdap.cli.util.table.Table) RowMaker(co.cask.cdap.cli.util.RowMaker) BatchProgramResult(co.cask.cdap.proto.BatchProgramResult)

Aggregations

RowMaker (co.cask.cdap.cli.util.RowMaker)39 Table (co.cask.cdap.cli.util.table.Table)38 CommandInputError (co.cask.cdap.cli.exception.CommandInputError)4 ArtifactId (co.cask.cdap.proto.id.ArtifactId)4 StreamId (co.cask.cdap.proto.id.StreamId)4 DatasetModuleMeta (co.cask.cdap.proto.DatasetModuleMeta)3 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)3 ProgramRecord (co.cask.cdap.proto.ProgramRecord)3 ArtifactScope (co.cask.cdap.api.artifact.ArtifactScope)2 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)2 BatchProgramResult (co.cask.cdap.proto.BatchProgramResult)2 DatasetTypeMeta (co.cask.cdap.proto.DatasetTypeMeta)2 ApplicationId (co.cask.cdap.proto.id.ApplicationId)2 ProgramId (co.cask.cdap.proto.id.ProgramId)2 Principal (co.cask.cdap.proto.security.Principal)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 ArtifactInfo (co.cask.cdap.api.artifact.ArtifactInfo)1 FormatSpecification (co.cask.cdap.api.data.format.FormatSpecification)1