Search in sources :

Example 11 with InterfaceModel

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

the class NodeJSImportSectionTransformer method generateExternalImports.

private List<ImportFileView> generateExternalImports(InterfaceContext context) {
    ImmutableList.Builder<ImportFileView> imports = ImmutableList.builder();
    InterfaceModel apiInterface = context.getInterfaceModel();
    InterfaceConfig interfaceConfig = context.getInterfaceConfig();
    String configModule = context.getNamer().getClientConfigPath(interfaceConfig);
    imports.add(createImport("gapicConfig", "./" + configModule));
    imports.add(createImport("gax", "google-gax"));
    imports.add(createImport("merge", "lodash.merge"));
    imports.add(createImport("path", "path"));
    if (context.getInterfaceConfig().hasLongRunningOperations() || context.getInterfaceConfig().hasBatchingMethods()) {
        imports.add(createImport("protobuf", "protobufjs"));
    }
    return imports.build();
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) ImportFileView(com.google.api.codegen.viewmodel.ImportFileView) InterfaceModel(com.google.api.codegen.config.InterfaceModel) ImmutableList(com.google.common.collect.ImmutableList)

Example 12 with InterfaceModel

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

the class NodeJSPackageMetadataTransformer method generateExampleMethods.

// Generates methods used as examples for the README.md file.
// Note: This is based on sample gen method calls. In the future, the example
// methods may be configured separately.
private List<ApiMethodView> generateExampleMethods(ApiModel model, GapicProductConfig productConfig) {
    ImmutableList.Builder<ApiMethodView> exampleMethods = ImmutableList.builder();
    for (InterfaceModel apiInterface : model.getInterfaces()) {
        GapicInterfaceContext context = createContext(apiInterface, productConfig);
        if (context.getInterfaceConfig().getSmokeTestConfig() != null) {
            MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
            FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig());
            GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
            exampleMethods.add(createExampleApiMethodView(flattenedMethodContext, model.hasMultipleServices()));
        }
    }
    return exampleMethods.build();
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) GapicMethodContext(com.google.api.codegen.transformer.GapicMethodContext) InterfaceModel(com.google.api.codegen.config.InterfaceModel) ApiMethodView(com.google.api.codegen.viewmodel.ApiMethodView) ImmutableList(com.google.common.collect.ImmutableList) GapicInterfaceContext(com.google.api.codegen.transformer.GapicInterfaceContext) FlatteningConfig(com.google.api.codegen.config.FlatteningConfig)

Example 13 with InterfaceModel

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

the class PhpGapicSurfaceTransformer method transform.

@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
    List<ViewModel> surfaceDocs = new ArrayList<>();
    for (InterfaceModel apiInterface : model.getInterfaces()) {
        ModelTypeTable modelTypeTable = new ModelTypeTable(new PhpTypeTable(productConfig.getPackageName()), new PhpModelTypeNameConverter(productConfig.getPackageName()));
        GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, modelTypeTable, new PhpSurfaceNamer(productConfig.getPackageName()), new PhpFeatureConfig());
        surfaceDocs.addAll(transform(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) PhpTypeTable(com.google.api.codegen.util.php.PhpTypeTable)

Example 14 with InterfaceModel

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

the class PythonGapicSurfaceTestTransformer method createSmokeTestViews.

private List<ViewModel> createSmokeTestViews(ApiModel model, GapicProductConfig productConfig) {
    ImmutableList.Builder<ViewModel> models = ImmutableList.builder();
    SurfaceNamer surfacePackageNamer = new PythonSurfaceNamer(productConfig.getPackageName());
    SurfaceNamer testPackageNamer = new PythonSurfaceNamer(surfacePackageNamer.getTestPackageName());
    for (InterfaceModel apiInterface : model.getInterfaces()) {
        ModelTypeTable typeTable = createTypeTable(surfacePackageNamer.getTestPackageName());
        GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, typeTable, surfacePackageNamer, featureConfig);
        if (context.getInterfaceConfig().getSmokeTestConfig() != null) {
            models.add(createSmokeTestClassView(context, testPackageNamer));
        }
    }
    return models.build();
}
Also used : InterfaceModel(com.google.api.codegen.config.InterfaceModel) ImmutableList(com.google.common.collect.ImmutableList) 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 15 with InterfaceModel

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

the class PythonGapicSurfaceTestTransformer method createUnitTestViews.

