Search in sources :

Example 36 with RowMaker

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

the class ListArtifactPluginTypesCommand 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);
    List<String> types;
    String scopeStr = arguments.getOptional(ArgumentName.SCOPE.toString());
    if (scopeStr == null) {
        types = artifactClient.getPluginTypes(artifactId);
    } else {
        types = artifactClient.getPluginTypes(artifactId, ArtifactScope.valueOf(scopeStr.toUpperCase()));
    }
    Table table = Table.builder().setHeader("plugin type").setRows(types, new RowMaker<String>() {

        @Override
        public List<?> makeRow(String object) {
            return Lists.newArrayList(object);
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : Table(io.cdap.cdap.cli.util.table.Table) ArtifactId(io.cdap.cdap.proto.id.ArtifactId) RowMaker(io.cdap.cdap.cli.util.RowMaker)

Example 37 with RowMaker

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

the class ListProgramsCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    List<ProgramRecord> programs = appClient.listAllPrograms(cliConfig.getCurrentNamespace(), programType);
    Table table = Table.builder().setHeader("app", "id", "description").setRows(programs, new RowMaker<ProgramRecord>() {

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

Example 38 with RowMaker

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

the class ListAllProgramsCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    Map<ProgramType, List<ProgramRecord>> allPrograms = appClient.listAllPrograms(cliConfig.getCurrentNamespace());
    List<ProgramRecord> allProgramsList = Lists.newArrayList();
    for (List<ProgramRecord> subList : allPrograms.values()) {
        allProgramsList.addAll(subList);
    }
    Table table = Table.builder().setHeader("type", "app", "id", "description").setRows(allProgramsList, new RowMaker<ProgramRecord>() {

        @Override
        public List<?> makeRow(ProgramRecord object) {
            return Lists.newArrayList(object.getType().getCategoryName(), object.getApp(), object.getName(), object.getDescription());
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : Table(io.cdap.cdap.cli.util.table.Table) ProgramRecord(io.cdap.cdap.proto.ProgramRecord) RowMaker(io.cdap.cdap.cli.util.RowMaker) List(java.util.List) ProgramType(io.cdap.cdap.proto.ProgramType)

Example 39 with RowMaker

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

Example 40 with RowMaker

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

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

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