use of com.google.api.codegen.transformer.PackageMetadataNamer in project toolkit by googleapis.
the class PythonPackageMetadataTransformer method generateDocFiles.
private List<ViewModel> generateDocFiles(ApiModel model, GapicProductConfig productConfig) {
PackageMetadataNamer namer = new PackageMetadataNamer();
SurfaceNamer surfaceNamer = new PythonSurfaceNamer(productConfig.getPackageName());
String docsGapicPath = docsGapicPath(packageConfig.apiVersion());
String typesOutputPath = String.format("docs/%s/types.rst", docsGapicPath);
String apiOutputPath = String.format("docs/%s/api.rst", docsGapicPath);
return ImmutableList.<ViewModel>builder().add(generateMetadataView(model, productConfig, TYPES_DOC_TEMPLATE_FILE, namer, surfaceNamer, typesOutputPath).build()).add(generateMetadataView(model, productConfig, API_DOC_TEMPLATE_FILE, namer, surfaceNamer, apiOutputPath).build()).build();
}
use of com.google.api.codegen.transformer.PackageMetadataNamer in project toolkit by googleapis.
the class PythonPackageMetadataTransformer method generateNoxFile.
private ViewModel generateNoxFile(ApiModel model, GapicProductConfig productConfig) {
PackageMetadataNamer namer = new PackageMetadataNamer();
SurfaceNamer surfaceNamer = new PythonSurfaceNamer(productConfig.getPackageName());
String outputPath = "nox.py";
return generateMetadataView(model, productConfig, NOX_TEMPLATE_FILE, namer, surfaceNamer, outputPath).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSectionTransformer.generateNoxImportSection(), new PythonSurfaceNamer(productConfig.getPackageName()))).build();
}
use of com.google.api.codegen.transformer.PackageMetadataNamer in project toolkit by googleapis.
the class PythonGrpcMetadataTransformer method transform.
public List<PackageMetadataView> transform(ApiModel model, PackageMetadataConfig config) {
ArrayList<PackageMetadataView> views = new ArrayList<>();
PythonSurfaceNamer surfaceNamer = new PythonSurfaceNamer(config.packageName(TargetLanguage.PYTHON));
PackageMetadataTransformer transformer = new PackageMetadataTransformer();
for (String snippetFilename : SNIPPETS) {
PackageMetadataView view = transformer.generateMetadataView(new PackageMetadataNamer(), config, model, snippetFilename, outputPath(snippetFilename), TargetLanguage.PYTHON, PROTO_PACKAGE_DEPENDENCY_WHITELIST).namespacePackages(copierResult.namespacePackages()).developmentStatus(surfaceNamer.getReleaseAnnotation(config.releaseLevel(TargetLanguage.PYTHON))).build();
views.add(view);
}
return views;
}
use of com.google.api.codegen.transformer.PackageMetadataNamer in project toolkit by googleapis.
the class PythonPackageMetadataTransformer method generateTopLevelFiles.
private List<ViewModel> generateTopLevelFiles(ApiModel model, GapicProductConfig productConfig) {
PackageMetadataNamer namer = new PackageMetadataNamer();
SurfaceNamer surfaceNamer = new PythonSurfaceNamer(productConfig.getPackageName());
ImmutableList.Builder<ViewModel> metadata = ImmutableList.builder();
for (Map.Entry<String, String> entry : TOP_LEVEL_TEMPLATE_FILES.entrySet()) {
metadata.add(generateMetadataView(model, productConfig, entry.getKey(), namer, surfaceNamer, entry.getValue()).build());
}
return metadata.build();
}
use of com.google.api.codegen.transformer.PackageMetadataNamer in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateApiClass.
private ViewModel generateApiClass(GapicInterfaceContext context, String packageName) {
SurfaceNamer namer = context.getNamer();
PackageMetadataNamer metadataNamer = new RubyPackageMetadataNamer(packageName);
String subPath = pathMapper.getOutputPath(context.getInterface().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.fileHeader(fileHeaderTransformer.generateFileHeader(context));
xapiClass.protoFilename(context.getInterface().getFile().getSimpleName());
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(batchingTransformer.generateDescriptors(context));
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.grpcClientTypeName(namer.getAndSaveNicknameForGrpcClientTypeName(context.getImportTypeTable(), context.getInterfaceModel()));
xapiClass.apiMethods(methods);
xapiClass.toolkitVersion(GeneratorVersionProvider.getGeneratorVersion());
xapiClass.gapicPackageName(RubyUtil.isLongrunning(context.getProductConfig().getPackageName()) ? "google-gax" : metadataNamer.getMetadataIdentifier());
xapiClass.fullyQualifiedCredentialsClassName(namer.getFullyQualifiedCredentialsClassName());
xapiClass.defaultCredentialsInitializerCall(RubyUtil.isLongrunning(context.getProductConfig().getPackageName()) ? "default(scopes: scopes)" : "default");
return xapiClass.build();
}
Aggregations