use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class RubyGapicSurfaceTestTransformer method createSmokeTestViews.
// /////////////////////////////////// Smoke Test ///////////////////////////////////////
private List<ViewModel> createSmokeTestViews(ApiModel model, GapicProductConfig productConfig) {
ImmutableList.Builder<ViewModel> views = ImmutableList.builder();
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) {
continue;
}
GapicInterfaceContext context = createContext(apiInterface, productConfig);
views.add(createSmokeTestClassView(context));
}
return views.build();
}
use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class RubyGapicSurfaceTestTransformer method createUnitTestViews.
// /////////////////////////////////// Unit Test ///////////////////////////////////////
private List<ClientTestFileView> createUnitTestViews(ApiModel model, GapicProductConfig productConfig) {
ImmutableList.Builder<ClientTestFileView> views = ImmutableList.builder();
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
if (!productConfig.hasInterfaceConfig(apiInterface)) {
continue;
}
GapicInterfaceContext context = createContext(apiInterface, productConfig);
String testClassName = namer.getUnitTestClassName(context.getInterfaceConfig());
String outputPath = unitTestPathMapper.getOutputPath(context.getInterfaceModel().getFullName(), productConfig);
ImportSectionView importSection = importSectionTransformer.generateTestImportSection(context);
views.add(ClientTestFileView.newBuilder().templateFileName(UNIT_TEST_TEMPLATE_FILE).outputPath(namer.getSourceFilePath(outputPath, testClassName)).testClass(createUnitTestClassView(context, model.hasMultipleServices())).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSection, namer)).apiVersion(packageConfig.apiVersion()).build());
}
return views.build();
}
use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateApiClasses.
private List<ViewModel> generateApiClasses(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
FeatureConfig featureConfig = new RubyFeatureConfig();
ImmutableList.Builder<ViewModel> serviceSurfaces = ImmutableList.builder();
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
if (!productConfig.hasInterfaceConfig(apiInterface)) {
continue;
}
String packageName = productConfig.getPackageName();
ModelTypeTable modelTypeTable = new ModelTypeTable(new RubyTypeTable(productConfig.getPackageName()), new RubyModelTypeNameConverter(packageName));
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, modelTypeTable, namer, featureConfig);
serviceSurfaces.add(generateApiClass(context, packageName));
}
return serviceSurfaces.build();
}
use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateTopLevelIndexView.
private ViewModel generateTopLevelIndexView(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
ImmutableList.Builder<VersionIndexRequireView> requireViews = ImmutableList.builder();
List<String> modules = namer.getTopLevelApiModules();
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
if (!productConfig.hasInterfaceConfig(apiInterface)) {
continue;
}
GapicInterfaceContext context = createContext(apiInterface, productConfig);
String clientName = namer.getPackageName();
String serviceName = namer.getPackageServiceName(context.getInterfaceConfig());
if (model.hasMultipleServices()) {
clientName += "::" + serviceName;
}
String topLevelNamespace = namer.getTopLevelNamespace();
String postVersionNamespace = postVersionNamespace(namer);
requireViews.add(VersionIndexRequireView.newBuilder().clientName(clientName).serviceName(serviceName).fileName(versionPackagePath(namer)).topLevelNamespace(topLevelNamespace).postVersionNamespace(postVersionNamespace).doc(serviceTransformer.generateServiceDoc(context, generateApiMethods(context).get(0), productConfig)).build());
}
String versionDirBasePath = namer.packageFilePathPiece(Name.upperCamel(modules.get(modules.size() - 1)));
return VersionIndexView.newBuilder().apiVersion(packageConfig.apiVersion()).requireViews(requireViews.build()).templateFileName(VERSION_INDEX_TEMPLATE_FILE).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer)).outputPath("lib" + File.separator + topLevelPackagePath(namer) + ".rb").modules(generateModuleViews(model, productConfig, false)).type(VersionIndexType.TopLevelIndex).versionDirBasePath(versionDirBasePath).postVersionDirPath(postVersionDirPath(namer)).build();
}
use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateCredentialsView.
private ViewModel generateCredentialsView(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
CredentialsClassView credentialsClass = generateCredentialsClass(model, productConfig);
ImportSectionView importSection = ImportSectionView.newBuilder().externalImports(ImmutableList.of(ImportFileView.newBuilder().moduleName("googleauth").types(ImmutableList.<ImportTypeView>of()).build())).build();
List<String> modules = namer.getApiModules();
InterfaceModel apiInterface = model.getInterfaces(productConfig).stream().filter(productConfig::hasInterfaceConfig).findFirst().orElseThrow(() -> new NoSuchElementException("reachable API interfaces"));
GapicInterfaceContext context = createContext(apiInterface, productConfig);
String subPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
return CredentialsClassFileView.newBuilder().outputPath(namer.getSourceFilePath(subPath, "Credentials")).templateFileName(CREDENTIALS_CLASS_TEMPLATE_FILE).credentialsClass(credentialsClass).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSection, namer, ImmutableList.copyOf(modules))).build();
}
Aggregations