# Path: freezer_api/common/elasticv2_utils.py
# LOG = log.getLogger(__name__)
# class BackupMetadataDoc(object):
# class JobDoc(object):
# class ActionDoc(object):
# class SessionDoc(object):
# class ClientDoc(object):
#     def __init__(self, project_id='', user_id='', user_name='', data={}):
#     def is_valid(self):
#     def serialize(self):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, project_id, user_id):
#     def update(doc, project_id, user_id, job_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id, project_id):
#     def update(doc, user_id, action_id, project_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id, project_id, hold_off=30):
#     def update(doc, user_id, session_id, project_id):
#     def validate(doc):
#     def create(doc, project_id, user_id):
# 
# Path: freezer_api/common/exceptions.py
# class FreezerAPIException(falcon.HTTPError):
# class BadDataFormat(FreezerAPIException):
# class DocumentExists(FreezerAPIException):
# class StorageEngineError(FreezerAPIException):
# class DocumentNotFound(FreezerAPIException):
# class AccessForbidden(FreezerAPIException):
# class MethodNotImplemented(FreezerAPIException):
#     def __init__(self, message=''):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):


import elasticsearch
import logging
import os
from freezer_api.common import elasticv2_utils as utils
from freezer_api.common import exceptions as freezer_api_exc
from oslo_config import cfg
from oslo_log import log
                                    project_id=project_id
                                    )
        except freezer_api_exc.DocumentNotFound:
            pass

        valid_doc = utils.ActionDoc.update(doc, user_id, action_id, project_id)

        (created, version) = self.action_manager.insert(valid_doc, action_id)
        if created:
            logging.info('Action {0} created'.format(action_id))
        else:
            logging.info('Action {0} replaced with version'
                         ' {1}'.format(action_id, version))
        return version

    def get_session(self, user_id, session_id, project_id):
        return self.session_manager.get(user_id=user_id,
                                        doc_id=session_id,
                                        project_id=project_id)

    def search_session(self, user_id, offset=0, limit=10, search=None,
                       project_id=None):
        search = search or {}
        return self.session_manager.search(user_id=user_id,
                                           project_id=project_id,
                                           search=search,
                                           offset=offset,
                                           limit=limit)

    def add_session(self, user_id, doc, project_id):

# Path: freezer_api/common/elasticv2_utils.py
# LOG = log.getLogger(__name__)
# class BackupMetadataDoc(object):
# class JobDoc(object):
# class ActionDoc(object):
# class SessionDoc(object):
# class ClientDoc(object):
#     def __init__(self, project_id='', user_id='', user_name='', data={}):
#     def is_valid(self):
#     def serialize(self):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, project_id, user_id):
#     def update(doc, project_id, user_id, job_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id, project_id):
#     def update(doc, user_id, action_id, project_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id, project_id, hold_off=30):
#     def update(doc, user_id, session_id, project_id):
#     def validate(doc):
#     def create(doc, project_id, user_id):
# 
# Path: freezer_api/common/exceptions.py
# class FreezerAPIException(falcon.HTTPError):
# class BadDataFormat(FreezerAPIException):
# class DocumentExists(FreezerAPIException):
# class StorageEngineError(FreezerAPIException):
# class DocumentNotFound(FreezerAPIException):
# class AccessForbidden(FreezerAPIException):
# class MethodNotImplemented(FreezerAPIException):
#     def __init__(self, message=''):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):
#     def handle(ex, req, resp, params):


# Path: freezer_api/storage/elasticv2.py
import elasticsearch
import logging
import os
from freezer_api.common import elasticv2_utils as utils
from freezer_api.common import exceptions as freezer_api_exc
from oslo_config import cfg
from oslo_log import log

                                    project_id=project_id
                                    )
        except freezer_api_exc.DocumentNotFound:
            pass

        valid_doc = utils.ActionDoc.update(doc, user_id, action_id, project_id)

        (created, version) = self.action_manager.insert(valid_doc, action_id)
        if created:
            logging.info('Action {0} created'.format(action_id))
        else:
            logging.info('Action {0} replaced with version'
                         ' {1}'.format(action_id, version))
        return version

    def get_session(self, user_id, session_id, project_id):
        return self.session_manager.get(user_id=user_id,
                                        doc_id=session_id,
                                        project_id=project_id)

    def search_session(self, user_id, offset=0, limit=10, search=None,
                       project_id=None):
        search = search or {}
        return self.session_manager.search(user_id=user_id,
                                           project_id=project_id,
                                           search=search,
                                           offset=offset,
                                           limit=limit)

    def add_session(self, user_id, doc, project_id):

        session_doc = utils.SessionDoc.create(doc=doc,