Search in sources :

Example 26 with ImportTypeTable

use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.

the class JavaSurfaceTransformer method addSettingsImports.

private void addSettingsImports(InterfaceContext context) {
    ImportTypeTable typeTable = context.getImportTypeTable();
    typeTable.saveNicknameFor("com.google.api.core.ApiFunction");
    typeTable.saveNicknameFor("com.google.api.core.BetaApi");
    typeTable.saveNicknameFor("com.google.api.gax.core.CredentialsProvider");
    typeTable.saveNicknameFor("com.google.api.gax.core.ExecutorProvider");
    typeTable.saveNicknameFor("com.google.api.gax.core.GaxProperties");
    typeTable.saveNicknameFor("com.google.api.gax.core.GoogleCredentialsProvider");
    typeTable.saveNicknameFor("com.google.api.gax.core.InstantiatingExecutorProvider");
    typeTable.saveNicknameFor("com.google.api.gax.retrying.RetrySettings");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.ApiClientHeaderProvider");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientContext");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientSettings");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.StubSettings");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.HeaderProvider");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.StatusCode");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.TransportChannelProvider");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallSettings");
    typeTable.saveNicknameFor("com.google.auth.Credentials");
    typeTable.saveNicknameFor("com.google.common.collect.ImmutableList");
    typeTable.saveNicknameFor("com.google.common.collect.ImmutableMap");
    typeTable.saveNicknameFor("com.google.common.collect.ImmutableSet");
    typeTable.saveNicknameFor("com.google.common.collect.Lists");
    typeTable.saveNicknameFor("com.google.common.collect.Sets");
    typeTable.saveNicknameFor("java.io.IOException");
    typeTable.saveNicknameFor("java.util.List");
    typeTable.saveNicknameFor("java.util.concurrent.ScheduledExecutorService");
    typeTable.saveNicknameFor("javax.annotation.Generated");
    typeTable.saveNicknameFor("org.threeten.bp.Duration");
    InterfaceConfig interfaceConfig = context.getInterfaceConfig();
    if (interfaceConfig.hasPageStreamingMethods()) {
        typeTable.saveNicknameFor("com.google.api.core.ApiFuture");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.ApiCallContext");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.PageContext");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.PagedCallSettings");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.PagedListDescriptor");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.PagedListResponseFactory");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallable");
    }
    if (interfaceConfig.hasBatchingMethods()) {
        typeTable.saveNicknameFor("com.google.api.gax.batching.BatchingSettings");
        typeTable.saveNicknameFor("com.google.api.gax.batching.FlowController");
        typeTable.saveNicknameFor("com.google.api.gax.batching.FlowController.LimitExceededBehavior");
        typeTable.saveNicknameFor("com.google.api.gax.batching.FlowControlSettings");
        typeTable.saveNicknameFor("com.google.api.gax.batching.PartitionKey");
        typeTable.saveNicknameFor("com.google.api.gax.batching.RequestBuilder");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.BatchedRequestIssuer");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.BatchingCallSettings");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.BatchingDescriptor");
        typeTable.saveNicknameFor("java.util.ArrayList");
        typeTable.saveNicknameFor("java.util.Collection");
    }
    if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingType.ServerStreaming)) {
        typeTable.saveNicknameFor("com.google.api.gax.rpc.ServerStreamingCallSettings");
    }
    if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingType.ClientStreaming) || interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingType.BidiStreaming)) {
        typeTable.saveNicknameFor("com.google.api.gax.rpc.StreamingCallSettings");
    }
    if (interfaceConfig.hasLongRunningOperations()) {
        typeTable.saveNicknameFor("com.google.api.gax.longrunning.OperationSnapshot");
        typeTable.saveNicknameFor("com.google.api.gax.rpc.OperationCallSettings");
        typeTable.saveNicknameFor("com.google.longrunning.Operation");
        typeTable.saveNicknameFor("com.google.api.gax.longrunning.OperationTimedPollAlgorithm");
    }
    switch(context.getProductConfig().getTransportProtocol()) {
        case GRPC:
            typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcTransportChannel");
            typeTable.saveNicknameFor("com.google.api.gax.grpc.InstantiatingGrpcChannelProvider");
            if (interfaceConfig.hasLongRunningOperations()) {
                typeTable.saveNicknameFor("com.google.api.gax.grpc.ProtoOperationTransformers");
            }
            typeTable.saveNicknameFor("com.google.api.gax.grpc.GaxGrpcProperties");
            break;
        case HTTP:
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonTransportChannel");
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider");
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.GaxHttpJsonProperties");
            typeTable.saveNicknameFor("java.lang.Void");
            break;
    }
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) ImportTypeTable(com.google.api.codegen.transformer.ImportTypeTable)

