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;
}
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);
}
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();
}
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;
}
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();
}
Aggregations