use of com.google.api.codegen.viewmodel.ApiCallableView in project toolkit by googleapis.
the class ApiCallableTransformer method generatePagedApiCallable.
private ApiCallableView generatePagedApiCallable(MethodContext context) {
MethodConfig methodConfig = context.getMethodConfig();
SurfaceNamer namer = context.getNamer();
MethodModel method = context.getMethodModel();
PageStreamingConfig pageStreaming = methodConfig.getPageStreaming();
ApiCallableView.Builder pagedApiCallableBuilder = ApiCallableView.newBuilder();
pagedApiCallableBuilder.type(ApiCallableImplType.PagedApiCallable);
pagedApiCallableBuilder.interfaceTypeName(namer.getApiCallableTypeName(ServiceMethodType.UnaryMethod));
String pagedResponseTypeName = namer.getAndSavePagedResponseTypeName(context, pageStreaming.getResourcesFieldConfig());
pagedApiCallableBuilder.requestTypeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer()));
pagedApiCallableBuilder.responseTypeName(pagedResponseTypeName);
pagedApiCallableBuilder.name(namer.getPagedCallableName(method));
pagedApiCallableBuilder.methodName(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
pagedApiCallableBuilder.asyncMethodName(namer.getAsyncApiMethodName(method, VisibilityConfig.PUBLIC));
pagedApiCallableBuilder.memberName(namer.getSettingsMemberName(method));
pagedApiCallableBuilder.settingsFunctionName(namer.getSettingsFunctionName(method));
pagedApiCallableBuilder.grpcClientVarName(namer.getReroutedGrpcClientVarName(methodConfig));
setCommonApiCallableFields(context, pagedApiCallableBuilder);
return pagedApiCallableBuilder.build();
}
use of com.google.api.codegen.viewmodel.ApiCallableView in project toolkit by googleapis.
the class ApiCallableTransformer method generateStaticLangApiCallables.
public List<ApiCallableView> generateStaticLangApiCallables(InterfaceContext context) {
List<ApiCallableView> callableMembers = new ArrayList<>();
boolean excludeMixins = !context.getFeatureConfig().enableMixins();
for (MethodModel method : context.getSupportedMethods()) {
if (excludeMixins && context.getMethodConfig(method).getRerouteToGrpcInterface() != null) {
continue;
}
callableMembers.addAll(generateStaticLangApiCallables(context.asRequestMethodContext(method)));
}
return callableMembers;
}
use of com.google.api.codegen.viewmodel.ApiCallableView in project toolkit by googleapis.
the class ApiCallableTransformer method generateMainApiCallable.
private ApiCallableView generateMainApiCallable(MethodContext context) {
MethodConfig methodConfig = context.getMethodConfig();
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
ApiCallableView.Builder apiCallableBuilder = ApiCallableView.newBuilder();
apiCallableBuilder.requestTypeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer()));
apiCallableBuilder.responseTypeName(method.getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()));
apiCallableBuilder.name(namer.getCallableName(method));
apiCallableBuilder.methodName(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
apiCallableBuilder.asyncMethodName(namer.getAsyncApiMethodName(method, VisibilityConfig.PUBLIC));
apiCallableBuilder.memberName(namer.getSettingsMemberName(method));
apiCallableBuilder.settingsFunctionName(namer.getSettingsFunctionName(method));
apiCallableBuilder.grpcClientVarName(namer.getReroutedGrpcClientVarName(methodConfig));
apiCallableBuilder.headerRequestParams(headerRequestParamTransformer.generateHeaderRequestParams(context));
setCommonApiCallableFields(context, apiCallableBuilder);
ApiCallableImplType callableImplType = ApiCallableImplType.SimpleApiCallable;
if (methodConfig.isGrpcStreaming()) {
callableImplType = ApiCallableImplType.of(methodConfig.getGrpcStreamingType());
apiCallableBuilder.grpcStreamingType(methodConfig.getGrpcStreamingType());
} else if (methodConfig.isBatching()) {
callableImplType = ApiCallableImplType.BatchingApiCallable;
}
apiCallableBuilder.type(callableImplType);
apiCallableBuilder.interfaceTypeName(namer.getApiCallableTypeName(callableImplType.serviceMethodType()));
return apiCallableBuilder.build();
}
use of com.google.api.codegen.viewmodel.ApiCallableView in project toolkit by googleapis.
the class ApiCallableTransformer method generateOperationApiCallable.
private ApiCallableView generateOperationApiCallable(GapicMethodContext context) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
ApiCallableView.Builder operationApiCallableBuilder = ApiCallableView.newBuilder();
operationApiCallableBuilder.type(ApiCallableImplType.OperationApiCallable);
operationApiCallableBuilder.interfaceTypeName(namer.getApiCallableTypeName(ServiceMethodType.LongRunningMethod));
LongRunningOperationDetailView lroView = lroTransformer.generateDetailView(context);
operationApiCallableBuilder.requestTypeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer()));
operationApiCallableBuilder.responseTypeName(lroView.operationPayloadTypeName());
operationApiCallableBuilder.metadataTypeName(lroView.metadataTypeName());
operationApiCallableBuilder.name(namer.getOperationCallableName(method));
setCommonApiCallableFields(context, operationApiCallableBuilder);
operationApiCallableBuilder.settingsFunctionName(namer.getOperationSettingsFunctionName(method));
return operationApiCallableBuilder.build();
}
use of com.google.api.codegen.viewmodel.ApiCallableView 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 = 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();
}
Aggregations