Search in sources :

Example 41 with RowMaker

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

Example 42 with RowMaker

use of io.cdap.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(io.cdap.cdap.cli.util.table.Table) RowMaker(io.cdap.cdap.cli.util.RowMaker) NamespaceMeta(io.cdap.cdap.proto.NamespaceMeta)

Example 43 with RowMaker

use of io.cdap.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();
}
Also used : RowMaker(io.cdap.cdap.cli.util.RowMaker) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowTokenDetail(io.cdap.cdap.proto.WorkflowTokenDetail) Map(java.util.Map)

Example 44 with RowMaker

use of io.cdap.cdap.cli.util.RowMaker in project cdap by caskdata.

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 45 with RowMaker

use of io.cdap.cdap.cli.util.RowMaker in project cdap by caskdata.

the class DescribeDatasetModuleCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    DatasetModuleId moduleId = cliConfig.getCurrentNamespace().datasetModule(arguments.get(ArgumentName.DATASET_MODULE.toString()));
    DatasetModuleMeta datasetModuleMeta = datasetModuleClient.get(moduleId);
    Table table = Table.builder().setHeader("name", "className", "jarLocationPath", "types", "usesModules", "usedByModules").setRows(ImmutableList.of(datasetModuleMeta), new RowMaker<DatasetModuleMeta>() {

        @Override
        public List<?> makeRow(DatasetModuleMeta object) {
            return Lists.newArrayList(object.getName(), object.getClassName(), object.getJarLocationPath(), Joiner.on(", ").join(object.getTypes()), Joiner.on(", ").join(object.getUsesModules()), Joiner.on(", ").join(object.getUsedByModules()));
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : DatasetModuleId(io.cdap.cdap.proto.id.DatasetModuleId) Table(io.cdap.cdap.cli.util.table.Table) DatasetModuleMeta(io.cdap.cdap.proto.DatasetModuleMeta) RowMaker(io.cdap.cdap.cli.util.RowMaker)

Aggregations

RowMaker (io.cdap.cdap.cli.util.RowMaker)62 Table (io.cdap.cdap.cli.util.table.Table)60 ArtifactId (io.cdap.cdap.proto.id.ArtifactId)8 CommandInputError (io.cdap.cdap.cli.exception.CommandInputError)6 DatasetModuleMeta (io.cdap.cdap.proto.DatasetModuleMeta)6 NamespaceMeta (io.cdap.cdap.proto.NamespaceMeta)6 ProgramRecord (io.cdap.cdap.proto.ProgramRecord)6 ArtifactScope (io.cdap.cdap.api.artifact.ArtifactScope)4 ArtifactSummary (io.cdap.cdap.api.artifact.ArtifactSummary)4 BatchProgramResult (io.cdap.cdap.proto.BatchProgramResult)4 DatasetTypeMeta (io.cdap.cdap.proto.DatasetTypeMeta)4 ProgramId (io.cdap.cdap.proto.id.ProgramId)4 ArrayList (java.util.ArrayList)4 List (java.util.List)3 Map (java.util.Map)3 ArtifactInfo (io.cdap.cdap.api.artifact.ArtifactInfo)2 ServiceHttpEndpoint (io.cdap.cdap.api.service.http.ServiceHttpEndpoint)2 ExploreExecutionResult (io.cdap.cdap.explore.client.ExploreExecutionResult)2 HandleNotFoundException (io.cdap.cdap.explore.service.HandleNotFoundException)2 ApplicationRecord (io.cdap.cdap.proto.ApplicationRecord)2