use of com.google.api.codegen.config.InterfaceModel in project toolkit by googleapis.
the class PythonPackageMetadataTransformer method generateExampleMethods.
// Generates methods used as examples for the README.md file.
// This currently generates a list of methods that have smoke test configuration. 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));
}
}
return exampleMethods.build();
}
use of com.google.api.codegen.config.InterfaceModel in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateVersionIndexView.
private ViewModel generateVersionIndexView(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
ImmutableList.Builder<VersionIndexRequireView> requireViews = ImmutableList.builder();
Iterable<? extends InterfaceModel> interfaces = model.getInterfaces();
for (InterfaceModel apiInterface : interfaces) {
GapicInterfaceContext context = createContext(apiInterface, productConfig);
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
requireViews.add(VersionIndexRequireView.newBuilder().clientName(namer.getFullyQualifiedApiWrapperClassName(interfaceConfig)).fileName(namer.getServiceFileName(interfaceConfig)).serviceName(namer.getPackageServiceName(context.getInterfaceConfig())).doc(serviceTransformer.generateServiceDoc(context, generateApiMethods(context).get(0), productConfig)).build());
}
// append any additional types
Set<String> requireTypes = new HashSet<>();
for (TypeModel type : model.getAdditionalTypes()) {
if (type instanceof ProtoTypeRef) {
ProtoTypeRef t = (ProtoTypeRef) type;
String name = namer.getVersionIndexFileImportName() + "/" + namer.getProtoFileImportName(t.getProtoType().getMessageType().getFile().getSimpleName());
requireTypes.add(name);
}
}
return VersionIndexView.newBuilder().apiVersion(packageConfig.apiVersion()).requireViews(requireViews.build()).requireTypes(ImmutableList.copyOf(requireTypes)).templateFileName(VERSION_INDEX_TEMPLATE_FILE).packageVersion(packageConfig.generatedPackageVersionBound(TargetLanguage.RUBY).lower()).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer)).outputPath("lib" + File.separator + versionPackagePath(namer) + ".rb").modules(generateModuleViews(model, productConfig, true)).type(VersionIndexType.VersionIndex).toolkitVersion(GeneratorVersionProvider.getGeneratorVersion()).build();
}
use of com.google.api.codegen.config.InterfaceModel in project toolkit by googleapis.
the class MockServiceTransformer method createMockServices.
public List<MockServiceUsageView> createMockServices(SurfaceNamer namer, ApiModel model, GapicProductConfig productConfig) {
List<MockServiceUsageView> mockServices = new ArrayList<>();
for (InterfaceModel apiInterface : getGrpcInterfacesToMock(model, productConfig)) {
MockServiceUsageView mockService = MockServiceUsageView.newBuilder().className(namer.getMockServiceClassName(apiInterface)).varName(namer.getMockServiceVarName(apiInterface)).implName(namer.getMockGrpcServiceImplName(apiInterface)).registerFunctionName(namer.getServerRegisterFunctionName(apiInterface)).build();
mockServices.add(mockService);
}
return mockServices;
}
use of com.google.api.codegen.config.InterfaceModel in project toolkit by googleapis.
the class CSharpGapicClientTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
CSharpFeatureConfig featureConfig = new CSharpFeatureConfig();
InterfaceModel lastApiInterface = null;
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, createTypeTable(productConfig.getPackageName()), namer, featureConfig);
surfaceDocs.add(generateApiAndSettingsView(context));
lastApiInterface = apiInterface;
}
GapicInterfaceContext context = GapicInterfaceContext.create(lastApiInterface, productConfig, createTypeTable(productConfig.getPackageName()), namer, featureConfig);
surfaceDocs.add(generateResourceNamesView(context));
surfaceDocs.add(generateCsProjView(context));
return surfaceDocs;
}
use of com.google.api.codegen.config.InterfaceModel in project toolkit by googleapis.
the class GoGapicSurfaceTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
GoSurfaceNamer namer = new GoSurfaceNamer(productConfig.getPackageName());
List<ViewModel> models = new ArrayList<ViewModel>();
models.add(generateMockServiceView(model, productConfig, namer));
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, GoGapicSurfaceTransformer.createTypeTable(), namer, featureConfig);
if (context.getInterfaceConfig().getSmokeTestConfig() != null) {
models.add(createSmokeTestClassView(context));
}
}
return models;
}
Aggregations