# Path: networking_odl/common/client.py
# LOG = log.getLogger(__name__)
# class OpenDaylightRestClient(object):
# class OpenDaylightRestClientGlobal(object):
#     def _check_opt(url):
#     def create_client(cls, url=None):
#     def __init__(self, url, username, password, timeout):
#     def get_resource(self, resource_type, resource_id):
#     def get(self, urlpath='', data=None):
#     def request(self, method, urlpath='', data=None):
#     def sendjson(self, method, urlpath, obj):
#     def _check_response(self, response):
#     def __init__(self):
#     def get_client(self):
# 
# Path: networking_odl/common/utils.py
# def try_del(d, keys):
# def make_url_object(object_type):
# def neutronify(name):
# def get_odl_url(path=''):


import copy
import itertools
import time
from oslo_config import cfg
from oslo_log import log
from oslo_serialization import jsonutils
from requests import exceptions
from networking_odl.common import client as odl_client
from networking_odl.common import utils

def deinit():
    '''Set odl_features back to it's pre-initlialized '''
    global feature_configs
    feature_configs = copy.copy(EMPTY_FEATURES)


def _load_features(json):
    """parse and save features from json"""
    features = json['features']
    if 'feature' not in features:
        return copy.copy(EMPTY_FEATURES)

    # documentation on the JSON received can be found at:
    # https://github.com/opendaylight/neutron/blob/master/model/src/main/yang/neutron-extensions.yang
    LOG.info('Retrieved ODL features %s', features)
    response = {}
    for feature in features['feature']:
        cfg = feature.get('configuration', '')
        response[feature['service-provider-feature'].split(':')[1]] = cfg
    return response


def _fetch_features():
    '''Fetch the list of features declared by ODL.

    This function should be called once during initialization
    '''

    path = 'restconf/operational/neutron:neutron/neutron:features'

# Path: networking_odl/common/client.py
# LOG = log.getLogger(__name__)
# class OpenDaylightRestClient(object):
# class OpenDaylightRestClientGlobal(object):
#     def _check_opt(url):
#     def create_client(cls, url=None):
#     def __init__(self, url, username, password, timeout):
#     def get_resource(self, resource_type, resource_id):
#     def get(self, urlpath='', data=None):
#     def request(self, method, urlpath='', data=None):
#     def sendjson(self, method, urlpath, obj):
#     def _check_response(self, response):
#     def __init__(self):
#     def get_client(self):
# 
# Path: networking_odl/common/utils.py
# def try_del(d, keys):
# def make_url_object(object_type):
# def neutronify(name):
# def get_odl_url(path=''):


# Path: networking_odl/common/odl_features.py
import copy
import itertools
import time
from oslo_config import cfg
from oslo_log import log
from oslo_serialization import jsonutils
from requests import exceptions
from networking_odl.common import client as odl_client
from networking_odl.common import utils


def deinit():
    '''Set odl_features back to it's pre-initlialized '''
    global feature_configs
    feature_configs = copy.copy(EMPTY_FEATURES)


def _load_features(json):
    """parse and save features from json"""
    features = json['features']
    if 'feature' not in features:
        return copy.copy(EMPTY_FEATURES)

    # documentation on the JSON received can be found at:
    # https://github.com/opendaylight/neutron/blob/master/model/src/main/yang/neutron-extensions.yang
    LOG.info('Retrieved ODL features %s', features)
    response = {}
    for feature in features['feature']:
        cfg = feature.get('configuration', '')
        response[feature['service-provider-feature'].split(':')[1]] = cfg
    return response


def _fetch_features():
    '''Fetch the list of features declared by ODL.

    This function should be called once during initialization
    '''

    path = 'restconf/operational/neutron:neutron/neutron:features'

    features_url = utils.get_odl_url(path)