aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/NetworkConfigService.java
blob: f1b22c41d1d2de254881dc761dad6d8e0e04051a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
 * Copyright 2015 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.net.config;

import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.annotations.Beta;
import org.onosproject.event.ListenerService;

import java.util.Set;

/**
 * Service for tracking network configurations which specify how the discovered
 * network information should be interpreted and how the core or applications
 * should act on or configure the network.
 */
@Beta
public interface NetworkConfigService
        extends ListenerService<NetworkConfigEvent, NetworkConfigListener> {

    /**
     * Returns the set of subject classes for which configuration may be
     * available.
     *
     * @return set of subject classes
     */
    Set<Class> getSubjectClasses();

    /**
     * Returns the subject factory with the specified key.
     *
     * @param subjectClassKey subject class key
     * @return subject class
     */
    SubjectFactory getSubjectFactory(String subjectClassKey);

    /**
     * Returns the subject factory for the specified class.
     *
     * @param subjectClass subject class
     * @return subject class factory
     */
    SubjectFactory getSubjectFactory(Class subjectClass);

    /**
     * Returns the configuration class with the specified key.
     *
     * @param subjectClassKey subject class key
     * @param configKey       subject class name
     * @return subject class
     */
    Class<? extends Config> getConfigClass(String subjectClassKey, String configKey);

    /**
     * Returns the set of subjects for which some configuration is available.
     *
     * @param subjectClass subject class
     * @param <S>          type of subject
     * @return set of configured subjects
     */
    <S> Set<S> getSubjects(Class<S> subjectClass);

    /**
     * Returns the set of subjects for which the specified configuration is
     * available.
     *
     * @param subjectClass subject class
     * @param configClass  configuration class
     * @param <S>          type of subject
     * @param <C>          type of configuration
     * @return set of configured subjects
     */
    <S, C extends Config<S>> Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass);

    /**
     * Returns all configurations for the specified subject.
     *
     * @param subject configuration subject
     * @param <S>     type of subject
     * @return set of configurations
     */
    <S> Set<? extends Config<S>> getConfigs(S subject);

    /**
     * Returns the configuration for the specified subject and configuration
     * class if one is available; null otherwise.
     *
     * @param subject     configuration subject
     * @param configClass configuration class
     * @param <S>         type of subject
     * @param <C>         type of configuration
     * @return configuration or null if one is not available
     */
    <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass);

    /**
     * Creates a new configuration for the specified subject and configuration
     * class. If one already exists, it is simply returned.
     *
     * @param subject     configuration subject
     * @param configClass configuration class
     * @param <S>         type of subject
     * @param <C>         type of configuration
     * @return configuration or null if one is not available
     */
    <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass);

    /**
     * Applies configuration for the specified subject and configuration
     * class using the raw JSON node. If configuration already exists, it
     * will be updated.
     *
     * @param subject     configuration subject
     * @param configClass configuration class
     * @param json        raw JSON node containing the configuration data
     * @param <S>         type of subject
     * @param <C>         type of configuration
     * @return configuration or null if one is not available
     * @throws IllegalArgumentException if the supplied JSON node contains
     *                                  invalid data
     */
    <S, C extends Config<S>> C applyConfig(S subject, Class<C> configClass,
                                           JsonNode json);

    /**
     * Clears any configuration for the specified subject and configuration
     * class. If one does not exist, this call has no effect.
     *
     * @param subject     configuration subject
     * @param configClass configuration class
     * @param <S>         type of subject
     * @param <C>         type of configuration
     */
    <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass);

}