Search in sources :

Example 81 with SurfaceNamer

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

Example 82 with SurfaceNamer

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

the class JavaSurfaceTransformer method getAndSaveNicknameForStubType.

private String getAndSaveNicknameForStubType(InterfaceContext context, String nickname) {
    SurfaceNamer namer = context.getNamer();
    ImportTypeTable typeTable = context.getImportTypeTable();
    String fullyQualifiedTypeName = namer.getStubPackageName() + "." + nickname;
    return typeTable.getAndSaveNicknameFor(fullyQualifiedTypeName);
}
Also used : ImportTypeTable(com.google.api.codegen.transformer.ImportTypeTable) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 83 with SurfaceNamer

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

the class JavaSurfaceTransformer method generateApiClass.

private StaticLangApiView generateApiClass(InterfaceContext context, GapicProductConfig productConfig) {
    SurfaceNamer namer = context.getNamer();
    InterfaceConfig interfaceConfig = context.getInterfaceConfig();
    addApiImports(context);
    List<StaticLangApiMethodView> methods = javaApiMethodTransformer.generateApiMethods(context);
    StaticLangApiView.Builder xapiClass = StaticLangApiView.newBuilder();
    ApiMethodView exampleApiMethod = getExampleApiMethod(methods);
    xapiClass.doc(serviceTransformer.generateServiceDoc(context, exampleApiMethod, productConfig));
    String name = context.getNamer().getApiWrapperClassName(context.getInterfaceConfig());
    xapiClass.releaseLevelAnnotation(namer.getReleaseAnnotation(productConfig.getReleaseLevel()));
    xapiClass.name(name);
    xapiClass.settingsClassName(namer.getApiSettingsClassName(interfaceConfig));
    xapiClass.stubInterfaceName(getAndSaveNicknameForStubType(context, namer.getApiStubInterfaceName(interfaceConfig)));
    xapiClass.stubSettingsClassName(getAndSaveNicknameForStubType(context, namer.getApiStubSettingsClassName(interfaceConfig)));
    xapiClass.apiCallableMembers(apiCallableTransformer.generateStaticLangApiCallables(context));
    xapiClass.pathTemplates(pathTemplateTransformer.generatePathTemplates(context));
    xapiClass.formatResourceFunctions(pathTemplateTransformer.generateFormatResourceFunctions(context));
    xapiClass.parseResourceFunctions(pathTemplateTransformer.generateParseResourceFunctions(context));
    xapiClass.apiMethods(methods);
    xapiClass.hasDefaultInstance(interfaceConfig.hasDefaultInstance());
    xapiClass.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
    xapiClass.pagedResponseViews(generatePagedResponseWrappers(context));
    return xapiClass.build();
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) ApiMethodView(com.google.api.codegen.viewmodel.ApiMethodView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) StaticLangApiView(com.google.api.codegen.viewmodel.StaticLangApiView)

Example 84 with SurfaceNamer

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

the class JavaSurfaceTransformer method getIterateMethods.

private List<PagedResponseIterateMethodView> getIterateMethods(MethodContext context) {
    SurfaceNamer namer = context.getNamer();
    List<PagedResponseIterateMethodView> iterateMethods = new ArrayList<>();
    FieldConfig resourceFieldConfig = context.getMethodConfig().getPageStreaming().getResourcesFieldConfig();
    if (context.getFeatureConfig().useResourceNameFormatOption(resourceFieldConfig)) {
        String resourceTypeName = namer.getAndSaveElementResourceTypeName(context.getTypeTable(), resourceFieldConfig);
        String resourceTypeIterateMethodName = namer.getPagedResponseIterateMethod(context.getFeatureConfig(), resourceFieldConfig);
        String resourceTypeGetValuesMethodName = namer.getPageGetValuesMethod(context.getFeatureConfig(), resourceFieldConfig);
        String parseMethodName = namer.getResourceTypeParseMethodName(context.getTypeTable(), resourceFieldConfig);
        PagedResponseIterateMethodView.Builder iterateMethod = PagedResponseIterateMethodView.newBuilder().overloadResourceTypeName(resourceTypeName).overloadResourceTypeParseFunctionName(parseMethodName).overloadResourceTypeIterateMethodName(resourceTypeIterateMethodName).overloadResourceTypeGetValuesMethodName(resourceTypeGetValuesMethodName).iterateMethodName(namer.getPagedResponseIterateMethod()).getValuesMethodName(namer.getPageGetValuesMethod());
        iterateMethods.add(iterateMethod.build());
    }
    return iterateMethods;
}
Also used : FieldConfig(com.google.api.codegen.config.FieldConfig) ArrayList(java.util.ArrayList) PagedResponseIterateMethodView(com.google.api.codegen.viewmodel.PagedResponseIterateMethodView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 85 with SurfaceNamer

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

the class PhpGapicSurfaceTransformer method buildDescriptorConfigViewModel.

private ViewModel buildDescriptorConfigViewModel(GapicInterfaceContext context) {
    String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
    SurfaceNamer namer = context.getNamer();
    return DescriptorConfigView.newBuilder().batchingDescriptors(ImmutableList.<BatchingDescriptorView>of()).pageStreamingDescriptors(pageStreamingTransformer.generateDescriptors(context)).longRunningDescriptors(createLongRunningDescriptors(context)).grpcStreamingDescriptors(createGrpcStreamingDescriptors(context)).interfaceKey(context.getInterface().getFullName()).templateFileName(DESCRIPTOR_CONFIG_TEMPLATE_FILENAME).outputPath(outputPath + namer.getConfigPath(context.getInterfaceConfig(), "descriptor_config")).build();
}
Also used : BatchingDescriptorView(com.google.api.codegen.viewmodel.BatchingDescriptorView) 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