Search in sources :

Example 6 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class CSharpGapicSmokeTestTransformer method createSmokeTestCaseApiMethodView.

private StaticLangApiMethodView createSmokeTestCaseApiMethodView(GapicInterfaceContext context, MethodContext methodContext) {
    SurfaceNamer namer = context.getNamer();
    MethodConfig methodConfig = methodContext.getMethodConfig();
    StaticLangApiMethodView.Builder apiMethodView;
    if (methodConfig.isPageStreaming()) {
        apiMethodView = apiMethodTransformer.generatePagedFlattenedMethod(methodContext).toBuilder();
        FieldConfig resourceFieldConfig = methodContext.getMethodConfig().getPageStreaming().getResourcesFieldConfig();
        String callerResponseTypeName = namer.getAndSaveCallerPagedResponseTypeName(methodContext, resourceFieldConfig);
        apiMethodView.responseTypeName(callerResponseTypeName);
    } else if (methodConfig.isLongRunningOperation()) {
        ArrayList<ParamWithSimpleDoc> emptyParams = new ArrayList<ParamWithSimpleDoc>();
        apiMethodView = apiMethodTransformer.generateOperationFlattenedMethod(methodContext, emptyParams).toBuilder();
    } else {
        apiMethodView = apiMethodTransformer.generateFlattenedMethod(methodContext).toBuilder();
    }
    InitCodeTransformer initCodeTransformer = new InitCodeTransformer();
    InitCodeView initCodeView = initCodeTransformer.generateInitCode(methodContext, testCaseTransformer.createSmokeTestInitContext(methodContext));
    apiMethodView.initCode(initCodeView);
    return apiMethodView.build();
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) ParamWithSimpleDoc(com.google.api.codegen.transformer.ParamWithSimpleDoc) FieldConfig(com.google.api.codegen.config.FieldConfig) ArrayList(java.util.ArrayList) InitCodeTransformer(com.google.api.codegen.transformer.InitCodeTransformer) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) InitCodeView(com.google.api.codegen.viewmodel.InitCodeView)

Example 7 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView 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 8 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView 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 9 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView 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 10 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView 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

StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)45 MethodModel (com.google.api.codegen.config.MethodModel)23 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)22 Builder (com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder)17 FieldConfig (com.google.api.codegen.config.FieldConfig)6 MethodConfig (com.google.api.codegen.config.MethodConfig)6 MethodContext (com.google.api.codegen.transformer.MethodContext)6 ArrayList (java.util.ArrayList)6 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)5 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)5 TypeModel (com.google.api.codegen.config.TypeModel)5 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)4 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)4 InterfaceContext (com.google.api.codegen.transformer.InterfaceContext)3 ParamWithSimpleDoc (com.google.api.codegen.transformer.ParamWithSimpleDoc)3 StaticLangApiView (com.google.api.codegen.viewmodel.StaticLangApiView)3 ApiModel (com.google.api.codegen.config.ApiModel)2 GapicProductConfig (com.google.api.codegen.config.GapicProductConfig)2 InterfaceModel (com.google.api.codegen.config.InterfaceModel)2 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)2