# Path: ironicclient/common/filecache.py
# LOG = logging.getLogger(__name__)
# AUTHOR = 'openstack'
# PROGNAME = 'python-ironicclient'
# CACHE = None
# CACHE_DIR = appdirs.user_cache_dir(PROGNAME, AUTHOR)
# CACHE_EXPIRY_ENV_VAR = 'IRONICCLIENT_CACHE_EXPIRY'  # environment variable
# CACHE_FILENAME = os.path.join(CACHE_DIR, 'ironic-api-version.dbm')
# DEFAULT_EXPIRY = 300  # seconds
#         CACHE = dogpile.cache.make_region(key_mangler=str).configure(
#             'dogpile.cache.dbm',
#             expiration_time=expiry_time,
#             arguments={
#                 "filename": CACHE_FILENAME,
#             }
#         )
# def _get_cache():
# def _build_key(host, port):
# def save_data(host, port, data):
# def retrieve_data(host, port, expiry=None):
# 
# Path: ironicclient/common/http.py
# DEFAULT_VER = '1.9'
# LAST_KNOWN_API_VERSION = 78
# LATEST_VERSION = '1.{}'.format(LAST_KNOWN_API_VERSION)
# LOG = logging.getLogger(__name__)
# USER_AGENT = 'python-ironicclient'
# CHUNKSIZE = 1024 * 64  # 64kB
# _MAJOR_VERSION = 1
# API_VERSION = '/v%d' % _MAJOR_VERSION
# API_VERSION_SELECTED_STATES = ('user', 'negotiated', 'cached', 'default')
# DEFAULT_MAX_RETRIES = 5
# DEFAULT_RETRY_INTERVAL = 2
# SENSITIVE_HEADERS = ('X-Auth-Token',)
# SUPPORTED_ENDPOINT_SCHEME = ('http', 'https')
# _API_VERSION_RE = re.compile(r'/+(v%d)?/*$' % _MAJOR_VERSION)
# _RETRY_EXCEPTIONS = (exc.Conflict, exc.ServiceUnavailable,
#                      exc.ConnectionRefused, kexc.RetriableConnectionFailure)
# def _trim_endpoint_api_version(url):
# def _extract_error_json(body):
# def get_server(url):
#     def negotiate_version(self, conn, resp):
#         def _query_server(conn):
#     def _generic_parse_version_headers(self, accessor_func):
#     def _parse_version_headers(self, accessor_func):
#     def _make_simple_request(self, conn, method, url):
#     def _must_negotiate_version(self):
# def with_retries(func):
#     def wrapper(self, url, method, **kwargs):
#     def __init__(self,
#                  os_ironic_api_version,
#                  api_version_select_state,
#                  max_retries,
#                  retry_interval,
#                  **kwargs):
#     def _parse_version_headers(self, resp):
#     def _get_endpoint_filter(self):
#     def _make_simple_request(self, conn, method, url):
#     def _http_request(self, url, method, **kwargs):
#     def json_request(self, method, url, **kwargs):
#     def raw_request(self, method, url, **kwargs):
# def _construct_http_client(session,
#                            token=None,
#                            auth_ref=None,
#                            os_ironic_api_version=DEFAULT_VER,
#                            api_version_select_state='default',
#                            max_retries=DEFAULT_MAX_RETRIES,
#                            retry_interval=DEFAULT_RETRY_INTERVAL,
#                            timeout=600,
#                            ca_file=None,
#                            cert_file=None,
#                            key_file=None,
#                            insecure=None,
#                            **kwargs):
# class VersionNegotiationMixin(object):
# class SessionClient(VersionNegotiationMixin, adapter.LegacyJsonAdapter):
# 
# Path: ironicclient/exc.py
# class AmbiguousAuthSystem(exceptions.ClientException):
# class InvalidAttribute(exceptions.ClientException):
# class StateTransitionFailed(exceptions.ClientException):
# class StateTransitionTimeout(exceptions.ClientException):
# def from_response(response, message=None, traceback=None, method=None,
#                   url=None):
# 
# Path: ironicclient/tests/unit/utils.py
# class BaseTestCase(testtools.TestCase):
# class FakeAPI(object):
# class FakeConnection(object):
# class FakeResponse(object):
#     def setUp(self):
#     def __init__(self, responses, path_prefix=None):
#     def _request(self, method, url, headers=None, body=None, params=None):
#     def raw_request(self, *args, **kwargs):
#     def json_request(self, *args, **kwargs):
#     def __init__(self, response=None, path_prefix=None):
#     def request(self, method, conn_url, **kwargs):
#     def setresponse(self, response):
#     def getresponse(self):
#     def __repr__(self):
#     def __init__(self, headers, body=None, version=None, status=None,
#                  reason=None, request_headers={}):
#     def getheaders(self):
#     def getheader(self, key, default):
#     def read(self, amt):
#     def __repr__(self):
# def mockSessionResponse(headers, content=None, status_code=None, version=None,
#                         request_headers={}):
# def mockSession(headers, content=None, status_code=None, version=None):


