Search in sources :

Example 1 with ServiceDocView

use of com.google.api.codegen.viewmodel.ServiceDocView 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 ServiceDocView

use of com.google.api.codegen.viewmodel.ServiceDocView 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()) {
        boolean enableStringFormatFunctions = productConfig.getResourceNameMessageConfigs().isEmpty();
        ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
        InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable, enableStringFormatFunctions);
        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.transformer.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 3 with ServiceDocView

use of com.google.api.codegen.viewmodel.ServiceDocView in project toolkit by googleapis.

the class ServiceTransformer method generateServiceDoc.

public ServiceDocView generateServiceDoc(InterfaceContext context, ApiMethodView exampleApiMethod, GapicProductConfig productConfig) {
    SurfaceNamer namer = context.getNamer();
    ServiceDocView.Builder serviceDoc = ServiceDocView.newBuilder();
    ImmutableList.Builder<String> docLines = ImmutableList.builder();
    docLines.addAll(namer.getDocLines(context.getInterfaceDescription()));
    InterfaceConfig conf = context.getInterfaceConfig();
    if (!conf.getManualDoc().isEmpty()) {
        docLines.add("");
        docLines.addAll(namer.getDocLines(conf.getManualDoc()));
    }
    List<String> lines = docLines.build();
    serviceDoc.lines(lines);
    if (lines.isEmpty()) {
        serviceDoc.firstLine("");
        serviceDoc.remainingLines(ImmutableList.<String>of());
    } else {
        serviceDoc.firstLine(lines.get(0));
        serviceDoc.remainingLines(lines.subList(1, lines.size()));
    }
    serviceDoc.exampleApiMethod(exampleApiMethod);
    serviceDoc.apiVarName(namer.getApiWrapperVariableName(context.getInterfaceConfig()));
    serviceDoc.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
    serviceDoc.settingsVarName(namer.getApiSettingsVariableName(context.getInterfaceConfig()));
    serviceDoc.settingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
    serviceDoc.hasDefaultInstance(context.getInterfaceConfig().hasDefaultInstance());
    serviceDoc.serviceTitle(context.serviceTitle());
    serviceDoc.defaultTransportProviderBuilder(namer.getDefaultTransportProviderBuilder(productConfig.getTransportProtocol()));
    serviceDoc.defaultChannelProviderBuilder(namer.getDefaultChannelProviderBuilder(productConfig.getTransportProtocol()));
    return serviceDoc.build();
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) ServiceDocView(com.google.api.codegen.viewmodel.ServiceDocView) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

ServiceDocView (com.google.api.codegen.viewmodel.ServiceDocView)3 InterfaceModel (com.google.api.codegen.config.InterfaceModel)2 PackageInfoView (com.google.api.codegen.viewmodel.PackageInfoView)2 ViewModel (com.google.api.codegen.viewmodel.ViewModel)2 ApiModel (com.google.api.codegen.config.ApiModel)1 GapicProductConfig (com.google.api.codegen.config.GapicProductConfig)1 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)1 MethodModel (com.google.api.codegen.config.MethodModel)1 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)1 InterfaceContext (com.google.api.codegen.transformer.InterfaceContext)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 Model (com.google.api.tools.framework.model.Model)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1