Search in sources :

Example 6 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.

the class CSharpGapicSnippetsTransformer method generateGrpcStreamingRequestMethod.

private StaticLangApiMethodSnippetView generateGrpcStreamingRequestMethod(MethodContext methodContext) {
    SurfaceNamer namer = methodContext.getNamer();
    StaticLangApiMethodView method = apiMethodTransformer.generateGrpcStreamingRequestObjectMethod(methodContext);
    String callerResponseTypeName = method.name() + "Stream";
    return StaticLangApiMethodSnippetView.newBuilder().method(method).snippetMethodName(method.name()).callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).build();
}
Also used : StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 7 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.

the class CSharpGapicSnippetsTransformer method generatePagedFlattenedAsyncMethod.

private StaticLangApiMethodSnippetView generatePagedFlattenedAsyncMethod(MethodContext methodContext, String suffix, boolean requiresNamedArguments) {
    StaticLangApiMethodView method = apiMethodTransformer.generatePagedFlattenedAsyncMethod(methodContext, csharpCommonTransformer.pagedMethodAdditionalParams());
    SurfaceNamer namer = methodContext.getNamer();
    PageStreamingConfig pageStreaming = methodContext.getMethodConfig().getPageStreaming();
    FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
    String callerResponseTypeName = namer.getAndSaveCallerAsyncPagedResponseTypeName(methodContext, resourceFieldConfig);
    return StaticLangApiMethodSnippetView.newBuilder().method(method).snippetMethodName(method.name() + suffix).callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).requiresNamedArguments(requiresNamedArguments).build();
}
Also used : StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) FieldConfig(com.google.api.codegen.config.FieldConfig) PageStreamingConfig(com.google.api.codegen.config.PageStreamingConfig) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 8 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.

the class CSharpGapicSnippetsTransformer method generateRequestMethod.

private StaticLangApiMethodSnippetView generateRequestMethod(MethodContext methodContext) {
    SurfaceNamer namer = methodContext.getNamer();
    StaticLangApiMethodView method = apiMethodTransformer.generateRequestObjectMethod(methodContext);
    String callerResponseTypeName = methodContext.getTypeTable().getAndSaveNicknameFor(namer.getStaticLangCallerAsyncReturnTypeName(methodContext));
    return StaticLangApiMethodSnippetView.newBuilder().method(method).snippetMethodName(method.name() + "_RequestObject").callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).build();
}
Also used : StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 9 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.

the class CSharpGapicSnippetsTransformer method transform.

@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
    List<ViewModel> surfaceDocs = new ArrayList<>();
    SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
    for (InterfaceModel apiInterface : model.getInterfaces()) {
        GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getExamplePackageName()), namer, new CSharpFeatureConfig());
        csharpCommonTransformer.addCommonImports(context);
        context.getImportTypeTable().saveNicknameFor("Google.Protobuf.Bytestring");
        context.getImportTypeTable().saveNicknameFor("System.Linq.__import__");
        SnippetsFileView snippets = generateSnippets(context);
        surfaceDocs.add(snippets);
    }
    return surfaceDocs;
}
Also used : InterfaceModel(com.google.api.codegen.config.InterfaceModel) ArrayList(java.util.ArrayList) GapicInterfaceContext(com.google.api.codegen.transformer.GapicInterfaceContext) ViewModel(com.google.api.codegen.viewmodel.ViewModel) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) SnippetsFileView(com.google.api.codegen.viewmodel.SnippetsFileView)

Example 10 with SurfaceNamer

use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.

the class CSharpGapicSnippetsTransformer method generateOperationRequestAsyncMethod.

private StaticLangApiMethodSnippetView generateOperationRequestAsyncMethod(MethodContext methodContext) {
    SurfaceNamer namer = methodContext.getNamer();
    StaticLangApiMethodView method = apiMethodTransformer.generateAsyncOperationRequestObjectMethod(methodContext, Collections.<ParamWithSimpleDoc>emptyList(), true);
    String callerResponseTypeName = method.operationMethod().clientReturnTypeName();
    return StaticLangApiMethodSnippetView.newBuilder().method(method).snippetMethodName(method.name() + "_RequestObject").callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).build();
}
Also used : StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Aggregations

SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)91 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)22 InterfaceModel (com.google.api.codegen.config.InterfaceModel)18 ImmutableList (com.google.common.collect.ImmutableList)16 ViewModel (com.google.api.codegen.viewmodel.ViewModel)14 ArrayList (java.util.ArrayList)14 GapicInterfaceContext (com.google.api.codegen.transformer.GapicInterfaceContext)13 MethodModel (com.google.api.codegen.config.MethodModel)12 FileHeaderView (com.google.api.codegen.viewmodel.FileHeaderView)10 ImportSectionView (com.google.api.codegen.viewmodel.ImportSectionView)10 MethodConfig (com.google.api.codegen.config.MethodConfig)9 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)9 ApiModel (com.google.api.codegen.config.ApiModel)8 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)8 ModelTypeTable (com.google.api.codegen.transformer.ModelTypeTable)8 SmokeTestClassView (com.google.api.codegen.viewmodel.testing.SmokeTestClassView)8 FieldConfig (com.google.api.codegen.config.FieldConfig)6 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)6 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)5 PackageMetadataNamer (com.google.api.codegen.transformer.PackageMetadataNamer)5