Search in sources :

Example 1 with ParamWithSimpleDoc

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

the class CSharpGapicClientTransformer method generateApiMethods.

private List<StaticLangApiMethodView> generateApiMethods(GapicInterfaceContext context) {
    List<ParamWithSimpleDoc> pagedMethodAdditionalParams = new ImmutableList.Builder<ParamWithSimpleDoc>().addAll(csharpCommonTransformer.pagedMethodAdditionalParams()).addAll(csharpCommonTransformer.callSettingsParam()).build();
    List<StaticLangApiMethodView> apiMethods = new ArrayList<>();
    for (MethodModel method : csharpCommonTransformer.getSupportedMethods(context)) {
        MethodConfig methodConfig = context.getMethodConfig(method);
        MethodContext requestMethodContext = context.asRequestMethodContext(method);
        if (methodConfig.isGrpcStreaming()) {
            // Only for protobuf-based APIs.
            apiMethods.add(apiMethodTransformer.generateGrpcStreamingRequestObjectMethod(requestMethodContext));
        } else if (methodConfig.isLongRunningOperation()) {
            // Only for protobuf-based APIs.
            GapicMethodContext gapicMethodContext = (GapicMethodContext) requestMethodContext;
            if (methodConfig.isFlattening()) {
                for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
                    GapicMethodContext methodContext = context.asFlattenedMethodContext(requestMethodContext.getMethodModel(), flatteningGroup);
                    apiMethods.add(apiMethodTransformer.generateAsyncOperationFlattenedMethod(methodContext, csharpCommonTransformer.callSettingsParam(), ClientMethodType.AsyncOperationFlattenedCallSettingsMethod, true));
                    apiMethods.add(apiMethodTransformer.generateAsyncOperationFlattenedMethod(methodContext, csharpCommonTransformer.cancellationTokenParam(), ClientMethodType.AsyncOperationFlattenedCancellationMethod, true));
                    apiMethods.add(apiMethodTransformer.generateOperationFlattenedMethod(methodContext, csharpCommonTransformer.callSettingsParam()));
                }
            }
            apiMethods.add(apiMethodTransformer.generateAsyncOperationRequestObjectMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam(), true));
            apiMethods.add(apiMethodTransformer.generateOperationRequestObjectMethod(gapicMethodContext, csharpCommonTransformer.callSettingsParam()));
        } else if (methodConfig.isPageStreaming()) {
            if (methodConfig.isFlattening()) {
                for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
                    GapicMethodContext methodContext = context.asFlattenedMethodContext(method, flatteningGroup);
                    apiMethods.add(apiMethodTransformer.generatePagedFlattenedAsyncMethod(methodContext, pagedMethodAdditionalParams));
                    apiMethods.add(apiMethodTransformer.generatePagedFlattenedMethod(methodContext, pagedMethodAdditionalParams));
                }
            }
            apiMethods.add(apiMethodTransformer.generatePagedRequestObjectAsyncMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam()));
            apiMethods.add(apiMethodTransformer.generatePagedRequestObjectMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam()));
        } else {
            if (methodConfig.isFlattening()) {
                for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
                    GapicMethodContext methodContext = context.asFlattenedMethodContext(method, flatteningGroup);
                    apiMethods.add(apiMethodTransformer.generateFlattenedAsyncMethod(methodContext, csharpCommonTransformer.callSettingsParam(), ClientMethodType.FlattenedAsyncCallSettingsMethod));
                    apiMethods.add(apiMethodTransformer.generateFlattenedAsyncMethod(methodContext, csharpCommonTransformer.cancellationTokenParam(), ClientMethodType.FlattenedAsyncCancellationTokenMethod));
                    apiMethods.add(apiMethodTransformer.generateFlattenedMethod(methodContext, csharpCommonTransformer.callSettingsParam()));
                }
            }
            apiMethods.add(apiMethodTransformer.generateRequestObjectAsyncMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam(), ClientMethodType.AsyncRequestObjectCallSettingsMethod));
            apiMethods.add(apiMethodTransformer.generateRequestObjectAsyncMethod(requestMethodContext, csharpCommonTransformer.cancellationTokenParam(), ClientMethodType.AsyncRequestObjectCancellationMethod));
            apiMethods.add(apiMethodTransformer.generateRequestObjectMethod(requestMethodContext, csharpCommonTransformer.callSettingsParam()));
        }
    }
    return apiMethods;
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) GapicMethodContext(com.google.api.codegen.transformer.GapicMethodContext) ParamWithSimpleDoc(com.google.api.codegen.transformer.ParamWithSimpleDoc) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) ImmutableList(com.google.common.collect.ImmutableList) ArrayList(java.util.ArrayList) GapicMethodContext(com.google.api.codegen.transformer.GapicMethodContext) MethodContext(com.google.api.codegen.transformer.MethodContext) FlatteningConfig(com.google.api.codegen.config.FlatteningConfig)

