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 getOperationalPolicyJsonSchema() {
74 return this.loopJsonCache["operationalPolicies"]["0"]["jsonRepresentation"];
77 getOperationalPolicies() {
78 return this.loopJsonCache["operationalPolicies"];
81 getOperationalPoliciesNoJsonSchema() {
82 var operationalPolicies = JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]));
83 delete operationalPolicies[0]["jsonRepresentation"];
84 return operationalPolicies;
87 getGlobalProperties() {
88 return this.loopJsonCache["globalPropertiesJson"];
91 getDcaeDeploymentProperties() {
92 return this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"];
95 getMicroServicePolicies() {
96 return this.loopJsonCache["microServicePolicies"];
99 getOperationalPolicyForName(name) {
100 var opProperties=this.getOperationalPolicies();
101 for (var policy in opProperties) {
102 if (opProperties[policy]["name"] === name) {
103 return opProperties[policy];
109 getOperationalPolicyPropertiesForName(name) {
110 var opConfig = this.getOperationalPolicyForName(name);
111 if (opConfig !== null) {
112 return opConfig["configurationsJson"];
117 getOperationalPolicyJsonRepresentationForName(name) {
118 var opConfig = this.getOperationalPolicyForName(name);
119 if (opConfig !== null) {
120 return opConfig["jsonRepresentation"];
125 getOperationalPolicySupportedPdpGroup(name) {
126 var opConfig=this.getOperationalPolicyForName(name);
127 if (opConfig !== null) {
128 if (opConfig["policyModel"]["policyPdpGroup"] !== undefined && opConfig["policyModel"]["policyPdpGroup"]["supportedPdpGroups"] !== undefined) {
129 return opConfig["policyModel"]["policyPdpGroup"]["supportedPdpGroups"];
135 getOperationalPolicyPdpGroup(name) {
136 var opConfig=this.getOperationalPolicyForName(name);
137 if (opConfig !== null) {
138 return opConfig["pdpGroup"];
143 getOperationalPolicyPdpSubgroup(name) {
144 var opConfig=this.getOperationalPolicyForName(name);
145 if (opConfig !== null) {
146 return opConfig["pdpSubgroup"];
151 getMicroServiceSupportedPdpGroup(name) {
152 var microService=this.getMicroServiceForName(name);
153 if (microService !== null) {
154 if (microService["policyModel"]["policyPdpGroup"] !== undefined && microService["policyModel"]["policyPdpGroup"]["supportedPdpGroups"] !== undefined) {
155 return microService["policyModel"]["policyPdpGroup"]["supportedPdpGroups"];
161 getMicroServicePdpGroup(name) {
162 var microService=this.getMicroServiceForName(name);
163 if (microService !== null) {
164 return microService["pdpGroup"];
169 getMicroServicePdpSubgroup(name) {
170 var microService=this.getMicroServiceForName(name);
171 if (microService !== null) {
172 return microService["pdpSubgroup"];
177 getMicroServiceForName(name) {
178 var msProperties=this.getMicroServicePolicies();
179 for (var policy in msProperties) {
180 if (msProperties[policy]["name"] === name) {
181 return msProperties[policy];
187 getMicroServicePropertiesForName(name) {
188 var msConfig = this.getMicroServiceForName(name);
189 if (msConfig !== null) {
190 return msConfig["configurationsJson"];
195 getMicroServiceJsonRepresentationForName(name) {
196 var msConfig = this.getMicroServiceForName(name);
197 if (msConfig !== null) {
198 return msConfig["jsonRepresentation"];
203 getResourceDetailsVfProperty() {
204 return this.loopJsonCache["modelService"]["resourceDetails"]["VF"];
207 getResourceDetailsVfModuleProperty() {
208 return this.loopJsonCache["modelService"]["resourceDetails"]["VFModule"];
212 return this.loopJsonCache.loopLogs;
216 return this.loopJsonCache.lastComputedState;
219 getComponentStates() {
220 return this.loopJsonCache.components;