Search in sources :

Example 1 with ModelTypeTable

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

the class CSharpCommonTransformer method addCommonImports.

public void addCommonImports(GapicInterfaceContext context) {
    ModelTypeTable typeTable = context.getImportTypeTable();
    // Common imports, only one class per required namespace is needed.
    typeTable.saveNicknameFor("Google.Api.Gax.GaxPreconditions");
    typeTable.saveNicknameFor("Google.Api.Gax.Grpc.ServiceSettingsBase");
    typeTable.saveNicknameFor("Google.Protobuf.WellKnownTypes.SomeSortOfWellKnownType");
    typeTable.saveNicknameFor("Grpc.Core.StatusCode");
    typeTable.saveNicknameFor("System.Collections.ObjectModel.ReadOnlyCollection");
    typeTable.saveNicknameFor("System.Threading.Tasks.Task");
    typeTable.saveNicknameFor("System.Threading.Thread");
    typeTable.saveNicknameFor("System.NotImplementedException");
    typeTable.saveNicknameFor("System.Collections.IEnumerable");
    typeTable.saveNicknameFor("System.Collections.Generic.IEnumerable");
}
Also used : ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable)

Example 2 with ModelTypeTable

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

the class CSharpGapicUnitTestTransformer method transform.

@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
    List<ViewModel> surfaceDocs = new ArrayList<>();
    SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
    for (InterfaceModel apiInterface : model.getInterfaces()) {
        GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getPackageName()), namer, new CSharpFeatureConfig());
        csharpCommonTransformer.addCommonImports(context);
        ModelTypeTable typeTable = context.getImportTypeTable();
        typeTable.saveNicknameFor("Xunit.FactAttribute");
        typeTable.saveNicknameFor("Moq.Mock");
        if (context.getLongRunningMethods().iterator().hasNext()) {
            typeTable.saveNicknameFor("Google.LongRunning.Operations");
        }
        surfaceDocs.add(generateUnitTest(context));
        surfaceDocs.add(generateUnitTestCsproj(context));
    }
    return surfaceDocs;
}
Also used : InterfaceModel(com.google.api.codegen.config.InterfaceModel) ArrayList(java.util.ArrayList) ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable) GapicInterfaceContext(com.google.api.codegen.transformer.GapicInterfaceContext) ViewModel(com.google.api.codegen.viewmodel.ViewModel) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 3 with ModelTypeTable

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

the class NodeJSGapicSurfaceDocTransformer method generateDoc.

private ViewModel generateDoc(ProtoFile file, GapicProductConfig productConfig) {
    ModelTypeTable typeTable = new ModelTypeTable(new JSTypeTable(productConfig.getPackageName()), new NodeJSModelTypeNameConverter(productConfig.getPackageName()));
    // Use file path for package name to get file-specific package instead of package for the API.
    SurfaceNamer namer = new NodeJSSurfaceNamer(productConfig.getPackageName(), NodeJSUtils.isGcloud(productConfig));
    JSCommentReformatter commentReformatter = new JSCommentReformatter();
    GrpcDocView.Builder doc = GrpcDocView.newBuilder();
    doc.templateFileName(DOC_TEMPLATE_FILENAME);
    doc.outputPath(getOutputPath(namer, file));
    doc.fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer));
    doc.elementDocs(grpcElementDocTransformer.generateElementDocs(typeTable, namer, file));
    return doc.build();
}
Also used : JSTypeTable(com.google.api.codegen.util.js.JSTypeTable) JSCommentReformatter(com.google.api.codegen.util.js.JSCommentReformatter) ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable) GrpcDocView(com.google.api.codegen.viewmodel.GrpcDocView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 4 with ModelTypeTable

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

the class PhpGapicSurfaceTestTransformer method createContext.

private GapicInterfaceContext createContext(InterfaceModel apiInterface, GapicProductConfig productConfig, PhpSurfaceNamer.TestKind testKind) {
    PhpSurfaceNamer surfacePackageNamer = new PhpSurfaceNamer(productConfig.getPackageName());
    String testPackageName = surfacePackageNamer.getTestPackageName(testKind);
    ModelTypeTable typeTable = new ModelTypeTable(new PhpTypeTable(testPackageName), new PhpModelTypeNameConverter(testPackageName));
    return GapicInterfaceContext.create(apiInterface, productConfig, typeTable, surfacePackageNamer, featureConfig);
}
Also used : ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable) PhpTypeTable(com.google.api.codegen.util.php.PhpTypeTable)

