Search in sources :

Example 1 with ProgramIdArgument

use of co.cask.cdap.cli.ProgramIdArgument in project cdap by caskdata.

the class HttpEndpointPrefixCompleter method complete.

@Override
public int complete(String buffer, int cursor, List<CharSequence> candidates) {
    Map<String, String> arguments = ArgumentParser.getArguments(buffer, PATTERN);
    ProgramIdArgument programIdArgument = ArgumentParser.parseProgramId(arguments.get(SERVICE_ID));
    if (programIdArgument != null) {
        ServiceId service;
        if (arguments.get(APP_VERSION) == null) {
            service = cliConfig.getCurrentNamespace().app(programIdArgument.getAppId()).service(programIdArgument.getProgramId());
        } else {
            service = cliConfig.getCurrentNamespace().app(programIdArgument.getAppId(), arguments.get(APP_VERSION)).service(programIdArgument.getProgramId());
        }
        completer.setEndpoints(getEndpoints(service, arguments.get(METHOD)));
    } else {
        completer.setEndpoints(Collections.<String>emptyList());
    }
    return super.complete(buffer, cursor, candidates);
}
Also used : ProgramIdArgument(co.cask.cdap.cli.ProgramIdArgument) ServiceId(co.cask.cdap.proto.id.ServiceId)

Example 2 with ProgramIdArgument

use of co.cask.cdap.cli.ProgramIdArgument in project cdap by caskdata.

the class HttpMethodPrefixCompleter method complete.

@Override
public int complete(String buffer, int cursor, List<CharSequence> candidates) {
    Map<String, String> arguments = ArgumentParser.getArguments(buffer, PATTERN);
    ProgramIdArgument programIdArgument = ArgumentParser.parseProgramId(arguments.get(SERVICE_ID));
    if (programIdArgument != null) {
        ServiceId service;
        if (arguments.get(APP_VERSION) == null) {
            service = cliConfig.getCurrentNamespace().app(programIdArgument.getAppId()).service(programIdArgument.getProgramId());
        } else {
            service = cliConfig.getCurrentNamespace().app(programIdArgument.getAppId(), arguments.get(APP_VERSION)).service(programIdArgument.getProgramId());
        }
        completer.setEndpoints(getMethods(service));
    } else {
        completer.setEndpoints(Collections.<String>emptyList());
    }
    return super.complete(buffer, cursor, candidates);
}
Also used : ProgramIdArgument(co.cask.cdap.cli.ProgramIdArgument) ServiceId(co.cask.cdap.proto.id.ServiceId)

Aggregations

ProgramIdArgument (co.cask.cdap.cli.ProgramIdArgument)2 ServiceId (co.cask.cdap.proto.id.ServiceId)2