use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class CSharpGapicClientTransformer method generateApiClass.
private StaticLangApiView generateApiClass(GapicInterfaceContext context) {
SurfaceNamer namer = context.getNamer();
StaticLangApiView.Builder apiClass = StaticLangApiView.newBuilder();
List<StaticLangApiMethodView> methods = apiMethodTransformer.generateApiMethods(context);
apiClass.doc(serviceTransformer.generateServiceDoc(context, null, context.getProductConfig()));
apiClass.name(namer.getApiWrapperClassName(context.getInterfaceConfig()));
apiClass.implName(namer.getApiWrapperClassImplName(context.getInterfaceConfig()));
apiClass.grpcServiceName(namer.getGrpcContainerTypeName(context.getInterfaceModel()));
String grpcTypeName = namer.getGrpcServiceClassName(context.getInterfaceModel());
int dotIndex = grpcTypeName.indexOf('.');
apiClass.grpcTypeNameOuter(grpcTypeName.substring(0, dotIndex));
apiClass.grpcTypeNameInner(grpcTypeName.substring(dotIndex + 1, grpcTypeName.length()));
apiClass.settingsClassName(context.getNamer().getApiSettingsClassName(context.getInterfaceConfig()));
List<ApiCallableView> callables = new ArrayList<>();
for (ApiCallableView call : apiCallableTransformer.generateStaticLangApiCallables(context)) {
if (call.type() == ApiCallableImplType.SimpleApiCallable || call.type() == ApiCallableImplType.BatchingApiCallable || call.type() == ApiCallableImplType.BidiStreamingApiCallable || call.type() == ApiCallableImplType.ServerStreamingApiCallable) {
callables.add(call);
}
}
apiClass.apiCallableMembers(callables);
apiClass.pathTemplates(pathTemplateTransformer.generatePathTemplates(context));
apiClass.formatResourceFunctions(pathTemplateTransformer.generateFormatResourceFunctions(context));
apiClass.parseResourceFunctions(pathTemplateTransformer.generateParseResourceFunctions(context));
apiClass.apiMethods(methods);
List<StaticLangApiMethodView> methodsImpl = new ArrayList<>();
for (StaticLangApiMethodView method : methods) {
if (methodTypeHasImpl(method.type())) {
methodsImpl.add(method);
}
}
apiClass.apiMethodsImpl(methodsImpl);
apiClass.hasDefaultInstance(context.getInterfaceConfig().hasDefaultInstance());
apiClass.hasLongRunningOperations(context.getInterfaceConfig().hasLongRunningOperations());
apiClass.reroutedGrpcClients(csharpCommonTransformer.generateReroutedGrpcView(context));
apiClass.modifyMethods(generateModifyMethods(context));
apiClass.apiHasUnaryMethod(methods.stream().anyMatch(m -> m.grpcStreamingType() == GrpcStreamingType.NonStreaming));
apiClass.apiHasServerStreamingMethod(methods.stream().anyMatch(m -> m.grpcStreamingType() == GrpcStreamingType.ServerStreaming));
apiClass.apiHasClientStreamingMethod(methods.stream().anyMatch(m -> m.grpcStreamingType() == GrpcStreamingType.ClientStreaming));
apiClass.apiHasBidiStreamingMethod(methods.stream().anyMatch(m -> m.grpcStreamingType() == GrpcStreamingType.BidiStreaming));
return apiClass.build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method generatePagedRequestAsyncMethod.
private StaticLangApiMethodSnippetView generatePagedRequestAsyncMethod(MethodContext methodContext) {
StaticLangApiMethodView method = generateInitCode(apiMethodTransformer.generatePagedRequestObjectAsyncMethod(methodContext, csharpCommonTransformer.pagedMethodAdditionalParams(), null), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.RequestAsyncPaged);
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() + "_RequestObject").callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method generateRequestAsyncMethod.
private StaticLangApiMethodSnippetView generateRequestAsyncMethod(MethodContext methodContext) {
SurfaceNamer namer = methodContext.getNamer();
StaticLangApiMethodView method = generateInitCode(apiMethodTransformer.generateRequestObjectAsyncMethod(methodContext, null), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.RequestAsync);
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();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method generateOperationRequestMethod.
private StaticLangApiMethodSnippetView generateOperationRequestMethod(MethodContext methodContext) {
SurfaceNamer namer = methodContext.getNamer();
StaticLangApiMethodView method = generateInitCode(apiMethodTransformer.generateOperationRequestObjectMethod(methodContext, null), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.LongRunningRequest);
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();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method generatePagedRequestMethod.
private StaticLangApiMethodSnippetView generatePagedRequestMethod(MethodContext methodContext) {
StaticLangApiMethodView method = generateInitCode(apiMethodTransformer.generatePagedRequestObjectMethod(methodContext, csharpCommonTransformer.pagedMethodAdditionalParams(), null), methodContext, methodContext.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject, CallingForm.RequestPaged);
SurfaceNamer namer = methodContext.getNamer();
PageStreamingConfig pageStreaming = methodContext.getMethodConfig().getPageStreaming();
FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
String callerResponseTypeName = namer.getAndSaveCallerPagedResponseTypeName(methodContext, resourceFieldConfig);
return StaticLangApiMethodSnippetView.newBuilder().method(method).snippetMethodName(method.name() + "_RequestObject").callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).build();
}
Aggregations