Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 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 | */ |
Ray Milkey | a412236 | 2015-08-18 15:19:08 -0700 | [diff] [blame] | 16 | package org.onosproject.net.config; |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 17 | |
Thomas Vachuska | 0a400ea | 2015-09-04 11:25:03 -0700 | [diff] [blame] | 18 | import com.fasterxml.jackson.databind.JsonNode; |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 19 | import org.onosproject.store.Store; |
| 20 | |
| 21 | import java.util.Set; |
| 22 | |
| 23 | /** |
| 24 | * Mechanism for distributing and storing network configuration information. |
| 25 | */ |
| 26 | public interface NetworkConfigStore extends Store<NetworkConfigEvent, NetworkConfigStoreDelegate> { |
| 27 | |
| 28 | /** |
| 29 | * Adds a new configuration factory. |
| 30 | * |
| 31 | * @param configFactory configuration factory to add |
| 32 | */ |
| 33 | void addConfigFactory(ConfigFactory configFactory); |
| 34 | |
| 35 | /** |
| 36 | * Removes a configuration factory. |
| 37 | * |
| 38 | * @param configFactory configuration factory to remove |
| 39 | */ |
| 40 | void removeConfigFactory(ConfigFactory configFactory); |
| 41 | |
| 42 | /** |
| 43 | * Returns the configuration factory for the specified configuration class. |
| 44 | * |
| 45 | * @param configClass configuration class |
| 46 | * @param <S> type of subject |
Thomas Vachuska | d894b5d | 2015-07-30 11:59:07 -0700 | [diff] [blame] | 47 | * @param <C> type of configuration |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 48 | * @return configuration factory or null |
| 49 | */ |
| 50 | <S, C extends Config<S>> ConfigFactory<S, C> getConfigFactory(Class<C> configClass); |
| 51 | |
| 52 | /** |
| 53 | * Returns set of subjects of the specified class, which have some |
| 54 | * network configuration associated with them. |
| 55 | * |
| 56 | * @param subjectClass subject class |
| 57 | * @param <S> type of subject |
| 58 | * @return set of subject |
| 59 | */ |
| 60 | <S> Set<S> getSubjects(Class<S> subjectClass); |
| 61 | |
| 62 | /** |
| 63 | * Returns set of subjects of the specified class, which have the |
| 64 | * specified class of network configuration associated with them. |
| 65 | * |
| 66 | * @param subjectClass subject class |
| 67 | * @param configClass configuration class |
| 68 | * @param <S> type of subject |
| 69 | * @param <C> type of configuration |
| 70 | * @return set of subject |
| 71 | */ |
| 72 | <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass); |
| 73 | |
| 74 | /** |
| 75 | * Returns set of configuration classes available for the specified subject. |
| 76 | * |
| 77 | * @param subject configuration subject |
| 78 | * @param <S> type of subject |
| 79 | * @return set of configuration classes |
| 80 | */ |
| 81 | <S> Set<Class<? extends Config<S>>> getConfigClasses(S subject); |
| 82 | |
| 83 | /** |
| 84 | * Get the configuration of the given class and for the specified subject. |
| 85 | * |
| 86 | * @param subject configuration subject |
| 87 | * @param configClass configuration class |
| 88 | * @param <S> type of subject |
| 89 | * @param <C> type of configuration |
| 90 | * @return configuration object |
| 91 | */ |
| 92 | <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass); |
| 93 | |
| 94 | /** |
| 95 | * Creates a new configuration of the given class for the specified subject. |
| 96 | * |
| 97 | * @param subject configuration subject |
| 98 | * @param configClass configuration class |
| 99 | * @param <S> type of subject |
| 100 | * @param <C> type of configuration |
| 101 | * @return configuration object |
| 102 | */ |
| 103 | <S, C extends Config<S>> C createConfig(S subject, Class<C> configClass); |
| 104 | |
| 105 | /** |
| 106 | * Applies configuration for the specified subject and configuration |
| 107 | * class using the raw JSON object. If configuration already exists, it |
| 108 | * will be updated. |
| 109 | * |
| 110 | * @param subject configuration subject |
| 111 | * @param configClass configuration class |
| 112 | * @param json raw JSON node containing the configuration data |
| 113 | * @param <S> type of subject |
| 114 | * @param <C> type of configuration |
Thomas Vachuska | d894b5d | 2015-07-30 11:59:07 -0700 | [diff] [blame] | 115 | * @return configuration object |
Thomas Vachuska | ce0bbb3 | 2015-11-18 16:56:10 -0800 | [diff] [blame] | 116 | * @throws IllegalArgumentException if the supplied JSON node contains |
| 117 | * invalid data |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 118 | */ |
| 119 | <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass, |
Thomas Vachuska | 0a400ea | 2015-09-04 11:25:03 -0700 | [diff] [blame] | 120 | JsonNode json); |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * Clears the configuration of the given class for the specified subject. |
| 124 | * |
| 125 | * @param subject configuration subject |
| 126 | * @param configClass configuration class |
| 127 | * @param <S> type of subject |
| 128 | * @param <C> type of configuration |
| 129 | */ |
| 130 | <S, C extends Config<S>> void clearConfig(S subject, Class<C> configClass); |
| 131 | |
Thomas Vachuska | 6f350ed | 2016-01-08 09:53:03 -0800 | [diff] [blame] | 132 | /** |
| 133 | * Queues pending configuration for the specified subject and configuration |
| 134 | * class using the raw JSON object. |
| 135 | * |
| 136 | * @param subject configuration subject |
| 137 | * @param configKey configuration key |
| 138 | * @param json raw JSON node containing the configuration data |
| 139 | * @param <S> type of subject |
| 140 | * @throws IllegalArgumentException if the supplied JSON node contains |
| 141 | * invalid data |
| 142 | */ |
| 143 | <S> void queueConfig(S subject, String configKey, JsonNode json); |
| 144 | |
| 145 | /** |
| 146 | * Clears the configuration of the given class for the specified subject. |
| 147 | * |
| 148 | * @param subject configuration subject |
| 149 | * @param configKey configuration key |
| 150 | * @param <S> type of subject |
| 151 | */ |
| 152 | <S> void clearQueuedConfig(S subject, String configKey); |
| 153 | |
Deepa Vaddireddy | 0c49b60 | 2016-06-02 12:19:07 +0530 | [diff] [blame] | 154 | /** |
| 155 | * Clears the configuration based on the subject including queued. |
| 156 | * If does not exists this call has no effect. |
| 157 | * |
Ray Milkey | bb23e0b | 2016-08-02 17:00:21 -0700 | [diff] [blame] | 158 | * @param <S> type of subject |
Deepa Vaddireddy | 0c49b60 | 2016-06-02 12:19:07 +0530 | [diff] [blame] | 159 | * @param subject configuration subject |
| 160 | */ |
| 161 | <S> void clearConfig(S subject); |
| 162 | |
| 163 | /** |
| 164 | * Clears the complete configuration including queued. |
| 165 | * If does not exists this call has no effect. |
| 166 | * |
Ray Milkey | bb23e0b | 2016-08-02 17:00:21 -0700 | [diff] [blame] | 167 | * @param <S> type of subject |
Deepa Vaddireddy | 0c49b60 | 2016-06-02 12:19:07 +0530 | [diff] [blame] | 168 | */ |
| 169 | <S> void clearConfig(); |
| 170 | |
Thomas Vachuska | 96d55b1 | 2015-05-11 08:52:03 -0700 | [diff] [blame] | 171 | } |