Search in sources :

Example 26 with InterfaceConfig

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

the class NodeJSGapicSurfaceTestTransformer method createSmokeTestViews.

private List<ViewModel> createSmokeTestViews(ApiModel model, GapicProductConfig productConfig) {
    ImmutableList.Builder<ViewModel> views = ImmutableList.builder();
    for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
        InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
        if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) {
            continue;
        }
        GapicInterfaceContext context = createContext(apiInterface, productConfig);
        views.add(createSmokeTestClassView(context, model.hasMultipleServices()));
    }
    return views.build();
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) InterfaceModel(com.google.api.codegen.config.InterfaceModel) ImmutableList(com.google.common.collect.ImmutableList) GapicInterfaceContext(com.google.api.codegen.config.GapicInterfaceContext) ViewModel(com.google.api.codegen.viewmodel.ViewModel)

Example 27 with InterfaceConfig

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

the class RubyGapicSurfaceDocTransformer method generateTocModuleView.

private TocModuleView generateTocModuleView(ApiModel model, ProtoFile file, ProductConfig productConfig, SurfaceNamer namer, String moduleName) {
    RubyPackageMetadataTransformer metadataTransformer = new RubyPackageMetadataTransformer(packageConfig);
    RubyPackageMetadataNamer packageNamer = new RubyPackageMetadataNamer(productConfig.getPackageName());
    String packageFilePath = file.getFullName().replace(".", File.separator);
    ImmutableList.Builder<TocContentView> tocContents = ImmutableList.builder();
    for (Interface apiInterface : file.getReachableInterfaces()) {
        String description = RubyUtil.getSentence(namer.getDocLines(GapicParser.getDocString(apiInterface)));
        InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(new ProtoInterfaceModel(apiInterface));
        tocContents.add(metadataTransformer.generateTocContent(description, packageNamer, packageFilePath, namer.getApiWrapperClassName(interfaceConfig)));
    }
    tocContents.add(metadataTransformer.generateTocContent("Data types for " + productConfig.getPackageName(), packageNamer, packageFilePath, "Data Types"));
    return TocModuleView.newBuilder().moduleName(moduleName).fullName(model.getTitle()).contents(tocContents.build()).build();
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) ProtoInterfaceModel(com.google.api.codegen.config.ProtoInterfaceModel) ImmutableList(com.google.common.collect.ImmutableList) TocContentView(com.google.api.codegen.viewmodel.metadata.TocContentView) Interface(com.google.api.tools.framework.model.Interface)

Example 28 with InterfaceConfig

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

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

the class JavaSurfaceTransformer method generateApiClass.

private StaticLangApiView generateApiClass(InterfaceContext context, GapicProductConfig productConfig) {
    SurfaceNamer namer = context.getNamer();
    InterfaceConfig interfaceConfig = context.getInterfaceConfig();
    addApiImports(context);
    List<StaticLangApiMethodView> methods = javaApiMethodTransformer.generateApiMethods(context);
    StaticLangApiView.Builder xapiClass = StaticLangApiView.newBuilder();
    ApiMethodView exampleApiMethod = getExampleApiMethod(methods);
    xapiClass.doc(serviceTransformer.generateServiceDoc(context, exampleApiMethod, productConfig));
    String name = context.getNamer().getApiWrapperClassName(context.getInterfaceConfig());
    xapiClass.releaseLevelAnnotation(namer.getReleaseAnnotation(productConfig.getReleaseLevel()));
    xapiClass.name(name);
    xapiClass.settingsClassName(namer.getApiSettingsClassName(interfaceConfig));
    xapiClass.stubInterfaceName(getAndSaveNicknameForStubType(context, namer.getApiStubInterfaceName(interfaceConfig)));
    xapiClass.stubSettingsClassName(getAndSaveNicknameForStubType(context, namer.getApiStubSettingsClassName(interfaceConfig)));
    xapiClass.apiCallableMembers(apiCallableTransformer.generateStaticLangApiCallables(context));
    xapiClass.pathTemplates(pathTemplateTransformer.generatePathTemplates(context));
    xapiClass.formatResourceFunctions(pathTemplateTransformer.generateFormatResourceFunctions(context));
    xapiClass.parseResourceFunctions(pathTemplateTransformer.generateParseResourceFunctions(context));
    xapiClass.apiMethods(methods);
    xapiClass.hasDefaultInstance(interfaceConfig.hasDefaultInstance());
    xapiClass.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
    xapiClass.pagedResponseViews(generatePagedResponseWrappers(context));
    return xapiClass.build();
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) ApiMethodView(com.google.api.codegen.viewmodel.ApiMethodView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) StaticLangApiView(com.google.api.codegen.viewmodel.StaticLangApiView)

Example 30 with InterfaceConfig

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

the class JavaSurfaceTransformer method generateStubInterface.

private StaticLangStubInterfaceView generateStubInterface(InterfaceContext context, GapicProductConfig productConfig) {
    InterfaceConfig interfaceConfig = context.getInterfaceConfig();
    addStubInterfaceImports(context);
    // Stub class has different default package name from methods classes.
    InterfaceContext apiMethodsContext = context.withNewTypeTable(context.getNamer().getRootPackageName());
    List<StaticLangApiMethodView> methods = javaApiMethodTransformer.generateApiMethods(apiMethodsContext);
    for (TypeAlias alias : apiMethodsContext.getImportTypeTable().getTypeTable().getAllImports().values()) {
        context.getImportTypeTable().getAndSaveNicknameFor(alias);
    }
    StaticLangStubInterfaceView.Builder stubInterface = StaticLangStubInterfaceView.newBuilder();
    stubInterface.doc(serviceTransformer.generateServiceDoc(context, null, productConfig));
    String name = context.getNamer().getApiStubInterfaceName(context.getInterfaceConfig());
    stubInterface.releaseLevelAnnotation(context.getNamer().getReleaseAnnotation(productConfig.getReleaseLevel()));
    stubInterface.name(name);
    stubInterface.callableMethods(filterIncludeCallableMethods(methods));
    stubInterface.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
    return stubInterface.build();
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) StaticLangStubInterfaceView(com.google.api.codegen.viewmodel.StaticLangStubInterfaceView) TypeAlias(com.google.api.codegen.util.TypeAlias) InterfaceContext(com.google.api.codegen.config.InterfaceContext)

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