use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class PhpSurfaceNamer method getDynamicLangReturnTypeName.
@Override
public String getDynamicLangReturnTypeName(MethodContext methodContext) {
MethodModel method = methodContext.getMethodModel();
MethodConfig methodConfig = methodContext.getMethodConfig();
if (method.isOutputTypeEmpty()) {
return "";
}
if (methodConfig.isPageStreaming()) {
return "\\Google\\ApiCore\\PagedListResponse";
}
if (methodConfig.isLongRunningOperation()) {
return "\\Google\\ApiCore\\OperationResponse";
}
switch(methodConfig.getGrpcStreamingType()) {
case NonStreaming:
return method.getOutputTypeName(methodContext.getTypeTable()).getFullName();
case BidiStreaming:
return "\\Google\\ApiCore\\BidiStream";
case ClientStreaming:
return "\\Google\\ApiCore\\ClientStream";
case ServerStreaming:
return "\\Google\\ApiCore\\ServerStream";
default:
return getNotImplementedString("SurfaceNamer.getDynamicReturnTypeName grpcStreamingType:" + methodConfig.getGrpcStreamingType().toString());
}
}
use of com.google.api.codegen.config.MethodModel 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.config.MethodModel in project toolkit by googleapis.
the class RubySurfaceNamer method getDynamicLangReturnTypeName.
@Override
public String getDynamicLangReturnTypeName(MethodContext methodContext) {
MethodModel method = methodContext.getMethodModel();
MethodConfig methodConfig = methodContext.getMethodConfig();
if (method.isOutputTypeEmpty()) {
return "";
}
String classInfo = method.getOutputTypeName(methodContext.getTypeTable()).getFullName();
if (method.getResponseStreaming()) {
return "Enumerable<" + classInfo + ">";
}
if (methodConfig.isPageStreaming()) {
String resourceTypeName = getModelTypeFormatter().getFullNameForElementType(methodConfig.getPageStreaming().getResourcesField());
return "Google::Gax::PagedEnumerable<" + resourceTypeName + ">";
}
if (methodConfig.isLongRunningOperation()) {
return "Google::Gax::Operation";
}
return classInfo;
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class GoGapicSurfaceTransformerTest method testGetImportsPageStream.
@Test
public void testGetImportsPageStream() {
MethodModel method = new ProtoMethodModel(getMethod(context.getInterface(), "PageStreamMethod"));
transformer.addXApiImports(context, Collections.singletonList(method));
transformer.generateRetryConfigDefinitions(context, Collections.singletonList(method));
Truth.assertThat(context.getImportTypeTable().getImports()).containsKey("math");
Truth.assertThat(context.getImportTypeTable().getImports()).doesNotContainKey("cloud.google.com/go/longrunning");
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class GoGapicSurfaceTransformerTest method testGetExampleImportsClientStream.
@Test
public void testGetExampleImportsClientStream() {
MethodModel method = new ProtoMethodModel(getMethod(context.getInterface(), "ClientStreamMethod"));
transformer.addXExampleImports(context, Collections.singletonList(method));
Truth.assertThat(context.getImportTypeTable().getImports()).doesNotContainKey("io");
}
Aggregations