Search in sources :

Example 21 with Table

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

Example 22 with Table

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

Example 23 with Table

use of io.cdap.cdap.cli.util.table.Table in project cdap by cdapio.

the class DescribeArtifactCommand 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);
    String scopeStr = arguments.getOptional(ArgumentName.SCOPE.toString());
    ArtifactInfo info;
    if (scopeStr == null) {
        info = artifactClient.getArtifactInfo(artifactId);
    } else {
        ArtifactScope scope = ArtifactScope.valueOf(scopeStr.toUpperCase());
        info = artifactClient.getArtifactInfo(artifactId, scope);
    }
    Table table = Table.builder().setHeader("name", "version", "scope", "app classes", "plugin classes", "properties", "parents").setRows(ImmutableList.of((List<String>) ImmutableList.of(info.getName(), info.getVersion(), info.getScope().name(), GSON.toJson(info.getClasses().getApps()), GSON.toJson(info.getClasses().getPlugins()), GSON.toJson(info.getProperties()), Joiner.on('/').join(info.getParents())))).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : ArtifactScope(io.cdap.cdap.api.artifact.ArtifactScope) Table(io.cdap.cdap.cli.util.table.Table) ArtifactId(io.cdap.cdap.proto.id.ArtifactId) ArtifactInfo(io.cdap.cdap.api.artifact.ArtifactInfo)

Example 24 with Table

use of io.cdap.cdap.cli.util.table.Table 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);
}
Also used : Table(io.cdap.cdap.cli.util.table.Table) RowMaker(io.cdap.cdap.cli.util.RowMaker) DatasetSpecificationSummary(io.cdap.cdap.proto.DatasetSpecificationSummary)

Example 25 with Table

use of io.cdap.cdap.cli.util.table.Table in project cdap by cdapio.

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

Aggregations

Table (io.cdap.cdap.cli.util.table.Table)82 RowMaker (io.cdap.cdap.cli.util.RowMaker)60 CommandInputError (io.cdap.cdap.cli.exception.CommandInputError)12 ArtifactId (io.cdap.cdap.proto.id.ArtifactId)10 List (java.util.List)10 PrintStream (java.io.PrintStream)8 Lists (com.google.common.collect.Lists)6 Inject (com.google.inject.Inject)6 ArtifactScope (io.cdap.cdap.api.artifact.ArtifactScope)6 MetadataEntity (io.cdap.cdap.api.metadata.MetadataEntity)6 ArgumentName (io.cdap.cdap.cli.ArgumentName)6 CLIConfig (io.cdap.cdap.cli.CLIConfig)6 DatasetModuleMeta (io.cdap.cdap.proto.DatasetModuleMeta)6 NamespaceMeta (io.cdap.cdap.proto.NamespaceMeta)6 ProgramId (io.cdap.cdap.proto.id.ProgramId)6 ProgramRunId (io.cdap.cdap.proto.id.ProgramRunId)6 Map (java.util.Map)6 Nullable (javax.annotation.Nullable)6 ProgramRecord (io.cdap.cdap.proto.ProgramRecord)5 DatasetId (io.cdap.cdap.proto.id.DatasetId)5