use of com.google.api.codegen.transformer.GapicMethodContext 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;
}
Aggregations