Search in sources :

Example 21 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");
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpRequestFormatter");
            typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpResponseParser");
            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 22 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 = 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(packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
    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, productConfig, packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
    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 23 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)

Aggregations

InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)23 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)7 ImmutableList (com.google.common.collect.ImmutableList)5 InterfaceModel (com.google.api.codegen.config.InterfaceModel)4 SingleResourceNameConfig (com.google.api.codegen.config.SingleResourceNameConfig)4 GapicInterfaceConfig (com.google.api.codegen.config.GapicInterfaceConfig)3 MethodConfig (com.google.api.codegen.config.MethodConfig)3 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)3 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)3 Interface (com.google.api.tools.framework.model.Interface)3 ArrayList (java.util.ArrayList)3 ApiModel (com.google.api.codegen.config.ApiModel)2 GapicMethodConfig (com.google.api.codegen.config.GapicMethodConfig)2 ProtoInterfaceModel (com.google.api.codegen.config.ProtoInterfaceModel)2 InterfaceContext (com.google.api.codegen.transformer.InterfaceContext)2 TypeAlias (com.google.api.codegen.util.TypeAlias)2 StaticLangSettingsView (com.google.api.codegen.viewmodel.StaticLangSettingsView)2 HashSet (java.util.HashSet)2 InterfaceView (com.google.api.codegen.InterfaceView)1 ServiceMessages (com.google.api.codegen.ServiceMessages)1