aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/fixture/express.js
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-02-19 12:57:33 +0200
committerMichael Lando <ml636r@att.com>2017-02-19 13:47:13 +0200
commitefa037d34be7b1570efdc767c79fad8d4005f10e (patch)
treecf1036ba2728dea8a61492b678fa91954e629403 /openecomp-ui/fixture/express.js
parentf5f13c4f6b6fe3b4d98e349dfd7db59339803436 (diff)
Add new code new version
Change-Id: Ic02a76313503b526f17c3df29eb387a29fe6a42a Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-ui/fixture/express.js')
-rw-r--r--openecomp-ui/fixture/express.js231
1 files changed, 231 insertions, 0 deletions
diff --git a/openecomp-ui/fixture/express.js b/openecomp-ui/fixture/express.js
new file mode 100644
index 0000000000..ed8bf956f9
--- /dev/null
+++ b/openecomp-ui/fixture/express.js
@@ -0,0 +1,231 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+var args = process.argv.slice(2);
+
+function defineRoutes(router) {
+
+ //LICENSE-MODELS
+ router.get('/v1.0/vendor-license-models', licenseModelsList);
+
+ //FEATURE-GROUP
+ router.get('/v1.0/vendor-license-models/:licenseModelId/feature-groups', featureGroupList);
+ router.get('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', featureGroup);
+ router.post('/v1.0/vendor-license-models/:licenseModelId/feature-groups', addFeatureGroup);
+ router.delete('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', deletefeatureGroup);
+ router.put('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', updatefeatureGroup);
+
+
+
+ //LICENSE-AGREEMENT
+ router.get('/v1.0/vendor-license-models/:licenseModelId/license-agreements', licenseAgreementList);
+ router.post('/v1.0/vendor-license-models/:licenseModelId/license-agreements/', addLicenseAgreement);
+ router.delete('/v1.0/vendor-license-models/:licenseModelId/license-agreements/:licenseAgreementId', deleteLicenseAgreement);
+ router.put('/v1.0/vendor-license-models/:licenseModelId/license-agreements/:licenseAgreementId', updateLicenseAgreement);
+
+ //ENTITLEMENT POOLS
+ router.get('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools', entitlementPoolsList);
+ router.post('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools', addEntitlementPool);
+ router.put('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools/:entitlementPoolId', updateEntitlementPool);
+ router.delete('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools/:entitlementPoolId', deleteEntitlementPool);
+
+ //LICENSE KEY GROUPS
+ router.get('/v1.0/vendor-license-models/:licenseModelId/license-key-groups', licenseKeyGroupsList);
+ router.post('/v1.0/vendor-license-models/:licenseModelId/license-key-groups', addLicenseKeyGroup);
+ router.delete('/v1.0/vendor-license-models/:licenseModelId/license-key-groups/:licenseKeyGroupId', deleteLicenseKeyGroup);
+ router.put('/v1.0/vendor-license-models/:licenseModelId/license-key-groups/:licenseKeyGroupId', updateLicenseKeyGroup);
+
+ //VENDOR SOFTWARE PRODUCT
+
+ router.post('/v1.0/vendor-software-products/:vspId/upload', softwareProductUpload);
+ router.get('/v1.0/vendor-software-products/:vspId', getSoftwareProduct);
+ router.get('/v1.0/vendor-software-products', softwareProductList);
+
+ router.put('/v1.0/vendor-software-products/:vspId/processes/:prcId', putSoftwareProductProcess);
+ router.post('/v1.0/vendor-software-products/:vspId/processes', postSoftwareProductProcess);
+}
+
+
+function licenseModelsList(req, res) {
+ res.json(require('./data/licenseModels'));
+}
+
+function featureGroupList(req, res) {
+ res.json(require('./data/featureGroups'));
+}
+
+function featureGroup(req, res) {
+ res.json(require('./data/featureGroup'));
+}
+
+function deletefeatureGroup(req, res) {
+ res.json({
+ returnCode: 'OK'
+ });
+}
+
+
+function updatefeatureGroup(req, res) {
+ res.json({
+ returnCode: 'OK'
+ });
+}
+
+function addFeatureGroup(req,res) {
+ var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
+ res.json({
+ returnCode: 'OK',
+ value: id
+ })
+}
+
+/** ENTITLEMENT POOLS **/
+function entitlementPoolsList(req, res) {
+ res.json(require('./data/entitlementPools'));
+}
+
+function updateEntitlementPool(req, res) {
+ res.json({
+ returnCode: 'OK'
+ });
+}
+
+function addEntitlementPool(req,res) {
+ var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
+ res.json({
+ returnCode: 'OK',
+ value: id
+ })
+}
+
+function deleteEntitlementPool(req, res) {
+ res.json({
+ returnCode: 'OK'
+ });
+}
+
+/** LICENSE KEY GROUPS */
+
+function licenseKeyGroupsList(req, res) {
+ res.json(require('./data/licenseKeyGroups'));
+}
+
+function addLicenseKeyGroup(req,res) {
+ var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
+ res.json({
+ returnCode: 'OK',
+ value: id
+ })
+}
+
+function deleteLicenseKeyGroup(req, res) {
+ res.json({
+ returnCode: 'OK'
+ });
+}
+
+function updateLicenseKeyGroup(req, res) {
+ res.json({
+ returnCode: 'OK'
+ });
+}
+
+function licenseAgreementList(req, res) {
+ res.json(require('./data/licenseAgreementList'));
+}
+
+
+function addLicenseAgreement(req,res) {
+ var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
+ res.json({
+ returnCode: 'OK',
+ value: id
+ })
+}
+function deleteLicenseAgreement(req, res) {
+ res.json({
+ returnCode: 'OK'
+ });
+}
+function updateLicenseAgreement(req, res) {
+ res.json({
+ returnCode: 'OK'
+ });
+}
+
+/** VENDOR SOFTWARE PRODUCT */
+
+function softwareProductUpload(req, res) {
+ res.json({
+ status: 'SUCCESS'
+ });
+}
+
+function getSoftwareProduct(req, res) {
+ res.json(require('./data/softwareProduct'));
+}
+
+
+function putSoftwareProductProcess(req, res) {
+ res.json({
+ status: 'SUCCESS'
+ });
+}
+
+function postSoftwareProductProcess(req, res) {
+ var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
+ res.json({
+ returnCode: 'OK',
+ value: id
+ });
+}
+
+
+
+
+function createFixtureServer(port) {
+ var express = require('express');
+ var app = express();
+ var bodyParser = require('body-parser');
+ app.use(bodyParser.urlencoded({extended: true}));
+ app.use(bodyParser.json());
+
+ var router = express.Router();
+
+ defineRoutes(router);
+
+ app.use('/api', router);
+ app.use('/onboarding-api', router);
+ app.use('/sdc1/feProxy/onboarding-api', router);
+
+ app.listen(port);
+
+ console.log('Fixture server is up. port->', port);
+ //console.log(router.stack);
+ return app;
+}
+
+/** SOFTWARE PRODUCT LIST **/
+function softwareProductList(req, res) {
+ res.json(require('./data/softwareProductList'));
+}
+
+
+createFixtureServer(args[0]);