Search in sources :

Example 26 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView 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 27 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView 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 28 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView 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 29 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView 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 30 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView 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

StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)45 MethodModel (com.google.api.codegen.config.MethodModel)23 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)22 Builder (com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder)17 FieldConfig (com.google.api.codegen.config.FieldConfig)6 MethodConfig (com.google.api.codegen.config.MethodConfig)6 MethodContext (com.google.api.codegen.transformer.MethodContext)6 ArrayList (java.util.ArrayList)6 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)5 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)5 TypeModel (com.google.api.codegen.config.TypeModel)5 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)4 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)4 InterfaceContext (com.google.api.codegen.transformer.InterfaceContext)3 ParamWithSimpleDoc (com.google.api.codegen.transformer.ParamWithSimpleDoc)3 StaticLangApiView (com.google.api.codegen.viewmodel.StaticLangApiView)3 ApiModel (com.google.api.codegen.config.ApiModel)2 GapicProductConfig (com.google.api.codegen.config.GapicProductConfig)2 InterfaceModel (com.google.api.codegen.config.InterfaceModel)2 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)2