use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class PythonGapicSurfaceTestTransformer method createSmokeTestViews.
private List<ViewModel> createSmokeTestViews(ApiModel model, GapicProductConfig productConfig) {
ImmutableList.Builder<ViewModel> models = ImmutableList.builder();
SurfaceNamer surfacePackageNamer = new PythonSurfaceNamer(productConfig.getPackageName());
SurfaceNamer testPackageNamer = new PythonSurfaceNamer(surfacePackageNamer.getTestPackageName());
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) {
continue;
}
ModelTypeTable typeTable = createTypeTable(surfacePackageNamer.getTestPackageName());
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, typeTable, surfacePackageNamer, featureConfig);
models.add(createSmokeTestClassView(context, testPackageNamer));
}
return models.build();
}
use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class PythonGapicSurfaceTestTransformer method createUnitTestViews.
private List<ViewModel> createUnitTestViews(ApiModel model, GapicProductConfig productConfig) {
ImmutableList.Builder<ViewModel> models = ImmutableList.builder();
SurfaceNamer surfacePackageNamer = new PythonSurfaceNamer(productConfig.getPackageName());
SurfaceNamer testPackageNamer = new PythonSurfaceNamer(surfacePackageNamer.getTestPackageName());
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
if (!productConfig.hasInterfaceConfig(apiInterface)) {
continue;
}
ModelTypeTable typeTable = createTypeTable(surfacePackageNamer.getTestPackageName());
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, typeTable, surfacePackageNamer, featureConfig);
String testClassName = surfacePackageNamer.getUnitTestClassName(context.getInterfaceConfig());
ClientTestClassView testClassView = ClientTestClassView.newBuilder().apiSettingsClassName(surfacePackageNamer.getNotImplementedString("PythonGapicSurfaceTestTransformer.createUnitTestViews - apiSettingsClassName")).apiClassName(surfacePackageNamer.getApiWrapperClassName(context.getInterfaceConfig())).apiVariableName(surfacePackageNamer.getApiWrapperModuleName()).name(testClassName).apiName(surfacePackageNamer.publicClassName(Name.upperCamelKeepUpperAcronyms(context.getInterfaceModel().getSimpleName()))).testCases(createTestCaseViews(context)).apiHasUnaryUnaryMethod(hasUnaryUnary(context.getInterfaceConfig())).apiHasUnaryStreamingMethod(hasUnaryStreaming(context.getInterfaceConfig())).apiHasStreamingUnaryMethod(hasStreamingUnary(context.getInterfaceConfig())).apiHasStreamingStreamingMethod(hasStreamingStreaming(context.getInterfaceConfig())).missingDefaultServiceAddress(!context.getInterfaceConfig().hasDefaultServiceAddress()).missingDefaultServiceScopes(!context.getInterfaceConfig().hasDefaultServiceScopes()).mockServices(ImmutableList.<MockServiceUsageView>of()).build();
String version = packageConfig.apiVersion();
String filename = surfacePackageNamer.classFileNameBase(Name.upperCamel(testClassName).join(version)) + ".py";
String outputPath = Joiner.on(File.separator).join("tests", "unit", "gapic", version, filename);
ImportSectionView importSection = importSectionTransformer.generateTestImportSection(context);
models.add(ClientTestFileView.newBuilder().templateFileName(TEST_TEMPLATE_FILE).outputPath(outputPath).testClass(testClassView).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSection, testPackageNamer)).build());
}
return models.build();
}
use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class PhpGapicSurfaceTransformer method transform.
@Override
public List<ViewModel> transform(ProtoApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
if (!productConfig.hasInterfaceConfig(apiInterface)) {
continue;
}
ModelTypeTable modelTypeTable = new ModelTypeTable(new PhpTypeTable(productConfig.getPackageName()), new PhpModelTypeNameConverter(productConfig.getPackageName()));
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, modelTypeTable, new PhpSurfaceNamer(productConfig.getPackageName()), new PhpFeatureConfig(productConfig));
surfaceDocs.addAll(transform(context));
}
return surfaceDocs;
}
use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class PhpGapicSurfaceTransformer method transform.
public List<ViewModel> transform(GapicInterfaceContext context) {
GapicInterfaceContext gapicImplContext = context.withNewTypeTable(context.getNamer().getGapicImplNamespace());
List<ViewModel> surfaceData = new ArrayList<>();
surfaceData.add(buildGapicClientViewModel(gapicImplContext));
surfaceData.add(buildClientViewModel(context));
surfaceData.add(buildDescriptorConfigViewModel(context));
surfaceData.add(buildRestConfigViewModel(context));
return surfaceData;
}
use of com.google.api.codegen.config.GapicInterfaceContext in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateVersionIndexView.
private ViewModel generateVersionIndexView(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
ImmutableList.Builder<VersionIndexRequireView> requireViews = ImmutableList.builder();
Iterable<? extends InterfaceModel> interfaces = model.getInterfaces(productConfig);
for (InterfaceModel apiInterface : interfaces) {
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
if (interfaceConfig == null) {
continue;
}
GapicInterfaceContext context = createContext(apiInterface, productConfig);
requireViews.add(VersionIndexRequireView.newBuilder().clientName(namer.getFullyQualifiedApiWrapperClassName(interfaceConfig)).fileName(namer.getServiceFileName(interfaceConfig)).serviceName(namer.getPackageServiceName(context.getInterfaceConfig())).doc(serviceTransformer.generateServiceDoc(context, generateApiMethods(context).get(0), productConfig)).build());
}
// append any additional types
Set<String> requireTypes = new HashSet<>();
for (TypeModel type : model.getAdditionalTypes()) {
if (type instanceof ProtoTypeRef) {
ProtoTypeRef t = (ProtoTypeRef) type;
String name = namer.getProtoFileImportName(t.getProtoType().getMessageType().getFile().getSimpleName());
requireTypes.add(name);
}
}
return VersionIndexView.newBuilder().apiVersion(packageConfig.apiVersion()).requireViews(requireViews.build()).requireTypes(ImmutableList.copyOf(requireTypes)).templateFileName(VERSION_INDEX_TEMPLATE_FILE).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer)).outputPath("lib" + File.separator + versionPackagePath(namer) + ".rb").modules(generateModuleViews(model, productConfig, true)).type(VersionIndexType.VersionIndex).build();
}
Aggregations