2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 var args = process.argv.slice(2);
23 function defineRoutes(router) {
26 router.get('/v1.0/vendor-license-models', licenseModelsList);
29 router.get('/v1.0/vendor-license-models/:licenseModelId/feature-groups', featureGroupList);
30 router.get('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', featureGroup);
31 router.post('/v1.0/vendor-license-models/:licenseModelId/feature-groups', addFeatureGroup);
32 router.delete('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', deletefeatureGroup);
33 router.put('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', updatefeatureGroup);
38 router.get('/v1.0/vendor-license-models/:licenseModelId/license-agreements', licenseAgreementList);
39 router.post('/v1.0/vendor-license-models/:licenseModelId/license-agreements/', addLicenseAgreement);
40 router.delete('/v1.0/vendor-license-models/:licenseModelId/license-agreements/:licenseAgreementId', deleteLicenseAgreement);
41 router.put('/v1.0/vendor-license-models/:licenseModelId/license-agreements/:licenseAgreementId', updateLicenseAgreement);
44 router.get('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools', entitlementPoolsList);
45 router.post('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools', addEntitlementPool);
46 router.put('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools/:entitlementPoolId', updateEntitlementPool);
47 router.delete('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools/:entitlementPoolId', deleteEntitlementPool);
50 router.get('/v1.0/vendor-license-models/:licenseModelId/license-key-groups', licenseKeyGroupsList);
51 router.post('/v1.0/vendor-license-models/:licenseModelId/license-key-groups', addLicenseKeyGroup);
52 router.delete('/v1.0/vendor-license-models/:licenseModelId/license-key-groups/:licenseKeyGroupId', deleteLicenseKeyGroup);
53 router.put('/v1.0/vendor-license-models/:licenseModelId/license-key-groups/:licenseKeyGroupId', updateLicenseKeyGroup);
55 //VENDOR SOFTWARE PRODUCT
57 router.post('/v1.0/vendor-software-products/:vspId/upload', softwareProductUpload);
58 router.get('/v1.0/vendor-software-products/:vspId', getSoftwareProduct);
59 router.get('/v1.0/vendor-software-products', softwareProductList);
61 router.put('/v1.0/vendor-software-products/:vspId/processes/:prcId', putSoftwareProductProcess);
62 router.post('/v1.0/vendor-software-products/:vspId/processes', postSoftwareProductProcess);
66 function licenseModelsList(req, res) {
67 res.json(require('./data/licenseModels'));
70 function featureGroupList(req, res) {
71 res.json(require('./data/featureGroups'));
74 function featureGroup(req, res) {
75 res.json(require('./data/featureGroup'));
78 function deletefeatureGroup(req, res) {
85 function updatefeatureGroup(req, res) {
91 function addFeatureGroup(req,res) {
92 var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
99 /** ENTITLEMENT POOLS **/
100 function entitlementPoolsList(req, res) {
101 res.json(require('./data/entitlementPools'));
104 function updateEntitlementPool(req, res) {
110 function addEntitlementPool(req,res) {
111 var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
118 function deleteEntitlementPool(req, res) {
124 /** LICENSE KEY GROUPS */
126 function licenseKeyGroupsList(req, res) {
127 res.json(require('./data/licenseKeyGroups'));
130 function addLicenseKeyGroup(req,res) {
131 var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
138 function deleteLicenseKeyGroup(req, res) {
144 function updateLicenseKeyGroup(req, res) {
150 function licenseAgreementList(req, res) {
151 res.json(require('./data/licenseAgreementList'));
155 function addLicenseAgreement(req,res) {
156 var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
162 function deleteLicenseAgreement(req, res) {
167 function updateLicenseAgreement(req, res) {
173 /** VENDOR SOFTWARE PRODUCT */
175 function softwareProductUpload(req, res) {
181 function getSoftwareProduct(req, res) {
182 res.json(require('./data/softwareProduct'));
186 function putSoftwareProductProcess(req, res) {
192 function postSoftwareProductProcess(req, res) {
193 var id = Math.floor(Math.random() * (100 - 1) + 1).toString();
203 function createFixtureServer(port) {
204 var express = require('express');
206 var bodyParser = require('body-parser');
207 app.use(bodyParser.urlencoded({extended: true}));
208 app.use(bodyParser.json());
210 var router = express.Router();
212 defineRoutes(router);
214 app.use('/api', router);
215 app.use('/onboarding-api', router);
216 app.use('/sdc1/feProxy/onboarding-api', router);
220 console.log('Fixture server is up. port->', port);
221 //console.log(router.stack);
225 /** SOFTWARE PRODUCT LIST **/
226 function softwareProductList(req, res) {
227 res.json(require('./data/softwareProductList'));
231 createFixtureServer(args[0]);