Example 2 with ParamWithSimpleDoc

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

the class CSharpGapicSnippetsTransformer method generateOperationFlattenedAsyncMethod.

private StaticLangApiMethodSnippetView generateOperationFlattenedAsyncMethod(MethodContext methodContext, String suffix) {
    SurfaceNamer namer = methodContext.getNamer();
    StaticLangApiMethodView method = generateInitCode(apiMethodTransformer.generateAsyncOperationFlattenedMethod(methodContext, Collections.<ParamWithSimpleDoc>emptyList(), ClientMethodType.AsyncOperationFlattenedMethod, true, null), methodContext, methodContext.getFlatteningConfig().getFlattenedFieldConfigs().values(), InitCodeOutputType.FieldList, CallingForm.LongRunningFlattenedAsync);
    String callerResponseTypeName = method.operationMethod().clientReturnTypeName();
    return StaticLangApiMethodSnippetView.newBuilder().method(method).snippetMethodName(method.name() + suffix).callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).build();
}
Also used : StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) ParamWithSimpleDoc(com.google.api.codegen.transformer.ParamWithSimpleDoc) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 3 with ParamWithSimpleDoc

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

the class CSharpGapicSnippetsTransformer method generateOperationRequestAsyncMethod.

private StaticLangApiMethodSnippetView generateOperationRequestAsyncMethod(MethodContext methodContext) {
    SurfaceNamer namer = methodContext.getNamer();
    StaticLangApiMethodView method = generateInitCode(apiMethodTransformer.generateAsyncOperationRequestObjectMethod(methodContext, Collections.<ParamWithSimpleDoc>emptyList(), true, null), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.LongRunningRequestAsync);
    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) ParamWithSimpleDoc(com.google.api.codegen.transformer.ParamWithSimpleDoc) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 4 with ParamWithSimpleDoc

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

the class CSharpGapicSnippetsTransformer method generateOperationFlattenedMethod.

private StaticLangApiMethodSnippetView generateOperationFlattenedMethod(MethodContext methodContext, String suffix) {
    SurfaceNamer namer = methodContext.getNamer();
    StaticLangApiMethodView method = generateInitCode(apiMethodTransformer.generateOperationFlattenedMethod(methodContext, Collections.<ParamWithSimpleDoc>emptyList(), null), methodContext, methodContext.getFlatteningConfig().getFlattenedFieldConfigs().values(), InitCodeOutputType.FieldList, CallingForm.LongRunningFlattened);
    String callerResponseTypeName = method.operationMethod().clientReturnTypeName();
    return StaticLangApiMethodSnippetView.newBuilder().method(method).snippetMethodName(method.name() + suffix).callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).build();
}
Also used : StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) ParamWithSimpleDoc(com.google.api.codegen.transformer.ParamWithSimpleDoc) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 5 with ParamWithSimpleDoc

use of com.google.api.codegen.transformer.ParamWithSimpleDoc 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, null).toBuilder();
        FieldConfig resourceFieldConfig = methodContext.getMethodConfig().getPageStreaming().getResourcesFieldConfig();
        String callerResponseTypeName = namer.getAndSaveCallerPagedResponseTypeName(methodContext, resourceFieldConfig);
        apiMethodView.responseTypeName(callerResponseTypeName);
    } else if (methodContext.isLongRunningMethodContext()) {
        ArrayList<ParamWithSimpleDoc> emptyParams = new ArrayList<ParamWithSimpleDoc>();
        apiMethodView = apiMethodTransformer.generateOperationFlattenedMethod(methodContext, emptyParams, null).toBuilder();
    } else {
        apiMethodView = apiMethodTransformer.generateFlattenedMethod(methodContext, null).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)

Aggregations

ParamWithSimpleDoc (com.google.api.codegen.transformer.ParamWithSimpleDoc)6 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)6 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)4 MethodConfig (com.google.api.codegen.config.MethodConfig)3 ArrayList (java.util.ArrayList)3 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)2 MethodModel (com.google.api.codegen.config.MethodModel)2 ImmutableList (com.google.common.collect.ImmutableList)2 FieldConfig (com.google.api.codegen.config.FieldConfig)1 GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)1 GapicMethodContext (com.google.api.codegen.config.GapicMethodContext)1 MethodContext (com.google.api.codegen.config.MethodContext)1 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)1 InitCodeTransformer (com.google.api.codegen.transformer.InitCodeTransformer)1 MethodContext (com.google.api.codegen.transformer.MethodContext)1 InitCodeView (com.google.api.codegen.viewmodel.InitCodeView)1