blob: 5a89ccbc54cdcae47e1fbbabf92565249579bb92 [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
31 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 *
60 * @param configKey subject class name
61 * @return subject class
62 */
Jonathan Hart111b42b2015-07-14 13:28:05 -070063 Class<? extends Config> getConfigClass(String subjectKey, String configKey);
Thomas Vachuska96d55b12015-05-11 08:52:03 -070064
65 /**
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070066 * Returns the set of subjects for which some configuration is available.
67 *
68 * @param subjectClass subject class
Thomas Vachuska96d55b12015-05-11 08:52:03 -070069 * @param <S> type of subject
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070070 * @return set of configured subjects
71 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070072 <S> Set<S> getSubjects(Class<S> subjectClass);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070073
74 /**
75 * Returns the set of subjects for which the specified configuration is
76 * available.
77 *
78 * @param subjectClass subject class
79 * @param configClass configuration class
Thomas Vachuska96d55b12015-05-11 08:52:03 -070080 * @param <S> type of subject
81 * @param <C> type of configuration
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070082 * @return set of configured subjects
83 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070084 <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070085
86 /**
87 * Returns all configurations for the specified subject.
88 *
89 * @param subject configuration subject
Thomas Vachuska96d55b12015-05-11 08:52:03 -070090 * @param <S> type of subject
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070091 * @return set of configurations
92 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -070093 <S> Set<? extends Config<S>> getConfigs(S subject);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070094
95 /**
96 * Returns the configuration for the specified subject and configuration
97 * class if one is available; null otherwise.
98 *
99 * @param subject configuration subject
100 * @param configClass configuration class
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700101 * @param <S> type of subject
102 * @param <C> type of configuration
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700103 * @return configuration or null if one is not available
104 */
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700105 <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass);
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700106
Thomas Vachuska96d55b12015-05-11 08:52:03 -0700107 /**
108 * Creates a new configuration for the specified subject and configuration
109 * class. If one already exists, it is simply returned.
110 *
111 * @param subject configuration subject
112 * @param configClass configuration class
113 * @param <S> type of subject
114 * @param <C> type of configuration
115 * @return configuration or null if one is not available
116 */
117 <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass);
118
119 /**
120 * Applies configuration for the specified subject and configuration
121 * class using the raw JSON object. If configuration already exists, it
122 * will be updated.
123 *
124 * @param subject configuration subject
125 * @param configClass configuration class
126 * @param json raw JSON node containing the configuration data
127 * @param <S> type of subject
128 * @param <C> type of configuration
129 * @return configuration or null if one is not available
130 */
131 <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
132 ObjectNode json);
133
134 /**
135 * Clears any configuration for the specified subject and configuration
136 * class. If one does not exist, this call has no effect.
137 *
138 * @param subject configuration subject
139 * @param configClass configuration class
140 * @param <S> type of subject
141 * @param <C> type of configuration
142 */
143 <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass);
144
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -0700145}