use of com.google.api.codegen.viewmodel.ApiMethodView 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 = 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(packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
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, productConfig, packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
return xapiClass.build();
}
use of com.google.api.codegen.viewmodel.ApiMethodView in project toolkit by googleapis.
the class NodeJSGapicSurfaceTransformer method generateApiClass.
private ViewModel generateApiClass(GapicInterfaceContext context, boolean hasMultipleServices) {
SurfaceNamer namer = context.getNamer();
String subPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
List<ApiMethodView> methods = generateApiMethods(context, hasMultipleServices);
DynamicLangXApiView.Builder xapiClass = DynamicLangXApiView.newBuilder();
xapiClass.templateFileName(XAPI_TEMPLATE_FILENAME);
xapiClass.outputPath(subPath + "/" + namer.getServiceFileName(context.getInterfaceConfig()));
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.serviceAddress(model.getServiceAddress());
xapiClass.servicePort(model.getServicePort());
xapiClass.serviceTitle(model.getTitle());
xapiClass.authScopes(model.getAuthScopes());
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.<PathTemplateGetterFunctionView>of());
xapiClass.methodKeys(ImmutableList.<String>of());
xapiClass.interfaceKey(context.getInterface().getFullName());
xapiClass.clientConfigPath(namer.getClientConfigPath(context.getInterfaceConfig()));
xapiClass.grpcClientTypeName(namer.getAndSaveNicknameForGrpcClientTypeName(context.getImportTypeTable(), context.getInterfaceModel()));
xapiClass.apiMethods(methods);
xapiClass.toolkitVersion(GeneratorVersionProvider.getGeneratorVersion());
xapiClass.packageVersion(packageConfig.generatedPackageVersionBound(TargetLanguage.NODEJS).lower());
xapiClass.apiVersion(packageConfig.apiVersion());
xapiClass.packageHasMultipleServices(hasMultipleServices);
xapiClass.packageServiceName(namer.getPackageServiceName(context.getInterfaceConfig()));
xapiClass.validDescriptorsNames(generateValidDescriptorsNames(context));
xapiClass.constructorName(namer.getApiWrapperClassConstructorName(context.getInterfaceConfig()));
xapiClass.isGcloud(NodeJSUtils.isGcloud(context.getProductConfig()));
return xapiClass.build();
}
use of com.google.api.codegen.viewmodel.ApiMethodView in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateApiClass.
private ViewModel generateApiClass(GapicInterfaceContext context, String packageName) {
SurfaceNamer namer = context.getNamer();
PackageMetadataNamer metadataNamer = new RubyPackageMetadataNamer(packageName);
String subPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
String name = namer.getApiWrapperClassName(context.getInterfaceConfig());
List<ApiMethodView> methods = generateApiMethods(context);
DynamicLangXApiView.Builder xapiClass = DynamicLangXApiView.newBuilder();
xapiClass.templateFileName(XAPI_TEMPLATE_FILENAME);
xapiClass.outputPath(namer.getSourceFilePath(subPath, name));
xapiClass.fileHeader(fileHeaderTransformer.generateFileHeader(context));
xapiClass.protoFilename(context.getInterface().getFile().getSimpleName());
xapiClass.name(name);
xapiClass.doc(serviceTransformer.generateServiceDoc(context, methods.get(0), context.getProductConfig()));
xapiClass.stubs(grpcStubTransformer.generateGrpcStubs(context));
ApiModel model = context.getApiModel();
xapiClass.serviceAddress(model.getServiceAddress());
xapiClass.servicePort(model.getServicePort());
xapiClass.serviceTitle(model.getTitle());
xapiClass.authScopes(model.getAuthScopes());
xapiClass.hasDefaultServiceAddress(context.getInterfaceConfig().hasDefaultServiceAddress());
xapiClass.hasDefaultServiceScopes(context.getInterfaceConfig().hasDefaultServiceScopes());
xapiClass.pageStreamingDescriptors(pageStreamingTransformer.generateDescriptors(context));
xapiClass.batchingDescriptors(batchingTransformer.generateDescriptors(context));
xapiClass.longRunningDescriptors(ImmutableList.<LongRunningOperationDetailView>of());
xapiClass.grpcStreamingDescriptors(ImmutableList.<GrpcStreamingDetailView>of());
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.<PathTemplateGetterFunctionView>of());
xapiClass.methodKeys(ImmutableList.<String>of());
xapiClass.interfaceKey(context.getInterface().getFullName());
xapiClass.clientConfigPath(namer.getClientConfigPath(context.getInterfaceConfig()));
xapiClass.grpcClientTypeName(namer.getAndSaveNicknameForGrpcClientTypeName(context.getImportTypeTable(), context.getInterfaceModel()));
xapiClass.apiMethods(methods);
xapiClass.toolkitVersion(GeneratorVersionProvider.getGeneratorVersion());
xapiClass.gapicPackageName(RubyUtil.isLongrunning(context.getProductConfig().getPackageName()) ? "google-gax" : metadataNamer.getMetadataIdentifier());
xapiClass.fullyQualifiedCredentialsClassName(namer.getFullyQualifiedCredentialsClassName());
xapiClass.defaultCredentialsInitializerCall(RubyUtil.isLongrunning(context.getProductConfig().getPackageName()) ? "default(scopes: scopes)" : "default");
return xapiClass.build();
}
use of com.google.api.codegen.viewmodel.ApiMethodView in project toolkit by googleapis.
the class RubyPackageMetadataTransformer method generateExampleMethods.
// Generates methods used as examples for the README.md file.
// This currently generates a list of methods that have smoke test configuration. In the future,
// the example methods may be configured separately.
private List<ApiMethodView> generateExampleMethods(ApiModel model, GapicProductConfig productConfig) {
ImmutableList.Builder<ApiMethodView> exampleMethods = ImmutableList.builder();
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = createContext(apiInterface, productConfig);
if (context.getInterfaceConfig().getSmokeTestConfig() != null) {
MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig());
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
exampleMethods.add(createExampleApiMethodView(flattenedMethodContext, model.hasMultipleServices()));
}
}
return exampleMethods.build();
}
Aggregations