use of com.google.api.codegen.viewmodel.FormatResourceFunctionView in project toolkit by googleapis.
the class PathTemplateTransformer method generateFormatResourceFunctions.
public List<FormatResourceFunctionView> generateFormatResourceFunctions(InterfaceContext context) {
List<FormatResourceFunctionView> functions = new ArrayList<>();
if (!context.getFeatureConfig().enableStringFormatFunctions()) {
return functions;
}
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
for (SingleResourceNameConfig resourceNameConfig : getSingleResourceNameConfigsUsedByInterface(context)) {
FormatResourceFunctionView.Builder function = FormatResourceFunctionView.newBuilder().entityName(resourceNameConfig.getEntityName()).name(namer.getFormatFunctionName(interfaceConfig, resourceNameConfig)).pathTemplateName(namer.getPathTemplateName(interfaceConfig, resourceNameConfig)).pathTemplateGetterName(namer.getPathTemplateNameGetter(interfaceConfig, resourceNameConfig)).pattern(resourceNameConfig.getNamePattern());
List<ResourceIdParamView> resourceIdParams = new ArrayList<>();
for (String var : resourceNameConfig.getNameTemplate().vars()) {
ResourceIdParamView param = ResourceIdParamView.newBuilder().name(namer.getParamName(var)).docName(namer.getParamDocName(var)).templateKey(var).build();
resourceIdParams.add(param);
}
function.resourceIdParams(resourceIdParams);
functions.add(function.build());
}
return functions;
}
Aggregations