use of io.cdap.cdap.cli.CLIConfig in project cdap by caskdata.
the class GenerateCLIDocsTable method main.
public static void main(String[] args) throws Exception {
PrintStream output = System.out;
CLIConfig config = new CLIConfig();
GenerateCLIDocsTable generateCLIDocsTable = new GenerateCLIDocsTable(config);
generateCLIDocsTable.printDocsCommand.execute(null, output);
}
use of io.cdap.cdap.cli.CLIConfig in project cdap by caskdata.
the class ListPrivilegesCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String principalType = arguments.get(ArgumentName.PRINCIPAL_TYPE.toString());
String principalName = arguments.get(ArgumentName.PRINCIPAL_NAME.toString());
Table table = Table.builder().setHeader("Authorizable", "Action").setRows(Lists.newArrayList(client.listGrants(new Principal(principalName, Principal.PrincipalType.valueOf(principalType.toUpperCase())))), grantedPermission -> Lists.newArrayList(grantedPermission.getAuthorizable().toString(), grantedPermission.getPermission().name())).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.CLIConfig in project cdap by caskdata.
the class GetMetadataCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
MetadataEntity metadataEntity = MetadataCommandHelper.toMetadataEntity(arguments.get(ArgumentName.ENTITY.toString()));
String scope = arguments.getOptional(ArgumentName.METADATA_SCOPE.toString());
Set<MetadataRecord> metadata = scope == null ? client.getMetadata(metadataEntity) : client.getMetadata(metadataEntity, MetadataScope.valueOf(scope.toUpperCase()));
Table table = getTableBuilder().setRows(metadata.stream().map(record -> Lists.newArrayList(record.toString(), Joiner.on("\n").join(record.getTags()), Joiner.on("\n").withKeyValueSeparator(":").join(record.getProperties()), record.getScope().name())).collect(Collectors.toList())).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.CLIConfig 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(), searchQuery, parseTargetType(type), null, 0, Integer.MAX_VALUE, 0, null, false);
Set<MetadataSearchResultRecord> searchResults = metadataSearchResponse.getResults();
Table table = Table.builder().setHeader("Entity").setRows(Lists.newArrayList(searchResults), searchResult -> Lists.newArrayList(searchResult.getEntityId().toString())).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Aggregations