aa2027ab8a3a8368ba5d351f7662c9406831b72a
[policy/clamp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.clamp.controlloop.participant.intermediary.api;
22
23 import java.util.List;
24 import java.util.Map;
25 import java.util.UUID;
26 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
27 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
28 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
29 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
30 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
31 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
32 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
33 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
34 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
35 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
36
37 /**
38  * This interface is used by participant implementations to use the participant intermediary.
39  */
40 public interface ParticipantIntermediaryApi {
41
42     /**
43      * Register a listener for control loop elements that are mediated by the intermediary.
44      *
45      * @param controlLoopElementListener The control loop element listener to register
46      */
47     void registerControlLoopElementListener(ControlLoopElementListener controlLoopElementListener);
48
49     /**
50      * Send participant register message to controlloop runtime.
51      */
52     void sendParticipantRegister();
53
54     /**
55      * Send participant deregister message to controlloop runtime.
56      */
57     void sendParticipantDeregister();
58
59     /**
60      * Get participants loops from the intermediary API.
61      *
62      * @param name the participant name, null for all
63      * @param version the participant version, null for all
64      * @return the participants
65      */
66     List<Participant> getParticipants(String name, String version);
67
68     /**
69      * Update the state of a participant.
70      *
71      * @param definition the definition of the participant to update the state on
72      * @param state the state of the participant
73      * @return the participant
74      */
75     Participant updateParticipantState(ToscaConceptIdentifier definition, ParticipantState state);
76
77     /**
78      * Update the statistics of a participant.
79      *
80      * @param participantStatistics the statistics of the participant
81      */
82     void updateParticipantStatistics(ParticipantStatistics participantStatistics);
83
84     /**
85      * Get control loops from the intermediary API.
86      *
87      * @param name the control loop element name, null for all
88      * @param version the control loop element version, null for all
89      * @return the control loop elements
90      */
91     ControlLoops getControlLoops(String name, String version);
92
93     /**
94      * Get control loop elements from the intermediary API.
95      *
96      * @param name the control loop element name, null for all
97      * @param version the control loop element version, null for all
98      * @return the control loop elements
99      */
100     Map<UUID, ControlLoopElement> getControlLoopElements(String name, String version);
101
102     /**
103      * Get ToscaServiceTemplate from the intermediary API.
104      *
105      * @return the control loop element
106      */
107     ToscaServiceTemplate getToscaServiceTemplate();
108
109     /**
110      * Get control loop element from the intermediary API.
111      *
112      * @param id control loop element ID
113      * @return the control loop element
114      */
115     ControlLoopElement getControlLoopElement(UUID id);
116
117     /**
118      * Update the state of a control loop element.
119      *
120      * @param id the ID of the control loop element to update the state on
121      * @param currentState the state of the control loop element
122      * @param newState the state of the control loop element
123      * @return ControlLoopElement updated control loop element
124      */
125     ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState currentState,
126             ControlLoopState newState);
127
128     /**
129      * Update the control loop element statistics.
130      *
131      * @param id the ID of the control loop element to update the state on
132      * @param elementStatistics the updated statistics
133      */
134     void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics);
135 }