Implemented new API generator
diff --git a/views/ngXosLib/.eslintrc b/views/ngXosLib/.eslintrc
new file mode 100644
index 0000000..f9a952f
--- /dev/null
+++ b/views/ngXosLib/.eslintrc
@@ -0,0 +1,42 @@
+{
+ "ecmaFeatures": {
+ "blockBindings": true,
+ "forOf": true,
+ "destructuring": true,
+ "arrowFunctions": true,
+ "templateStrings": true
+ },
+ "env": {
+ "browser": true,
+ "node": true,
+ "es6": true
+ },
+ "plugins": [
+ //"angular"
+ ],
+ "rules": {
+ "quotes": [2, "single"],
+ "camelcase": [0, {"properties": "always"}],
+ "no-underscore-dangle": 1,
+ "eqeqeq": [2, "smart"],
+ "no-alert": 1,
+ "key-spacing": [1, { "beforeColon": false, "afterColon": true }],
+ "indent": [2, 2],
+ "no-irregular-whitespace": 1,
+ "eol-last": 0,
+ "max-nested-callbacks": [2, 4],
+ "comma-spacing": [1, {"before": false, "after": true}],
+ "no-trailing-spaces": [1, { skipBlankLines: true }],
+ "no-unused-vars": [1, {"vars": "all", "args": "after-used"}],
+ "new-cap": 0,
+
+ //"angular/ng_module_name": [2, '/^xos\.*[a-z]*$/'],
+ //"angular/ng_controller_name": [2, '/^[a-z].*Ctrl$/'],
+ //"angular/ng_service_name": [2, '/^[A-Z].*Service$/'],
+ //"angular/ng_directive_name": [2, '/^[a-z]+[[A-Z].*]*$/'],
+ //"angular/ng_di": [0, "function or array"]
+ },
+ "globals" :{
+ "angular": true
+ }
+}
\ No newline at end of file
diff --git a/views/ngXosLib/apigen/blueprintToNgResource.js b/views/ngXosLib/apigen/blueprintToNgResource.js
new file mode 100644
index 0000000..20f2869
--- /dev/null
+++ b/views/ngXosLib/apigen/blueprintToNgResource.js
@@ -0,0 +1,75 @@
+'use strict';
+
+const protagonist = require('protagonist');
+const fs = require('fs');
+const P = require('bluebird');
+const _ = require('lodash');
+const chalk = require('chalk');
+const Handlebars = require('handlebars');
+
+P.promisifyAll(fs);
+P.promisifyAll(protagonist);
+
+const angualarModuleName = 'xos.helpers'
+
+// format href in angular format
+const formatHref = url => url.replace('{', ':').replace('}', '');
+
+const formatTitle = title => title.split(' ').join('-');
+
+const getParamName = url => url.match(/\{([^)]+)\}/) ? url.match(/\{([^)]+)\}/)[1] : '';
+
+// Get Group description
+const getGroupDescription = (group) => _.find(group, {element: 'copy'}) ? _.find(group, {element: 'copy'}).content.replace(/\n$/, '') : '';
+
+// Loop APIs endpoint
+const loopApiEndpoint = (group) => {
+ // {name: 'ResourceName', attributes: {href: '/ahhsiiis'}}
+ _.remove(group, {element: 'copy'})
+ // console.log(group);
+ // _.forEach(group, d => console.log(d));
+
+ return _.map(group, g => {
+ return {
+ name: formatTitle(g.meta.title),
+ param: {href: formatHref(g.attributes.href), name: getParamName(g.attributes.href)},
+ }
+ })
+};
+
+// Loop APIs groups
+const loopApiGroups = (defs) => {
+ if (!Array.isArray(defs)) {
+ return;
+ }
+ _.forEach(defs, d => {
+ console.info(chalk.blue.bold(`Parsing Group: ${d.meta.title}`));
+ var data = {
+ description: getGroupDescription(d.content),
+ ngModule: angualarModuleName,
+ resources: loopApiEndpoint(d.content)
+ };
+ fs.writeFileSync(`../xosHelpers/src/services/rest/${formatTitle(d.meta.title)}.js`, handlebarsTemplate(data));
+ });
+
+ console.info(chalk.green.bold(`Api Generated`));
+
+};
+
+// Loop the top level definitions
+const loopApiDefinitions = (defs) => {
+ _.forEach(defs, d => loopApiGroups(d.content));
+};
+
+let handlebarsTemplate;
+
+// read blueprint docs and parse
+fs.readFileAsync('./ngResourceTemplate.handlebars', 'utf8')
+.then((template) => {
+ handlebarsTemplate = Handlebars.compile(template);
+ return fs.readFileAsync('../../../xos/tests/api/apiary.apib', 'utf8')
+})
+.then(data => protagonist.parseAsync(data))
+.then(result => loopApiDefinitions(result.content))
+.catch(console.warn);
+
diff --git a/views/ngXosLib/apigen/ngResourceTemplate.handlebars b/views/ngXosLib/apigen/ngResourceTemplate.handlebars
new file mode 100644
index 0000000..d326a51
--- /dev/null
+++ b/views/ngXosLib/apigen/ngResourceTemplate.handlebars
@@ -0,0 +1,14 @@
+'use strict';
+{{#if description}}
+
+/*
+ * {{description}}
+ */
+{{/if}}
+
+angular.module('{{ngModule}}')
+{{#each resources}}
+.service('{{name}}', function($resource){
+ return $resource('{{param.href}}'{{#if param.name}}, { {{param.name}}: '@id' }{{/if}});
+})
+{{/each}}
\ No newline at end of file
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/ONOS-Apps.js b/views/ngXosLib/xosHelpers/src/services/rest/ONOS-Apps.js
new file mode 100644
index 0000000..8634f2b
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/ONOS-Apps.js
@@ -0,0 +1,6 @@
+'use strict';
+
+angular.module('xos.helpers')
+.service('ONOS-App-Collection', function($resource){
+ return $resource('/api/tenant/onos/app/');
+})
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/ONOS-Services.js b/views/ngXosLib/xosHelpers/src/services/rest/ONOS-Services.js
new file mode 100644
index 0000000..a2302fb
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/ONOS-Services.js
@@ -0,0 +1,11 @@
+'use strict';
+
+/*
+ * List of the active onos services
+
+ */
+
+angular.module('xos.helpers')
+.service('ONOS-Services-Collection', function($resource){
+ return $resource('/api/service/onos/');
+})
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js b/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js
new file mode 100644
index 0000000..9618b27
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js
@@ -0,0 +1,29 @@
+'use strict';
+
+/*
+ * Resource related to the CORD Subscribers.
+
+ */
+
+angular.module('xos.helpers')
+.service('Subscribers', function($resource){
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/', { subscriber_id: '@id'});
+})
+.service('Subscriber-features', function($resource){
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/', { subscriber_id: '@id'});
+})
+.service('Subscriber-features-uplink_speed', function($resource){
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uplink_speed/', { subscriber_id: '@id'});
+})
+.service('Subscriber-features-downlink_speed', function($resource){
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/downlink_speed/', { subscriber_id: '@id'});
+})
+.service('Subscriber-features-cdn', function($resource){
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/cdn/', { subscriber_id: '@id'});
+})
+.service('Subscriber-features-uverse', function($resource){
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uverse/', { subscriber_id: '@id'});
+})
+.service('Subscriber-features-status', function($resource){
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/status/', { subscriber_id: '@id'});
+})
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js b/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js
new file mode 100644
index 0000000..4e3f39a
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js
@@ -0,0 +1,11 @@
+'use strict';
+
+/*
+ * Virtual Truckroll, enable to perform basic test on user connectivity such as ping, traceroute and tcpdump.
+
+ */
+
+angular.module('xos.helpers')
+.service('Truckroll-Collection', function($resource){
+ return $resource('/api/tenant/truckroll/:truckroll_id/', { truckroll_id: '@id'});
+})
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js b/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js
new file mode 100644
index 0000000..fc1cda2
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js
@@ -0,0 +1,11 @@
+'use strict';
+
+/*
+ * OLT devices aggregate a set of subscriber connections
+
+ */
+
+angular.module('xos.helpers')
+.service('vOLT-Collection', function($resource){
+ return $resource('/api/tenant/cord/volt/:volt_id/', { volt_id: '@id'});
+})
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/vSG.js b/views/ngXosLib/xosHelpers/src/services/rest/vSG.js
new file mode 100644
index 0000000..04ffa0e
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/vSG.js
@@ -0,0 +1,6 @@
+'use strict';
+
+angular.module('xos.helpers')
+.service('vSG-Collection', function($resource){
+ return $resource('/api/service/vsg/');
+})