# 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.

import logging

import six

from keystoneclient import exceptions
from keystoneclient import session as client_session
from keystoneclient.v2_0 import client as v2_client
from keystoneclient.v3 import client as v3_client


_logger = logging.getLogger(__name__)


class _KeystoneVersion(object):
    """A factory object that holds all the information to create a client.

     Instances of this class are callable objects that hold all the kwargs that
     were passed to discovery so that a user may simply call it to create a new
     client object.  Additional arguments passed to the call will override or
     add to those provided to the object.
    """

    _CLIENT_VERSIONS = {2: v2_client.Client,
                        3: v3_client.Client}

    def __init__(self, version, status, client_class=None, **kwargs):
        """Create a new discovered version object.

        :param tuple version: the version of the available API.
        :param string status: the stability of the API.
        :param Class client_class: the client class that should be used to
                                   instantiate against this version of the API.
                                   (optional, will be matched against known)