Search in sources :

Example 1 with ApiCallableImplType

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());
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) PathTemplateCheckView(com.google.api.codegen.viewmodel.PathTemplateCheckView) ArrayList(java.util.ArrayList) ApiCallableImplType(com.google.api.codegen.viewmodel.ApiCallableImplType) RequestObjectParamView(com.google.api.codegen.viewmodel.RequestObjectParamView)

Example 2 with ApiCallableImplType

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();
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) DiscoveryMethodModel(com.google.api.codegen.config.DiscoveryMethodModel) ApiCallableView(com.google.api.codegen.viewmodel.ApiCallableView) ApiCallableImplType(com.google.api.codegen.viewmodel.ApiCallableImplType)

Aggregations

MethodConfig (com.google.api.codegen.config.MethodConfig)2 MethodModel (com.google.api.codegen.config.MethodModel)2 ApiCallableImplType (com.google.api.codegen.viewmodel.ApiCallableImplType)2 DiscoveryMethodModel (com.google.api.codegen.config.DiscoveryMethodModel)1 ApiCallableView (com.google.api.codegen.viewmodel.ApiCallableView)1 PathTemplateCheckView (com.google.api.codegen.viewmodel.PathTemplateCheckView)1 RequestObjectParamView (com.google.api.codegen.viewmodel.RequestObjectParamView)1 ArrayList (java.util.ArrayList)1