Example 27 with ImportTypeTable

use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.

the class JavaSurfaceTransformer method getAndSaveNicknameForStubType.

private String getAndSaveNicknameForStubType(InterfaceContext context, String nickname) {
    SurfaceNamer namer = context.getNamer();
    ImportTypeTable typeTable = context.getImportTypeTable();
    String fullyQualifiedTypeName = namer.getStubPackageName() + "." + nickname;
    return typeTable.getAndSaveNicknameFor(fullyQualifiedTypeName);
}
Also used : ImportTypeTable(com.google.api.codegen.transformer.ImportTypeTable) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 28 with ImportTypeTable

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

use of com.google.api.codegen.transformer.ImportTypeTable 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)

Example 30 with ImportTypeTable

use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.

the class JavaSurfaceTransformer method addCallableFactoryImports.

private void addCallableFactoryImports(InterfaceContext context) {
    ImportTypeTable typeTable = context.getImportTypeTable();
    typeTable.saveNicknameFor("com.google.api.gax.rpc.OperationCallable");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.OperationCallSettings");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.BidiStreamingCallable");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.StreamingCallSettings");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.ServerStreamingCallSettings");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.ServerStreamingCallable");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientStreamingCallable");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientContext");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallable");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallSettings");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.PagedCallSettings");
    typeTable.saveNicknameFor("com.google.api.gax.rpc.BatchingCallSettings");
    switch(context.getProductConfig().getTransportProtocol()) {
        case GRPC:
            typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcCallableFactory");
            typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcStubCallableFactory");
            typeTable.saveNicknameFor("com.google.longrunning.Operation");
            typeTable.saveNicknameFor("com.google.longrunning.stub.OperationsStub");
            break;
        case HTTP:
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonCallableFactory");
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonStubCallableFactory");
            typeTable.saveNicknameFor("javax.annotation.Nullable");
            break;
    }
}
Also used : ImportTypeTable(com.google.api.codegen.transformer.ImportTypeTable)

Aggregations

ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)33 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)8 MethodModel (com.google.api.codegen.config.MethodModel)5 ArrayList (java.util.ArrayList)5 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)3 InterfaceContext (com.google.api.codegen.config.InterfaceContext)3 InterfaceModel (com.google.api.codegen.config.InterfaceModel)3 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)3 ViewModel (com.google.api.codegen.viewmodel.ViewModel)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 MethodConfig (com.google.api.codegen.config.MethodConfig)2 TypeModel (com.google.api.codegen.config.TypeModel)2 OutputTransformer (com.google.api.codegen.transformer.OutputTransformer)2 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)1 InitCodeNode (com.google.api.codegen.metacode.InitCodeNode)1 InterfaceContext (com.google.api.codegen.transformer.InterfaceContext)1 MethodContext (com.google.api.codegen.transformer.MethodContext)1 TypeName (com.google.api.codegen.util.TypeName)1 CallingForm (com.google.api.codegen.viewmodel.CallingForm)1 PackageInfoView (com.google.api.codegen.viewmodel.PackageInfoView)1