use of com.google.api.tools.framework.model.Interface in project toolkit by googleapis.
the class ProtoInterfaceModel method getMethods.
@Override
public List<MethodModel> getMethods() {
ImmutableList.Builder<MethodModel> methods = ImmutableList.builder();
for (Method method : protoInterface.getMethods()) {
methods.add(new ProtoMethodModel(method));
}
SymbolTable symbolTable = protoInterface.getModel().getSymbolTable();
for (Mixin mixin : protoInterface.getConfig().getMixinsList()) {
Interface mixinInterface = symbolTable.lookupInterface(mixin.getName());
for (Method method : mixinInterface.getMethods()) {
methods.add(new ProtoMethodModel(method));
}
}
return methods.build();
}
use of com.google.api.tools.framework.model.Interface in project toolkit by googleapis.
the class ProtoInterfaceTransformer method getResourceToEntityNameMap.
@Override
public Map<String, String> getResourceToEntityNameMap(InterfaceModel apiInterface) {
Interface protoInterface = ((ProtoInterfaceModel) apiInterface).getInterface();
// Using a map with the string representation of the resource path to avoid duplication
// of equivalent paths.
// Using a TreeMap in particular so that the ordering is deterministic
// (useful for testability).
Map<String, CollectionPattern> specs = new TreeMap<>();
for (Method method : protoInterface.getReachableMethods()) {
for (CollectionPattern collectionPattern : CollectionPattern.getCollectionPatternsFromMethod(method)) {
String resourcePath = collectionPattern.getTemplatizedResourcePath();
// If there are multiple field segments with the same resource path, the last
// one will be used, making the output deterministic. Also, the first field path
// encountered tends to be simply "name" because it is the corresponding create
// API method for the type.
specs.put(resourcePath, collectionPattern);
}
}
Set<String> usedNameSet = new HashSet<>();
ImmutableMap.Builder<String, String> nameMapBuilder = ImmutableMap.builder();
for (CollectionPattern collectionPattern : specs.values()) {
String resourceNameString = collectionPattern.getTemplatizedResourcePath();
String entityNameString = collectionPattern.getUniqueName(usedNameSet);
usedNameSet.add(entityNameString);
nameMapBuilder.put(resourceNameString, entityNameString);
}
return nameMapBuilder.build();
}
use of com.google.api.tools.framework.model.Interface in project toolkit by googleapis.
the class PythonGapicSurfaceTransformer method topLevelRequireViews.
private List<VersionIndexRequireView> topLevelRequireViews(Model model, GapicProductConfig productConfig, SurfaceNamer namer) {
ImmutableList.Builder<VersionIndexRequireView> views = ImmutableList.builder();
Iterable<Interface> apiInterfaces = new InterfaceView().getElementIterable(model);
for (Interface apiInterface : apiInterfaces) {
views.add(VersionIndexRequireView.newBuilder().clientName(namer.getApiWrapperClassName(productConfig.getInterfaceConfig(apiInterface))).localName(namer.getApiWrapperVariableName(productConfig.getInterfaceConfig(apiInterface))).fileName(namer.getNotImplementedString("VersionIndexRequireView.fileName")).build());
}
return views.build();
}
use of com.google.api.tools.framework.model.Interface in project toolkit by googleapis.
the class PythonImportSectionTransformer method generateTopLevelEntryPointAppImports.
private List<ImportFileView> generateTopLevelEntryPointAppImports(Model model, GapicProductConfig productConfig, SurfaceNamer namer, boolean packageHasEnums) {
Set<ImportFileView> imports = new TreeSet<>(importFileViewComparator());
for (Interface apiInterface : new InterfaceView().getElementIterable(model)) {
imports.add(createImport(namer.getVersionedDirectoryNamespace(), namer.getApiWrapperClassName(productConfig.getInterfaceConfig(apiInterface))));
}
if (packageHasEnums) {
imports.add(createImport(namer.getVersionedDirectoryNamespace(), "enums"));
}
imports.add(createImport(namer.getVersionedDirectoryNamespace(), "types"));
return ImmutableList.<ImportFileView>builder().addAll(imports).build();
}
use of com.google.api.tools.framework.model.Interface in project toolkit by googleapis.
the class RubyGapicSurfaceDocTransformer method generateTocModuleView.
private TocModuleView generateTocModuleView(ApiModel model, ProtoFile file, ProductConfig productConfig, SurfaceNamer namer, String moduleName) {
RubyPackageMetadataTransformer metadataTransformer = new RubyPackageMetadataTransformer(packageConfig);
RubyPackageMetadataNamer packageNamer = new RubyPackageMetadataNamer(productConfig.getPackageName());
String packageFilePath = file.getFullName().replace(".", File.separator);
ImmutableList.Builder<TocContentView> tocContents = ImmutableList.builder();
for (Interface apiInterface : file.getReachableInterfaces()) {
String description = RubyUtil.getSentence(namer.getDocLines(GapicParser.getDocString(apiInterface)));
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(new ProtoInterfaceModel(apiInterface));
tocContents.add(metadataTransformer.generateTocContent(description, packageNamer, packageFilePath, namer.getApiWrapperClassName(interfaceConfig)));
}
tocContents.add(metadataTransformer.generateTocContent("Data types for " + productConfig.getPackageName(), packageNamer, packageFilePath, "Data Types"));
return TocModuleView.newBuilder().moduleName(moduleName).fullName(model.getTitle()).contents(tocContents.build()).build();
}
Aggregations