use of com.google.api.codegen.config.ApiModel in project toolkit by googleapis.
the class PythonGapicSurfaceTransformer method generateApiClass.
private ViewModel generateApiClass(GapicInterfaceContext context) {
SurfaceNamer namer = context.getNamer();
String subPath = pathMapper.getOutputPath(context.getInterfaceModel().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.protoFilename(context.getInterface().getFile().getSimpleName());
xapiClass.servicePhraseName(namer.getServicePhraseName(context.getInterfaceConfig()));
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(ImmutableList.<BatchingDescriptorView>of());
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.clientConfigName(namer.getClientConfigName(context.getInterfaceConfig()));
xapiClass.grpcClientTypeName(namer.getAndSaveNicknameForGrpcClientTypeName(context.getImportTypeTable(), context.getInterfaceModel()));
xapiClass.apiMethods(methods);
xapiClass.toolkitVersion(GeneratorVersionProvider.getGeneratorVersion());
xapiClass.gapicPackageName(namer.getGapicPackageName(packageConfig.packageName(TargetLanguage.PYTHON)));
xapiClass.fileHeader(fileHeaderTransformer.generateFileHeader(context));
return xapiClass.build();
}
use of com.google.api.codegen.config.ApiModel in project toolkit by googleapis.
the class PythonGapicSurfaceTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel apiModel, GapicProductConfig productConfig) {
// TODO(andrealin): Remove the ProtoApiModel cast.
Model model = ((ProtoApiModel) apiModel).getProtoModel();
ImmutableList.Builder<ViewModel> views = ImmutableList.builder();
views.addAll(generateServiceSurfaces(model, productConfig));
views.addAll(generateVersionedDirectoryViews(model, productConfig));
views.addAll(generateTopLevelViews(model, productConfig));
return views.build();
}
use of com.google.api.codegen.config.ApiModel in project toolkit by googleapis.
the class CSharpGapicClientTransformer method generateSettingsDoc.
public SettingsDocView generateSettingsDoc(GapicInterfaceContext context) {
SurfaceNamer namer = context.getNamer();
SettingsDocView.Builder settingsDoc = SettingsDocView.newBuilder();
ApiModel model = context.getApiModel();
settingsDoc.serviceAddress(model.getServiceAddress());
settingsDoc.servicePort(model.getServicePort());
// Unused in C#
settingsDoc.exampleApiMethodName("");
// Unused in C#
settingsDoc.exampleApiMethodSettingsGetter("");
settingsDoc.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
settingsDoc.settingsVarName(namer.getApiSettingsVariableName(context.getInterfaceConfig()));
settingsDoc.settingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
settingsDoc.settingsBuilderVarName(namer.getApiSettingsBuilderVarName(context.getInterfaceConfig()));
settingsDoc.hasDefaultInstance(context.getInterfaceConfig().hasDefaultInstance());
return settingsDoc.build();
}
use of com.google.api.codegen.config.ApiModel 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.config.ApiModel 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();
}
Aggregations