use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class ListArtifactVersionsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String scopeStr = arguments.getOptional(ArgumentName.SCOPE.toString());
String artifactName = arguments.get(ArgumentName.ARTIFACT_NAME.toString());
List<ArtifactSummary> artifactSummaries;
if (scopeStr == null) {
artifactSummaries = artifactClient.listVersions(cliConfig.getCurrentNamespace(), artifactName);
} else {
ArtifactScope scope = ArtifactScope.valueOf(scopeStr.toUpperCase());
artifactSummaries = artifactClient.listVersions(cliConfig.getCurrentNamespace(), artifactName, scope);
}
Table table = Table.builder().setHeader("name", "version", "scope").setRows(artifactSummaries, new RowMaker<ArtifactSummary>() {
@Override
public List<?> makeRow(ArtifactSummary object) {
return Lists.newArrayList(object.getName(), object.getVersion(), object.getScope().name());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class ListArtifactsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
List<ArtifactSummary> artifactSummaries;
String artifactScope = arguments.getOptional(ArgumentName.SCOPE.toString());
if (artifactScope == null) {
artifactSummaries = artifactClient.list(cliConfig.getCurrentNamespace());
} else {
artifactSummaries = artifactClient.list(cliConfig.getCurrentNamespace(), ArtifactScope.valueOf(artifactScope.toUpperCase()));
}
Table table = Table.builder().setHeader("name", "version", "scope").setRows(artifactSummaries, new RowMaker<ArtifactSummary>() {
@Override
public List<?> makeRow(ArtifactSummary object) {
return Lists.newArrayList(object.getName(), object.getVersion(), object.getScope().name());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class SearchMetadataCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String searchQuery = arguments.get(ArgumentName.SEARCH_QUERY.toString());
String type = arguments.getOptional(ArgumentName.TARGET_TYPE.toString());
MetadataSearchResponse metadataSearchResponse = metadataClient.searchMetadata(cliConfig.getCurrentNamespace().toId(), searchQuery, parseTargetType(type));
Set<MetadataSearchResultRecord> searchResults = metadataSearchResponse.getResults();
Table table = Table.builder().setHeader("Entity").setRows(Lists.newArrayList(searchResults), new RowMaker<MetadataSearchResultRecord>() {
@Override
public List<?> makeRow(MetadataSearchResultRecord searchResult) {
return Lists.newArrayList(searchResult.getEntityId().toString());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class GetMetricCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String metric = arguments.get("metric-name");
Map<String, String> tags = ArgumentParser.parseMap(arguments.getOptional("tags", ""), "<tags>");
String start = arguments.getOptional("start", "");
String end = arguments.getOptional("end", "");
MetricQueryResult result = client.query(tags, ImmutableList.of(metric), ImmutableList.<String>of(), start.isEmpty() ? null : start, end.isEmpty() ? null : end);
output.printf("Start time: %d\n", result.getStartTime());
output.printf("End time: %d\n", result.getEndTime());
for (MetricQueryResult.TimeSeries series : result.getSeries()) {
output.println();
output.printf("Series: %s\n", series.getMetricName());
if (!series.getGrouping().isEmpty()) {
output.printf("Grouping: %s\n", Joiner.on(",").withKeyValueSeparator("=").join(series.getGrouping()));
}
Table table = Table.builder().setHeader("timestamp", "value").setRows(ImmutableList.copyOf(series.getData()), new RowMaker<MetricQueryResult.TimeValue>() {
@Override
public List<?> makeRow(MetricQueryResult.TimeValue object) {
return Lists.newArrayList(object.getTime(), object.getValue());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class ListStreamViewsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString()));
List<String> views = client.list(streamId);
Table table = Table.builder().setHeader("id").setRows(views, new RowMaker<String>() {
@Override
public List<?> makeRow(String object) {
return Lists.newArrayList(object);
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Aggregations