Search in sources :

Example 91 with MethodModel

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());
    }
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel)

Example 92 with MethodModel

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();
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) GapicMethodContext(com.google.api.codegen.transformer.GapicMethodContext) InterfaceModel(com.google.api.codegen.config.InterfaceModel) ApiMethodView(com.google.api.codegen.viewmodel.ApiMethodView) ImmutableList(com.google.common.collect.ImmutableList) GapicInterfaceContext(com.google.api.codegen.transformer.GapicInterfaceContext) FlatteningConfig(com.google.api.codegen.config.FlatteningConfig)

Example 93 with MethodModel

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;
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel)

Example 94 with MethodModel

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");
}
Also used : ProtoMethodModel(com.google.api.codegen.config.ProtoMethodModel) MethodModel(com.google.api.codegen.config.MethodModel) ProtoMethodModel(com.google.api.codegen.config.ProtoMethodModel) Test(org.junit.Test)

Example 95 with MethodModel

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");
}
Also used : ProtoMethodModel(com.google.api.codegen.config.ProtoMethodModel) MethodModel(com.google.api.codegen.config.MethodModel) ProtoMethodModel(com.google.api.codegen.config.ProtoMethodModel) Test(org.junit.Test)

Aggregations

MethodModel (com.google.api.codegen.config.MethodModel)95 ArrayList (java.util.ArrayList)30 MethodConfig (com.google.api.codegen.config.MethodConfig)29 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)23 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)20 ImmutableList (com.google.common.collect.ImmutableList)16 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)14 Builder (com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder)14 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)12 DiscoveryMethodModel (com.google.api.codegen.config.DiscoveryMethodModel)11 FieldConfig (com.google.api.codegen.config.FieldConfig)11 ProtoMethodModel (com.google.api.codegen.config.ProtoMethodModel)9 Test (org.junit.Test)9 FieldModel (com.google.api.codegen.config.FieldModel)8 MethodContext (com.google.api.codegen.transformer.MethodContext)8 SymbolTable (com.google.api.codegen.util.SymbolTable)8 TypeModel (com.google.api.codegen.config.TypeModel)7 TestCaseView (com.google.api.codegen.viewmodel.testing.TestCaseView)7 InterfaceModel (com.google.api.codegen.config.InterfaceModel)6 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)6