@Override public DiscoGapicInterfaceConfig getInterfaceConfig() { return (DiscoGapicInterfaceConfig) getProductConfig().getInterfaceConfig(getInterfaceName()); }
.flatMap(f -> f.getInterfaces().stream()) .filter(Interface::isReachable) .filter(i -> productConfig.getInterfaceConfig(i) == null) .map(Interface::getFile) .collect(ImmutableSet.toImmutableSet());
@Override public InterfaceConfig getInterfaceConfig() { return getProductConfig().getInterfaceConfig(interfaceName()); }
@Override public GapicInterfaceConfig getInterfaceConfig() { return getProductConfig().getInterfaceConfig(getInterface()); }
private List<ViewModel> createSmokeTestViews(ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ViewModel> views = ImmutableList.builder(); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig); views.add(createSmokeTestClassView(context)); } return views.build(); }
private List<ViewModel> createSmokeTestViews(ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ViewModel> views = ImmutableList.builder(); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig); views.add(createSmokeTestClassView(context, model.hasMultipleServices())); } return views.build(); }
public Map<String, InterfaceModel> getGrpcInterfacesForService( ApiModel model, GapicProductConfig productConfig, InterfaceModel apiInterface) { if (!productConfig.getTransportProtocol().equals(TransportProtocol.GRPC)) { return ImmutableMap.of(); } Map<String, InterfaceModel> interfaces = new LinkedHashMap<>(); interfaces.put(apiInterface.getFullName(), apiInterface); InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); for (MethodConfig methodConfig : interfaceConfig.getMethodConfigs()) { String reroute = methodConfig.getRerouteToGrpcInterface(); if (!Strings.isNullOrEmpty(reroute)) { InterfaceModel targetInterface = model.getInterface(reroute); interfaces.put(reroute, targetInterface); } } return interfaces; }
@Override public GapicInterfaceConfig getInterfaceConfig() { return getProductConfig().getInterfaceConfig(getInterfaceModel().getInterface()); }
/** * Returns a list of RPC methods supported by the context, taking into account GRPC interface * rerouting. TODO replace getSupportedMethods with this when all languages are migrated. */ public List<Method> getSupportedMethodsV2(Interface apiInterface) { GapicInterfaceConfig interfaceConfig = getApiConfig().getInterfaceConfig(apiInterface); if (interfaceConfig == null) { throw new IllegalStateException( "Service not configured in GAPIC config: " + apiInterface.getFullName()); } List<Method> methods = new ArrayList<>(interfaceConfig.getMethodConfigs().size()); for (MethodConfig methodConfig : interfaceConfig.getMethodConfigs()) { Method method = ((GapicMethodConfig) methodConfig).getMethod(); if (isSupported(method)) { methods.add(method); } } return methods; }
public static DiscoGapicInterfaceContext createWithInterface( InterfaceModel interfaceModel, GapicProductConfig productConfig, ImportTypeTable typeTable, SurfaceNamer namer, FeatureConfig featureConfig) { Preconditions.checkArgument(typeTable instanceof SchemaTypeTable); ImmutableList.Builder<MethodModel> interfaceMethods = new ImmutableList.Builder<>(); for (MethodConfig method : productConfig.getInterfaceConfig(interfaceModel.getFullName()).getMethodConfigs()) { interfaceMethods.add(method.getMethodModel()); } return new AutoValue_DiscoGapicInterfaceContext( productConfig, (SchemaTypeTable) typeTable, new DiscoGapicNamer(), (DiscoInterfaceModel) interfaceModel, namer, featureConfig); }
/** * Returns the MethodConfig object of the given gRPC method. * * <p>If the method is a gRPC re-route method, returns the MethodConfig of the original method. */ public GapicMethodConfig getMethodConfig(MethodModel method) { Interface originalInterface = getInterface(); if (getGrpcRerouteMap().containsKey(originalInterface)) { originalInterface = getGrpcRerouteMap().get(originalInterface); } InterfaceConfig originalInterfaceConfig = getProductConfig().getInterfaceConfig(originalInterface); if (originalInterfaceConfig != null) { return (GapicMethodConfig) originalInterfaceConfig.getMethodConfig(method); } else { throw new IllegalArgumentException( "Interface config does not exist for method: " + method.getSimpleName()); } }
private static Map<Interface, Interface> createGrpcRerouteMap( Model model, GapicProductConfig productConfig) { HashMap<Interface, Interface> grpcRerouteMap = new HashMap<>(); for (Interface apiInterface : ProtoModels.getInterfaces(model)) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null) { continue; } if (!apiInterface.isReachable()) { continue; } for (MethodConfig methodConfig : interfaceConfig.getMethodConfigs()) { String reroute = methodConfig.getRerouteToGrpcInterface(); if (!Strings.isNullOrEmpty(reroute)) { Interface targetInterface = model.getSymbolTable().lookupInterface(reroute); grpcRerouteMap.put(targetInterface, apiInterface); } } } return grpcRerouteMap; }
private static DiscoGapicInterfaceContext createWithInterface( DiscoApiModel model, String interfaceName, GapicProductConfig productConfig, SchemaTypeTable typeTable, SurfaceNamer namer, FeatureConfig featureConfig) { ImmutableList.Builder<MethodModel> interfaceMethods = new ImmutableList.Builder<>(); for (MethodConfig method : productConfig.getInterfaceConfig(interfaceName).getMethodConfigs()) { interfaceMethods.add(method.getMethodModel()); } return new AutoValue_DiscoGapicInterfaceContext( productConfig, typeTable, new DiscoGapicNamer(), new DiscoInterfaceModel(interfaceName, model), namer, featureConfig); }
@Override public List<ViewModel> transform(ProtoApiModel model, GapicProductConfig productConfig) { GoSurfaceNamer namer = new GoSurfaceNamer(productConfig.getPackageName()); List<ViewModel> models = new ArrayList<ViewModel>(); models.add(generateMockServiceView(model, productConfig, namer)); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } GapicInterfaceContext context = GapicInterfaceContext.create( apiInterface, productConfig, GoGapicSurfaceTransformer.createTypeTable(), namer, featureConfig); models.add(createSmokeTestClassView(context)); } return models; }
private List<ViewModel> createSmokeTestViews(ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ViewModel> models = ImmutableList.builder(); SurfaceNamer surfacePackageNamer = new PythonSurfaceNamer(productConfig.getPackageName()); SurfaceNamer testPackageNamer = new PythonSurfaceNamer(surfacePackageNamer.getTestPackageName()); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } ModelTypeTable typeTable = createTypeTable(surfacePackageNamer.getTestPackageName()); GapicInterfaceContext context = GapicInterfaceContext.create( apiInterface, productConfig, typeTable, surfacePackageNamer, featureConfig); models.add(createSmokeTestClassView(context, testPackageNamer)); } return models.build(); }
if (context.getApiConfig().getInterfaceConfig(modelInterface) == null) { continue;
private List<ApiMethodView> generateExampleMethods( ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ApiMethodView> exampleMethods = ImmutableList.builder(); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig); MethodModel method = interfaceConfig.getSmokeTestConfig().getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup( context.getMethodConfig(method), interfaceConfig.getSmokeTestConfig()); GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup); exampleMethods.add(createExampleApiMethodView(flattenedMethodContext)); } return exampleMethods.build(); }
private List<ApiMethodView> generateExampleMethods( ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ApiMethodView> exampleMethods = ImmutableList.builder(); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig); MethodModel method = interfaceConfig.getSmokeTestConfig().getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup( context.getMethodConfig(method), interfaceConfig.getSmokeTestConfig()); GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup); exampleMethods.add( createExampleApiMethodView(flattenedMethodContext, model.hasMultipleServices())); } return exampleMethods.build(); }
private List<ApiMethodView> generateExampleMethods( ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ApiMethodView> exampleMethods = ImmutableList.builder(); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig); MethodModel method = interfaceConfig.getSmokeTestConfig().getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup( context.getMethodConfig(method), interfaceConfig.getSmokeTestConfig()); GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup); exampleMethods.add( createExampleApiMethodView(flattenedMethodContext, model.hasMultipleServices())); } return exampleMethods.build(); }
Iterable<? extends InterfaceModel> interfaces = model.getInterfaces(); for (InterfaceModel apiInterface : interfaces) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null) { continue;