Search in sources :

Example 11 with ApiModel

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

the class NodeJSGapicSurfaceTransformer method prepareApiClassBuilder.

private DynamicLangXApiView.Builder prepareApiClassBuilder(GapicInterfaceContext context) {
    SurfaceNamer namer = context.getNamer();
    List<OptionalArrayMethodView> methods = apiMethodTransformer.generateApiMethods(context);
    DynamicLangXApiView.Builder xapiClass = DynamicLangXApiView.newBuilder();
    xapiClass.fileHeader(fileHeaderTransformer.generateFileHeader(context));
    xapiClass.protoFilename(context.getInterface().getFile().getSimpleName());
    xapiClass.name(namer.getApiWrapperClassName(context.getInterfaceConfig()));
    xapiClass.doc(serviceTransformer.generateServiceDoc(context, methods.get(0), context.getProductConfig()));
    xapiClass.stubs(grpcStubTransformer.generateGrpcStubs(context));
    ApiModel model = context.getApiModel();
    xapiClass.serviceHostname(productServiceConfig.getServiceHostname(context.getServiceAddress()));
    xapiClass.servicePort(productServiceConfig.getServicePort(context.getServiceAddress()));
    xapiClass.serviceTitle(model.getTitle());
    xapiClass.authScopes(model.getAuthScopes(context.getProductConfig()));
    xapiClass.hasDefaultServiceAddress(context.getInterfaceConfig().hasDefaultServiceAddress());
    xapiClass.hasDefaultServiceScopes(context.getInterfaceConfig().hasDefaultServiceScopes());
    xapiClass.pageStreamingDescriptors(pageStreamingTransformer.generateDescriptors(context));
    xapiClass.batchingDescriptors(batchingTransformer.generateDescriptors(context));
    xapiClass.longRunningDescriptors(createLongRunningDescriptors(context));
    xapiClass.grpcStreamingDescriptors(createGrpcStreamingDescriptors(context));
    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.of());
    xapiClass.interfaceKey(context.getInterface().getFullName());
    xapiClass.clientConfigPath(namer.getClientConfigPath(context.getInterfaceConfig()));
    xapiClass.grpcClientTypeName(namer.getAndSaveNicknameForGrpcClientTypeName(context.getImportTypeTable(), context.getInterfaceModel()));
    xapiClass.supportsGrpcTransport(true);
    xapiClass.apiMethods(new ArrayList<>(methods));
    String packageName = context.getProductConfig().getPackageName();
    xapiClass.apiVersion(packageName.substring(packageName.lastIndexOf('.') + 1));
    xapiClass.validDescriptorsNames(generateValidDescriptorsNames(context));
    return xapiClass;
}
Also used : OptionalArrayMethodView(com.google.api.codegen.viewmodel.OptionalArrayMethodView) DynamicLangXApiView(com.google.api.codegen.viewmodel.DynamicLangXApiView) ProtoApiModel(com.google.api.codegen.config.ProtoApiModel) ApiModel(com.google.api.codegen.config.ApiModel) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Aggregations

ApiModel (com.google.api.codegen.config.ApiModel)11 ProtoApiModel (com.google.api.codegen.config.ProtoApiModel)9 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)8 DynamicLangXApiView (com.google.api.codegen.viewmodel.DynamicLangXApiView)5 ApiMethodView (com.google.api.codegen.viewmodel.ApiMethodView)4 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)3 OptionalArrayMethodView (com.google.api.codegen.viewmodel.OptionalArrayMethodView)3 ViewModel (com.google.api.codegen.viewmodel.ViewModel)3 ImmutableList (com.google.common.collect.ImmutableList)3 GapicProductConfig (com.google.api.codegen.config.GapicProductConfig)2 InterfaceModel (com.google.api.codegen.config.InterfaceModel)2 MethodModel (com.google.api.codegen.config.MethodModel)2 Model (com.google.api.tools.framework.model.Model)2 ProtoFileView (com.google.api.codegen.ProtoFileView)1 TargetLanguage (com.google.api.codegen.common.TargetLanguage)1 FieldModel (com.google.api.codegen.config.FieldModel)1 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)1 GapicInterfaceConfig (com.google.api.codegen.config.GapicInterfaceConfig)1 GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)1 GapicMethodContext (com.google.api.codegen.config.GapicMethodContext)1