2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 export default class LoopCache {
27 constructor(loopJson) {
28 this.loopJsonCache=loopJson;
31 updateMicroServiceProperties(name, newMsProperties) {
32 for (var policy in this.loopJsonCache["microServicePolicies"]) {
33 if (this.loopJsonCache["microServicePolicies"][policy]["name"] === name) {
34 this.loopJsonCache["microServicePolicies"][policy]["configurationsJson"] = newMsProperties;
39 updateMicroServicePdpGroup(name, pdpGroup, pdpSubgroup) {
40 for (var policy in this.loopJsonCache["microServicePolicies"]) {
41 if (this.loopJsonCache["microServicePolicies"][policy]["name"] === name) {
42 this.loopJsonCache["microServicePolicies"][policy]["pdpGroup"] = pdpGroup;
43 this.loopJsonCache["microServicePolicies"][policy]["pdpSubgroup"] = pdpSubgroup;
48 updateGlobalProperties(newGlobalProperties) {
49 this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties;
52 updateOperationalPolicyProperties(name, newOpProperties) {
53 for (var policy in this.loopJsonCache["operationalPolicies"]) {
54 if (this.loopJsonCache["operationalPolicies"][policy]["name"] === name) {
55 this.loopJsonCache["operationalPolicies"][policy]["configurationsJson"] = newOpProperties;
60 updateOperationalPolicyPdpGroup(name, pdpGroup, pdpSubgroup) {
61 for (var policy in this.loopJsonCache["operationalPolicies"]) {
62 if (this.loopJsonCache["operationalPolicies"][policy]["name"] === name) {
63 this.loopJsonCache["operationalPolicies"][policy]["pdpGroup"] = pdpGroup;
64 this.loopJsonCache["operationalPolicies"][policy]["pdpSubgroup"] = pdpSubgroup;
70 return this.loopJsonCache["name"];
73 getOperationalPolicyConfigurationJson() {
74 return this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"];
77 getOperationalPolicyJsonSchema() {
78 return this.loopJsonCache["operationalPolicies"]["0"]["jsonRepresentation"];
81 getOperationalPolicies() {
82 return this.loopJsonCache["operationalPolicies"];
85 getOperationalPoliciesNoJsonSchema() {
86 var operationalPolicies = JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]));
87 delete operationalPolicies[0]["jsonRepresentation"];
88 return operationalPolicies;
91 getGlobalProperties() {
92 return this.loopJsonCache["globalPropertiesJson"];
95 getDcaeDeploymentProperties() {
96 return this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"];
99 getMicroServicePolicies() {
100 return this.loopJsonCache["microServicePolicies"];
103 getOperationalPolicyForName(name) {
104 var opProperties=this.getOperationalPolicies();
105 for (var policy in opProperties) {
106 if (opProperties[policy]["name"] === name) {
107 return opProperties[policy];
113 getOperationalPolicyPropertiesForName(name) {
114 var opConfig = this.getOperationalPolicyForName(name);
115 if (opConfig !== null) {
116 return opConfig["configurationsJson"];
121 getOperationalPolicyJsonRepresentationForName(name) {
122 var opConfig = this.getOperationalPolicyForName(name);
123 if (opConfig !== null) {
124 return opConfig["jsonRepresentation"];
129 getOperationalPolicySupportedPdpGroup(name) {
130 var opConfig=this.getOperationalPolicyForName(name);
131 if (opConfig !== null) {
132 if (opConfig["policyModel"]["policyPdpGroup"] !== undefined && opConfig["policyModel"]["policyPdpGroup"]["supportedPdpGroups"] !== undefined) {
133 return opConfig["policyModel"]["policyPdpGroup"]["supportedPdpGroups"];
139 getOperationalPolicyPdpGroup(name) {
140 var opConfig=this.getOperationalPolicyForName(name);
141 if (opConfig !== null) {
142 return opConfig["pdpGroup"];
147 getOperationalPolicyPdpSubgroup(name) {
148 var opConfig=this.getOperationalPolicyForName(name);
149 if (opConfig !== null) {
150 return opConfig["pdpSubgroup"];
155 getMicroServiceSupportedPdpGroup(name) {
156 var microService=this.getMicroServiceForName(name);
157 if (microService !== null) {
158 if (microService["policyModel"]["policyPdpGroup"] !== undefined && microService["policyModel"]["policyPdpGroup"]["supportedPdpGroups"] !== undefined) {
159 return microService["policyModel"]["policyPdpGroup"]["supportedPdpGroups"];
165 getMicroServicePdpGroup(name) {
166 var microService=this.getMicroServiceForName(name);
167 if (microService !== null) {
168 return microService["pdpGroup"];
173 getMicroServicePdpSubgroup(name) {
174 var microService=this.getMicroServiceForName(name);
175 if (microService !== null) {
176 return microService["pdpSubgroup"];
181 getMicroServiceForName(name) {
182 var msProperties=this.getMicroServicePolicies();
183 for (var policy in msProperties) {
184 if (msProperties[policy]["name"] === name) {
185 return msProperties[policy];
191 getMicroServicePropertiesForName(name) {
192 var msConfig = this.getMicroServiceForName(name);
193 if (msConfig !== null) {
194 return msConfig["configurationsJson"];
199 getMicroServiceJsonRepresentationForName(name) {
200 var msConfig = this.getMicroServiceForName(name);
201 if (msConfig !== null) {
202 return msConfig["jsonRepresentation"];
207 getResourceDetailsVfProperty() {
208 return this.loopJsonCache["modelService"]["resourceDetails"]["VF"];
211 getResourceDetailsVfModuleProperty() {
212 return this.loopJsonCache["modelService"]["resourceDetails"]["VFModule"];
216 return this.loopJsonCache.loopLogs;
220 return this.loopJsonCache.lastComputedState;
223 getComponentStates() {
224 return this.loopJsonCache.components;