use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateCallableFactoryClass.
private StaticLangCallableFactoryView generateCallableFactoryClass(InterfaceContext context, GapicProductConfig productConfig) {
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
addCallableFactoryImports(context);
StaticLangCallableFactoryView.Builder callableFactory = StaticLangCallableFactoryView.newBuilder();
callableFactory.doc(serviceTransformer.generateServiceDoc(context, null, productConfig));
callableFactory.releaseLevelAnnotation(namer.getReleaseAnnotation(ReleaseLevel.BETA));
callableFactory.name(namer.getCallableFactoryClassName(interfaceConfig, productConfig.getTransportProtocol()));
return callableFactory.build();
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateRpcStubClass.
private StaticLangRpcStubView generateRpcStubClass(InterfaceContext context, GapicProductConfig productConfig) {
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
addRpcStubImports(context);
// Stub class has different default package name from method, request, and resource classes.
InterfaceContext apiMethodsContext = context.withNewTypeTable(context.getNamer().getRootPackageName());
List<StaticLangApiMethodView> methods = generateApiMethods(apiMethodsContext);
StaticLangRpcStubView.Builder stubClass = StaticLangRpcStubView.newBuilder();
stubClass.doc(serviceTransformer.generateServiceDoc(context, null, productConfig));
String name = namer.getApiRpcStubClassName(interfaceConfig.getInterfaceModel(), productConfig.getTransportProtocol());
stubClass.releaseLevelAnnotation(namer.getReleaseAnnotation(ReleaseLevel.BETA));
stubClass.name(name);
stubClass.parentName(namer.getApiStubInterfaceName(interfaceConfig));
stubClass.settingsClassName(getAndSaveNicknameForRootType(apiMethodsContext, namer.getApiSettingsClassName(interfaceConfig)));
stubClass.stubSettingsClassName(getAndSaveNicknameForStubType(apiMethodsContext, namer.getApiStubSettingsClassName(interfaceConfig)));
stubClass.callableFactoryClassName(getAndSaveNicknameForStubType(apiMethodsContext, namer.getCallableFactoryClassName(interfaceConfig, productConfig.getTransportProtocol())));
stubClass.methodDescriptors(apiCallableTransformer.generateMethodDescriptors(apiMethodsContext));
stubClass.apiCallables(apiCallableTransformer.generateStaticLangApiCallables(apiMethodsContext));
stubClass.callableMethods(filterIncludeCallableMethods(methods));
stubClass.hasDefaultInstance(interfaceConfig.hasDefaultInstance());
stubClass.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
for (TypeAlias alias : apiMethodsContext.getImportTypeTable().getTypeTable().getAllImports().values()) {
context.getImportTypeTable().getAndSaveNicknameFor(alias);
}
return stubClass.build();
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateStubSettingsClass.
private StaticLangStubSettingsView generateStubSettingsClass(InterfaceContext context, GapicProductConfig productConfig, StaticLangApiMethodView exampleApiMethod) {
addSettingsImports(context);
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
ApiModel model = context.getApiModel();
StaticLangStubSettingsView.Builder xsettingsClass = StaticLangStubSettingsView.newBuilder();
xsettingsClass.releaseLevelAnnotation(context.getNamer().getReleaseAnnotation(packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
xsettingsClass.doc(generateSettingsDoc(context, exampleApiMethod, productConfig, context.getNamer().getApiStubSettingsClassName(interfaceConfig), namer.getApiStubInterfaceName(context.getInterfaceConfig())));
String name = namer.getApiStubSettingsClassName(context.getInterfaceConfig());
xsettingsClass.name(name);
xsettingsClass.serviceAddress(model.getServiceAddress());
xsettingsClass.servicePort(model.getServicePort());
xsettingsClass.authScopes(model.getAuthScopes());
if (productConfig.getTransportProtocol().equals(TransportProtocol.HTTP)) {
xsettingsClass.useDefaultServicePortInEndpoint(false);
}
xsettingsClass.transportProtocol(productConfig.getTransportProtocol());
xsettingsClass.rpcTransportName(namer.getTransportClassName(productConfig.getTransportProtocol()));
xsettingsClass.transportNameGetter(namer.getTransporNameGetMethod(productConfig.getTransportProtocol()));
xsettingsClass.defaultTransportProviderBuilder(namer.getDefaultTransportProviderBuilder(productConfig.getTransportProtocol()));
xsettingsClass.transportProvider(namer.getTransportProvider(productConfig.getTransportProtocol()));
xsettingsClass.instantiatingChannelProvider(namer.getInstantiatingChannelProvider(productConfig.getTransportProtocol()));
List<ApiCallSettingsView> apiCallSettings = apiCallableTransformer.generateCallSettings(context);
xsettingsClass.callSettings(apiCallSettings);
xsettingsClass.pageStreamingDescriptors(pageStreamingTransformer.generateDescriptorClasses(context));
xsettingsClass.pagedListResponseFactories(pageStreamingTransformer.generateFactoryClasses(context));
xsettingsClass.batchingDescriptors(batchingTransformer.generateDescriptorClasses(context));
xsettingsClass.retryCodesDefinitions(retryDefinitionsTransformer.generateRetryCodesDefinitions(context));
xsettingsClass.retryParamsDefinitions(retryDefinitionsTransformer.generateRetryParamsDefinitions(context));
xsettingsClass.transportProtocol(productConfig.getTransportProtocol());
xsettingsClass.hasDefaultServiceAddress(interfaceConfig.hasDefaultServiceAddress());
xsettingsClass.hasDefaultServiceScopes(interfaceConfig.hasDefaultServiceScopes());
xsettingsClass.hasDefaultInstance(interfaceConfig.hasDefaultInstance());
xsettingsClass.stubInterfaceName(getAndSaveNicknameForStubType(context, namer.getApiStubInterfaceName(interfaceConfig)));
xsettingsClass.rpcStubClassName(getAndSaveNicknameForStubType(context, namer.getApiRpcStubClassName(interfaceConfig.getInterfaceModel(), productConfig.getTransportProtocol())));
return xsettingsClass.build();
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class NodeJSImportSectionTransformer method generateExternalImports.
private List<ImportFileView> generateExternalImports(InterfaceContext context) {
ImmutableList.Builder<ImportFileView> imports = ImmutableList.builder();
InterfaceModel apiInterface = context.getInterfaceModel();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
String configModule = context.getNamer().getClientConfigPath(interfaceConfig);
imports.add(createImport("gapicConfig", "./" + configModule));
imports.add(createImport("gax", "google-gax"));
imports.add(createImport("merge", "lodash.merge"));
imports.add(createImport("path", "path"));
if (context.getInterfaceConfig().hasLongRunningOperations() || context.getInterfaceConfig().hasBatchingMethods()) {
imports.add(createImport("protobuf", "protobufjs"));
}
return imports.build();
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateVersionIndexView.
private ViewModel generateVersionIndexView(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
ImmutableList.Builder<VersionIndexRequireView> requireViews = ImmutableList.builder();
Iterable<? extends InterfaceModel> interfaces = model.getInterfaces();
for (InterfaceModel apiInterface : interfaces) {
GapicInterfaceContext context = createContext(apiInterface, productConfig);
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
requireViews.add(VersionIndexRequireView.newBuilder().clientName(namer.getFullyQualifiedApiWrapperClassName(interfaceConfig)).fileName(namer.getServiceFileName(interfaceConfig)).serviceName(namer.getPackageServiceName(context.getInterfaceConfig())).doc(serviceTransformer.generateServiceDoc(context, generateApiMethods(context).get(0), productConfig)).build());
}
// append any additional types
Set<String> requireTypes = new HashSet<>();
for (TypeModel type : model.getAdditionalTypes()) {
if (type instanceof ProtoTypeRef) {
ProtoTypeRef t = (ProtoTypeRef) type;
String name = namer.getVersionIndexFileImportName() + "/" + namer.getProtoFileImportName(t.getProtoType().getMessageType().getFile().getSimpleName());
requireTypes.add(name);
}
}
return VersionIndexView.newBuilder().apiVersion(packageConfig.apiVersion()).requireViews(requireViews.build()).requireTypes(ImmutableList.copyOf(requireTypes)).templateFileName(VERSION_INDEX_TEMPLATE_FILE).packageVersion(packageConfig.generatedPackageVersionBound(TargetLanguage.RUBY).lower()).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer)).outputPath("lib" + File.separator + versionPackagePath(namer) + ".rb").modules(generateModuleViews(model, productConfig, true)).type(VersionIndexType.VersionIndex).toolkitVersion(GeneratorVersionProvider.getGeneratorVersion()).build();
}
Aggregations