All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.onosproject.net.config.NetworkConfigService Maven / Gradle / Ivy

There is a newer version: 2.7.0
Show newest version
/*
 * 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 {

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

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

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

    /**
     * Returns the configuration class with the specified key.
     *
     * @param subjectKey subject class key
     * @param configKey  subject class name
     * @return subject class
     */
    Class getConfigClass(String subjectKey, String configKey);

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

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

    /**
     * Returns all configurations for the specified subject.
     *
     * @param subject configuration subject
     * @param      type of subject
     * @return set of configurations
     */
     Set> 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          type of subject
     * @param          type of configuration
     * @return configuration or null if one is not available
     */
    > C getConfig(S subject, Class 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          type of subject
     * @param          type of configuration
     * @return configuration or null if one is not available
     */
    > C addConfig(S subject, Class configClass);

    /**
     * Applies configuration for the specified subject and configuration
     * class using the raw JSON object. 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          type of subject
     * @param          type of configuration
     * @return configuration or null if one is not available
     */
    > C applyConfig(S subject, Class 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          type of subject
     * @param          type of configuration
     */
    > void removeConfig(S subject, Class configClass);

}