# Path: barbicanclient/exceptions.py
# class BarbicanException(Exception):
# class PayloadException(BarbicanException):
# class UnsupportedVersion(BarbicanException):
# class HTTPError(Exception):
# class HTTPServerError(HTTPError):
# class HTTPClientError(HTTPError):
# class HTTPAuthError(HTTPError):
#     def __init__(self, message, status_code=0):
#     def __init__(self, message, status_code=401):


import importlib
import logging
import os
import sys
import warnings
from keystoneauth1 import adapter
from keystoneauth1 import session as ks_session
from oslo_utils import importutils
from barbicanclient import exceptions
    :param interface: Used as an endpoint filter when using an
        authenticated keystone session. Defaults to 'public'.
    :param region_name: Used as an endpoint filter when using an
        authenticated keystone session.
    """
    LOG.debug("Creating Client object")

    if not session:
        session = ks_session.Session(verify=kwargs.pop('verify', True))

    if session.auth is None and kwargs.get('auth') is None:
        if not kwargs.get('endpoint'):
            raise ValueError('Barbican endpoint url must be provided when '
                             'not using auth in the Keystone Session.')

        if kwargs.get('project_id') is None:
            raise ValueError('Project ID must be provided when not using '
                             'auth in the Keystone Session')
    if not version:
        version = _DEFAULT_API_VERSION

    try:
        client_path = _SUPPORTED_API_VERSION_MAP[version]
        client_class = importutils.import_class(client_path)
        return client_class(session=session, *args, **kwargs)
    except (KeyError, ValueError):
        supported_versions = ', '.join(_SUPPORTED_API_VERSION_MAP.keys())
        msg = ("Invalid client version %(version)s; must be one of: "
               "%(versions)s") % {'version': version,
                                  'versions': supported_versions}

# Path: barbicanclient/exceptions.py
# class BarbicanException(Exception):
# class PayloadException(BarbicanException):
# class UnsupportedVersion(BarbicanException):
# class HTTPError(Exception):
# class HTTPServerError(HTTPError):
# class HTTPClientError(HTTPError):
# class HTTPAuthError(HTTPError):
#     def __init__(self, message, status_code=0):
#     def __init__(self, message, status_code=401):


# Path: barbicanclient/client.py
import importlib
import logging
import os
import sys
import warnings
from keystoneauth1 import adapter
from keystoneauth1 import session as ks_session
from oslo_utils import importutils
from barbicanclient import exceptions

    :param interface: Used as an endpoint filter when using an
        authenticated keystone session. Defaults to 'public'.
    :param region_name: Used as an endpoint filter when using an
        authenticated keystone session.
    """
    LOG.debug("Creating Client object")

    if not session:
        session = ks_session.Session(verify=kwargs.pop('verify', True))

    if session.auth is None and kwargs.get('auth') is None:
        if not kwargs.get('endpoint'):
            raise ValueError('Barbican endpoint url must be provided when '
                             'not using auth in the Keystone Session.')

        if kwargs.get('project_id') is None:
            raise ValueError('Project ID must be provided when not using '
                             'auth in the Keystone Session')
    if not version:
        version = _DEFAULT_API_VERSION

    try:
        client_path = _SUPPORTED_API_VERSION_MAP[version]
        client_class = importutils.import_class(client_path)
        return client_class(session=session, *args, **kwargs)
    except (KeyError, ValueError):
        supported_versions = ', '.join(_SUPPORTED_API_VERSION_MAP.keys())
        msg = ("Invalid client version %(version)s; must be one of: "
               "%(versions)s") % {'version': version,
                                  'versions': supported_versions}

        raise exceptions.UnsupportedVersion(msg)