use of com.google.api.codegen.config.GapicProductConfig in project toolkit by googleapis.
the class CSharpGapicClientTransformer method generateCsProjView.
private PackageInfoView generateCsProjView(GapicInterfaceContext context) {
Model model = context.getModel();
GapicProductConfig productConfig = context.getProductConfig();
PackageInfoView.Builder view = PackageInfoView.newBuilder();
view.templateFileName(CSPROJ_TEMPLATE_FILENAME);
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), productConfig);
view.outputPath(outputPath + File.separator + productConfig.getPackageName() + ".csproj");
view.fileHeader(fileHeaderTransformer.generateFileHeader(context));
view.serviceTitle(model.getServiceConfig().getTitle());
view.serviceDescription(model.getServiceConfig().getDocumentation().getSummary().trim());
view.domainLayerLocation(productConfig.getDomainLayerLocation());
// Unused in C#
view.authScopes(new ArrayList<String>());
view.releaseLevel(productConfig.getReleaseLevel());
String versionSuffix;
switch(productConfig.getReleaseLevel()) {
case ALPHA:
versionSuffix = "-alpha01";
break;
case BETA:
versionSuffix = "-beta01";
break;
default:
versionSuffix = "";
break;
}
view.version("1.0.0" + versionSuffix);
String tags = "";
for (String tag : Splitter.on('.').split(productConfig.getPackageName())) {
if (tag.matches("[vV][\\d.]+")) {
break;
}
tags += ";" + tag;
}
view.tags(tags.isEmpty() ? "" : tags.substring(1));
view.packageMetadata(generatePackageMetadataView(context));
view.serviceDocs(new ArrayList<ServiceDocView>());
return view.build();
}
use of com.google.api.codegen.config.GapicProductConfig in project toolkit by googleapis.
the class CSharpGapicUnitTestTransformer method generateUnitTestCsproj.
private ClientTestFileView generateUnitTestCsproj(GapicInterfaceContext context) {
ClientTestFileView.Builder builder = generateUnitTestBuilder(context);
GapicProductConfig productConfig = context.getProductConfig();
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), productConfig);
builder.outputPath(outputPath + File.separator + productConfig.getPackageName() + ".Tests.csproj");
builder.templateFileName(UNITTEST_CSPROJ_TEMPLATE_FILENAME);
return builder.build();
}
use of com.google.api.codegen.config.GapicProductConfig in project toolkit by googleapis.
the class GoGapicSurfaceTransformer method generate.
private StaticLangClientFileView generate(GapicInterfaceContext context) {
StaticLangClientFileView.Builder view = StaticLangClientFileView.newBuilder();
SurfaceNamer namer = context.getNamer();
ApiModel model = context.getApiModel();
ProtoInterfaceModel apiInterface = context.getInterfaceModel();
GapicProductConfig productConfig = context.getProductConfig();
GapicInterfaceConfig interfaceConfig = context.getInterfaceConfig();
view.templateFileName(API_TEMPLATE_FILENAME);
view.serviceDoc(serviceTransformer.generateServiceDoc(context, null, productConfig));
view.domainLayerLocation(productConfig.getDomainLayerLocation());
view.clientTypeName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
view.clientConstructorName(namer.getApiWrapperClassConstructorName(interfaceConfig));
view.defaultClientOptionFunctionName(namer.getDefaultApiSettingsFunctionName(interfaceConfig));
view.defaultCallOptionFunctionName(namer.getDefaultCallSettingsFunctionName(interfaceConfig));
view.callOptionsTypeName(namer.getCallSettingsTypeName(interfaceConfig));
view.serviceOriginalName(model.getTitle());
view.servicePhraseName(namer.getServicePhraseName(interfaceConfig));
String outputPath = pathMapper.getOutputPath(apiInterface.getFullName(), productConfig);
String fileName = namer.getServiceFileName(context.getInterfaceConfig());
view.outputPath(outputPath + File.separator + fileName);
List<RetryConfigDefinitionView> retryDef = generateRetryConfigDefinitions(context, context.getSupportedMethods());
view.retryPairDefinitions(retryDef);
view.callSettings(apiCallableTransformer.generateCallSettings(context));
List<StaticLangApiMethodView> apiMethods = generateApiMethods(context, context.getSupportedMethods());
view.apiMethods(apiMethods);
// "net/url" is needed for `url.QueryEscape`.
if (apiMethods.stream().anyMatch(m -> !m.headerRequestParams().isEmpty())) {
context.getImportTypeTable().saveNicknameFor("fmt;;;");
context.getImportTypeTable().saveNicknameFor("net/url;;;");
}
// In Go, multiple methods share the same iterator type, one iterator type per resource type.
// We have to dedupe the iterators.
Map<String, PageStreamingDescriptorClassView> iterators = new TreeMap<>();
for (PageStreamingDescriptorClassView desc : pageStreamingTransformer.generateDescriptorClasses(context)) {
iterators.put(desc.typeName(), desc);
}
view.pageStreamingDescriptorClasses(new ArrayList<>(iterators.values()));
// Same with long running operations.
Map<String, LongRunningOperationDetailView> lros = new TreeMap<>();
for (StaticLangApiMethodView apiMethod : apiMethods) {
LongRunningOperationDetailView lro = apiMethod.operationMethod();
if (lro != null) {
lros.put(lro.clientReturnTypeName(), lro);
}
}
view.lroDetailViews(new ArrayList<>(lros.values()));
view.serviceHostname(productServiceConfig.getServiceHostname(context.getServiceAddress()));
view.servicePort(productServiceConfig.getServicePort(context.getServiceAddress()));
view.stubs(grpcStubTransformer.generateGrpcStubs(context));
addXApiImports(context, context.getSupportedMethods());
view.fileHeader(fileHeaderTransformer.generateFileHeader(context));
return view.build();
}
use of com.google.api.codegen.config.GapicProductConfig in project toolkit by googleapis.
the class CSharpGapicClientPackageTransformer method generateCsProjView.
private PackageInfoView generateCsProjView(GapicInterfaceContext context) {
Model model = context.getModel();
GapicProductConfig productConfig = context.getProductConfig();
PackageInfoView.Builder view = PackageInfoView.newBuilder();
view.templateFileName(CSPROJ_TEMPLATE_FILENAME);
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), productConfig);
view.outputPath(outputPath + File.separator + productConfig.getPackageName() + ".csproj");
view.fileHeader(fileHeaderTransformer.generateFileHeader(context));
view.serviceTitle(model.getServiceConfig().getTitle());
view.serviceDescription(model.getServiceConfig().getDocumentation().getSummary().trim());
view.domainLayerLocation(productConfig.getDomainLayerLocation());
// Unused in C#
view.authScopes(new ArrayList<>());
view.releaseLevel(productConfig.getReleaseLevel());
String versionSuffix;
switch(productConfig.getReleaseLevel()) {
case ALPHA:
versionSuffix = "-alpha01";
break;
case BETA:
versionSuffix = "-beta01";
break;
default:
versionSuffix = "";
break;
}
view.version("1.0.0" + versionSuffix);
String tags = "";
for (String tag : Splitter.on('.').split(productConfig.getPackageName())) {
if (tag.matches("[vV][\\d.]+")) {
break;
}
tags += ";" + tag;
}
view.tags(tags.isEmpty() ? "" : tags.substring(1));
view.packageMetadata(generatePackageMetadataView(context));
view.serviceDocs(new ArrayList<>());
return view.build();
}
use of com.google.api.codegen.config.GapicProductConfig in project toolkit by googleapis.
the class StaticLangGapicSamplesTransformer method generateSamplesFromGapicConfigs.
private List<ViewModel> generateSamplesFromGapicConfigs(List<InterfaceContext> interfaceContexts, GapicProductConfig productConfig, SurfaceNamer namer) {
List<MethodSampleView> allSamples = interfaceContexts.stream().flatMap(iface -> apiMethodTransformer.generateApiMethods(iface).stream()).flatMap(method -> method.samples().stream()).collect(ImmutableList.toImmutableList());
SampleFileRegistry registry = new SampleFileRegistry(namer, allSamples);
List<ViewModel> sampleFileViews = new ArrayList<>();
for (InterfaceContext context : interfaceContexts) {
List<StaticLangApiMethodView> methods = apiMethodTransformer.generateApiMethods(context);
for (StaticLangApiMethodView method : methods) {
for (MethodSampleView sample : method.samples()) {
sampleFileViews.add(newSampleFileView(productConfig, context, registry.getSampleClassName(sample, method.name()), registry.getSampleFileName(sample, method.name()), method, sample));
}
}
}
return sampleFileViews;
}
Aggregations