0cb4963ec44b1957d5804afc4be2c7b7567803e5
[policy/clamp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 Nordix Foundation.
4  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.clamp.controlloop.participant.intermediary.api;
23
24 import java.util.List;
25 import java.util.Map;
26 import java.util.UUID;
27 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
28 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
29 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
30 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
31 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
32 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
33 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
34 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
35 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
36 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
37 import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
38
39 /**
40  * This interface is used by participant implementations to use the participant intermediary.
41  */
42 public interface ParticipantIntermediaryApi {
43
44     /**
45      * Register a listener for control loop elements that are mediated by the intermediary.
46      *
47      * @param controlLoopElementListener The control loop element listener to register
48      */
49     void registerControlLoopElementListener(ControlLoopElementListener controlLoopElementListener);
50
51     /**
52      * Get participants loops from the intermediary API.
53      *
54      * @param name the participant name, null for all
55      * @param version the participant version, null for all
56      * @return the participants
57      */
58     List<Participant> getParticipants(String name, String version);
59
60     /**
61      * Get common properties of a controlloopelement.
62      *
63      * @param clElementDef the control loop element definition
64      * @return the common properties
65      */
66     Map<String, ToscaProperty> getClElementDefinitionCommonProperties(ToscaConceptIdentifier clElementDef);
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 control loop element from the intermediary API.
104      *
105      * @param id control loop element ID
106      * @return the control loop element
107      */
108     ControlLoopElement getControlLoopElement(UUID id);
109
110     /**
111      * Update the state of a control loop element.
112      *
113      * @param id the ID of the control loop element to update the state on
114      * @param currentState the state of the control loop element
115      * @param newState the state of the control loop element
116      * @return ControlLoopElement updated control loop element
117      */
118     ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId,
119             UUID id, ControlLoopOrderedState currentState,
120             ControlLoopState newState, ParticipantMessageType messageType);
121
122     /**
123      * Update the control loop element statistics.
124      *
125      * @param id the ID of the control loop element to update the state on
126      * @param elementStatistics the updated statistics
127      */
128     void updateControlLoopElementStatistics(UUID id, ClElementStatistics elementStatistics);
129 }