Search in sources :

Example 1 with ProductServiceConfig

use of com.google.api.codegen.config.ProductServiceConfig in project toolkit by googleapis.

the class PhpGapicSurfaceTransformer method buildGapicClientViewModel.

private ViewModel buildGapicClientViewModel(GapicInterfaceContext context) {
    SurfaceNamer namer = context.getNamer();
    addApiImports(context);
    List<ApiMethodView> methods = generateApiMethods(context);
    DynamicLangXApiView.Builder apiImplClass = DynamicLangXApiView.newBuilder();
    apiImplClass.doc(serviceTransformer.generateServiceDoc(context, methods.get(0), context.getProductConfig()));
    apiImplClass.templateFileName(API_IMPL_TEMPLATE_FILENAME);
    apiImplClass.protoFilename(context.getInterface().getFile().getSimpleName());
    String implName = namer.getApiWrapperClassImplName(context.getInterfaceConfig());
    apiImplClass.name(implName);
    ProductServiceConfig productServiceConfig = new ProductServiceConfig();
    apiImplClass.serviceAddress(productServiceConfig.getServiceAddress(context.getInterface().getModel()));
    apiImplClass.servicePort(productServiceConfig.getServicePort());
    apiImplClass.serviceTitle(productServiceConfig.getTitle(context.getInterface().getModel()));
    apiImplClass.authScopes(productServiceConfig.getAuthScopes(context.getInterface().getModel()));
    apiImplClass.pathTemplates(pathTemplateTransformer.generatePathTemplates(context));
    apiImplClass.formatResourceFunctions(pathTemplateTransformer.generateFormatResourceFunctions(context));
    apiImplClass.parseResourceFunctions(pathTemplateTransformer.generateParseResourceFunctions(context));
    apiImplClass.pathTemplateGetterFunctions(pathTemplateTransformer.generatePathTemplateGetterFunctions(context));
    apiImplClass.pageStreamingDescriptors(pageStreamingTransformer.generateDescriptors(context));
    apiImplClass.hasPageStreamingMethods(context.getInterfaceConfig().hasPageStreamingMethods());
    apiImplClass.batchingDescriptors(ImmutableList.<BatchingDescriptorView>of());
    apiImplClass.hasBatchingMethods(context.getInterfaceConfig().hasBatchingMethods());
    apiImplClass.longRunningDescriptors(createLongRunningDescriptors(context));
    apiImplClass.hasLongRunningOperations(context.getInterfaceConfig().hasLongRunningOperations());
    apiImplClass.grpcStreamingDescriptors(createGrpcStreamingDescriptors(context));
    apiImplClass.methodKeys(generateMethodKeys(context));
    apiImplClass.clientConfigPath(namer.getClientConfigPath(context.getInterfaceConfig()));
    apiImplClass.clientConfigName(namer.getClientConfigName(context.getInterfaceConfig()));
    apiImplClass.interfaceKey(context.getInterface().getFullName());
    String grpcClientTypeName = namer.getAndSaveNicknameForGrpcClientTypeName(context.getImportTypeTable(), context.getInterfaceModel());
    apiImplClass.grpcClientTypeName(grpcClientTypeName);
    apiImplClass.apiMethods(methods);
    apiImplClass.stubs(grpcStubTransformer.generateGrpcStubs(context));
    apiImplClass.hasDefaultServiceAddress(context.getInterfaceConfig().hasDefaultServiceAddress());
    apiImplClass.hasDefaultServiceScopes(context.getInterfaceConfig().hasDefaultServiceScopes());
    apiImplClass.toolkitVersion(GeneratorVersionProvider.getGeneratorVersion());
    // must be done as the last step to catch all imports
    apiImplClass.fileHeader(fileHeaderTransformer.generateFileHeader(context));
    String outputPath = pathMapper.getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig());
    apiImplClass.outputPath(outputPath + "/" + implName + ".php");
    return apiImplClass.build();
}
Also used : ApiMethodView(com.google.api.codegen.viewmodel.ApiMethodView) DynamicLangXApiView(com.google.api.codegen.viewmodel.DynamicLangXApiView) ProductServiceConfig(com.google.api.codegen.config.ProductServiceConfig) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Aggregations

ProductServiceConfig (com.google.api.codegen.config.ProductServiceConfig)1 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)1 ApiMethodView (com.google.api.codegen.viewmodel.ApiMethodView)1 DynamicLangXApiView (com.google.api.codegen.viewmodel.DynamicLangXApiView)1