from http import client as http_client
from unittest import mock
from keystoneauth1 import exceptions as kexc
from ironicclient.common import filecache
from ironicclient.common import http
from ironicclient import exc
from ironicclient.tests.unit import utils
import json
import time
#    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.





DEFAULT_TIMEOUT = 600

DEFAULT_HOST = 'localhost'
DEFAULT_PORT = '1234'


def _get_error_body(faultstring=None, debuginfo=None, description=None):
    if description:
        error_body = {'description': description}
    else:
        error_body = {
            'faultstring': faultstring,
            'debuginfo': debuginfo
        }
    raw_error_body = json.dumps(error_body)
    body = {'error_message': raw_error_body}
    return json.dumps(body)


def _session_client(**kwargs):

# Path: ironicclient/common/filecache.py
# LOG = logging.getLogger(__name__)
# AUTHOR = 'openstack'
# PROGNAME = 'python-ironicclient'
# CACHE = None
# CACHE_DIR = appdirs.user_cache_dir(PROGNAME, AUTHOR)
# CACHE_EXPIRY_ENV_VAR = 'IRONICCLIENT_CACHE_EXPIRY'  # environment variable
# CACHE_FILENAME = os.path.join(CACHE_DIR, 'ironic-api-version.dbm')
# DEFAULT_EXPIRY = 300  # seconds
#         CACHE = dogpile.cache.make_region(key_mangler=str).configure(
#             'dogpile.cache.dbm',
#             expiration_time=expiry_time,
#             arguments={
#                 "filename": CACHE_FILENAME,
#             }
#         )
# def _get_cache():
# def _build_key(host, port):
# def save_data(host, port, data):
# def retrieve_data(host, port, expiry=None):
# 
# Path: ironicclient/common/http.py
# DEFAULT_VER = '1.9'
# LAST_KNOWN_API_VERSION = 78
# LATEST_VERSION = '1.{}'.format(LAST_KNOWN_API_VERSION)
# LOG = logging.getLogger(__name__)
# USER_AGENT = 'python-ironicclient'
# CHUNKSIZE = 1024 * 64  # 64kB
# _MAJOR_VERSION = 1
# API_VERSION = '/v%d' % _MAJOR_VERSION
# API_VERSION_SELECTED_STATES = ('user', 'negotiated', 'cached', 'default')
# DEFAULT_MAX_RETRIES = 5
# DEFAULT_RETRY_INTERVAL = 2
# SENSITIVE_HEADERS = ('X-Auth-Token',)
# SUPPORTED_ENDPOINT_SCHEME = ('http', 'https')
# _API_VERSION_RE = re.compile(r'/+(v%d)?/*$' % _MAJOR_VERSION)
# _RETRY_EXCEPTIONS = (exc.Conflict, exc.ServiceUnavailable,
#                      exc.ConnectionRefused, kexc.RetriableConnectionFailure)
# def _trim_endpoint_api_version(url):
# def _extract_error_json(body):
# def get_server(url):
#     def negotiate_version(self, conn, resp):
#         def _query_server(conn):
#     def _generic_parse_version_headers(self, accessor_func):
#     def _parse_version_headers(self, accessor_func):
#     def _make_simple_request(self, conn, method, url):
#     def _must_negotiate_version(self):
# def with_retries(func):
#     def wrapper(self, url, method, **kwargs):
#     def __init__(self,
#                  os_ironic_api_version,
#                  api_version_select_state,
#                  max_retries,
#                  retry_interval,
#                  **kwargs):
#     def _parse_version_headers(self, resp):
#     def _get_endpoint_filter(self):
#     def _make_simple_request(self, conn, method, url):
#     def _http_request(self, url, method, **kwargs):
#     def json_request(self, method, url, **kwargs):
#     def raw_request(self, method, url, **kwargs):
# def _construct_http_client(session,
#                            token=None,
#                            auth_ref=None,
#                            os_ironic_api_version=DEFAULT_VER,
#                            api_version_select_state='default',
#                            max_retries=DEFAULT_MAX_RETRIES,
#                            retry_interval=DEFAULT_RETRY_INTERVAL,
#                            timeout=600,
#                            ca_file=None,
#                            cert_file=None,
#                            key_file=None,
#                            insecure=None,
#                            **kwargs):
# class VersionNegotiationMixin(object):
# class SessionClient(VersionNegotiationMixin, adapter.LegacyJsonAdapter):
# 
# Path: ironicclient/exc.py
# class AmbiguousAuthSystem(exceptions.ClientException):
# class InvalidAttribute(exceptions.ClientException):
# class StateTransitionFailed(exceptions.ClientException):
# class StateTransitionTimeout(exceptions.ClientException):
# def from_response(response, message=None, traceback=None, method=None,
#                   url=None):
# 
# Path: ironicclient/tests/unit/utils.py
# class BaseTestCase(testtools.TestCase):
# class FakeAPI(object):
# class FakeConnection(object):
# class FakeResponse(object):
#     def setUp(self):
#     def __init__(self, responses, path_prefix=None):
#     def _request(self, method, url, headers=None, body=None, params=None):
#     def raw_request(self, *args, **kwargs):
#     def json_request(self, *args, **kwargs):
#     def __init__(self, response=None, path_prefix=None):
#     def request(self, method, conn_url, **kwargs):
#     def setresponse(self, response):
#     def getresponse(self):
#     def __repr__(self):
#     def __init__(self, headers, body=None, version=None, status=None,
#                  reason=None, request_headers={}):
#     def getheaders(self):
#     def getheader(self, key, default):
#     def read(self, amt):
#     def __repr__(self):
# def mockSessionResponse(headers, content=None, status_code=None, version=None,
#                         request_headers={}):
# def mockSession(headers, content=None, status_code=None, version=None):


# Path: ironicclient/tests/unit/common/test_http.py
from http import client as http_client
from unittest import mock
from keystoneauth1 import exceptions as kexc
from ironicclient.common import filecache
from ironicclient.common import http
from ironicclient import exc
from ironicclient.tests.unit import utils
import json
import time

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





DEFAULT_TIMEOUT = 600

DEFAULT_HOST = 'localhost'
DEFAULT_PORT = '1234'


def _get_error_body(faultstring=None, debuginfo=None, description=None):
    if description:
        error_body = {'description': description}
    else:
        error_body = {
            'faultstring': faultstring,
            'debuginfo': debuginfo
        }
    raw_error_body = json.dumps(error_body)
    body = {'error_message': raw_error_body}
    return json.dumps(body)


def _session_client(**kwargs):

    return http.SessionClient(os_ironic_api_version='1.6',