in server/lib/services/TemplatesService.dart [57:93]
Future<Template?> getTemplateById(
int templateId, String catalogSource) async {
final http.Client client = new http.Client();
// TODO: add logic to handle private catalog
if (catalogSource == "customer") {
return null;
}
var catalogUrl = _getCatalogUrl(catalogSource);
var response = await client.get(Uri.parse(catalogUrl));
Iterable templateList = json.decode(response.body);
List<Template> templates = List<Template>.from(
templateList.map((model) => Template.fromJson(model)));
List<Template> templateL =
templates.where((element) => element.id == templateId).toList();
Template template;
if (templateL.isEmpty) {
return null;
}
template = templateL.first;
Map<String, dynamic> cloudProvisionJsonConfig =
await _configService.getJson(template.cloudProvisionConfigUrl);
Iterable paramsList = cloudProvisionJsonConfig['inputs'];
List<Param> params =
List<Param>.from(paramsList.map((model) => Param.fromJson(model)));
template.inputs = params;
return template;
}