use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class NodeJSGapicSurfaceTransformer method createGrpcStreamingDescriptors.
private List<GrpcStreamingDetailView> createGrpcStreamingDescriptors(GapicInterfaceContext context) {
List<GrpcStreamingDetailView> result = new ArrayList<>();
for (MethodModel method : context.getGrpcStreamingMethods()) {
GrpcStreamingConfig grpcStreamingConfig = context.asDynamicMethodContext(method).getMethodConfig().getGrpcStreaming();
String resourcesFieldGetFunction = null;
if (grpcStreamingConfig.hasResourceField()) {
resourcesFieldGetFunction = context.getNamer().getFieldGetFunctionName(grpcStreamingConfig.getResourcesField());
}
result.add(GrpcStreamingDetailView.newBuilder().methodName(context.getNamer().getApiMethodName(method, VisibilityConfig.PUBLIC)).grpcStreamingType(grpcStreamingConfig.getType()).grpcResourcesField(resourcesFieldGetFunction).streamTypeName(context.getNamer().getStreamTypeName(grpcStreamingConfig.getType())).build());
}
return result;
}
use of com.google.api.codegen.config.MethodModel 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()) {
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.config.MethodModel 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();
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig());
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, 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(PhpPackageMetadataNamer.getApiNameFromPackageName(context.getNamer().getPackageName()).toLowerUnderscore());
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.MethodModel in project toolkit by googleapis.
the class PhpGapicSurfaceTransformer method createGrpcStreamingDescriptors.
private List<GrpcStreamingDetailView> createGrpcStreamingDescriptors(GapicInterfaceContext context) {
List<GrpcStreamingDetailView> result = new ArrayList<>();
for (MethodModel method : context.getGrpcStreamingMethods()) {
GrpcStreamingConfig grpcStreamingConfig = context.asDynamicMethodContext(method).getMethodConfig().getGrpcStreaming();
String resourcesFieldGetFunction = null;
if (grpcStreamingConfig.hasResourceField()) {
resourcesFieldGetFunction = context.getNamer().getFieldGetFunctionName(grpcStreamingConfig.getResourcesField());
}
result.add(GrpcStreamingDetailView.newBuilder().methodName(context.getNamer().getApiMethodName(method, VisibilityConfig.PUBLIC)).transportMethodName(context.getNamer().getGrpcMethodName(method)).grpcStreamingType(grpcStreamingConfig.getType()).grpcResourcesField(resourcesFieldGetFunction).build());
}
return result;
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class PhpGapicSurfaceTransformer method generateRestInterfaceConfigViews.
private List<RestInterfaceConfigView> generateRestInterfaceConfigViews(GapicInterfaceContext context) {
List<RestInterfaceConfigView> configViews = new ArrayList<>();
GapicInterfaceConfig interfaceConfig = context.getInterfaceConfig();
SurfaceNamer namer = context.getNamer();
Map<String, List<HttpRule>> interfaces = new TreeMap<>();
Service serviceConfig = serviceModel.getServiceConfig();
for (MethodModel methodModel : context.getSupportedMethods()) {
GapicMethodContext methodContext = context.asDynamicMethodContext(methodModel);
MethodConfig methodConfig = methodContext.getMethodConfig();
Method method = methodContext.getMethod();
// REST does not support streaming methods
if (methodConfig.isGrpcStreaming()) {
continue;
}
String interfaceName = methodConfig.getRerouteToGrpcInterface() == null ? context.getInterface().getFullName() : methodConfig.getRerouteToGrpcInterface();
HttpRule httpRule = getHttpRule(method.getOptionFields()).toBuilder().setSelector(String.format("%s.%s", interfaceName, method.getSimpleName())).build();
addHttpRuleToMap(interfaces, interfaceName, httpRule);
}
for (HttpRule httpRule : serviceConfig.getHttp().getRulesList()) {
String selector = httpRule.getSelector();
String interfaceName = selector.substring(0, selector.lastIndexOf("."));
addHttpRuleToMap(interfaces, interfaceName, httpRule);
}
for (Map.Entry<String, List<HttpRule>> entry : interfaces.entrySet()) {
configViews.add(generateRestInterfaceConfigView(entry.getKey(), entry.getValue(), namer));
}
return configViews;
}
Aggregations