use of com.google.api.codegen.viewmodel.ImportFileView in project toolkit by googleapis.
the class RubyImportSectionTransformer method generateRakefileAcceptanceTaskImportSection.
public ImportSectionView generateRakefileAcceptanceTaskImportSection(List<GapicInterfaceContext> contexts) {
List<ImportFileView> none = ImmutableList.of();
ImportSectionView.Builder importSection = ImportSectionView.newBuilder();
importSection.standardImports(none);
importSection.externalImports(none);
Set<ImportFileView> credentialsImports = new HashSet<>();
for (GapicInterfaceContext context : contexts) {
credentialsImports.add(createImport(context.getNamer().getCredentialsClassImportName()));
}
importSection.appImports(ImmutableList.copyOf(credentialsImports));
importSection.serviceImports(none);
return importSection.build();
}
use of com.google.api.codegen.viewmodel.ImportFileView in project toolkit by googleapis.
the class RubyImportSectionTransformer method generateTestAppImports.
private List<ImportFileView> generateTestAppImports(GapicInterfaceContext context) {
ImmutableList.Builder<ImportFileView> imports = ImmutableList.builder();
SurfaceNamer namer = context.getNamer();
if (RubyUtil.hasMajorVersion(context.getProductConfig().getPackageName())) {
imports.add(createImport(namer.getTopLevelIndexFileImportName()));
} else {
imports.add(createImport(namer.getVersionIndexFileImportName()));
}
// Import the client class directly so the client class is in scope for the static class methods
// used in the in the init code such as the path methods. This is not necessary for method
// samples since the client is initialized before the init code, and the initialization
// requires the client class file.
imports.add(createImport(namer.getServiceFileName(context.getInterfaceConfig())));
for (String filename : generateImportFilenames(context)) {
imports.add(createImport(namer.getServiceFileImportName(filename)));
}
if (context.getInterfaceConfig().hasLongRunningOperations()) {
imports.add(createImport("google/longrunning/operations_pb"));
}
return imports.build();
}
use of com.google.api.codegen.viewmodel.ImportFileView in project toolkit by googleapis.
the class GoImportSectionTransformer method generateImportSection.
public ImportSectionView generateImportSection(Map<String, TypeAlias> typeImports) {
ImmutableList.Builder<ImportFileView> standardImports = ImmutableList.builder();
ImmutableList.Builder<ImportFileView> externalImports = ImmutableList.builder();
for (TypeAlias alias : typeImports.values()) {
String importPath = alias.getFullName();
ImportTypeView.Builder imp = ImportTypeView.newBuilder();
imp.fullName('"' + importPath + '"');
imp.nickname(alias.getNickname());
imp.type(alias.getImportType());
ImmutableList.Builder<ImportFileView> target = isStandardImport(importPath) ? standardImports : externalImports;
target.add(ImportFileView.newBuilder().types(ImmutableList.of(imp.build())).build());
}
return ImportSectionView.newBuilder().standardImports(standardImports.build()).externalImports(externalImports.build()).build();
}
use of com.google.api.codegen.viewmodel.ImportFileView 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.codegen.viewmodel.ImportFileView in project toolkit by googleapis.
the class PythonImportSectionTransformer method generateTypesProtoImports.
private List<ImportFileView> generateTypesProtoImports(Model model, GapicProductConfig productConfig) {
ModelTypeTable typeTable = emptyTypeTable(productConfig);
Set<ImportFileView> imports = new TreeSet<>(importFileViewComparator());
// Save proto file import names to the type table for disambiguation.
List<ProtoFile> protoFileDependencies = model.getFiles();
populateTypeTable(protoFileDependencies, typeTable);
// Get disambiguated imports.
for (Map.Entry<String, TypeAlias> entry : typeTable.getImports().entrySet()) {
imports.add(generateAppImport(entry.getKey(), entry.getValue().getNickname()));
}
return ImmutableList.<ImportFileView>builder().addAll(imports).build();
}
Aggregations