blob: 85cc6ee932cf227d797bef21a62c4e3a21bda258 [file] [log] [blame]
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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 */
Thomas Vachuskad24aa7f2015-05-14 18:37:54 -070016package org.onosproject.incubator.net.config;
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070017
Thomas Vachuska96d55b12015-05-11 08:52:03 -070018import com.fasterxml.jackson.databind.node.ObjectNode;
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 *
44 * @param subjectKey subject class key
45 * @return subject class
46 */
47 SubjectFactory getSubjectFactory(String subjectKey);
48
49 /**
50 * Returns the subject factory for the specified class.
51 *
52 * @param subjectClass subject class
53 * @return subject class key
54 */
55 SubjectFactory getSubjectFactory(Class subjectClass);
56
57 /**
58 * Returns the configuration class with the specified key.
59 *
Thomas Vachuskad894b5d2015-07-30 11:59:07 -070060 * @param subjectKey subject class key
61 * @param configKey subject class name
Thomas Vachuska96d55b12015-05-11 08:52:03 -070062 * @return subject class
63 */
Jonathan Hart111b42b2015-07-14 13:28:05 -070064 Class<? extends Config> getConfigClass(String subjectKey, 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
122 * class using the raw JSON object. If configuration already exists, it
123 * 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
131 */
132 <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
133 ObjectNode json);
134
135 /**
136 * Clears any configuration for the specified subject and configuration
137 * class. If one does not exist, this call has no effect.
138 *
139 * @param subject configuration subject
140 * @param configClass configuration class
141 * @param <S> type of subject
142 * @param <C> type of configuration
143 */
144 <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass);
145
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700146}