Ejemplo n.º 1
0
    def test_post(self):
        edge = Edge(Mock())
        edge.make_request = Mock()
        edge.post({'doc': 1})

        edge.make_request.assert_called_once_with(method='POST',
                                                  uri='edges',
                                                  data={'doc': 1})
Ejemplo n.º 2
0
 def generate_auth(self):
     LOGGER.info('New Auth')
     self.auth = auth.Auth(
         api_url=GLOBOMAP_API_URL,
         username=GLOBOMAP_API_USERNAME,
         password=GLOBOMAP_API_PASSWORD
     )
     self.coll = Collection(auth=self.auth)
     self.edge = Edge(auth=self.auth)
Ejemplo n.º 3
0
    def test_search_with_pagination(self):
        edge = Edge(Mock())
        edge.make_request = Mock()
        query = [[{'field': 'name', 'operator': 'LIKE', 'value': 'test'}]]
        edge.search(query, 20, 2)

        params = {'query': json.dumps(query), 'per_page': 20, 'page': 2}
        edge.make_request.assert_called_once_with(method='GET',
                                                  uri='edges',
                                                  params=params)
Ejemplo n.º 4
0
    def test_list_with_pagination(self):
        edge = Edge(Mock())
        edge.make_request = Mock()
        edge.list(page=2, per_page=20)

        edge.make_request.assert_called_once_with(method='GET',
                                                  params={
                                                      'per_page': 20,
                                                      'page': 2
                                                  },
                                                  uri='edges')
Ejemplo n.º 5
0
    def test_list(self):
        edge = Edge(Mock())
        edge.make_request = Mock()
        edge.list()

        edge.make_request.assert_called_once_with(method='GET',
                                                  params={
                                                      'per_page': 10,
                                                      'page': 1
                                                  },
                                                  uri='edges')
Ejemplo n.º 6
0
class GloboMapClient(object):

    def __init__(self):
        self.generate_auth()

    def generate_auth(self):
        LOGGER.info('New Auth')
        self.auth = auth.Auth(
            api_url=GLOBOMAP_API_URL,
            username=GLOBOMAP_API_USERNAME,
            password=GLOBOMAP_API_PASSWORD
        )
        self.coll = Collection(auth=self.auth)
        self.edge = Edge(auth=self.auth)

    def get_collections(self, user):
        query = [[{'field': 'users', 'operator': 'IN', 'value': user}]]
        return self.coll.search(query, page=1, per_page=100)

    def get_edges(self, user):
        query = [[{'field': 'users', 'operator': 'IN', 'value': user}]]
        return self.edge.search(query, page=1, per_page=100)
Ejemplo n.º 7
0
import os
from globomap_api_client.auth import Auth
from globomap_api_client.collection import Collection
from globomap_api_client.edge import Edge
from globomap_api_client.graph import Graph
from globomap_api_client.query import Query

GMAP_API_PORT = os.getenv('GMAP_API_PORT', '7002')

auth_inst = Auth(api_url='http://localhost:{}'.format(GMAP_API_PORT),
                 username='******',
                 password='******')
coll = Collection(auth=auth_inst)
edge = Edge(auth=auth_inst)
graph = Graph(auth=auth_inst)
query = Query(auth=auth_inst)
coll.post({
    'name': 'vip',
    'alias': 'vip',
    'icon': 'icon',
})
coll.post({
    'name': 'vm',
    'alias': 'vm',
    'icon': 'icon',
})
coll.post({
    'name': 'network',
    'alias': 'network',
    'icon': 'icon',
})