Search in sources :

Example 76 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.

the class RubyGapicSurfaceDocTransformer method generateDoc.

private ViewModel generateDoc(ProtoFile file, GapicProductConfig productConfig) {
    ModelTypeTable typeTable = new ModelTypeTable(new RubyTypeTable(productConfig.getPackageName()), new RubyModelTypeNameConverter(productConfig.getPackageName()));
    // Use file path for package name to get file-specific package instead of package for the API.
    SurfaceNamer namer = new RubySurfaceNamer(typeTable.getFullNameFor(file));
    String subPath = pathMapper.getOutputPath(file.getFullName(), productConfig);
    String baseFilename = namer.getProtoFileName(file.getSimpleName());
    GrpcDocView.Builder doc = GrpcDocView.newBuilder();
    doc.templateFileName(DOC_TEMPLATE_FILENAME);
    doc.outputPath(subPath + "/doc/" + baseFilename);
    doc.fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer));
    doc.elementDocs(elementDocTransformer.generateElementDocs(productConfig, typeTable, namer, file));
    doc.modules(generateModuleViews(new ProtoApiModel(file.getModel()), productConfig, namer, isSourceApiInterfaceFile(file) ? file : null));
    return doc.build();
}
Also used : RubyTypeTable(com.google.api.codegen.util.ruby.RubyTypeTable) ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable) ProtoApiModel(com.google.api.codegen.config.ProtoApiModel) GrpcDocView(com.google.api.codegen.viewmodel.GrpcDocView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 77 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer 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 78 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.

the class GoGapicSurfaceTestTransformer method createSmokeTestClassView.

private SmokeTestClassView createSmokeTestClassView(InterfaceContext context) {
    SurfaceNamer namer = context.getNamer();
    MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
    MethodContext methodContext = context.asRequestMethodContext(method);
    SmokeTestClassView.Builder testClass = SmokeTestClassView.newBuilder();
    StaticLangApiMethodView apiMethodView = createSmokeTestCaseApiMethodView(methodContext);
    testClass.apiSettingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
    testClass.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
    testClass.name(namer.getSmokeTestClassName(context.getInterfaceConfig()));
    testClass.outputPath(context.getProductConfig().getPackageName() + File.separator + method.getSimpleName() + "_smoke_test.go");
    testClass.templateFileName(SMOKE_TEST_TEMPLATE_FILE);
    testClass.apiMethod(apiMethodView);
    testClass.requireProjectId(testCaseTransformer.requireProjectIdInSmokeTest(apiMethodView.initCode(), context.getNamer()));
    // The shared code above add imports both for input and output.
    // Since we use short decls, we don't need to import anything for output.
    context.getImportTypeTable().getImports().clear();
    method.getAndSaveRequestTypeName(methodContext.getTypeTable(), methodContext.getNamer());
    FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context);
    testClass.fileHeader(fileHeader);
    return testClass.build();
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) SmokeTestClassView(com.google.api.codegen.viewmodel.testing.SmokeTestClassView) GapicMethodContext(com.google.api.codegen.config.GapicMethodContext) MethodContext(com.google.api.codegen.config.MethodContext) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) FileHeaderView(com.google.api.codegen.viewmodel.FileHeaderView)

Example 79 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.

the class NodeJSGapicSurfaceTransformer method generateProtoList.

private ViewModel generateProtoList(GapicInterfaceContext context) {
    DynamicLangXApiView.Builder protoList = prepareApiClassBuilder(context);
    SurfaceNamer namer = context.getNamer();
    String subPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
    protoList.templateFileName(PROTO_LIST_TEMPLATE_FILENAME);
    protoList.outputPath(subPath + "/" + namer.getProtoListFileName(context.getInterfaceConfig()));
    return protoList.build();
}
Also used : DynamicLangXApiView(com.google.api.codegen.viewmodel.DynamicLangXApiView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 80 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.

the class NodeJSGapicSurfaceTransformer method generateApiClass.

private ViewModel generateApiClass(GapicInterfaceContext context) {
    DynamicLangXApiView.Builder xapiClass = prepareApiClassBuilder(context);
    SurfaceNamer namer = context.getNamer();
    String subPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
    xapiClass.templateFileName(XAPI_TEMPLATE_FILENAME);
    xapiClass.outputPath(subPath + "/" + namer.getServiceFileName(context.getInterfaceConfig()));
    return xapiClass.build();
}
Also used : DynamicLangXApiView(com.google.api.codegen.viewmodel.DynamicLangXApiView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Aggregations

SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)109 InterfaceModel (com.google.api.codegen.config.InterfaceModel)26 ViewModel (com.google.api.codegen.viewmodel.ViewModel)23 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)22 ArrayList (java.util.ArrayList)22 ImmutableList (com.google.common.collect.ImmutableList)17 GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)15 MethodModel (com.google.api.codegen.config.MethodModel)14 ImportSectionView (com.google.api.codegen.viewmodel.ImportSectionView)13 SmokeTestClassView (com.google.api.codegen.viewmodel.testing.SmokeTestClassView)11 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)10 ModelTypeTable (com.google.api.codegen.transformer.ModelTypeTable)10 FileHeaderView (com.google.api.codegen.viewmodel.FileHeaderView)10 ApiModel (com.google.api.codegen.config.ApiModel)9 MethodConfig (com.google.api.codegen.config.MethodConfig)9 ProtoApiModel (com.google.api.codegen.config.ProtoApiModel)9 DynamicLangXApiView (com.google.api.codegen.viewmodel.DynamicLangXApiView)9 FieldConfig (com.google.api.codegen.config.FieldConfig)8 GapicMethodContext (com.google.api.codegen.config.GapicMethodContext)8 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)8