# Path: arangodb/api.py
# class Client(object):
#     class_instance = None
# 
# 
#     def __init__(self, hostname, auth=None, protocol='http', port=8529, database=SYSTEM_DATABASE):
#         """
#             This should be done only once and sets the instance
#         """
# 
#         Client.class_instance = self
# 
#         self.hostname = hostname
#         self.auth = auth
#         self.protocol = protocol
#         self.port = port
#         self.database = database
# 
#         self._create_api()
# 
#     def set_database(self, name):
#         """
#         """
# 
#         self.database = name
#         self._create_api()
# 
#     def _create_api(self):
# 
#         url = '%s://%s:%s/_db/%s/_api/' % (self.protocol, self.hostname, self.port, self.database)
# 
#         self.api = slumber.API(url, auth=self.auth, append_slash=False)
# 
#     @classmethod
#     def instance(cls, hostname=None, auth=None, protocol=None, port=None, database=None):
#         """
#             This method is called from everywhere in the code which accesses the database.
# 
#             If one of the parameters is set, these variables are overwritten for all others.
#         """
# 
#         if cls.class_instance is None:
#             if hostname is None and auth is None and protocol is None and port is None and database is None:
#                 cls.class_instance = Client(hostname='localhost')
#             else:
#                 cls.class_instance = Client(hostname=hostname, auth=auth, protocol=protocol, port=port, database=database)
#         else:
#             if hostname is not None:
#                 cls.class_instance.hostname = hostname
# 
#             if protocol is not None:
#                 cls.class_instance.hostname = protocol
# 
#             if port is not None:
#                 cls.class_instance.hostname = port
# 
#             if database is not None:
#                 cls.class_instance.database = database
# 
#             if auth is not None:
#                 cls.class_instance.auth = auth
# 
#             cls.class_instance._create_api()
# 
#         return cls.class_instance
# 
#     def collection(self, name):
#         """
#             Returns a collection with the given name
# 
#             :param name Collection name
# 
#             :returns Collection
#         """
# 
#         return Collection(
#             name=name,
#             api_resource=self.api.collection(name),
#             api=self.api,
#         )
# 
# Path: arangodb/query/utils/document.py
# def create_document_from_result_dict(result_dict, api):
#     collection_name = result_dict['_id'].split('/')[0]
# 
#     doc = Document(
#         id=result_dict['_id'],
#         key=result_dict['_key'],
#         rev=result_dict['_rev'],
#         collection=collection_name,
#         api=api,
#     )
# 
#     doc.is_loaded = True
# 
#     del result_dict['_id']
#     del result_dict['_key']
#     del result_dict['_rev']
# 
#     for result_key in result_dict:
#         result_value = result_dict[result_key]
# 
#         doc.set(key=result_key, value=result_value)
# 
#     return doc


from arangodb.api import Client
from arangodb.query.utils.document import create_document_from_result_dict
        return cls._construct_query(name='remove-by-example',
                                    collection=collection, example=example_data, result=False,
                                    **kwargs)


    @classmethod
    def random(cls, collection):
        """
            Returns a random document from a collection.

            :param collection Collection instance

            :returns document
        """

        return cls._construct_query(name='any', collection=collection)


    @classmethod
    def _construct_query(cls, name, collection, multiple=False, result=True, **kwargs):
        """
        """

        query = {
            'collection': collection.name,
        }

        for arg_name in kwargs:
            query[arg_name] = kwargs[arg_name]


# Path: arangodb/api.py
# class Client(object):
#     class_instance = None
# 
# 
#     def __init__(self, hostname, auth=None, protocol='http', port=8529, database=SYSTEM_DATABASE):
#         """
#             This should be done only once and sets the instance
#         """
# 
#         Client.class_instance = self
# 
#         self.hostname = hostname
#         self.auth = auth
#         self.protocol = protocol
#         self.port = port
#         self.database = database
# 
#         self._create_api()
# 
#     def set_database(self, name):
#         """
#         """
# 
#         self.database = name
#         self._create_api()
# 
#     def _create_api(self):
# 
#         url = '%s://%s:%s/_db/%s/_api/' % (self.protocol, self.hostname, self.port, self.database)
# 
#         self.api = slumber.API(url, auth=self.auth, append_slash=False)
# 
#     @classmethod
#     def instance(cls, hostname=None, auth=None, protocol=None, port=None, database=None):
#         """
#             This method is called from everywhere in the code which accesses the database.
# 
#             If one of the parameters is set, these variables are overwritten for all others.
#         """
# 
#         if cls.class_instance is None:
#             if hostname is None and auth is None and protocol is None and port is None and database is None:
#                 cls.class_instance = Client(hostname='localhost')
#             else:
#                 cls.class_instance = Client(hostname=hostname, auth=auth, protocol=protocol, port=port, database=database)
#         else:
#             if hostname is not None:
#                 cls.class_instance.hostname = hostname
# 
#             if protocol is not None:
#                 cls.class_instance.hostname = protocol
# 
#             if port is not None:
#                 cls.class_instance.hostname = port
# 
#             if database is not None:
#                 cls.class_instance.database = database
# 
#             if auth is not None:
#                 cls.class_instance.auth = auth
# 
#             cls.class_instance._create_api()
# 
#         return cls.class_instance
# 
#     def collection(self, name):
#         """
#             Returns a collection with the given name
# 
#             :param name Collection name
# 
#             :returns Collection
#         """
# 
#         return Collection(
#             name=name,
#             api_resource=self.api.collection(name),
#             api=self.api,
#         )
# 
# Path: arangodb/query/utils/document.py
# def create_document_from_result_dict(result_dict, api):
#     collection_name = result_dict['_id'].split('/')[0]
# 
#     doc = Document(
#         id=result_dict['_id'],
#         key=result_dict['_key'],
#         rev=result_dict['_rev'],
#         collection=collection_name,
#         api=api,
#     )
# 
#     doc.is_loaded = True
# 
#     del result_dict['_id']
#     del result_dict['_key']
#     del result_dict['_rev']
# 
#     for result_key in result_dict:
#         result_value = result_dict[result_key]
# 
#         doc.set(key=result_key, value=result_value)
# 
#     return doc


# Path: arangodb/query/simple.py
from arangodb.api import Client
from arangodb.query.utils.document import create_document_from_result_dict

        return cls._construct_query(name='remove-by-example',
                                    collection=collection, example=example_data, result=False,
                                    **kwargs)


    @classmethod
    def random(cls, collection):
        """
            Returns a random document from a collection.

            :param collection Collection instance

            :returns document
        """

        return cls._construct_query(name='any', collection=collection)


    @classmethod
    def _construct_query(cls, name, collection, multiple=False, result=True, **kwargs):
        """
        """

        query = {
            'collection': collection.name,
        }

        for arg_name in kwargs:
            query[arg_name] = kwargs[arg_name]


        client = Client.instance()