use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class CSharpGapicSmokeTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getPackageName()), namer, new CSharpFeatureConfig());
csharpCommonTransformer.addCommonImports(context);
SmokeTestClassView smokeTests = generateSmokeTest(context);
if (smokeTests != null) {
surfaceDocs.add(smokeTests);
surfaceDocs.add(generateSmokeTestCsproj(context));
}
}
return surfaceDocs;
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getExamplePackageName()), namer, new CSharpFeatureConfig());
csharpCommonTransformer.addCommonImports(context);
context.getImportTypeTable().saveNicknameFor("Google.Protobuf.Bytestring");
context.getImportTypeTable().saveNicknameFor("System.Linq.__import__");
SnippetsFileView snippets = generateSnippets(context);
surfaceDocs.add(snippets);
}
return surfaceDocs;
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class CSharpGapicUnitTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getPackageName()), namer, new CSharpFeatureConfig());
csharpCommonTransformer.addCommonImports(context);
ModelTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("Xunit.FactAttribute");
typeTable.saveNicknameFor("Moq.Mock");
if (context.getLongRunningMethods().iterator().hasNext()) {
typeTable.saveNicknameFor("Google.LongRunning.Operations");
}
surfaceDocs.add(generateUnitTest(context));
surfaceDocs.add(generateUnitTestCsproj(context));
}
return surfaceDocs;
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class PythonGapicSurfaceTransformer method generateTopLevelEntryPoint.
private ViewModel generateTopLevelEntryPoint(Model model, GapicProductConfig productConfig) {
SurfaceNamer namer = new PythonSurfaceNamer(productConfig.getPackageName());
boolean packageHasEnums = packageHasEnums(model);
ImportSectionView imports = importSectionTransformer.generateTopLeveEntryPointImportSection(model, productConfig, namer, packageHasEnums);
return VersionIndexView.newBuilder().templateFileName(TOP_LEVEL_ENTRY_POINT_FILENAME).outputPath(topLevelEntryPointFileName(namer)).requireViews(topLevelRequireViews(model, productConfig, namer)).apiVersion(namer.getApiWrapperModuleVersion()).namespace(namer.getVersionedDirectoryNamespace()).packageVersion(packageConfig.generatedPackageVersionBound(TargetLanguage.PYTHON).lower()).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, imports, namer)).packageHasEnums(packageHasEnums).build();
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class PythonGapicSurfaceTransformer method generateApiClass.
private ViewModel generateApiClass(GapicInterfaceContext context) {
SurfaceNamer namer = context.getNamer();
String subPath = pathMapper.getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig());
String name = namer.getApiWrapperClassName(context.getInterfaceConfig());
List<ApiMethodView> methods = generateApiMethods(context);
DynamicLangXApiView.Builder xapiClass = DynamicLangXApiView.newBuilder();
xapiClass.templateFileName(XAPI_TEMPLATE_FILENAME);
xapiClass.outputPath(namer.getSourceFilePath(subPath, name));
xapiClass.protoFilename(context.getInterface().getFile().getSimpleName());
xapiClass.servicePhraseName(namer.getServicePhraseName(context.getInterfaceConfig()));
xapiClass.name(name);
xapiClass.doc(serviceTransformer.generateServiceDoc(context, methods.get(0), context.getProductConfig()));
xapiClass.stubs(grpcStubTransformer.generateGrpcStubs(context));
ApiModel model = context.getApiModel();
xapiClass.serviceAddress(model.getServiceAddress());
xapiClass.servicePort(model.getServicePort());
xapiClass.serviceTitle(model.getTitle());
xapiClass.authScopes(model.getAuthScopes());
xapiClass.hasDefaultServiceAddress(context.getInterfaceConfig().hasDefaultServiceAddress());
xapiClass.hasDefaultServiceScopes(context.getInterfaceConfig().hasDefaultServiceScopes());
xapiClass.pageStreamingDescriptors(pageStreamingTransformer.generateDescriptors(context));
xapiClass.batchingDescriptors(ImmutableList.<BatchingDescriptorView>of());
xapiClass.longRunningDescriptors(ImmutableList.<LongRunningOperationDetailView>of());
xapiClass.grpcStreamingDescriptors(ImmutableList.<GrpcStreamingDetailView>of());
xapiClass.hasPageStreamingMethods(context.getInterfaceConfig().hasPageStreamingMethods());
xapiClass.hasBatchingMethods(context.getInterfaceConfig().hasBatchingMethods());
xapiClass.hasLongRunningOperations(context.getInterfaceConfig().hasLongRunningOperations());
xapiClass.pathTemplates(pathTemplateTransformer.generatePathTemplates(context));
xapiClass.formatResourceFunctions(pathTemplateTransformer.generateFormatResourceFunctions(context));
xapiClass.parseResourceFunctions(pathTemplateTransformer.generateParseResourceFunctions(context));
xapiClass.pathTemplateGetterFunctions(ImmutableList.<PathTemplateGetterFunctionView>of());
xapiClass.methodKeys(ImmutableList.<String>of());
xapiClass.interfaceKey(context.getInterface().getFullName());
xapiClass.clientConfigPath(namer.getClientConfigPath(context.getInterfaceConfig()));
xapiClass.clientConfigName(namer.getClientConfigName(context.getInterfaceConfig()));
xapiClass.grpcClientTypeName(namer.getAndSaveNicknameForGrpcClientTypeName(context.getImportTypeTable(), context.getInterfaceModel()));
xapiClass.apiMethods(methods);
xapiClass.toolkitVersion(GeneratorVersionProvider.getGeneratorVersion());
xapiClass.gapicPackageName(namer.getGapicPackageName(packageConfig.packageName(TargetLanguage.PYTHON)));
xapiClass.fileHeader(fileHeaderTransformer.generateFileHeader(context));
return xapiClass.build();
}
Aggregations