Search in sources :

Example 31 with InterfaceConfig

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

the class JavaSurfaceTransformer method addStubInterfaceImports.

private void addStubInterfaceImports(InterfaceContext context) {
    ImportTypeTable typeTable = context.getImportTypeTable();
    typeTable.saveNicknameFor("com.google.api.core.BetaApi");
    typeTable.saveNicknameFor("com.google.api.gax.core.BackgroundResource");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallable");
    typeTable.saveNicknameFor("javax.annotation.Generated");
    typeTable.saveNicknameFor("java.lang.Void");
    InterfaceConfig interfaceConfig = context.getInterfaceConfig();
    if (interfaceConfig.hasLongRunningOperations()) {
        typeTable.saveNicknameFor("com.google.longrunning.Operation");
        typeTable.saveNicknameFor("com.google.longrunning.stub.OperationsStub");
    }
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) ImportTypeTable(com.google.api.codegen.transformer.ImportTypeTable)

Example 32 with InterfaceConfig

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

the class JavaSurfaceTransformer method addRpcStubImports.

private void addRpcStubImports(InterfaceContext context) {
    ImportTypeTable typeTable = context.getImportTypeTable();
    typeTable.saveNicknameFor("com.google.api.core.BetaApi");
    typeTable.saveNicknameFor("com.google.api.gax.core.BackgroundResource");
    typeTable.saveNicknameFor("com.google.api.gax.core.BackgroundResourceAggregation");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientContext");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallable");
    typeTable.saveNicknameFor("java.io.IOException");
    typeTable.saveNicknameFor("java.util.ArrayList");
    typeTable.saveNicknameFor("java.util.List");
    typeTable.saveNicknameFor("java.util.Map");
    typeTable.saveNicknameFor("java.util.concurrent.TimeUnit");
    typeTable.saveNicknameFor("javax.annotation.Generated");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.RequestParamsExtractor");
    typeTable.saveNicknameFor("com.google.common.collect.ImmutableMap");
    InterfaceConfig interfaceConfig = context.getInterfaceConfig();
    if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingConfig.GrpcStreamingType.BidiStreaming)) {
        typeTable.saveNicknameFor("com.google.api.gax.rpc.BidiStreamingCallable");
    }
    if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingConfig.GrpcStreamingType.ServerStreaming)) {
        typeTable.saveNicknameFor("com.google.api.gax.rpc.ServerStreamingCallable");
    }
    if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingConfig.GrpcStreamingType.ClientStreaming)) {
        typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientStreamingCallable");
    }
    if (interfaceConfig.hasLongRunningOperations()) {
        typeTable.saveNicknameFor("com.google.api.gax.longrunning.OperationSnapshot");
    }
    switch(context.getProductConfig().getTransportProtocol()) {
        case GRPC:
            typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcStubCallableFactory");
            typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcCallableFactory");
            typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcCallSettings");
            typeTable.saveNicknameFor("io.grpc.MethodDescriptor");
            typeTable.saveNicknameFor("io.grpc.protobuf.ProtoUtils");
            if (interfaceConfig.hasLongRunningOperations()) {
                typeTable.saveNicknameFor("com.google.longrunning.Operation");
                typeTable.saveNicknameFor("com.google.longrunning.stub.GrpcOperationsStub");
            }
            break;
        case HTTP:
            typeTable.saveNicknameFor("com.google.api.client.http.HttpMethods");
            typeTable.saveNicknameFor("com.google.api.core.InternalApi");
            typeTable.saveNicknameFor("com.google.api.pathtemplate.PathTemplate");
            if (context.getProductConfig().isDiscogapic()) {
                typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpRequestFormatter");
                typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpResponseParser");
            } else {
                typeTable.saveNicknameFor("com.google.api.gax.httpjson.FieldsExtractor");
                typeTable.saveNicknameFor("com.google.api.gax.httpjson.ProtoRestSerializer");
                typeTable.saveNicknameFor("com.google.api.gax.httpjson.ProtoMessageRequestFormatter");
                typeTable.saveNicknameFor("com.google.api.gax.httpjson.ProtoMessageResponseParser");
                typeTable.saveNicknameFor("java.util.HashMap");
            }
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMethodDescriptor");
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonCallSettings");
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonStubCallableFactory");
            typeTable.saveNicknameFor("com.google.common.collect.Sets");
            typeTable.saveNicknameFor("java.lang.Void");
            break;
    }
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) ImportTypeTable(com.google.api.codegen.transformer.ImportTypeTable)

Aggregations

InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)32 InterfaceModel (com.google.api.codegen.config.InterfaceModel)12 ImmutableList (com.google.common.collect.ImmutableList)11 GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)9 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)9 MethodModel (com.google.api.codegen.config.MethodModel)6 ApiMethodView (com.google.api.codegen.viewmodel.ApiMethodView)5 ViewModel (com.google.api.codegen.viewmodel.ViewModel)5 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)4 GapicInterfaceConfig (com.google.api.codegen.config.GapicInterfaceConfig)4 GapicMethodContext (com.google.api.codegen.config.GapicMethodContext)4 MethodConfig (com.google.api.codegen.config.MethodConfig)4 SingleResourceNameConfig (com.google.api.codegen.config.SingleResourceNameConfig)4 ArrayList (java.util.ArrayList)4 ApiModel (com.google.api.codegen.config.ApiModel)3 InterfaceContext (com.google.api.codegen.config.InterfaceContext)3 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)3 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)3 GapicMethodConfig (com.google.api.codegen.config.GapicMethodConfig)2 GapicProductConfig (com.google.api.codegen.config.GapicProductConfig)2