use of io.cdap.cdap.cli.util.table.Table in project cdap by caskdata.
the class ListAppVersionsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String appName = arguments.get(ArgumentName.APP.toString());
List<String> versions = appClient.listAppVersions(cliConfig.getCurrentNamespace(), appName);
Table table = Table.builder().setHeader("version").setRows(versions, new RowMaker<String>() {
@Override
public List<String> makeRow(String version) {
return Lists.newArrayList(version);
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.table.Table in project cdap by caskdata.
the class DescribeArtifactPluginCommand 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 pluginType = arguments.get(ArgumentName.PLUGIN_TYPE.toString());
String pluginName = arguments.get(ArgumentName.PLUGIN_NAME.toString());
List<PluginInfo> pluginInfos;
String scopeStr = arguments.getOptional(ArgumentName.SCOPE.toString());
if (scopeStr == null) {
pluginInfos = artifactClient.getPluginInfo(artifactId, pluginType, pluginName);
} else {
pluginInfos = artifactClient.getPluginInfo(artifactId, pluginType, pluginName, ArtifactScope.valueOf(scopeStr.toUpperCase()));
}
Table table = Table.builder().setHeader("type", "name", "classname", "description", "properties", "artifact").setRows(pluginInfos, new RowMaker<PluginInfo>() {
@Override
public List<?> makeRow(PluginInfo object) {
return Lists.newArrayList(object.getType(), object.getName(), object.getClassName(), object.getDescription(), GSON.toJson(object.getProperties()), object.getArtifact().toString());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.table.Table in project cdap by caskdata.
the class GetArtifactPropertiesCommand 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);
}
List<Map.Entry<String, String>> rows = new ArrayList<>(info.getProperties().size());
rows.addAll(info.getProperties().entrySet());
Table table = Table.builder().setHeader("key", "value").setRows(rows, new RowMaker<Map.Entry<String, String>>() {
@Override
public List<String> makeRow(Map.Entry<String, String> entry) {
List<String> columns = new ArrayList<>(2);
columns.add(entry.getKey());
columns.add(entry.getValue());
return columns;
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.table.Table in project cdap by caskdata.
the class DescribeDatasetInstanceCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
DatasetId instance = cliConfig.getCurrentNamespace().dataset(arguments.get(ArgumentName.DATASET.toString()));
DatasetMeta meta = datasetClient.get(instance);
Table table = Table.builder().setHeader("hive table", "spec", "type", "principal").setRows(ImmutableList.of(meta), new RowMaker<DatasetMeta>() {
@Override
public List<?> makeRow(DatasetMeta object) {
return Lists.newArrayList(object.getHiveTableName(), GSON.toJson(object.getSpec()), GSON.toJson(object.getType()), object.getOwnerPrincipal());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.table.Table in project cdap by caskdata.
the class GetDatasetInstancePropertiesCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
DatasetId instance = cliConfig.getCurrentNamespace().dataset(arguments.get(ArgumentName.DATASET.toString()));
Map<String, String> properties = datasetClient.getProperties(instance);
Table table = Table.builder().setHeader("property", "value").setRows(Iterables.transform(properties.entrySet(), new Function<Map.Entry<String, String>, List<String>>() {
@Nullable
@Override
public List<String> apply(Map.Entry<String, String> entry) {
return ImmutableList.of(entry.getKey(), entry.getValue());
}
})).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Aggregations