Commit includes ControlLoopPolicy API and bugfixes
[policy/engine.git] / ECOMP-ControlloopPolicy / src / main / java / org / openecomp / policy / controlloop / policy / guard / builder / ControlLoopGuardBuilder.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP Policy Engine
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20 package org.openecomp.policy.controlloop.policy.guard.builder;
21
22 import org.openecomp.policy.controlloop.policy.builder.BuilderException;
23 import org.openecomp.policy.controlloop.policy.builder.Results;
24 import org.openecomp.policy.controlloop.policy.guard.Constraint;
25 import org.openecomp.policy.controlloop.policy.guard.ControlLoopGuard;
26 import org.openecomp.policy.controlloop.policy.guard.Guard;
27 import org.openecomp.policy.controlloop.policy.guard.GuardPolicy;
28 import org.openecomp.policy.controlloop.policy.guard.builder.impl.ControlLoopGuardBuilderImpl;
29
30 public interface ControlLoopGuardBuilder {
31         
32         /**
33          * Adds one or more guard policies to the Control Loop Guard
34          * 
35          * 
36          * @param policies
37          * @return 
38          * @throws BuilderException
39          */
40         public ControlLoopGuardBuilder  addGuardPolicy(GuardPolicy... policies) throws BuilderException;
41         
42         /**
43          * Removes one or more guard policies from the Control Loop Guard
44          * 
45          * 
46          * @param policies
47          * @return 
48          * @throws BuilderException
49          */
50         public ControlLoopGuardBuilder  removeGuardPolicy(GuardPolicy... policies) throws BuilderException;
51         
52         /**
53          * Removes all guard policies from the Control Loop Guard
54          * 
55          * 
56          * @param 
57          * @return 
58          * @throws BuilderException
59          */
60         public ControlLoopGuardBuilder  removeAllGuardPolicies() throws BuilderException;
61         
62         /**
63          * Adds one or more time limit constraints to the guard policy
64          * 
65          * 
66          * @param id (guard policy id)
67          * @param constraints
68          * @return 
69          * @throws BuilderException
70          */
71         public ControlLoopGuardBuilder  addLimitConstraint(String id, Constraint... constraints) throws BuilderException;
72         
73         /**
74          * Removes one or more time limit constraints from the guard policy
75          * 
76          * 
77          * @param id (guard policy id)
78          * @param constraints
79          * @return 
80          * @throws BuilderException
81          */
82         public ControlLoopGuardBuilder  removeLimitConstraint(String id, Constraint... constraints) throws BuilderException;
83         
84         /**
85          * Removes all time limit constraints from the guard policy
86          * 
87          * 
88          * @param id (guard policy id)
89          * @return 
90          * @throws BuilderException
91          */
92         public ControlLoopGuardBuilder  removeAllLimitConstraints(String id) throws BuilderException;
93         
94         /**
95          *  Simply return a copy of control loop guard
96          *  
97          *  @return ControlLoopGuard
98          */
99         public ControlLoopGuard getControlLoopGuard();  
100         
101         /**
102          * This will compile and build the YAML specification for the Control Loop Guard. Please iterate the Results object for details.
103          * The Results object will contains warnings and errors. If the specification compiled successfully, you will be able to retrieve the
104          * YAML.
105          * 
106          * @return Results
107          */
108         public Results  buildSpecification();
109         
110         /**
111          * The Factory is used to build a ControlLoopGuardBuilder implementation.
112          *
113          */
114         public static class Factory {
115                 
116                 private Factory(){
117                         //Do Nothing Private Constructor. 
118                 }
119                 /**
120                  * @param guard
121                  * @return ControlLoopGuardBuilder object
122                  * @throws BuilderException
123                  */
124                 public static ControlLoopGuardBuilder   buildControlLoopGuard (Guard guard) throws BuilderException {
125                         
126                         return  new ControlLoopGuardBuilderImpl(guard);
127                         
128                 }
129         }
130 }