private List<ViewModel> createUnitTestViews(ApiModel model, GapicProductConfig productConfig) {
    ImmutableList.Builder<ViewModel> models = ImmutableList.builder();
    SurfaceNamer surfacePackageNamer = new PythonSurfaceNamer(productConfig.getPackageName());
    SurfaceNamer testPackageNamer = new PythonSurfaceNamer(surfacePackageNamer.getTestPackageName());
    for (InterfaceModel apiInterface : model.getInterfaces()) {
        ModelTypeTable typeTable = createTypeTable(surfacePackageNamer.getTestPackageName());
        GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, typeTable, surfacePackageNamer, featureConfig);
        String testClassName = surfacePackageNamer.getUnitTestClassName(context.getInterfaceConfig());
        ClientTestClassView testClassView = ClientTestClassView.newBuilder().apiSettingsClassName(surfacePackageNamer.getNotImplementedString("PythonGapicSurfaceTestTransformer.createUnitTestViews - apiSettingsClassName")).apiClassName(surfacePackageNamer.getApiWrapperClassName(context.getInterfaceConfig())).apiVariableName(surfacePackageNamer.getApiWrapperModuleName()).name(testClassName).apiName(surfacePackageNamer.publicClassName(Name.upperCamelKeepUpperAcronyms(context.getInterfaceModel().getSimpleName()))).testCases(createTestCaseViews(context)).apiHasLongRunningMethods(context.getInterfaceConfig().hasLongRunningOperations()).apiHasUnaryUnaryMethod(hasUnaryUnary(context.getInterfaceConfig())).apiHasUnaryStreamingMethod(hasUnaryStreaming(context.getInterfaceConfig())).apiHasStreamingUnaryMethod(hasStreamingUnary(context.getInterfaceConfig())).apiHasStreamingStreamingMethod(hasStreamingStreaming(context.getInterfaceConfig())).missingDefaultServiceAddress(!context.getInterfaceConfig().hasDefaultServiceAddress()).missingDefaultServiceScopes(!context.getInterfaceConfig().hasDefaultServiceScopes()).mockServices(ImmutableList.<MockServiceUsageView>of()).build();
        String version = packageConfig.apiVersion();
        String filename = surfacePackageNamer.classFileNameBase(Name.upperCamel(testClassName).join(version)) + ".py";
        String outputPath = Joiner.on(File.separator).join("tests", "unit", "gapic", version, filename);
        ImportSectionView importSection = importSectionTransformer.generateTestImportSection(context);
        models.add(ClientTestFileView.newBuilder().templateFileName(TEST_TEMPLATE_FILE).outputPath(outputPath).testClass(testClassView).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSection, testPackageNamer)).build());
    }
    return models.build();
}
Also used : MockServiceUsageView(com.google.api.codegen.viewmodel.testing.MockServiceUsageView) InterfaceModel(com.google.api.codegen.config.InterfaceModel) ImmutableList(com.google.common.collect.ImmutableList) ModelTypeTable(com.google.api.codegen.transformer.ModelTypeTable) ClientTestClassView(com.google.api.codegen.viewmodel.testing.ClientTestClassView) GapicInterfaceContext(com.google.api.codegen.transformer.GapicInterfaceContext) ViewModel(com.google.api.codegen.viewmodel.ViewModel) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) ImportSectionView(com.google.api.codegen.viewmodel.ImportSectionView)

Aggregations

InterfaceModel (com.google.api.codegen.config.InterfaceModel)33 GapicInterfaceContext (com.google.api.codegen.transformer.GapicInterfaceContext)23 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)17 ViewModel (com.google.api.codegen.viewmodel.ViewModel)17 ArrayList (java.util.ArrayList)16 ImmutableList (com.google.common.collect.ImmutableList)12 ModelTypeTable (com.google.api.codegen.transformer.ModelTypeTable)8 ImportSectionView (com.google.api.codegen.viewmodel.ImportSectionView)6 MethodModel (com.google.api.codegen.config.MethodModel)5 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)4 ApiMethodView (com.google.api.codegen.viewmodel.ApiMethodView)4 ClientTestClassView (com.google.api.codegen.viewmodel.testing.ClientTestClassView)4 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)3 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)3 VersionIndexRequireView (com.google.api.codegen.viewmodel.metadata.VersionIndexRequireView)3 MockServiceUsageView (com.google.api.codegen.viewmodel.testing.MockServiceUsageView)3 ProtoInterfaceModel (com.google.api.codegen.config.ProtoInterfaceModel)2 FeatureConfig (com.google.api.codegen.transformer.FeatureConfig)2 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)2 InterfaceContext (com.google.api.codegen.transformer.InterfaceContext)2