@Override /* Returns the DiscoGapicMethodConfig for the given method. */ public DiscoGapicMethodConfig getMethodConfig(MethodModel method) { String methodName = method.getFullName(); for (InterfaceConfig config : getProductConfig().getInterfaceConfigMap().values()) { for (MethodConfig methodConfig : config.getMethodConfigs()) { if (methodConfig.getMethodModel().getFullName().equals(methodName)) { return (DiscoGapicMethodConfig) methodConfig; } } } throw new IllegalArgumentException("Interface config does not exist for method: " + methodName); }
private List<SingleResourceNameConfig> getSingleResourceNameConfigsUsedByInterface( InterfaceContext context) { InterfaceConfig interfaceConfig = context.getInterfaceConfig(); Set<String> foundSet = new HashSet<>(); ImmutableList.Builder<SingleResourceNameConfig> resourceNameConfigsBuilder = ImmutableList.builder(); for (SingleResourceNameConfig config : interfaceConfig.getSingleResourceNameConfigs()) { resourceNameConfigsBuilder.add(config); foundSet.add(config.getEntityId()); } for (MethodConfig methodConfig : interfaceConfig.getMethodConfigs()) { MethodContext methodContext = context.asRequestMethodContext(methodConfig.getMethodModel()); for (String fieldNamePattern : methodConfig.getFieldNamePatterns().values()) { SingleResourceNameConfig resourceNameConfig = methodContext.getSingleResourceNameConfig(fieldNamePattern); if (resourceNameConfig != null && !foundSet.contains(resourceNameConfig.getEntityId())) { resourceNameConfigsBuilder.add(resourceNameConfig); foundSet.add(resourceNameConfig.getEntityId()); } } } return resourceNameConfigsBuilder.build(); }
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); }
boolean hasReturn = !methodConfig.getMethodModel().isOutputTypeEmpty(); switch (synchronicity) { case Sync:
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); }
/** * Gets the ProtoFile objects in which the fields of the reachable methods in the model are * defined. */ public static Iterable<ProtoFile> getProtoFiles(GapicProductConfig productConfig) { Set<ProtoFile> files = newFileSet(); for (InterfaceConfig interfaceConfig : productConfig.getInterfaceConfigMap().values()) { for (MethodConfig methodConfig : interfaceConfig.getMethodConfigs()) { MethodModel method = methodConfig.getMethodModel(); files.addAll( getFilesForMessage( ((ProtoTypeRef) method.getInputType()).getProtoType().getMessageType(), false)); files.addAll( getFilesForMessage( ((ProtoTypeRef) method.getOutputType()).getProtoType().getMessageType(), false)); } } return files; }
Method method = ((DiscoveryMethodModel) methodConfig.getMethodModel()).getDiscoMethod(); namePatternsToMethod.put(DiscoGapicParser.getCanonicalPath(method.flatPath()), method);
if (methodConfigs != null) { for (MethodConfig methodConfig : methodConfigs) { Method method = ((DiscoveryMethodModel) methodConfig.getMethodModel()).getDiscoMethod(); String canonicalMethodPath = DiscoGapicParser.getCanonicalPath(method.flatPath()); for (SingleResourceNameConfig nameConfig : singleResourceNames) {