Search in sources :

Example 41 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class RubyImportSectionTransformer method generateImportFilenames.

private Set<String> generateImportFilenames(GapicInterfaceContext context) {
    Set<String> filenames = new TreeSet<>();
    filenames.add(context.getInterface().getFile().getSimpleName());
    for (MethodModel method : context.getSupportedMethods()) {
        Interface targetInterface = context.asRequestMethodContext(method).getTargetInterface().getInterface();
        filenames.add(targetInterface.getFile().getSimpleName());
    }
    return filenames;
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) TreeSet(java.util.TreeSet) Interface(com.google.api.tools.framework.model.Interface)

Example 42 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class RubySurfaceNamer method getReturnDocLines.

@Override
public List<String> getReturnDocLines(TransformationContext context, MethodContext methodContext, Synchronicity synchronicity) {
    MethodModel method = methodContext.getMethodModel();
    MethodConfig methodConfig = methodContext.getMethodConfig();
    if (method.getResponseStreaming()) {
        String classInfo = method.getOutputTypeName(methodContext.getTypeTable()).getFullName();
        return ImmutableList.of("An enumerable of " + classInfo + " instances.", "");
    }
    if (methodConfig.isPageStreaming()) {
        String resourceTypeName = getTypeFormatter().getFullNameForElementType(methodConfig.getPageStreaming().getResourcesField());
        return ImmutableList.of("An enumerable of " + resourceTypeName + " instances.", "See Google::Gax::PagedEnumerable documentation for other", "operations such as per-page iteration or access to the response", "object.");
    }
    return ImmutableList.<String>of();
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel)

Example 43 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class GoGapicSurfaceTransformerTest method testGetImportsRetry.

@Test
public void testGetImportsRetry() {
    MethodModel method = new ProtoMethodModel(getMethod(context.getInterface(), "RetryMethod"));
    transformer.addXApiImports(context, Collections.singletonList(method));
    transformer.generateRetryConfigDefinitions(context, Collections.singletonList(method));
    Truth.assertThat(context.getImportTypeTable().getImports()).containsKey("time");
    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 44 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class GoGapicSurfaceTransformerTest method testGetExampleImportsBidiStream.

@Test
public void testGetExampleImportsBidiStream() {
    MethodModel method = new ProtoMethodModel(getMethod(context.getInterface(), "BidiStreamMethod"));
    transformer.addXExampleImports(context, Collections.singletonList(method));
    Truth.assertThat(context.getImportTypeTable().getImports()).containsKey("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)

Example 45 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class GoGapicSurfaceTransformerTest method testGetExampleImportsServerStream.

@Test
public void testGetExampleImportsServerStream() {
    MethodModel method = new ProtoMethodModel(getMethod(context.getInterface(), "ServerStreamMethod"));
    transformer.addXExampleImports(context, Collections.singletonList(method));
    Truth.assertThat(context.getImportTypeTable().getImports()).containsKey("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