# 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,
#         )


from arangodb.api import Client


class Endpoint(object):
    """
        Class to manage endpoints on which the server is listening
    """

    @classmethod
    def all(cls):
        """
            Returns a list of all configured endpoints the server is listening on. For each endpoint,
            the list of allowed databases is returned too if set.

            The result is a JSON hash which has the endpoints as keys, and the list of
            mapped database names as values for each endpoint.

            If a list of mapped databases is empty, it means that all databases can be accessed via the endpoint.
            If a list of mapped databases contains more than one database name, this means that any of the
            databases might be accessed via the endpoint, and the first database in the list will be treated
            as the default database for the endpoint. The default database will be used when an incoming request
            does not specify a database name in the request explicitly.

            *Note*: retrieving the list of all endpoints is allowed in the system database only.
            Calling this action in any other database will make the server return an error.
        """


# 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/server/endpoint.py
from arangodb.api import Client



class Endpoint(object):
    """
        Class to manage endpoints on which the server is listening
    """

    @classmethod
    def all(cls):
        """
            Returns a list of all configured endpoints the server is listening on. For each endpoint,
            the list of allowed databases is returned too if set.

            The result is a JSON hash which has the endpoints as keys, and the list of
            mapped database names as values for each endpoint.

            If a list of mapped databases is empty, it means that all databases can be accessed via the endpoint.
            If a list of mapped databases contains more than one database name, this means that any of the
            databases might be accessed via the endpoint, and the first database in the list will be treated
            as the default database for the endpoint. The default database will be used when an incoming request
            does not specify a database name in the request explicitly.

            *Note*: retrieving the list of all endpoints is allowed in the system database only.
            Calling this action in any other database will make the server return an error.
        """


        api = Client.instance().api