# Path: freezer_api/common/_i18n.py

# 
# 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/common/utils.py
# class BackupMetadataDoc(object):
# class JobDoc(object):
# class ActionDoc(object):
# class SessionDoc(object):
# class ClientDoc(object):
#     def __init__(self, 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, user_id):
#     def update(doc, user_id, job_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id):
#     def update(doc, user_id, action_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id, hold_off=30):
#     def update(doc, user_id, session_id):
#     def validate(doc):
#     def create(doc, user_id):


import elasticsearch
import logging
import os
from freezer_api.common import _i18n
from freezer_api.common import exceptions as freezer_api_exc
from freezer_api.common import utils
from oslo_config import cfg
from oslo_log import log
    def search_backup(self, user_id, offset=0, limit=10, search=None):
        search = search or {}
        return self.backup_manager.search(user_id,
                                          search=search,
                                          offset=offset,
                                          limit=limit)

    def add_backup(self, user_id, user_name, doc):
        # raises if data is malformed (HTTP_400) or already present (HTTP_409)
        backup_metadata_doc = utils.BackupMetadataDoc(user_id, user_name, doc)
        if not backup_metadata_doc.is_valid():
            raise freezer_api_exc.BadDataFormat(
                message=_i18n._('Bad Data Format'))
        backup_id = backup_metadata_doc.backup_id
        self.backup_manager.insert(backup_metadata_doc.serialize(), backup_id)
        return backup_id

    def delete_backup(self, user_id, backup_id):
        return self.backup_manager.delete(user_id, backup_id)

    def get_client(self, user_id, client_id=None,
                   offset=0, limit=10, search=None):
        search = search or {}
        return self.client_manager.search(user_id,
                                          client_id,
                                          search=search,
                                          offset=offset,
                                          limit=limit)

    def add_client(self, user_id, doc):

# Path: freezer_api/common/_i18n.py

# 
# 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/common/utils.py
# class BackupMetadataDoc(object):
# class JobDoc(object):
# class ActionDoc(object):
# class SessionDoc(object):
# class ClientDoc(object):
#     def __init__(self, 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, user_id):
#     def update(doc, user_id, job_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id):
#     def update(doc, user_id, action_id):
#     def validate(doc):
#     def validate_patch(doc):
#     def create_patch(doc):
#     def create(doc, user_id, hold_off=30):
#     def update(doc, user_id, session_id):
#     def validate(doc):
#     def create(doc, user_id):


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

    def search_backup(self, user_id, offset=0, limit=10, search=None):
        search = search or {}
        return self.backup_manager.search(user_id,
                                          search=search,
                                          offset=offset,
                                          limit=limit)

    def add_backup(self, user_id, user_name, doc):
        # raises if data is malformed (HTTP_400) or already present (HTTP_409)
        backup_metadata_doc = utils.BackupMetadataDoc(user_id, user_name, doc)
        if not backup_metadata_doc.is_valid():
            raise freezer_api_exc.BadDataFormat(
                message=_i18n._('Bad Data Format'))
        backup_id = backup_metadata_doc.backup_id
        self.backup_manager.insert(backup_metadata_doc.serialize(), backup_id)
        return backup_id

    def delete_backup(self, user_id, backup_id):
        return self.backup_manager.delete(user_id, backup_id)

    def get_client(self, user_id, client_id=None,
                   offset=0, limit=10, search=None):
        search = search or {}
        return self.client_manager.search(user_id,
                                          client_id,
                                          search=search,
                                          offset=offset,
                                          limit=limit)

    def add_client(self, user_id, doc):

        client_doc = utils.ClientDoc.create(doc, user_id)