Search in sources :

Example 16 with Interface

use of com.google.api.tools.framework.model.Interface in project toolkit by googleapis.

the class LanguageSettingsRule method getPackageName.

private String getPackageName(Model model) {
    String apiName = model.getServiceConfig().getApis(0).getName();
    Interface apiInterface = model.getSymbolTable().lookupInterface(apiName);
    return apiInterface.getFile().getFullName();
}
Also used : Interface(com.google.api.tools.framework.model.Interface)

Example 17 with Interface

use of com.google.api.tools.framework.model.Interface in project toolkit by googleapis.

the class GapicInterfaceConfig method createMethodConfigMap.

private static ImmutableMap<String, GapicMethodConfig> createMethodConfigMap(DiagCollector diagCollector, String language, InterfaceConfigProto interfaceConfigProto, Interface apiInterface, ResourceNameMessageConfigs messageConfigs, ImmutableMap<String, ResourceNameConfig> resourceNameConfigs, ImmutableSet<String> retryCodesConfigNames, ImmutableSet<String> retryParamsConfigNames) {
    ImmutableMap.Builder<String, GapicMethodConfig> methodConfigMapBuilder = ImmutableMap.builder();
    for (MethodConfigProto methodConfigProto : interfaceConfigProto.getMethodsList()) {
        Interface targetInterface = getTargetInterface(apiInterface, methodConfigProto.getRerouteToGrpcInterface());
        Method method = targetInterface.lookupMethod(methodConfigProto.getName());
        if (method == null) {
            diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "method not found: %s", methodConfigProto.getName()));
            continue;
        }
        GapicMethodConfig methodConfig = GapicMethodConfig.createMethodConfig(diagCollector, language, methodConfigProto, method, messageConfigs, resourceNameConfigs, retryCodesConfigNames, retryParamsConfigNames);
        if (methodConfig == null) {
            continue;
        }
        methodConfigMapBuilder.put(methodConfigProto.getName(), methodConfig);
    }
    if (diagCollector.getErrorCount() > 0) {
        return null;
    } else {
        return methodConfigMapBuilder.build();
    }
}
Also used : MethodConfigProto(com.google.api.codegen.MethodConfigProto) Method(com.google.api.tools.framework.model.Method) ImmutableMap(com.google.common.collect.ImmutableMap) Interface(com.google.api.tools.framework.model.Interface)

Aggregations

Interface (com.google.api.tools.framework.model.Interface)17 InterfaceView (com.google.api.codegen.InterfaceView)7 ImmutableList (com.google.common.collect.ImmutableList)5 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)3 Method (com.google.api.tools.framework.model.Method)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 GapicInterfaceConfig (com.google.api.codegen.config.GapicInterfaceConfig)2 GapicMethodConfig (com.google.api.codegen.config.GapicMethodConfig)2 ProtoInterfaceModel (com.google.api.codegen.config.ProtoInterfaceModel)2 TreeSet (java.util.TreeSet)2 ConfigProto (com.google.api.codegen.ConfigProto)1 InterfaceConfigProto (com.google.api.codegen.InterfaceConfigProto)1 MethodConfigProto (com.google.api.codegen.MethodConfigProto)1 ClientConfigGapicContext (com.google.api.codegen.clientconfig.ClientConfigGapicContext)1 ClientConfigSnippetSetRunner (com.google.api.codegen.clientconfig.ClientConfigSnippetSetRunner)1 PhpClientConfigGapicContext (com.google.api.codegen.clientconfig.php.PhpClientConfigGapicContext)1 MethodConfig (com.google.api.codegen.config.MethodConfig)1 MethodModel (com.google.api.codegen.config.MethodModel)1 NodeJSCodePathMapper (com.google.api.codegen.nodejs.NodeJSCodePathMapper)1 PhpGapicCodePathMapper (com.google.api.codegen.php.PhpGapicCodePathMapper)1