# Path: zaqarclient/transport/base.py
# class Transport(object):
#     def __init__(self, options):
#     def send(self, request):
# 
# Path: zaqarclient/transport/request.py
# def prepare_request(auth_opts=None, data=None, **kwargs):
#     def __init__(self, endpoint='', operation='',
#                  ref='', content=None, params=None,
#                  headers=None, api=None, verify=True, cert=None, session=None):
#     def api(self):
#     def validate(self):
# class Request(object):
# 
# Path: zaqarclient/transport/response.py
# class Response(object):
#     def __init__(self, request, content, headers=None, status_code=None):
#     def deserialized_content(self):


import json
from oslo_log import log as logging
from oslo_utils import importutils
from oslo_utils import uuidutils
from zaqarclient.transport import base
from zaqarclient.transport import request
from zaqarclient.transport import response
        """Initialize a websocket transport client.

        :param endpoint: The websocket endpoint. Example: ws://127.0.0.1:9000/.
                         Required.
        :type endpoint: string
        """
        self._websocket_client_id = uuidutils.generate_uuid()

        LOG.debug('Instantiating messaging websocket client: %s', endpoint)
        self._ws = self._create_connection(endpoint)

        auth_req = request.Request(endpoint, 'authenticate',
                                   headers={'X-Auth-Token': self._token})
        self.send(auth_req)

    def _create_connection(self, endpoint):
        return websocket.create_connection(endpoint)

    def send(self, request):
        if not self._ws:
            self._init_client(request.endpoint)

        headers = request.headers.copy()
        headers.update({
            'Client-ID': self._websocket_client_id,
            'X-Project-ID': self._project_id
        })

        msg = {'action': request.operation, 'headers': headers}
        if request.content:

# Path: zaqarclient/transport/base.py
# class Transport(object):
#     def __init__(self, options):
#     def send(self, request):
# 
# Path: zaqarclient/transport/request.py
# def prepare_request(auth_opts=None, data=None, **kwargs):
#     def __init__(self, endpoint='', operation='',
#                  ref='', content=None, params=None,
#                  headers=None, api=None, verify=True, cert=None, session=None):
#     def api(self):
#     def validate(self):
# class Request(object):
# 
# Path: zaqarclient/transport/response.py
# class Response(object):
#     def __init__(self, request, content, headers=None, status_code=None):
#     def deserialized_content(self):


# Path: zaqarclient/transport/ws.py
import json
from oslo_log import log as logging
from oslo_utils import importutils
from oslo_utils import uuidutils
from zaqarclient.transport import base
from zaqarclient.transport import request
from zaqarclient.transport import response

        """Initialize a websocket transport client.

        :param endpoint: The websocket endpoint. Example: ws://127.0.0.1:9000/.
                         Required.
        :type endpoint: string
        """
        self._websocket_client_id = uuidutils.generate_uuid()

        LOG.debug('Instantiating messaging websocket client: %s', endpoint)
        self._ws = self._create_connection(endpoint)

        auth_req = request.Request(endpoint, 'authenticate',
                                   headers={'X-Auth-Token': self._token})
        self.send(auth_req)

    def _create_connection(self, endpoint):
        return websocket.create_connection(endpoint)

    def send(self, request):
        if not self._ws:
            self._init_client(request.endpoint)

        headers = request.headers.copy()
        headers.update({
            'Client-ID': self._websocket_client_id,
            'X-Project-ID': self._project_id
        })

        msg = {'action': request.operation, 'headers': headers}
        if request.content:

            msg['body'] = json.loads(request.content)