diff options
Diffstat (limited to 'runtime/ui-react/src/api')
-rw-r--r-- | runtime/ui-react/src/api/LoopActionService.js | 74 | ||||
-rw-r--r-- | runtime/ui-react/src/api/LoopCache.js | 252 | ||||
-rw-r--r-- | runtime/ui-react/src/api/LoopCache.test.js | 305 | ||||
-rw-r--r-- | runtime/ui-react/src/api/LoopCacheMockFile.json | 135 | ||||
-rw-r--r-- | runtime/ui-react/src/api/LoopService.js | 244 | ||||
-rw-r--r-- | runtime/ui-react/src/api/PoliciesListCacheMockFile.json | 215 | ||||
-rw-r--r-- | runtime/ui-react/src/api/PolicyService.js | 152 | ||||
-rw-r--r-- | runtime/ui-react/src/api/PolicyToscaService.js | 80 | ||||
-rw-r--r-- | runtime/ui-react/src/api/TemplateService.js | 197 | ||||
-rw-r--r-- | runtime/ui-react/src/api/UserService.js | 75 |
10 files changed, 0 insertions, 1729 deletions
diff --git a/runtime/ui-react/src/api/LoopActionService.js b/runtime/ui-react/src/api/LoopActionService.js deleted file mode 100644 index 6f3b22fa2..000000000 --- a/runtime/ui-react/src/api/LoopActionService.js +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 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============================================ - * =================================================================== - * - */ - -export default class LoopActionService { - - static performAction(cl_name, uiAction) { - console.info("LoopActionService perform action: " + uiAction + " closedloopName=" + cl_name); - const svcAction = uiAction.toLowerCase(); - return fetch(window.location.pathname + "restservices/clds/v2/loop/" + svcAction + "/" + cl_name, { - method: 'PUT', - credentials: 'same-origin' - }) - .then(function (response) { - if (response.ok) { - return response; - } else { - return Promise.reject("Perform action failed with code:" + response.status); - } - }) - .then(function (data) { - console.info("Action Successful: " + uiAction); - return data; - }) - .catch(function (error) { - console.info("Action Failure: " + uiAction); - return Promise.reject(error); - }); - } - - - static refreshStatus(cl_name) { - console.info("Refresh the status for closedloopName=" + cl_name); - - return fetch(window.location.pathname + "restservices/clds/v2/loop/getstatus/" + cl_name, { - method: 'GET', - credentials: 'same-origin' - }) - .then(function (response) { - if (response.ok) { - return response.json(); - } else { - return Promise.reject("Refresh status failed with code:" + response.status); - } - }) - .then(function (data) { - console.info("Refresh status Successful"); - return data; - }) - .catch(function (error) { - console.info("Refresh status failed:", error); - return Promise.reject(error); - }); - } -} diff --git a/runtime/ui-react/src/api/LoopCache.js b/runtime/ui-react/src/api/LoopCache.js deleted file mode 100644 index ac2da07f2..000000000 --- a/runtime/ui-react/src/api/LoopCache.js +++ /dev/null @@ -1,252 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 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============================================ - * =================================================================== - * - */ - -export default class LoopCache { - loopJsonCache; - - constructor(loopJson) { - this.loopJsonCache = loopJson; - } - - updateMicroServiceProperties(name, newMsProperties) { - for (var policy in this.loopJsonCache["microServicePolicies"]) { - if (this.loopJsonCache["microServicePolicies"][policy]["name"] === name) { - this.loopJsonCache["microServicePolicies"][policy]["configurationsJson"] = newMsProperties; - } - } - } - - updateMicroServicePdpGroup(name, pdpGroup, pdpSubgroup) { - for (var policy in this.loopJsonCache["microServicePolicies"]) { - if (this.loopJsonCache["microServicePolicies"][policy]["name"] === name) { - this.loopJsonCache["microServicePolicies"][policy]["pdpGroup"] = pdpGroup; - this.loopJsonCache["microServicePolicies"][policy]["pdpSubgroup"] = pdpSubgroup; - } - } - } - - updateGlobalProperties(newGlobalProperties) { - this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties; - } - - updateOperationalPolicyProperties(name, newOpProperties) { - for (var policy in this.loopJsonCache["operationalPolicies"]) { - if (this.loopJsonCache["operationalPolicies"][policy]["name"] === name) { - this.loopJsonCache["operationalPolicies"][policy]["configurationsJson"] = newOpProperties; - } - } - } - - updateOperationalPolicyPdpGroup(name, pdpGroup, pdpSubgroup) { - for (var policy in this.loopJsonCache["operationalPolicies"]) { - if (this.loopJsonCache["operationalPolicies"][policy]["name"] === name) { - this.loopJsonCache["operationalPolicies"][policy]["pdpGroup"] = pdpGroup; - this.loopJsonCache["operationalPolicies"][policy]["pdpSubgroup"] = pdpSubgroup; - } - } - } - - getLoopName() { - return this.loopJsonCache["name"]; - } - - getOperationalPolicyJsonSchema() { - return this.loopJsonCache["operationalPolicies"]["0"]["jsonRepresentation"]; - } - - getOperationalPolicies() { - return this.loopJsonCache["operationalPolicies"]; - } - - getOperationalPoliciesNoJsonSchema() { - var operationalPolicies = JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"])); - delete operationalPolicies[0]["jsonRepresentation"]; - return operationalPolicies; - } - - getGlobalProperties() { - return this.loopJsonCache["globalPropertiesJson"]; - } - - getDcaeDeploymentProperties() { - return this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"]; - } - - getMicroServicePolicies() { - return this.loopJsonCache["microServicePolicies"]; - } - - getOperationalPolicyForName(name) { - var opProperties = this.getOperationalPolicies(); - for (var policy in opProperties) { - if (opProperties[policy]["name"] === name) { - return opProperties[policy]; - } - } - return null; - } - - getOperationalPolicyPropertiesForName(name) { - var opConfig = this.getOperationalPolicyForName(name); - if (opConfig !== null) { - return opConfig["configurationsJson"]; - } - return null; - } - - getOperationalPolicyJsonRepresentationForName(name) { - var opConfig = this.getOperationalPolicyForName(name); - if (opConfig !== null) { - return opConfig["jsonRepresentation"]; - } - return null; - } - - getOperationalPolicySupportedPdpGroup(name) { - var opConfig = this.getOperationalPolicyForName(name); - if (opConfig !== null) { - if (opConfig["policyModel"]["policyPdpGroup"] !== undefined && opConfig["policyModel"]["policyPdpGroup"]["supportedPdpGroups"] !== undefined) { - return opConfig["policyModel"]["policyPdpGroup"]["supportedPdpGroups"]; - } - } - return []; - } - - getOperationalPolicyPdpGroup(name) { - var opConfig = this.getOperationalPolicyForName(name); - if (opConfig !== null) { - return opConfig["pdpGroup"]; - } - return null; - } - - getOperationalPolicyPdpSubgroup(name) { - var opConfig = this.getOperationalPolicyForName(name); - if (opConfig !== null) { - return opConfig["pdpSubgroup"]; - } - return null; - } - - getMicroServiceSupportedPdpGroup(name) { - var microService = this.getMicroServiceForName(name); - if (microService !== null) { - if (microService["policyModel"]["policyPdpGroup"] !== undefined && microService["policyModel"]["policyPdpGroup"]["supportedPdpGroups"] !== undefined) { - return microService["policyModel"]["policyPdpGroup"]["supportedPdpGroups"]; - } - } - return []; - } - - getMicroServicePdpGroup(name) { - var microService = this.getMicroServiceForName(name); - if (microService !== null) { - return microService["pdpGroup"]; - } - return null; - } - - getMicroServicePdpSubgroup(name) { - var microService = this.getMicroServiceForName(name); - if (microService !== null) { - return microService["pdpSubgroup"]; - } - return null; - } - - getMicroServiceForName(name) { - var msProperties = this.getMicroServicePolicies(); - for (var policy in msProperties) { - if (msProperties[policy]["name"] === name) { - return msProperties[policy]; - } - } - return null; - } - - getMicroServicePropertiesForName(name) { - var msConfig = this.getMicroServiceForName(name); - if (msConfig !== null) { - return msConfig["configurationsJson"]; - } - return null; - } - - getMicroServiceJsonRepresentationForName(name) { - var msConfig = this.getMicroServiceForName(name); - if (msConfig !== null) { - return msConfig["jsonRepresentation"]; - } - return null; - } - - getResourceDetailsVfProperty() { - return this.loopJsonCache["modelService"]["resourceDetails"]["VF"]; - } - - getResourceDetailsVfModuleProperty() { - return this.loopJsonCache["modelService"]["resourceDetails"]["VFModule"]; - } - - getLoopLogsArray() { - return this.loopJsonCache.loopLogs; - } - - getComputedState() { - return this.loopJsonCache.lastComputedState; - } - - getComponentStates() { - return this.loopJsonCache.components; - } - - getTemplateName() { - if (this.getLoopTemplate() !== undefined) { - return this.getLoopTemplate().name; - } - return null; - } - - getLoopTemplate() { - return this.loopJsonCache["loopTemplate"]; - } - - isOpenLoopTemplate() { - var loopTemplate = this.getLoopTemplate(); - if (loopTemplate != null && loopTemplate["allowedLoopType"] === "OPEN") { - return true; - } - return false; - } - - getAllLoopElementModels() { - var loopTemplate = this.getLoopTemplate(); - var loopElementModels = []; - if (loopTemplate != null) { - for (var element of loopTemplate['loopElementModelsUsed']) { - loopElementModels.push(element['loopElementModel']) - } - } - return loopElementModels; - } -} diff --git a/runtime/ui-react/src/api/LoopCache.test.js b/runtime/ui-react/src/api/LoopCache.test.js deleted file mode 100644 index 76f819c69..000000000 --- a/runtime/ui-react/src/api/LoopCache.test.js +++ /dev/null @@ -1,305 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 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============================================ - * =================================================================== - * - */ -import LoopCache from '../api/LoopCache'; - -const json = require('./LoopCacheMockFile.json'); - -describe('Verify LoopCache functions', () => { - const loopCache = new LoopCache(json); - it('getLoopName', () => { - expect(loopCache.getLoopName()).toBe("LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca"); - }); - - it('getOperationalPolicies', () => { - const opPolicy = [{ - "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca", - "configurationsJson": { - "operational_policy": { - "controlLoop": {}, - "policies": [] - } - }, - "pdpGroup": "pdpGroupTest", - "pdpSubgroup": "pdpSubgroupTest", - "jsonRepresentation": { - "schema": {} - } - }]; - expect(loopCache.getOperationalPolicies()).toStrictEqual(opPolicy); - }); - - it('getOperationalPoliciesNoJsonSchema', () => { - const opPolicy = [{ - "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca", - "configurationsJson": { - "operational_policy": { - "controlLoop": {}, - "policies": [] - } - }, - "pdpGroup": "pdpGroupTest", - "pdpSubgroup": "pdpSubgroupTest", - }]; - expect(loopCache.getOperationalPoliciesNoJsonSchema()).toStrictEqual(opPolicy); - }); - - it('getOperationalPolicyJsonSchema', () => { - const jsonSchema = { - "schema": {} - }; - - expect(loopCache.getOperationalPolicyJsonSchema()).toStrictEqual(jsonSchema); - }); - it('getGlobalProperties', () => { - const globelProp = { - "dcaeDeployParameters": { - "location_id": "", - "service_id": "", - "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" - } - }; - expect(loopCache.getGlobalProperties()).toStrictEqual(globelProp); - }); - - it('getDcaeDeploymentProperties', () => { - const deploymentProp = { - "location_id": "", - "service_id": "", - "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" - }; - expect(loopCache.getDcaeDeploymentProperties()).toStrictEqual(deploymentProp); - }); - - it('getMicroServiceForName', () => { - const msJson = { - "name": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca", - "modelType": "onap.policies.monitoring.cdap.tca.hi.lo.app", - "configurationsJson": {"domain": "measurementsForVfScaling"}, - "shared": false, - "pdpGroup": "pdpGroupTest", - "pdpSubgroup": "pdpSubgroupTest", - "policyModel": {"policyPdpGroup": {"supportedPdpGroups": "supportedPdpGroupsTest"}}, - "jsonRepresentation": {"schema": {}} - }; - expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJson); - expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull(); - }); - - it('getMicroServicePropertiesForName', () => { - const msProp = {"domain": "measurementsForVfScaling"}; - expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msProp); - expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull(); - }); - - it('getMicroServiceJsonRepresentationForName', () => { - const msJsonRepresentation = {"schema": {}}; - expect(loopCache.getMicroServiceJsonRepresentationForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJsonRepresentation); - }); - - it('getResourceDetailsVfProperty', () => { - const resourceVF = { - "vLoadBalancerMS 0": { - "resourceVendor": "Test", - "resourceVendorModelNumber": "", - "name": "vLoadBalancerMS", - "description": "vLBMS", - "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", - "subcategory": "Load Balancer", - "category": "Application L4+", - "type": "VF", - "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", - "version": "1.0", - "resourceVendorRelease": "1.0", - "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" - } - }; - expect(loopCache.getResourceDetailsVfProperty()).toStrictEqual(resourceVF); - }); - - it('getResourceDetailsVfModuleProperty', () => { - const vfModule = { - "Vloadbalancerms..vpkg..module-1": { - "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", - "vfModuleModelVersion": "1", - "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", - "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", - "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", - "min_vf_module_instances": 0, - "vf_module_label": "vpkg", - "max_vf_module_instances": 1, - "vf_module_type": "Expansion", - "isBase": false, - "initial_count": 0, - "volume_group": false - } - }; - expect(loopCache.getResourceDetailsVfModuleProperty()).toStrictEqual(vfModule); - }); - - it('getLoopLogsArray', () => { - const logs = [ - { - "id": 1, - "logType": "INFO", - "logComponent": "CLAMP", - "message": "Operational policies UPDATED", - "logInstant": "2019-07-08T09:44:37Z" - } - ]; - expect(loopCache.getLoopLogsArray()).toStrictEqual(logs); - }); - - it('getComponentStates', () => { - const component = { - "POLICY": { - "componentState": { - "stateName": "NOT_SENT", - "description": "The policies defined have NOT yet been created on the policy engine" - } - }, - "DCAE": { - "componentState": { - "stateName": "BLUEPRINT_DEPLOYED", - "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop" - } - } - }; - expect(loopCache.getComponentStates()).toStrictEqual(component); - }); - - it('getOperationalPolicyForName', () => { - const opPolicy = { - "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca", - "configurationsJson": { - "operational_policy": { - "controlLoop": {}, - "policies": [] - } - }, - "pdpGroup": "pdpGroupTest", - "pdpSubgroup": "pdpSubgroupTest", - "jsonRepresentation": { - "schema": {} - } - }; - expect(loopCache.getOperationalPolicyForName("OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(opPolicy); - expect(loopCache.getOperationalPolicyForName("Not_Exist")).toBeNull(); - }); - - it('getOperationalPolicyPropertiesForName', () => { - const opPolicyJson = { - "operational_policy": { - "controlLoop": {}, - "policies": [] - }}; - expect(loopCache.getOperationalPolicyPropertiesForName("OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(opPolicyJson); - expect(loopCache.getOperationalPolicyPropertiesForName("Not_Exist")).toBeNull(); - }); - - it('getOperationalPolicyJsonRepresentationForName', () => { - const opPolicySchema = { - "schema": {} - }; - expect(loopCache.getOperationalPolicyJsonRepresentationForName("OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(opPolicySchema); - expect(loopCache.getOperationalPolicyJsonRepresentationForName("Not_Exist")).toBeNull(); - }); - - it('getOperationalPolicySupportedPdpGroup', () => { - expect(loopCache.getOperationalPolicySupportedPdpGroup("Not_Exist")).toStrictEqual([]); - }); - - it('getOperationalPolicyPdpGroup', () => { - expect(loopCache.getOperationalPolicyPdpGroup("OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual("pdpGroupTest"); - expect(loopCache.getOperationalPolicyPdpGroup("Not_Exist")).toBeNull(); - }); - - it('getOperationalPolicyPdpSubgroup', () => { - expect(loopCache.getOperationalPolicyPdpSubgroup("OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual("pdpSubgroupTest"); - expect(loopCache.getOperationalPolicyPdpSubgroup("Not_Exist")).toBeNull(); - }); - - it('getMicroServiceSupportedPdpGroup', () => { - expect(loopCache.getMicroServiceSupportedPdpGroup("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual("supportedPdpGroupsTest"); - expect(loopCache.getMicroServiceSupportedPdpGroup("Not_Exist")).toStrictEqual([]); - }); - - it('getMicroServicePdpGroup', () => { - expect(loopCache.getMicroServicePdpGroup("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual("pdpGroupTest"); - expect(loopCache.getMicroServicePdpGroup("Not_Exist")).toBeNull(); - }); - - it('getMicroServicePdpSubgroup', () => { - expect(loopCache.getMicroServicePdpSubgroup("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual("pdpSubgroupTest"); - expect(loopCache.getMicroServicePdpSubgroup("Not_Exist")).toBeNull(); - }); - - it('getMicroServiceJsonRepresentationForName', () => { - const msPolicySchema = { - "schema": {} - }; - expect(loopCache.getMicroServiceJsonRepresentationForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msPolicySchema); - expect(loopCache.getMicroServiceJsonRepresentationForName("Not_Exist")).toBeNull(); - }); - - it('getTemplateName', () => { - expect(loopCache.getTemplateName()).toStrictEqual("loopTemplateTest"); - }); - - it('updateGlobalProperties', () => { - const newGlobalProps = { - "dcaeDeployParameters": { - "location_id": "newLocation", - "service_id": "newServiceId", - "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2" - } - }; - loopCache.updateGlobalProperties(newGlobalProps); - expect(loopCache.getGlobalProperties()).toStrictEqual(newGlobalProps); - }); - - it('updateOperationalPolicyProperties', () => { - const newOpPolicy = { - "operational_policy": { - "controlLoop": {}, - "policies": [] - } - }; - loopCache.updateOperationalPolicyProperties("OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca",newOpPolicy); - expect(loopCache.getOperationalPolicyPropertiesForName("OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(newOpPolicy); - }); - - it('updateMicroServiceProperties', () => { - const newMsPolicyProperties = {"domain": "measurementsForVfScalingNew"}; - loopCache.updateMicroServiceProperties("TCA_h2NMX_v1_0_ResourceInstanceName1_tca", newMsPolicyProperties); - expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(newMsPolicyProperties); - }); - - it('updateMicroServicePdpGroup', () => { - const newMsPolicyProperties = {"domain": "measurementsForVfScalingNew"}; - loopCache.updateMicroServicePdpGroup("TCA_h2NMX_v1_0_ResourceInstanceName1_tca", "pdpGroupTest1", "pdpSubgroupTest1"); - expect(loopCache.getMicroServicePdpGroup("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual("pdpGroupTest1"); - expect(loopCache.getMicroServicePdpGroup("Not_Exist")).toBeNull(); - expect(loopCache.getMicroServicePdpSubgroup("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual("pdpSubgroupTest1"); - expect(loopCache.getMicroServicePdpSubgroup("Not_Exist")).toBeNull(); - }); - }); diff --git a/runtime/ui-react/src/api/LoopCacheMockFile.json b/runtime/ui-react/src/api/LoopCacheMockFile.json deleted file mode 100644 index e5a670218..000000000 --- a/runtime/ui-react/src/api/LoopCacheMockFile.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", - "dcaeBlueprintId": "typeId-3a942643-a8f7-4e54-b2c1-eea8daba2b17", - "globalPropertiesJson": { - "dcaeDeployParameters": { - "location_id": "", - "service_id": "", - "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" - } - }, - "loopTemplate": { - "name": "loopTemplateTest" - }, - "modelService": { - "serviceDetails": { - "serviceType": "", - "namingPolicy": "", - "environmentContext": "General_Revenue-Bearing", - "serviceEcompNaming": "true", - "serviceRole": "", - "name": "vLoadBalancerMS", - "description": "vLBMS", - "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f", - "ecompGeneratedNaming": "true", - "category": "Network L4+", - "type": "Service", - "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0", - "instantiationType": "A-la-carte" - }, - "resourceDetails": { - "CP": {}, - "VL": {}, - "VF": { - "vLoadBalancerMS 0": { - "resourceVendor": "Test", - "resourceVendorModelNumber": "", - "name": "vLoadBalancerMS", - "description": "vLBMS", - "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", - "subcategory": "Load Balancer", - "category": "Application L4+", - "type": "VF", - "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", - "version": "1.0", - "resourceVendorRelease": "1.0", - "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" - } - }, - "CR": {}, - "VFC": {}, - "PNF": {}, - "Service": {}, - "CVFC": {}, - "Service Proxy": {}, - "Configuration": {}, - "AllottedResource": {}, - "VFModule": { - "Vloadbalancerms..vpkg..module-1": { - "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", - "vfModuleModelVersion": "1", - "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", - "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", - "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", - "min_vf_module_instances": 0, - "vf_module_label": "vpkg", - "max_vf_module_instances": 1, - "vf_module_type": "Expansion", - "isBase": false, - "initial_count": 0, - "volume_group": false - } - } - } - }, - "lastComputedState": "DESIGN", - "components": { - "POLICY": { - "componentState": { - "stateName": "NOT_SENT", - "description": "The policies defined have NOT yet been created on the policy engine" - } - }, - "DCAE": { - "componentState": { - "stateName": "BLUEPRINT_DEPLOYED", - "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop" - } - } - }, - "operationalPolicies": [ - { - "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca", - "configurationsJson": { - "operational_policy": { - "controlLoop": {}, - "policies": [] - } - }, - "pdpGroup": "pdpGroupTest", - "pdpSubgroup": "pdpSubgroupTest", - "jsonRepresentation": { - "schema": {} - } - } - ], - "microServicePolicies": [ - { - "name": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca", - "modelType": "onap.policies.monitoring.cdap.tca.hi.lo.app", - "configurationsJson": { - "domain": "measurementsForVfScaling" - }, - "shared": false, - "pdpGroup": "pdpGroupTest", - "pdpSubgroup": "pdpSubgroupTest", - "policyModel": { - "policyPdpGroup": { - "supportedPdpGroups": "supportedPdpGroupsTest" - } - }, - "jsonRepresentation": { - "schema": {} - } - } - ], - "loopLogs": [ - { - "id": 1, - "logType": "INFO", - "logComponent": "CLAMP", - "message": "Operational policies UPDATED", - "logInstant": "2019-07-08T09:44:37Z" - } - ] -} diff --git a/runtime/ui-react/src/api/LoopService.js b/runtime/ui-react/src/api/LoopService.js deleted file mode 100644 index 16f1bec9e..000000000 --- a/runtime/ui-react/src/api/LoopService.js +++ /dev/null @@ -1,244 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 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============================================ - * =================================================================== - * - */ - -export default class LoopService { - static getLoopNames() { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/getAllNames', { method: 'GET', credentials: 'same-origin' }) - .then(function (response) { - console.debug("GetLoopNames response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("GetLoopNames query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("GetLoopNames error received", error); - return {}; - }); - } - - static createLoop(loopName, templateName) { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/create/' + loopName + '?templateName=' + templateName, { - method: 'POST', - headers: { - "Content-Type": "application/json" - }, - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("CreateLoop response received: ", response.status); - return response.json(); - }) - .catch(function (error) { - console.error("CreateLoop error received", error); - return ""; - }); - } - - static getLoop(loopName) { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/' + loopName, { - method: 'GET', - headers: { - "Content-Type": "application/json" - }, - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("GetLoop response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("GetLoop query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("GetLoop error received", error); - return {}; - }); - } - - static setMicroServiceProperties(loopName, jsonData) { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/updateMicroservicePolicy/' + loopName, { - method: 'POST', - credentials: 'same-origin', - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify(jsonData) - }) - .then(function (response) { - console.debug("updateMicroservicePolicy response received: ", response.status); - if (response.ok) { - return response.text(); - } else { - console.error("updateMicroservicePolicy query failed"); - return ""; - } - }) - .catch(function (error) { - console.error("updateMicroservicePolicy error received", error); - return ""; - }); - } - - static setOperationalPolicyProperties(loopName, jsonData) { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/updateOperationalPolicies/' + loopName, { - method: 'POST', - credentials: 'same-origin', - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify(jsonData) - }) - .then(function (response) { - console.debug("updateOperationalPolicies response received: ", response.status); - if (response.ok) { - return response.text(); - } else { - console.error("updateOperationalPolicies query failed"); - return ""; - } - }) - .catch(function (error) { - console.error("updateOperationalPolicies error received", error); - return ""; - }); - } - - static updateGlobalProperties(loopName, jsonData) { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/updateGlobalProperties/' + loopName, { - method: 'POST', - credentials: 'same-origin', - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify(jsonData) - }) - .then(function (response) { - console.debug("updateGlobalProperties response received: ", response.status); - if (response.ok) { - return response.text(); - } else { - console.error("updateGlobalProperties query failed"); - return ""; - } - }) - .catch(function (error) { - console.error("updateGlobalProperties error received", error); - return ""; - }); - } - - static refreshOperationalPolicyJson(loopName, operationalPolicyName) { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/refreshOperationalPolicyJsonSchema/' + loopName + '/' + operationalPolicyName, { - method: 'PUT', - headers: { - "Content-Type": "application/json" - }, - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("Refresh Operational Policy Json Schema response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("Refresh Operational Policy Json Schema query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("Refresh Operational Policy Json Schema error received", error); - return {}; - }); - } - - static refreshMicroServicePolicyJson(loopName, microServicePolicyName) { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/refreshMicroServicePolicyJsonSchema/' + loopName + '/' + microServicePolicyName, { - method: 'PUT', - headers: { - "Content-Type": "application/json" - }, - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("Refresh Operational Policy Json Schema response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("Refresh Operational Policy Json Schema query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("Refresh Operational Policy Json Schema error received", error); - return {}; - }); - } - - static addOperationalPolicyType(loopName, policyType, policyVersion) { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/addOperationaPolicy/' + loopName + '/policyModel/' + policyType + '/' + policyVersion, { - method: 'PUT', - headers: { - "Content-Type": "application/json" - }, - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("Add Operational Policy response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - return response.text(); - } - }) - .catch(function (error) { - console.error("Add Operational Policy query failed"); - throw new Error(error); - }) - } - - static removeOperationalPolicyType(loopName, policyType, policyVersion, policyName) { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/removeOperationaPolicy/' + loopName + '/policyModel/' + policyType + '/' + policyVersion + '/' + policyName, { - method: 'PUT', - headers: { - "Content-Type": "application/json" - }, - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("Remove Operational Policy response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("Remove Operational Policy query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("Remove Operational Policy error received", error); - return {}; - }); - } -} diff --git a/runtime/ui-react/src/api/PoliciesListCacheMockFile.json b/runtime/ui-react/src/api/PoliciesListCacheMockFile.json deleted file mode 100644 index 14d5cc653..000000000 --- a/runtime/ui-react/src/api/PoliciesListCacheMockFile.json +++ /dev/null @@ -1,215 +0,0 @@ -{ - "policies": [ - { - "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0": { - "type": "onap.policies.monitoring.tcagen2", - "type_version": "1.0.0", - "properties": { - "tca.policy": { - "domain": "measurementsForVfScaling", - "metricsPerEventName": [ - { - "policyScope": "DCAE", - "thresholds": [ - { - "version": "1.0.2", - "severity": "MAJOR", - "thresholdValue": 200, - "closedLoopEventStatus": "ONSET", - "closedLoopControlName": "LOOP_test", - "direction": "LESS_OR_EQUAL", - "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta" - } - ], - "eventName": "vLoadBalancer", - "policyVersion": "v0.0.1", - "controlLoopSchemaType": "VM", - "policyName": "DCAE.Config_tca-hi-lo" - } - ] - } - }, - "name": "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0", - "version": "1.0.0", - "metadata": { - "policy-id": "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0", - "policy-version": "1.0.0" - }, - "pdpGroupInfo": { - "pdpGroup": "pdpGroup2", - "pdpSubGroup": "subGroup2" - }, - "supportedPdpGroups": [ - { - "pdpGroup2": [ - "subGroup2", - "subGroup3" - ] - } - ] - } - }, - { - "OPERATIONAL_vLoadBalancerMS_v1_0_Drools_1_0_0_7xd": { - "type": "onap.policies.controlloop.operational.common.Drools", - "type_version": "1.0.0", - "properties": { - "abatement": false, - "operations": [ - { - "failure_retries": "final_failure_retries", - "id": "test1", - "failure_timeout": "final_failure_timeout", - "failure": "final_failure", - "operation": { - "payload": { - "artifact_name": "baseconfiguration", - "artifact_version": "1.0.0", - "mode": "async", - "data": "{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"hostname\":\"\",\"request-info\":{\"prop1\":\"\",\"prop2\":\"\"}}}" - }, - "target": { - "entityIds": { - "resourceID": "Vloadbalancerms..vdns..module-3", - "modelInvariantId": "4c10ba9b-f88f-415e-9de3-5d33336047fa", - "modelVersionId": "4fa73b49-8a6c-493e-816b-eb401567b720", - "modelName": "Vloadbalancerms..vdns..module-3", - "modelVersion": "1", - "modelCustomizationId": "bafcdab0-801d-4d81-9ead-f464640a38b1" - }, - "targetType": "VNF" - }, - "actor": "SDNR", - "operation": "BandwidthOnDemand" - }, - "failure_guard": "final_failure_guard", - "retries": 0, - "timeout": 0, - "failure_exception": "final_failure_exception", - "description": "test", - "success": "final_success" - } - ], - "trigger": "test1", - "timeout": 0, - "id": "LOOP_test" - }, - "name": "OPERATIONAL_vLoadBalancerMS_v1_0_Drools_1_0_0_7xd", - "version": "1.0.0", - "metadata": { - "policy-id": "OPERATIONAL_vLoadBalancerMS_v1_0_Drools_1_0_0_7xd", - "policy-version": "1.0.0" - }, - "pdpGroupInfo": { - "pdpGroup": "pdpGroup2", - "pdpSubGroup": "subGroup3" - }, - "supportedPdpGroups": [ - { - "pdpGroup2": [ - "subGroup2", - "subGroup3" - ] - } - ] - } - }, - { - "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP": { - "type": "onap.policies.Naming", - "type_version": "1.0.0", - "properties": { - "naming-models": [ - { - "naming-type": "VNF", - "naming-recipe": "AIC_CLOUD_REGION|DELIMITER|CONSTANT|DELIMITER|TIMESTAMP", - "name-operation": "to_lower_case()", - "naming-properties": [ - { - "property-name": "AIC_CLOUD_REGION" - }, - { - "property-name": "CONSTANT", - "property-value": "onap-nf" - }, - { - "property-name": "TIMESTAMP" - }, - { - "property-value": "-", - "property-name": "DELIMITER" - } - ] - }, - { - "naming-type": "VNFC", - "naming-recipe": "VNF_NAME|DELIMITER|NFC_NAMING_CODE|DELIMITER|SEQUENCE", - "name-operation": "to_lower_case()", - "naming-properties": [ - { - "property-name": "VNF_NAME" - }, - { - "property-name": "SEQUENCE", - "increment-sequence": { - "max": "zzz", - "scope": "ENTIRETY", - "start-value": "1", - "length": "3", - "increment": "1", - "sequence-type": "alpha-numeric" - } - }, - { - "property-name": "NFC_NAMING_CODE" - }, - { - "property-value": "-", - "property-name": "DELIMITER" - } - ] - }, - { - "naming-type": "VF-MODULE", - "naming-recipe": "VNF_NAME|DELIMITER|VF_MODULE_LABEL|DELIMITER|VF_MODULE_TYPE|DELIMITER|SEQUENCE", - "name-operation": "to_lower_case()", - "naming-properties": [ - { - "property-name": "VNF_NAME" - }, - { - "property-value": "-", - "property-name": "DELIMITER" - }, - { - "property-name": "VF_MODULE_LABEL" - }, - { - "property-name": "VF_MODULE_TYPE" - }, - { - "property-name": "SEQUENCE", - "increment-sequence": { - "max": "zzz", - "scope": "PRECEEDING", - "start-value": "1", - "length": "3", - "increment": "1", - "sequence-type": "alpha-numeric" - } - } - ] - } - ], - "policy-instance-name": "ONAP_NF_NAMING_TIMESTAMP" - }, - "name": "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", - "version": "1.0.0", - "metadata": { - "policy-id": "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", - "policy-version": "1.0.0" - } - } - } - ] -} diff --git a/runtime/ui-react/src/api/PolicyService.js b/runtime/ui-react/src/api/PolicyService.js deleted file mode 100644 index cf4f0fdba..000000000 --- a/runtime/ui-react/src/api/PolicyService.js +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP POLICY-CLAMP - * ================================================================================ - * Copyright (C) 2021 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============================================ - * =================================================================== - * - */ - -export default class PolicyService { - static getPoliciesList() { - return fetch(window.location.pathname + 'restservices/clds/v2/policies', { - method: 'GET', - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("getPoliciesList response received: ", response.status); - if (response.ok) { - console.info("getPoliciesList query successful"); - return response.json(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function (error) { - console.error("getPoliciesList error occurred ", error); - alert("getPoliciesList error occurred " + error); - return undefined; - }); - } - - static createNewPolicy(policyModelType, policyModelVersion, policyName, policyVersion, policyJson) { - return fetch(window.location.pathname + 'restservices/clds/v2/policies/' + policyModelType + '/' - + policyModelVersion + '/' + policyName + '/' + policyVersion, { - method: 'POST', - credentials: 'same-origin', - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify(policyJson) - }) - .then(function (response) { - console.debug("createNewPolicy response received: ", response.status); - if (response.ok) { - console.info("createNewPolicy query successful"); - return response.text(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function (error) { - console.error("createNewPolicy error occurred ", error); - alert("createNewPolicy error occurred " + error); - return undefined; - }); - } - - static deletePolicy(policyModelType, policyModelVersion, policyName, policyVersion) { - return fetch(window.location.pathname + 'restservices/clds/v2/policies/' + policyModelType + '/' - + policyModelVersion + '/' + policyName + '/' + policyVersion, { - method: 'DELETE', - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("deletePolicy response received: ", response.status); - if (response.ok) { - console.info("deletePolicy query successful"); - return response.text(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function (error) { - console.error("deletePolicy error occurred ", error); - alert("deletePolicy error occurred " + error); - return undefined; - }); - } - - static updatePdpDeployment(pdpOperationsList) { - return fetch(window.location.pathname + 'restservices/clds/v2/policies/pdpDeployment', { - method: 'PUT', - credentials: 'same-origin', - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify(pdpOperationsList) - }) - .then(function (response) { - console.debug("updatePdpDeployment response received: ", response.status); - if (response.ok) { - console.info("updatePdpDeployment query successful"); - return response.text(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function (error) { - console.error("updatePdpDeployment error occurred ", error); - alert("updatePdpDeployment error occurred " + error); - return undefined; - }); - } - - static sendNewPolicyModel(newPolicyModel) { - return fetch(window.location.pathname + 'restservices/clds/v2/policies/policytype', { - method: 'POST', - credentials: 'same-origin', - headers: { - "Content-Type": "plain/text" - }, - body: newPolicyModel - }) - .then(function (response) { - console.debug("sendNewPolicyModel response received: ", response.status); - if (response.ok) { - console.info("sendNewPolicyModel query successful"); - return response.text(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function (error) { - console.error("sendNewPolicyModel error occurred ", error); - alert("sendNewPolicyModel error occurred " + error); - return undefined; - }); - } -} diff --git a/runtime/ui-react/src/api/PolicyToscaService.js b/runtime/ui-react/src/api/PolicyToscaService.js deleted file mode 100644 index 6c74149d9..000000000 --- a/runtime/ui-react/src/api/PolicyToscaService.js +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019, 2021 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============================================ - * =================================================================== - * - */ - -export default class PolicyToscaService { - static getToscaPolicyModels() { - return fetch(window.location.pathname + 'restservices/clds/v2/policyToscaModels', { method: 'GET', credentials: 'same-origin' }) - .then(function (response) { - console.debug("getToscaPolicyModels response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("getToscaPolicyModels query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("getToscaPolicyModels error received", error); - return {}; - }); - } - - static getToscaPolicyModelYaml(policyModelType, policyModelVersion) { - return fetch(window.location.pathname + 'restservices/clds/v2/policyToscaModels/yaml/' + policyModelType + "/" + policyModelVersion, { - method: 'GET', - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("getToscaPolicyModelYaml response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("getToscaPolicyModelYaml query failed"); - return ""; - } - }) - .catch(function (error) { - console.error("getToscaPolicyModelYaml error received", error); - return ""; - }); - } - - static getToscaPolicyModel(policyModelType, policyModelVersion) { - return fetch(window.location.pathname + 'restservices/clds/v2/policyToscaModels/' + policyModelType + "/" + policyModelVersion, { - method: 'GET', - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("getToscaPolicyModel response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("getToscaPolicyModel query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("getToscaPolicyModel error received", error); - return {}; - }); - } -} diff --git a/runtime/ui-react/src/api/TemplateService.js b/runtime/ui-react/src/api/TemplateService.js deleted file mode 100644 index a6e386eac..000000000 --- a/runtime/ui-react/src/api/TemplateService.js +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 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============================================ - * =================================================================== - * - */ - -export default class TemplateService { - - static getLoopNames() { - return fetch(window.location.pathname + 'restservices/clds/v2/loop/getAllNames', { method: 'GET', credentials: 'same-origin' }) - .then(function (response) { - console.debug("getLoopNames response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("getLoopNames query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("getLoopNames error received", error); - return {}; - }); - } - - static getAllLoopTemplates() { - return fetch(window.location.pathname + 'restservices/clds/v2/templates', { method: 'GET', credentials: 'same-origin', }) - .then(function (response) { - console.debug("getAllLoopTemplates response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("getAllLoopTemplates query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("getAllLoopTemplates error received", error); - return {}; - }); - } - - static getDictionary() { - return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/', { method: 'GET', credentials: 'same-origin', }) - .then(function (response) { - console.debug("getDictionary response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("getDictionary query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("getDictionary error received", error); - return {}; - }); - } - - static getDictionaryElements(dictionaryName) { - return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + dictionaryName, { - method: 'GET', - headers: { - "Content-Type": "application/json", - }, - credentials: 'same-origin', - }) - .then(function (response) { - console.debug("getDictionaryElements response received: ", response.status); - if (response.ok) { - return response.json(); - } else { - console.error("getDictionaryElements query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("getDictionaryElements error received", error); - return {}; - }); - } - - static insDictionary(jsonData) { - console.log("dictionaryName is", jsonData.name) - return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/', { - method: 'PUT', - credentials: 'same-origin', - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(jsonData) - }) - .then(function (response) { - console.debug("insDictionary response received: ", response.status); - if (response.ok) { - return response.status; - } else { - var errorMessage = response.status; - console.error("insDictionary query failed", response.status); - return errorMessage; - } - }) - .catch(function (error) { - console.error("insDictionary error received", error); - return ""; - }); - } - - static insDictionaryElements(jsonData) { - console.log("dictionaryName is", jsonData.name) - return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + jsonData.name, { - method: 'PUT', - credentials: 'same-origin', - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(jsonData) - }) - .then(function (response) { - console.debug("insDictionary response received: ", response.status); - if (response.ok) { - return response.status; - } else { - var errorMessage = response.status; - console.error("insDictionary query failed", response.status); - return errorMessage; - } - }) - .catch(function (error) { - console.error("insDictionary error received", error); - return ""; - }); - } - - static deleteDictionary(dictionaryName) { - console.log("inside templaemenu service", dictionaryName) - return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + dictionaryName, { - method: 'DELETE', - headers: { - "Content-Type": "application/json", - }, - credentials: 'same-origin', - }) - .then(function (response) { - console.debug("deleteDictionary response received: ", response.status); - if (response.ok) { - return response.status; - } else { - console.error("deleteDictionary query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("deleteDictionary error received", error); - return {}; - }); - } - - static deleteDictionaryElements(dictionaryData) { - return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + dictionaryData.name + '/elements/' + dictionaryData.shortName, { - method: 'DELETE', - headers: { - "Content-Type": "application/json", - }, - credentials: 'same-origin', - }) - .then(function (response) { - console.debug("deleteDictionary response received: ", response.status); - if (response.ok) { - return response.status; - } else { - console.error("deleteDictionary query failed"); - return {}; - } - }) - .catch(function (error) { - console.error("deleteDictionary error received", error); - return {}; - }); - } -} diff --git a/runtime/ui-react/src/api/UserService.js b/runtime/ui-react/src/api/UserService.js deleted file mode 100644 index bcf46ea64..000000000 --- a/runtime/ui-react/src/api/UserService.js +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 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============================================ - * =================================================================== - * - */ - -export default class UserService { - static notLoggedUserName = 'Anonymous'; - - static login() { - return fetch(window.location.pathname + 'restservices/clds/v1/user/getUser', { - method: 'GET', - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("getUser response received, status code:", response.status); - if (response.ok) { - return response.text(); - } else { - console.error("getUser response is nok"); - return UserService.notLoggedUserName; - } - }) - .then(function (data) { - console.info("User connected:", data) - return data; - }) - .catch(function (error) { - console.warn("getUser error received, user set to: ", UserService.notLoggedUserName); - console.error("getUser error:", error); - return UserService.notLoggedUserName; - }); - } - - static getUserInfo() { - return fetch(window.location.pathname + 'restservices/clds/v2/clampInformation', { - method: 'GET', - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("getUserInfo response received, status code:", response.status); - if (response.ok) { - return response.json(); - } else { - return {} - } - }) - .then(function (data) { - console.info("User info received:", data) - return data; - }) - .catch(function (error) { - console.warn("getUserInfo error received, user set to: ", UserService.notLoggedUserName); - console.error("getUserInfo error:", error); - return {}; - }); - } -} |