use of com.google.api.codegen.viewmodel.ResourceIdParamView 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().resourceName(namer.getResourceTypeName(resourceNameConfig)).entityName(resourceNameConfig.getEntityName().toLowerUnderscore()).name(namer.getFormatFunctionName(interfaceConfig, resourceNameConfig)).pathTemplateName(namer.getPathTemplateName(interfaceConfig, resourceNameConfig)).pathTemplateGetterName(namer.getPathTemplateNameGetter(interfaceConfig, resourceNameConfig)).pattern(resourceNameConfig.getNamePattern()).isResourceNameDeprecated(resourceNameConfig.getDeprecated());
List<ResourceIdParamView> resourceIdParams = new ArrayList<>();
for (String variable : resourceNameConfig.getNameTemplate().vars()) {
ResourceIdParamView param = ResourceIdParamView.newBuilder().name(namer.getParamName(variable)).docName(namer.getParamDocName(variable)).templateKey(variable).build();
resourceIdParams.add(param);
}
function.resourceIdParams(resourceIdParams);
functions.add(function.build());
}
return functions;
}
Aggregations