use of com.google.api.codegen.transformer.SurfaceNamer 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(productConfig);
for (InterfaceModel apiInterface : interfaces) {
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
if (interfaceConfig == null) {
continue;
}
GapicInterfaceContext context = createContext(apiInterface, productConfig);
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.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).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer)).outputPath("lib" + File.separator + versionPackagePath(namer) + ".rb").modules(generateModuleViews(model, productConfig, true)).type(VersionIndexType.VersionIndex).build();
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateCredentialsClass.
private CredentialsClassView generateCredentialsClass(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
String sanitizedShortName = packageConfig.shortName().replaceAll("[^A-Za-z0-9]", " ");
Name.lowerCamel(sanitizedShortName.split(" "));
List<String> apiSpecificPathEnvVars = ImmutableList.of(namer.inittedConstantName(Name.lowerCamel(sanitizedShortName.split(" ")).join("credentials")), namer.inittedConstantName(Name.lowerCamel(sanitizedShortName.split(" ")).join("keyfile")));
List<String> apiSpecificJsonEnvVars = ImmutableList.of(namer.inittedConstantName(Name.lowerCamel(sanitizedShortName.split(" ")).join("credentials").join("json")), namer.inittedConstantName(Name.lowerCamel(sanitizedShortName.split(" ")).join("keyfile").join("json")));
List<String> pathEnvVars = ImmutableList.<String>builder().addAll(apiSpecificPathEnvVars).addAll(DEFAULT_PATH_ENV_VARS).build();
List<String> jsonEnvVars = ImmutableList.<String>builder().addAll(apiSpecificJsonEnvVars).addAll(DEFAULT_JSON_ENV_VARS).build();
return CredentialsClassView.newBuilder().pathEnvVars(pathEnvVars).jsonEnvVars(jsonEnvVars).defaultPaths(DEFAULT_PATHS).scopes(model.getAuthScopes(productConfig)).build();
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class PythonPackageMetadataTransformer method generateNoxFile.
private ViewModel generateNoxFile(ApiModel model, GapicProductConfig productConfig) {
PackageMetadataNamer namer = new PackageMetadataNamer();
SurfaceNamer surfaceNamer = new PythonSurfaceNamer(productConfig.getPackageName());
String outputPath = "noxfile.py";
return generateMetadataView(model, productConfig, NOX_TEMPLATE_FILE, namer, surfaceNamer, outputPath).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSectionTransformer.generateNoxImportSection(), new PythonSurfaceNamer(productConfig.getPackageName()))).build();
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class PythonPackageMetadataTransformer method generateDocFiles.
private List<ViewModel> generateDocFiles(ApiModel model, GapicProductConfig productConfig) {
PackageMetadataNamer namer = new PackageMetadataNamer();
SurfaceNamer surfaceNamer = new PythonSurfaceNamer(productConfig.getPackageName());
String docsGapicPath = docsGapicPath(packageConfig.apiVersion());
String typesOutputPath = String.format("docs/%s/types.rst", docsGapicPath);
String apiOutputPath = String.format("docs/%s/api.rst", docsGapicPath);
return ImmutableList.<ViewModel>builder().add(generateMetadataView(model, productConfig, TYPES_DOC_TEMPLATE_FILE, namer, surfaceNamer, typesOutputPath).build()).add(generateMetadataView(model, productConfig, API_DOC_TEMPLATE_FILE, namer, surfaceNamer, apiOutputPath).build()).build();
}
use of com.google.api.codegen.transformer.SurfaceNamer 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(productConfig, typeTable, namer, file));
return doc.build();
}
Aggregations