blob: 1784d90216360631e9e1ed0c8b1544102df7860a [file] [log] [blame]
/**
* © OpenCORD
*
* Visit http://guide.xosproject.org/devguide/addview/ for more information
*
* Created by teone on 6/22/16.
*/
(function () {
'use strict';
/**
* @ngdoc service
* @name xos.NetworkTemplateEncoder.serviceGrid
**/
// TODO write tests
angular.module('xos.serviceGrid')
.service('NetworkTemplateEncoder', function($q, Networkstemplates){
this.buildTosca = (templateId, toscaSpec) => {
const d = $q.defer();
Networkstemplates.get({id: templateId}).$promise
.then(template => {
const toscaObj = {};
toscaObj[`network_template#${template.name}`] = {
type: 'tosca.nodes.NetworkTemplate'
};
angular.extend(toscaSpec.topology_template.node_templates, toscaObj);
d.resolve([toscaSpec, template]);
})
.catch(e => {
d.reject(e);
});
return d.promise;
};
});
})();