Search in sources :

Example 66 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateAsyncOperationFlattenedMethod.

public StaticLangApiMethodView generateAsyncOperationFlattenedMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams, ClientMethodType type, boolean requiresOperationMethod) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getAsyncApiMethodName(context.getMethodModel(), context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(namer.getAsyncApiMethodExampleName(method));
    methodViewBuilder.callableName(namer.getCallableName(method));
    setFlattenedMethodFields(context, additionalParams, Synchronicity.Async, methodViewBuilder);
    if (requiresOperationMethod) {
        methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
    }
    TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType();
    methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType));
    methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
    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) TypeModel(com.google.api.codegen.config.TypeModel)

Example 67 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateGrpcStreamingRequestObjectMethod.

public StaticLangApiMethodView generateGrpcStreamingRequestObjectMethod(MethodContext context) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getGrpcStreamingApiMethodName(context.getMethodModel(), context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(context.getNamer().getGrpcStreamingApiMethodExampleName(context.getInterfaceConfig(), context.getMethodModel()));
    setRequestObjectMethodFields(context, namer.getCallableMethodName(method), Synchronicity.Sync, methodViewBuilder);
    setStaticLangGrpcStreamingReturnTypeName(context, methodViewBuilder);
    return methodViewBuilder.type(ClientMethodType.RequestObjectMethod).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 68 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generatePagedCallableMethod.

public StaticLangApiMethodView generatePagedCallableMethod(MethodContext context) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getPagedCallableMethodName(method));
    methodViewBuilder.exampleName(namer.getPagedCallableMethodExampleName(method));
    setListMethodFields(context, Synchronicity.Sync, methodViewBuilder);
    setCallableMethodFields(context, namer.getPagedCallableName(method), methodViewBuilder);
    return methodViewBuilder.type(ClientMethodType.PagedCallableMethod).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 69 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generatePagedRequestObjectAsyncMethod.

public StaticLangApiMethodView generatePagedRequestObjectAsyncMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getAsyncApiMethodName(context.getMethodModel(), context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(namer.getAsyncApiMethodExampleName(method));
    setListMethodFields(context, Synchronicity.Async, methodViewBuilder);
    setRequestObjectMethodFields(context, namer.getPagedCallableMethodName(method), Synchronicity.Async, additionalParams, methodViewBuilder);
    return methodViewBuilder.type(ClientMethodType.AsyncPagedRequestObjectMethod).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 70 with MethodModel

use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateAsyncOperationRequestObjectMethod.

public StaticLangApiMethodView generateAsyncOperationRequestObjectMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams, boolean requiresOperationMethod) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getAsyncApiMethodName(context.getMethodModel(), context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(namer.getAsyncApiMethodExampleName(method));
    setRequestObjectMethodFields(context, namer.getOperationCallableMethodName(method), Synchronicity.Async, additionalParams, methodViewBuilder);
    if (requiresOperationMethod) {
        // Only for protobuf-based APIs.
        methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
    }
    if (context.getMethodConfig().isLongRunningOperation()) {
        // Only for protobuf-based APIs.
        TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType();
        methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType));
        methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
    } else {
        throw new IllegalArgumentException("Discovery-based APIs do not have LongRunning operations.");
    }
    return methodViewBuilder.type(ClientMethodType.AsyncOperationRequestObjectMethod).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)

Aggregations

MethodModel (com.google.api.codegen.config.MethodModel)95 ArrayList (java.util.ArrayList)30 MethodConfig (com.google.api.codegen.config.MethodConfig)29 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)23 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)20 ImmutableList (com.google.common.collect.ImmutableList)16 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)14 Builder (com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder)14 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)12 DiscoveryMethodModel (com.google.api.codegen.config.DiscoveryMethodModel)11 FieldConfig (com.google.api.codegen.config.FieldConfig)11 ProtoMethodModel (com.google.api.codegen.config.ProtoMethodModel)9 Test (org.junit.Test)9 FieldModel (com.google.api.codegen.config.FieldModel)8 MethodContext (com.google.api.codegen.transformer.MethodContext)8 SymbolTable (com.google.api.codegen.util.SymbolTable)8 TypeModel (com.google.api.codegen.config.TypeModel)7 TestCaseView (com.google.api.codegen.viewmodel.testing.TestCaseView)7 InterfaceModel (com.google.api.codegen.config.InterfaceModel)6 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)6