Example 5 with ModelTypeTable

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

the class PhpGapicSurfaceTransformer method addApiImports.

private void addApiImports(GapicInterfaceContext context) {
    ModelTypeTable typeTable = context.getImportTypeTable();
    GapicInterfaceConfig interfaceConfig = context.getInterfaceConfig();
    typeTable.saveNicknameFor("\\Google\\ApiCore\\ApiException");
    typeTable.saveNicknameFor("\\Google\\ApiCore\\Call");
    typeTable.saveNicknameFor("\\Google\\ApiCore\\GapicClientTrait");
    typeTable.saveNicknameFor("\\Google\\ApiCore\\PathTemplate");
    typeTable.saveNicknameFor("\\Google\\ApiCore\\RequestParamsHeaderDescriptor");
    typeTable.saveNicknameFor("\\Google\\ApiCore\\RetrySettings");
    typeTable.saveNicknameFor("\\Google\\ApiCore\\Transport\\TransportInterface");
    typeTable.saveNicknameFor("\\Google\\ApiCore\\ValidationException");
    typeTable.saveNicknameFor("\\Google\\Auth\\CredentialsLoader");
    typeTable.saveNicknameFor("\\Grpc\\Channel");
    typeTable.saveNicknameFor("\\Grpc\\ChannelCredentials");
    if (interfaceConfig.hasLongRunningOperations()) {
        typeTable.saveNicknameFor("\\Google\\ApiCore\\LongRunning\\OperationsClient");
        typeTable.saveNicknameFor("\\Google\\ApiCore\\OperationResponse");
    }
}
Also used : ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable) GapicInterfaceConfig(com.google.api.codegen.config.GapicInterfaceConfig)

Aggregations

ModelTypeTable (com.google.api.codegen.transformer.ModelTypeTable)15 InterfaceModel (com.google.api.codegen.config.InterfaceModel)8 GapicInterfaceContext (com.google.api.codegen.transformer.GapicInterfaceContext)8 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)7 ViewModel (com.google.api.codegen.viewmodel.ViewModel)6 ImmutableList (com.google.common.collect.ImmutableList)4 ArrayList (java.util.ArrayList)4 GrpcDocView (com.google.api.codegen.viewmodel.GrpcDocView)3 ImportSectionView (com.google.api.codegen.viewmodel.ImportSectionView)3 ClientTestClassView (com.google.api.codegen.viewmodel.testing.ClientTestClassView)3 ProtoApiModel (com.google.api.codegen.config.ProtoApiModel)2 FeatureConfig (com.google.api.codegen.transformer.FeatureConfig)2 PhpTypeTable (com.google.api.codegen.util.php.PhpTypeTable)2 RubyTypeTable (com.google.api.codegen.util.ruby.RubyTypeTable)2 MockServiceImplView (com.google.api.codegen.viewmodel.testing.MockServiceImplView)2 MockServiceUsageView (com.google.api.codegen.viewmodel.testing.MockServiceUsageView)2 GapicInterfaceConfig (com.google.api.codegen.config.GapicInterfaceConfig)1 GapicMethodConfig (com.google.api.codegen.config.GapicMethodConfig)1 DefaultFeatureConfig (com.google.api.codegen.transformer.DefaultFeatureConfig)1 TypeAlias (com.google.api.codegen.util.TypeAlias)1