blob: 26c11b83a5ab37a07450fd0fb40e631ac5cfeaab [file] [log] [blame]
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Ray Milkeya4122362015-08-18 15:19:08 -070016package org.onosproject.net.config;
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070017
Thomas Vachuska0a400ea2015-09-04 11:25:03 -070018import com.fasterxml.jackson.databind.JsonNode;
Thomas Vachuskae2b7e7e2015-05-20 11:11:31 -070019import com.google.common.annotations.Beta;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070020import org.onosproject.event.ListenerService;
Thomas Vachuskae2b7e7e2015-05-20 11:11:31 -070021
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070022import java.util.Set;
23
24/**
25 * Service for tracking network configurations which specify how the discovered
Thomas Vachuska96d55b12015-05-11 08:52:03 -070026 * network information should be interpreted and how the core or applications
27 * should act on or configure the network.
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070028 */
Thomas Vachuskae2b7e7e2015-05-20 11:11:31 -070029@Beta
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070030public interface NetworkConfigService
Thomas Vachuskad894b5d2015-07-30 11:59:07 -070031 extends ListenerService<NetworkConfigEvent, NetworkConfigListener> {
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070032
33 /**
Thomas Vachuska96d55b12015-05-11 08:52:03 -070034 * Returns the set of subject classes for which configuration may be
35 * available.
36 *
37 * @return set of subject classes
38 */
39 Set<Class> getSubjectClasses();
40
41 /**
42 * Returns the subject factory with the specified key.
43 *
Thomas Vachuskaea5adc62015-10-07 11:52:30 -070044 * @param subjectClassKey subject class key
Thomas Vachuska96d55b12015-05-11 08:52:03 -070045 * @return subject class
46 */
Thomas Vachuskaea5adc62015-10-07 11:52:30 -070047 SubjectFactory getSubjectFactory(String subjectClassKey);
Thomas Vachuska96d55b12015-05-11 08:52:03 -070048
49 /**
50 * Returns the subject factory for the specified class.
51 *
52 * @param subjectClass subject class
Thomas Vachuskaea5adc62015-10-07 11:52:30 -070053 * @return subject class factory
Thomas Vachuska96d55b12015-05-11 08:52:03 -070054 */
55 SubjectFactory getSubjectFactory(Class subjectClass);
56
57 /**
58 * Returns the configuration class with the specified key.
59 *
Thomas Vachuskaea5adc62015-10-07 11:52:30 -070060 * @param subjectClassKey subject class key
61 * @param configKey subject class name
Thomas Vachuska96d55b12015-05-11 08:52:03 -070062 * @return subject class
63 */
Thomas Vachuskaea5adc62015-10-07 11:52:30 -070064 Class<? extends Config> getConfigClass(String subjectClassKey, String configKey);
Thomas Vachuska96d55b12015-05-11 08:52:03 -070065
66 /**
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070067 * Returns the set of subjects for which some configuration is available.
68 *
69 * @param subjectClass subject class
Thomas Vachuska96d55b12015-05-11 08:52:03 -070070 * @param <S> type of subject
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070071 * @return set of configured subjects
72 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070073 <S> Set<S> getSubjects(Class<S> subjectClass);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070074
75 /**
76 * Returns the set of subjects for which the specified configuration is
77 * available.
78 *
79 * @param subjectClass subject class
80 * @param configClass configuration class
Thomas Vachuska96d55b12015-05-11 08:52:03 -070081 * @param <S> type of subject
82 * @param <C> type of configuration
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070083 * @return set of configured subjects
84 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070085 <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070086
87 /**
88 * Returns all configurations for the specified subject.
89 *
90 * @param subject configuration subject
Thomas Vachuska96d55b12015-05-11 08:52:03 -070091 * @param <S> type of subject
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070092 * @return set of configurations
93 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070094 <S> Set<? extends Config<S>> getConfigs(S subject);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070095
96 /**
97 * Returns the configuration for the specified subject and configuration
98 * class if one is available; null otherwise.
99 *
100 * @param subject configuration subject
101 * @param configClass configuration class
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700102 * @param <S> type of subject
103 * @param <C> type of configuration
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700104 * @return configuration or null if one is not available
105 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700106 <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700107
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700108 /**
109 * Creates a new configuration for the specified subject and configuration
110 * class. If one already exists, it is simply returned.
111 *
112 * @param subject configuration subject
113 * @param configClass configuration class
114 * @param <S> type of subject
115 * @param <C> type of configuration
116 * @return configuration or null if one is not available
117 */
118 <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass);
119
120 /**
121 * Applies configuration for the specified subject and configuration
Thomas Vachuskace0bbb32015-11-18 16:56:10 -0800122 * class using the raw JSON node. If configuration already exists, it
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700123 * will be updated.
124 *
125 * @param subject configuration subject
126 * @param configClass configuration class
127 * @param json raw JSON node containing the configuration data
128 * @param <S> type of subject
129 * @param <C> type of configuration
130 * @return configuration or null if one is not available
Thomas Vachuskace0bbb32015-11-18 16:56:10 -0800131 * @throws IllegalArgumentException if the supplied JSON node contains
132 * invalid data
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700133 */
134 <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
Thomas Vachuska0a400ea2015-09-04 11:25:03 -0700135 JsonNode json);
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700136
137 /**
Thomas Vachuska6f350ed2016-01-08 09:53:03 -0800138 * Applies configuration for the specified subject and configuration
139 * key using the raw JSON object. If configuration already exists, it
140 * will be updated. If the specified configuration key does not yet have
141 * a registered class associated with it, the configuration will be pending
142 * and null value will be returned. Once the backing configuration class is
143 * registered, the configuration will be validated and accepted.
144 *
145 * @param subjectClassKey subject class key
146 * @param subject configuration subject
147 * @param configKey configuration class key
148 * @param json raw JSON node containing the configuration data
149 * @param <S> type of subject
150 * @param <C> type of configuration
151 * @return configuration object or null if configuration key does not have
152 * a registered class yet
153 * @throws IllegalArgumentException if the supplied JSON node contains
154 * invalid data
155 */
156 <S, C extends Config<S>> C applyConfig(String subjectClassKey, S subject,
157 String configKey, JsonNode json);
158
159 /**
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700160 * Clears any configuration for the specified subject and configuration
161 * class. If one does not exist, this call has no effect.
162 *
163 * @param subject configuration subject
164 * @param configClass configuration class
165 * @param <S> type of subject
166 * @param <C> type of configuration
167 */
168 <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass);
169
Thomas Vachuska6f350ed2016-01-08 09:53:03 -0800170 /**
171 * Clears any configuration for the specified subject and configuration
172 * key. If one does not exist, this call has no effect.
173 *
Jian Lidfba7392016-01-22 16:46:58 -0800174 * @param subjectClassKey subject class key
175 * @param subject configuration subject
176 * @param configKey configuration key
177 * @param <S> type of subject
Thomas Vachuska6f350ed2016-01-08 09:53:03 -0800178 */
179 <S> void removeConfig(String subjectClassKey, S subject, String configKey);
Deepa Vaddireddy0c49b602016-06-02 12:19:07 +0530180
181 /**
182 * Clears the configuration including queued based on the subject.
183 * If does not exists this call has no effect.
184 *
Ray Milkeybb23e0b2016-08-02 17:00:21 -0700185 * @param <S> type of subject
Deepa Vaddireddy0c49b602016-06-02 12:19:07 +0530186 * @param subject configuration subject
187 */
188 <S> void removeConfig(S subject);
189
190 /**
191 * Clears the complete configuration including queued.
192 * If does not exists this call has no effect.
193 *
Ray Milkeybb23e0b2016-08-02 17:00:21 -0700194 * @param <S> type of subject
Deepa Vaddireddy0c49b602016-06-02 12:19:07 +0530195 */
196 <S> void removeConfig();
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700197}