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 package org.openecomp.policy.controlloop.policy.builder;
25 import org.openecomp.policy.controlloop.policy.ControlLoop;
26 import org.openecomp.policy.controlloop.policy.OperationsAccumulateParams;
27 import org.openecomp.policy.controlloop.policy.Policy;
28 import org.openecomp.policy.controlloop.policy.PolicyResult;
29 import org.openecomp.policy.controlloop.policy.Target;
30 import org.openecomp.policy.controlloop.policy.builder.impl.ControlLoopPolicyBuilderImpl;
32 public interface ControlLoopPolicyBuilder {
37 * @throws BuilderException
39 public ControlLoopPolicyBuilder setAbatement(Boolean abatement) throws BuilderException;
43 * Sets the overall timeout value for the Control Loop. If any operational policies have retries and timeouts,
44 * then this overall timeout value should exceed all those values.
48 * @throws BuilderException
50 public ControlLoopPolicyBuilder setTimeout(Integer timeout) throws BuilderException;
53 * Scans the operational policies and calculate an minimum overall timeout for the Control Loop.
58 public Integer calculateTimeout();
61 * Sets the initial trigger policy when a DCAE Closed Loop Event arrives in the ECOMP Policy Platform.
72 * @throws BuilderException
74 public Policy setTriggerPolicy(String name, String description, String actor, Target target, String recipe, Map<String, String> payload, Integer retries, Integer timeout) throws BuilderException;
78 * Changes the trigger policy to point to another existing Policy.
83 * @throws BuilderException
85 public ControlLoop setTriggerPolicy(String id) throws BuilderException;
90 public boolean isOpenLoop();
94 * @throws BuilderException
96 public Policy getTriggerPolicy() throws BuilderException;
99 * Simply returns a copy of the ControlLoop information.
102 * @return ControlLoop
104 public ControlLoop getControlLoop();
107 * Creates a policy that is chained to the result of another Policy.
120 * @throws BuilderException
122 public Policy setPolicyForPolicyResult(String name, String description, String actor,
123 Target target, String recipe, Map<String, String> payload, Integer retries, Integer timeout, String policyID, PolicyResult... results) throws BuilderException;
127 * Sets the policy result(s) to an existing Operational Policy.
130 * @param policyResultID
134 * @throws BuilderException
136 public Policy setPolicyForPolicyResult(String policyResultID, String policyID, PolicyResult... results) throws BuilderException;
139 * Removes an Operational Policy. Be mindful that if any other Operational Policies have results that point to this policy, any
140 * policies that have results pointing to this policy will have their result reset to the appropriate default FINAL_* result.
145 * @throws BuilderException
147 public boolean removePolicy(String policyID) throws BuilderException;
150 * Resets a policy's results to defualt FINAL_* codes.
154 * @throws BuilderException - Policy does not exist
156 public Policy resetPolicyResults(String policyID) throws BuilderException;
159 * Removes all existing Operational Policies and reverts back to an Open Loop.
163 public ControlLoopPolicyBuilder removeAllPolicies();
166 * Adds an operationsAccumulateParams to an existing operational policy
169 * @throws BuilderException - Policy does not exist
171 public Policy addOperationsAccumulateParams(String policyID, OperationsAccumulateParams operationsAccumulateParams) throws BuilderException;
174 * This will compile and build the YAML specification for the Control Loop Policy. Please iterate the Results object for details.
175 * The Results object will contains warnings and errors. If the specification compiled successfully, you will be able to retrieve the
180 public Results buildSpecification();
183 * The Factory is used to build a ControlLoopPolicyBuilder implementation.
185 * @author pameladragosh
188 public static class Factory {
191 * Builds a basic Control Loop with an overall timeout. Use this method if you wish to create an OpenLoop, or if you
192 * want to interactively build a Closed Loop.
194 * @param controlLoopName - Per Closed Loop AID v1.0, unique string for the closed loop.
195 * @param timeout - Overall timeout for the Closed Loop to execute.
196 * @return ControlLoopPolicyBuilder object
197 * @throws BuilderException
199 public static ControlLoopPolicyBuilder buildControlLoop (String controlLoopName, Integer timeout) throws BuilderException {
201 ControlLoopPolicyBuilder builder = new ControlLoopPolicyBuilderImpl(controlLoopName, timeout);