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