use of com.google.api.codegen.viewmodel.ApiCallableImplType in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method setCallableMethodFields.
private void setCallableMethodFields(MethodContext context, String callableName, Builder methodViewBuilder) {
MethodModel method = context.getMethodModel();
methodViewBuilder.doc(ApiMethodDocView.newBuilder().mainDocLines(context.getNamer().getDocLines(method, context.getMethodConfig())).paramDocs(new ArrayList<ParamDocView>()).throwsDocLines(new ArrayList<String>()).build());
methodViewBuilder.initCode(initCodeTransformer.generateInitCode(context.cloneWithEmptyTypeTable(), createInitCodeContext(context, context.getMethodConfig().getRequiredFieldConfigs(), InitCodeOutputType.SingleObject)));
methodViewBuilder.methodParams(new ArrayList<RequestObjectParamView>());
methodViewBuilder.requestObjectParams(new ArrayList<RequestObjectParamView>());
methodViewBuilder.pathTemplateChecks(new ArrayList<PathTemplateCheckView>());
String genericAwareResponseTypeFullName = context.getNamer().getGenericAwareResponseTypeName(context);
String genericAwareResponseType = context.getTypeTable().getAndSaveNicknameFor(genericAwareResponseTypeFullName);
MethodConfig methodConfig = context.getMethodConfig();
ApiCallableImplType callableImplType = ApiCallableImplType.SimpleApiCallable;
if (methodConfig.isGrpcStreaming()) {
callableImplType = ApiCallableImplType.of(methodConfig.getGrpcStreamingType());
} else if (methodConfig.isBatching()) {
callableImplType = ApiCallableImplType.BatchingApiCallable;
}
methodViewBuilder.callableMethod(CallableMethodDetailView.newBuilder().genericAwareResponseType(genericAwareResponseType).callableName(callableName).interfaceTypeName(context.getNamer().getApiCallableTypeName(callableImplType.serviceMethodType())).build());
}
use of com.google.api.codegen.viewmodel.ApiCallableImplType 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();
}
Aggregations