use of com.google.api.codegen.viewmodel.PackageInfoView in project toolkit by googleapis.
the class CSharpGapicClientTransformer method generateCsProjView.
private PackageInfoView generateCsProjView(GapicInterfaceContext context) {
Model model = context.getModel();
GapicProductConfig productConfig = context.getProductConfig();
PackageInfoView.Builder view = PackageInfoView.newBuilder();
view.templateFileName(CSPROJ_TEMPLATE_FILENAME);
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), productConfig);
view.outputPath(outputPath + File.separator + productConfig.getPackageName() + ".csproj");
view.fileHeader(fileHeaderTransformer.generateFileHeader(context));
view.serviceTitle(model.getServiceConfig().getTitle());
view.serviceDescription(model.getServiceConfig().getDocumentation().getSummary().trim());
view.domainLayerLocation(productConfig.getDomainLayerLocation());
// Unused in C#
view.authScopes(new ArrayList<String>());
view.releaseLevel(productConfig.getReleaseLevel());
String versionSuffix;
switch(productConfig.getReleaseLevel()) {
case ALPHA:
versionSuffix = "-alpha01";
break;
case BETA:
versionSuffix = "-beta01";
break;
default:
versionSuffix = "";
break;
}
view.version("1.0.0" + versionSuffix);
String tags = "";
for (String tag : Splitter.on('.').split(productConfig.getPackageName())) {
if (tag.matches("[vV][\\d.]+")) {
break;
}
tags += ";" + tag;
}
view.tags(tags.isEmpty() ? "" : tags.substring(1));
view.packageMetadata(generatePackageMetadataView(context));
view.serviceDocs(new ArrayList<ServiceDocView>());
return view.build();
}
use of com.google.api.codegen.viewmodel.PackageInfoView in project toolkit by googleapis.
the class JavaSurfaceTransformer method generatePackageInfo.
private PackageInfoView generatePackageInfo(ApiModel model, GapicProductConfig productConfig, SurfaceNamer namer, List<ServiceDocView> serviceDocs) {
PackageInfoView.Builder packageInfo = PackageInfoView.newBuilder();
packageInfo.templateFileName(PACKAGE_INFO_TEMPLATE_FILENAME);
packageInfo.serviceTitle(model.getTitle());
packageInfo.serviceDocs(serviceDocs);
packageInfo.domainLayerLocation(productConfig.getDomainLayerLocation());
packageInfo.authScopes(model.getAuthScopes());
packageInfo.fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer));
InterfaceModel firstInterface = model.getInterfaces().iterator().next();
String outputPath = pathMapper.getOutputPath(firstInterface.getFullName(), productConfig);
packageInfo.outputPath(outputPath + File.separator + "package-info.java");
packageInfo.releaseLevel(productConfig.getReleaseLevel());
return packageInfo.build();
}
use of com.google.api.codegen.viewmodel.PackageInfoView in project toolkit by googleapis.
the class JavaSurfaceTransformer method transform.
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = surfaceTransformer.createSurfaceNamer(productConfig);
List<ServiceDocView> serviceDocs = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
if (!productConfig.hasInterfaceConfig(apiInterface)) {
continue;
}
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable);
StaticLangFileView<StaticLangApiView> apiFile = generateApiFile(context, productConfig);
surfaceDocs.add(apiFile);
serviceDocs.add(apiFile.classView().doc());
StaticLangApiMethodView exampleApiMethod = getExampleApiMethod(apiFile.classView().apiMethods());
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangStubSettingsView> stubSettingsFile = generateStubSettingsFile(context, productConfig, exampleApiMethod);
context = context.withNewTypeTable(namer.getRootPackageName());
StaticLangFileView<StaticLangSettingsView> settingsFile = generateSettingsFile(context, productConfig, exampleApiMethod, stubSettingsFile.classView());
surfaceDocs.add(settingsFile);
surfaceDocs.add(stubSettingsFile);
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangStubInterfaceView> stubInterfaceFile = generateStubInterfaceFile(context, productConfig);
surfaceDocs.add(stubInterfaceFile);
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangRpcStubView> grpcStubFile = generateRpcStubClassFile(context, productConfig);
surfaceDocs.add(grpcStubFile);
surfaceDocs.add(generateCallableFactoryClassFile(context, productConfig));
}
PackageInfoView packageInfo = generatePackageInfo(model, productConfig, namer, serviceDocs);
surfaceDocs.add(packageInfo);
return surfaceDocs;
}
use of com.google.api.codegen.viewmodel.PackageInfoView in project toolkit by googleapis.
the class CSharpGapicClientPackageTransformer method generateCsProjView.
private PackageInfoView generateCsProjView(GapicInterfaceContext context) {
Model model = context.getModel();
GapicProductConfig productConfig = context.getProductConfig();
PackageInfoView.Builder view = PackageInfoView.newBuilder();
view.templateFileName(CSPROJ_TEMPLATE_FILENAME);
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), productConfig);
view.outputPath(outputPath + File.separator + productConfig.getPackageName() + ".csproj");
view.fileHeader(fileHeaderTransformer.generateFileHeader(context));
view.serviceTitle(model.getServiceConfig().getTitle());
view.serviceDescription(model.getServiceConfig().getDocumentation().getSummary().trim());
view.domainLayerLocation(productConfig.getDomainLayerLocation());
// Unused in C#
view.authScopes(new ArrayList<>());
view.releaseLevel(productConfig.getReleaseLevel());
String versionSuffix;
switch(productConfig.getReleaseLevel()) {
case ALPHA:
versionSuffix = "-alpha01";
break;
case BETA:
versionSuffix = "-beta01";
break;
default:
versionSuffix = "";
break;
}
view.version("1.0.0" + versionSuffix);
String tags = "";
for (String tag : Splitter.on('.').split(productConfig.getPackageName())) {
if (tag.matches("[vV][\\d.]+")) {
break;
}
tags += ";" + tag;
}
view.tags(tags.isEmpty() ? "" : tags.substring(1));
view.packageMetadata(generatePackageMetadataView(context));
view.serviceDocs(new ArrayList<>());
return view.build();
}
Aggregations