Search in sources :

Example 1 with PackageInfoView

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();
}
Also used : GapicProductConfig(com.google.api.codegen.config.GapicProductConfig) ServiceDocView(com.google.api.codegen.viewmodel.ServiceDocView) ViewModel(com.google.api.codegen.viewmodel.ViewModel) InterfaceModel(com.google.api.codegen.config.InterfaceModel) MethodModel(com.google.api.codegen.config.MethodModel) ApiModel(com.google.api.codegen.config.ApiModel) Model(com.google.api.tools.framework.model.Model) PackageInfoView(com.google.api.codegen.viewmodel.PackageInfoView)

Example 2 with PackageInfoView

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();
}
Also used : InterfaceModel(com.google.api.codegen.config.InterfaceModel) PackageInfoView(com.google.api.codegen.viewmodel.PackageInfoView)

Example 3 with PackageInfoView

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;
}
Also used : StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) StaticLangStubInterfaceView(com.google.api.codegen.viewmodel.StaticLangStubInterfaceView) ArrayList(java.util.ArrayList) PackageInfoView(com.google.api.codegen.viewmodel.PackageInfoView) ViewModel(com.google.api.codegen.viewmodel.ViewModel) InterfaceContext(com.google.api.codegen.config.InterfaceContext) ServiceDocView(com.google.api.codegen.viewmodel.ServiceDocView) InterfaceModel(com.google.api.codegen.config.InterfaceModel) ImportTypeTable(com.google.api.codegen.transformer.ImportTypeTable) StaticLangSettingsView(com.google.api.codegen.viewmodel.StaticLangSettingsView) StaticLangStubSettingsView(com.google.api.codegen.viewmodel.StaticLangStubSettingsView) StaticLangRpcStubView(com.google.api.codegen.viewmodel.StaticLangRpcStubView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) StaticLangApiView(com.google.api.codegen.viewmodel.StaticLangApiView)

Example 4 with PackageInfoView

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();
}
Also used : GapicProductConfig(com.google.api.codegen.config.GapicProductConfig) ViewModel(com.google.api.codegen.viewmodel.ViewModel) ProtoApiModel(com.google.api.codegen.config.ProtoApiModel) InterfaceModel(com.google.api.codegen.config.InterfaceModel) Model(com.google.api.tools.framework.model.Model) PackageInfoView(com.google.api.codegen.viewmodel.PackageInfoView)

Aggregations

InterfaceModel (com.google.api.codegen.config.InterfaceModel)4 PackageInfoView (com.google.api.codegen.viewmodel.PackageInfoView)4 ViewModel (com.google.api.codegen.viewmodel.ViewModel)3 GapicProductConfig (com.google.api.codegen.config.GapicProductConfig)2 ServiceDocView (com.google.api.codegen.viewmodel.ServiceDocView)2 Model (com.google.api.tools.framework.model.Model)2 ApiModel (com.google.api.codegen.config.ApiModel)1 InterfaceContext (com.google.api.codegen.config.InterfaceContext)1 MethodModel (com.google.api.codegen.config.MethodModel)1 ProtoApiModel (com.google.api.codegen.config.ProtoApiModel)1 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)1 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)1 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)1 StaticLangApiView (com.google.api.codegen.viewmodel.StaticLangApiView)1 StaticLangRpcStubView (com.google.api.codegen.viewmodel.StaticLangRpcStubView)1 StaticLangSettingsView (com.google.api.codegen.viewmodel.StaticLangSettingsView)1 StaticLangStubInterfaceView (com.google.api.codegen.viewmodel.StaticLangStubInterfaceView)1 StaticLangStubSettingsView (com.google.api.codegen.viewmodel.StaticLangStubSettingsView)1 ArrayList (java.util.ArrayList)1