Search in sources :

Example 1 with PackageMetadataNamer

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();
}
Also used : PackageMetadataNamer(com.google.api.codegen.transformer.PackageMetadataNamer) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 2 with PackageMetadataNamer

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();
}
Also used : PackageMetadataNamer(com.google.api.codegen.transformer.PackageMetadataNamer) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 3 with PackageMetadataNamer

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;
}
Also used : PythonSurfaceNamer(com.google.api.codegen.transformer.py.PythonSurfaceNamer) PackageMetadataTransformer(com.google.api.codegen.transformer.PackageMetadataTransformer) ArrayList(java.util.ArrayList) PackageMetadataView(com.google.api.codegen.viewmodel.metadata.PackageMetadataView) PackageMetadataNamer(com.google.api.codegen.transformer.PackageMetadataNamer)

Example 4 with PackageMetadataNamer

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();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ViewModel(com.google.api.codegen.viewmodel.ViewModel) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) PackageMetadataNamer(com.google.api.codegen.transformer.PackageMetadataNamer) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 5 with PackageMetadataNamer

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();
}
Also used : ApiMethodView(com.google.api.codegen.viewmodel.ApiMethodView) DynamicLangXApiView(com.google.api.codegen.viewmodel.DynamicLangXApiView) ApiModel(com.google.api.codegen.config.ApiModel) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) PackageMetadataNamer(com.google.api.codegen.transformer.PackageMetadataNamer)

Aggregations

PackageMetadataNamer (com.google.api.codegen.transformer.PackageMetadataNamer)5 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)4 ApiModel (com.google.api.codegen.config.ApiModel)1 PackageMetadataTransformer (com.google.api.codegen.transformer.PackageMetadataTransformer)1 PythonSurfaceNamer (com.google.api.codegen.transformer.py.PythonSurfaceNamer)1 ApiMethodView (com.google.api.codegen.viewmodel.ApiMethodView)1 DynamicLangXApiView (com.google.api.codegen.viewmodel.DynamicLangXApiView)1 ViewModel (com.google.api.codegen.viewmodel.ViewModel)1 PackageMetadataView (com.google.api.codegen.viewmodel.metadata.PackageMetadataView)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1