use of com.google.api.codegen.config.GapicMethodContext in project toolkit by googleapis.
the class PythonPackageMetadataTransformer 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(productConfig)) {
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) {
continue;
}
GapicInterfaceContext context = createContext(apiInterface, productConfig);
MethodModel method = interfaceConfig.getSmokeTestConfig().getMethod();
GapicMethodContext methodContext = context.asRequestMethodContext(method);
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method));
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(methodContext, flatteningGroup);
exampleMethods.add(createExampleApiMethodView(flattenedMethodContext));
}
return exampleMethods.build();
}
use of com.google.api.codegen.config.GapicMethodContext in project toolkit by googleapis.
the class NodeJSPackageMetadataTransformer method generateExampleMethods.
// Generates methods used as examples for the README.md file.
// Note: This is based on sample gen method calls. 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(productConfig)) {
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) {
continue;
}
GapicInterfaceContext context = createContext(apiInterface, productConfig);
MethodModel method = interfaceConfig.getSmokeTestConfig().getMethod();
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method));
GapicMethodContext defaultMethodContext = context.asRequestMethodContext(method);
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(defaultMethodContext, flatteningGroup);
exampleMethods.add(createExampleApiMethodView(flattenedMethodContext, model.hasMultipleServices()));
}
return exampleMethods.build();
}
use of com.google.api.codegen.config.GapicMethodContext in project toolkit by googleapis.
the class NodeJSSurfaceNamer method getReturnDocLines.
/**
* Return JSDoc callback comment and return type comment for the given method.
*/
@Override
public List<String> getReturnDocLines(TransformationContext context, MethodContext methodContext, Synchronicity synchronicity) {
GapicMethodContext gapicMethodContext = (GapicMethodContext) methodContext;
GapicMethodConfig methodConfig = (GapicMethodConfig) methodContext.getMethodConfig();
Method method = methodConfig.getMethod();
if (method.getRequestStreaming() && method.getResponseStreaming()) {
return bidiStreamingReturnDocLines(method);
} else if (method.getResponseStreaming()) {
return responseStreamingReturnDocLines(method);
}
List<String> callbackLines = returnCallbackDocLines(context.getImportTypeTable(), gapicMethodContext);
List<String> returnObjectLines = returnObjectDocLines(context.getImportTypeTable(), gapicMethodContext);
return ImmutableList.<String>builder().addAll(callbackLines).addAll(returnObjectLines).build();
}
use of com.google.api.codegen.config.GapicMethodContext in project toolkit by googleapis.
the class PhpGapicSurfaceTestTransformer method createSmokeTestClassViewBuilder.
private SmokeTestClassView.Builder createSmokeTestClassViewBuilder(GapicInterfaceContext context) {
addSmokeTestImports(context.getImportTypeTable());
SurfaceNamer namer = context.getNamer();
MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
GapicMethodContext defaultMethodContext = context.asRequestMethodContext(method);
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method));
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(defaultMethodContext, flatteningGroup);
SmokeTestClassView.Builder testClass = SmokeTestClassView.newBuilder();
OptionalArrayMethodView apiMethod = createSmokeTestCaseApiMethodView(flattenedMethodContext);
testClass.apiSettingsClassName(context.getNamer().getApiSettingsClassName(context.getInterfaceConfig()));
testClass.apiClassName(context.getNamer().getApiWrapperClassName(context.getInterfaceConfig()));
testClass.apiName(getApiName(context.getProductConfig().getPackageName()));
testClass.templateFileName(SMOKE_TEST_TEMPLATE_FILE);
testClass.apiMethod(apiMethod);
testClass.requireProjectId(testCaseTransformer.requireProjectIdInSmokeTest(apiMethod.initCode(), context.getNamer()));
testClass.methodName(namer.getTestCaseName(new SymbolTable(), method));
ImportSectionView importSection = importSectionTransformer.generateImportSection(context.getImportTypeTable().getImports());
SurfaceNamer testPackageNamer = namer.cloneWithPackageName(namer.getTestPackageName(SurfaceNamer.TestKind.SYSTEM));
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context.getProductConfig(), importSection, testPackageNamer);
testClass.fileHeader(fileHeader);
return testClass;
}
use of com.google.api.codegen.config.GapicMethodContext 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(productConfig)) {
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) {
continue;
}
GapicInterfaceContext context = createContext(apiInterface, productConfig);
MethodModel method = interfaceConfig.getSmokeTestConfig().getMethod();
GapicMethodContext defaultMethodContext = context.asRequestMethodContext(method);
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method));
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(defaultMethodContext, flatteningGroup);
exampleMethods.add(createExampleApiMethodView(flattenedMethodContext, model.hasMultipleServices()));
}
return exampleMethods.build();
}
Aggregations