Search in sources :

Example 46 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateCallableMethod.

public StaticLangApiMethodView generateCallableMethod(MethodContext context) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getCallableMethodName(method));
    methodViewBuilder.exampleName(context.getNamer().getCallableMethodExampleName(method));
    setCallableMethodFields(context, namer.getCallableName(method), methodViewBuilder);
    methodViewBuilder.responseTypeName(context.getMethodModel().getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()));
    return methodViewBuilder.type(ClientMethodType.CallableMethod).build();
}
Also used : Builder(com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder) MethodModel(com.google.api.codegen.config.MethodModel) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView)

Example 47 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generatePagedFlattenedAsyncMethod.

public StaticLangApiMethodView generatePagedFlattenedAsyncMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams) {
    MethodModel methodModel = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getAsyncApiMethodName(methodModel, context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(namer.getAsyncApiMethodExampleName(methodModel));
    setListMethodFields(context, Synchronicity.Async, methodViewBuilder);
    setFlattenedMethodFields(context, additionalParams, Synchronicity.Async, methodViewBuilder);
    return methodViewBuilder.type(ClientMethodType.PagedFlattenedAsyncMethod).build();
}
Also used : Builder(com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder) MethodModel(com.google.api.codegen.config.MethodModel) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView)

Example 48 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateFlattenedAsyncMethod.

public StaticLangApiMethodView generateFlattenedAsyncMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams, ClientMethodType type) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getAsyncApiMethodName(method, context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(namer.getCallableMethodExampleName(method));
    methodViewBuilder.callableName(namer.getCallableName(method));
    setFlattenedMethodFields(context, additionalParams, Synchronicity.Async, methodViewBuilder);
    setStaticLangAsyncReturnTypeName(context, methodViewBuilder);
    return methodViewBuilder.type(type).build();
}
Also used : Builder(com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder) MethodModel(com.google.api.codegen.config.MethodModel) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView)

Example 49 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateOperationFlattenedMethod.

public StaticLangApiMethodView generateOperationFlattenedMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(namer.getApiMethodExampleName(context.getInterfaceConfig(), method));
    methodViewBuilder.callableName(namer.getCallableName(method));
    setFlattenedMethodFields(context, additionalParams, Synchronicity.Sync, methodViewBuilder);
    methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
    TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType();
    methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType));
    return methodViewBuilder.type(ClientMethodType.OperationFlattenedMethod).build();
}
Also used : Builder(com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder) MethodModel(com.google.api.codegen.config.MethodModel) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) TypeModel(com.google.api.codegen.config.TypeModel)

Example 50 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class GoGapicSurfaceTransformer method generateApiMethods.

@VisibleForTesting
List<StaticLangApiMethodView> generateApiMethods(InterfaceContext context, Iterable<MethodModel> methods) {
    List<StaticLangApiMethodView> apiMethods = new ArrayList<>();
    for (MethodModel method : methods) {
        MethodConfig methodConfig = context.getMethodConfig(method);
        MethodContext methodContext = context.asRequestMethodContext(method);
        if (method.getRequestStreaming() || method.getResponseStreaming()) {
            apiMethods.add(apiMethodTransformer.generateGrpcStreamingRequestObjectMethod(methodContext));
        } else if (methodConfig.isPageStreaming()) {
            apiMethods.add(apiMethodTransformer.generatePagedRequestObjectMethod(methodContext));
        } else if (methodConfig.isLongRunningOperation()) {
            apiMethods.add(apiMethodTransformer.generateOperationRequestObjectMethod(methodContext));
        } else {
            apiMethods.add(apiMethodTransformer.generateRequestObjectMethod(methodContext));
        }
    }
    return apiMethods;
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) ArrayList(java.util.ArrayList) MethodContext(com.google.api.codegen.transformer.MethodContext) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)71 MethodModel (com.google.api.codegen.config.MethodModel)43 Builder (com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder)35 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)22 ArrayList (java.util.ArrayList)14 FieldConfig (com.google.api.codegen.config.FieldConfig)12 MethodConfig (com.google.api.codegen.config.MethodConfig)12 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)10 TypeModel (com.google.api.codegen.config.TypeModel)10 InterfaceContext (com.google.api.codegen.config.InterfaceContext)9 MethodContext (com.google.api.codegen.config.MethodContext)9 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)8 ParamWithSimpleDoc (com.google.api.codegen.transformer.ParamWithSimpleDoc)6 GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)4 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)4 ViewModel (com.google.api.codegen.viewmodel.ViewModel)4 GapicMethodContext (com.google.api.codegen.config.GapicMethodContext)3 GapicProductConfig (com.google.api.codegen.config.GapicProductConfig)3 ProtoApiModel (com.google.api.codegen.config.ProtoApiModel)3 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)3