use of com.google.api.codegen.viewmodel.ImportFileView in project toolkit by googleapis.
the class StandardImportSectionTransformer method generateImportSection.
public ImportSectionView generateImportSection(Map<String, TypeAlias> typeImports, String className) {
ImmutableList.Builder<ImportFileView> appImports = ImmutableList.builder();
for (TypeAlias alias : typeImports.values()) {
if (excludeAppImport(alias, className)) {
continue;
}
ImportTypeView.Builder imp = ImportTypeView.newBuilder();
imp.fullName(alias.getFullName());
imp.nickname(alias.getNickname());
imp.type(alias.getImportType());
appImports.add(ImportFileView.newBuilder().types(ImmutableList.of(imp.build())).build());
}
return ImportSectionView.newBuilder().appImports(appImports.build()).build();
}
use of com.google.api.codegen.viewmodel.ImportFileView in project toolkit by googleapis.
the class NodeJSImportSectionTransformer method generateExternalImports.
private List<ImportFileView> generateExternalImports(InterfaceContext context) {
ImmutableList.Builder<ImportFileView> imports = ImmutableList.builder();
InterfaceModel apiInterface = context.getInterfaceModel();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
String configModule = context.getNamer().getClientConfigPath(interfaceConfig);
imports.add(createImport("gapicConfig", "./" + configModule));
imports.add(createImport("gax", "google-gax"));
imports.add(createImport("merge", "lodash.merge"));
imports.add(createImport("path", "path"));
if (context.getInterfaceConfig().hasLongRunningOperations() || context.getInterfaceConfig().hasBatchingMethods()) {
imports.add(createImport("protobuf", "protobufjs"));
}
return imports.build();
}
use of com.google.api.codegen.viewmodel.ImportFileView in project toolkit by googleapis.
the class PhpImportSectionTransformer method generateImportSection.
/**
* Package-private for use in PhpGapicSurfaceTestTransformer
*/
ImportSectionView generateImportSection(Map<String, TypeAlias> typeImports) {
ImmutableList.Builder<ImportFileView> appImports = ImmutableList.builder();
for (Map.Entry<String, TypeAlias> entry : typeImports.entrySet()) {
String key = entry.getKey();
TypeAlias alias = entry.getValue();
// Remove leading backslash because it is not required by PHP use statements
String fullName = key.startsWith("\\") ? key.substring(1) : key;
ImportTypeView.Builder imp = ImportTypeView.newBuilder();
imp.fullName(fullName);
imp.nickname(alias.getNickname());
imp.type(alias.getImportType());
appImports.add(ImportFileView.newBuilder().types(ImmutableList.of(imp.build())).build());
}
return ImportSectionView.newBuilder().appImports(appImports.build()).build();
}
use of com.google.api.codegen.viewmodel.ImportFileView in project toolkit by googleapis.
the class PythonImportSectionTransformer method generateMainAppImports.
private List<ImportFileView> generateMainAppImports(InterfaceContext context) {
List<ImportFileView> imports = generateFileHeaderAppImports(context.getImportTypeTable().getImports());
SurfaceNamer namer = context.getNamer();
imports.add(createImport(namer.getPackageName(), namer.getClientConfigName(context.getInterfaceConfig())));
Collections.sort(imports, importFileViewComparator());
return imports;
}
use of com.google.api.codegen.viewmodel.ImportFileView in project toolkit by googleapis.
the class PythonImportSectionTransformer method generateVersionedInitAppImports.
private List<ImportFileView> generateVersionedInitAppImports(Model model, GapicProductConfig productConfig, SurfaceNamer namer, boolean packageHasEnums) {
Set<ImportFileView> imports = new TreeSet<>(importFileViewComparator());
for (Interface apiInterface : new InterfaceView().getElementIterable(model)) {
imports.add(createImport(productConfig.getPackageName(), namer.getApiWrapperVariableName(productConfig.getInterfaceConfig(apiInterface))));
}
if (packageHasEnums) {
imports.add(createImport(productConfig.getPackageName(), "enums"));
}
imports.add(createImport(namer.getVersionedDirectoryNamespace(), "types"));
return ImmutableList.<ImportFileView>builder().addAll(imports).build();
}
Aggregations