use of com.google.api.codegen.transformer.GapicInterfaceContext 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();
}
use of com.google.api.codegen.transformer.GapicInterfaceContext in project toolkit by googleapis.
the class RubyPackageMetadataTransformer method generateMetadataView.
private ViewModel generateMetadataView(ApiModel model, GapicProductConfig productConfig, String template, RubyPackageMetadataNamer namer, String filePrefix) {
String noLeadingRubyDir = template.startsWith(RUBY_PREFIX) ? template.substring(RUBY_PREFIX.length()) : template;
if (!Strings.isNullOrEmpty(filePrefix)) {
noLeadingRubyDir = filePrefix + noLeadingRubyDir;
}
int extensionIndex = noLeadingRubyDir.lastIndexOf(".");
String outputPath = noLeadingRubyDir.substring(0, extensionIndex);
boolean hasSmokeTests = false;
List<InterfaceModel> interfaceModels = new LinkedList<>();
List<GapicInterfaceContext> contexts = new LinkedList<>();
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = createContext(apiInterface, productConfig);
interfaceModels.add(context.getInterfaceModel());
contexts.add(context);
if (context.getInterfaceConfig().getSmokeTestConfig() != null) {
hasSmokeTests = true;
}
}
SurfaceNamer surfaceNamer = new RubySurfaceNamer(productConfig.getPackageName());
ImportSectionView importSection = importSectionTransformer.generateRakefileAcceptanceTaskImportSection(contexts);
return metadataTransformer.generateMetadataView(namer, packageConfig, model, template, outputPath, TargetLanguage.RUBY).identifier(namer.getMetadataIdentifier()).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSection, surfaceNamer)).hasSmokeTests(hasSmokeTests).versionPath(surfaceNamer.getVersionIndexFileImportName()).versionNamespace(validVersionNamespace(interfaceModels, surfaceNamer)).credentialsClassName(surfaceNamer.getFullyQualifiedCredentialsClassName()).smokeTestProjectVariable(namer.getProjectVariable(true)).smokeTestKeyfileVariable(namer.getKeyfileVariable(true)).smokeTestJsonKeyVariable(namer.getJsonKeyVariable(true)).projectVariable(namer.getProjectVariable(false)).keyfileVariable(namer.getKeyfileVariable(false)).jsonKeyVariable(namer.getJsonKeyVariable(false)).build();
}
Aggregations