forked from Scala-Dev/exp-python2-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
103 lines (69 loc) · 2.55 KB
/
Copy path__init__.py
File metadata and controls
103 lines (69 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import urllib
from .. lib import api_utils
from .. lib.models.device import Device
from .. lib.models.location import Location
from .. lib.models.experience import Experience
from .. lib.models.content import Content
from .. lib.models.data import Data
from .. lib.models.thing import Thing
from .. lib.models.feed import Feed
""" Content """
def get_content(uuid):
return Content(
api_utils.get("/api/content/" + uuid + "/children"),
_is_children_populated=True)
""" Devices """
def find_devices(**params):
query = api_utils.get('/api/devices', params=params)
empty = []
return [Device(x, _new=False) for x in query.get("results", empty)]
def get_device(uuid):
return Device(api_utils.get('/api/devices/' + uuid), _new=False)
def create_device(document):
return Device(document).save()
""" Things """
def find_things(**params):
query = api_utils.get('/api/things', params=params)
empty = []
return [Thing(x, _new=False) for x in query.get("results", empty)]
def get_thing(uuid):
return Thing(api_utils.get('/api/things/' + uuid), _new=False)
def create_thing(document):
return Thing(document).save()
""" Experiences """
def find_experiences(**params):
query = api_utils.get('/api/experiences', params=params)
empty = []
return [Experience(x, _new=False) for x in query.get("results", empty)]
def get_experience(uuid):
return Experience(api_utils.get('/api/experiences/' + uuid), _new=False)
def create_experience(document):
return Experience(document).save()
""" Locations """
def find_locations(**params):
query = api_utils.get('/api/locations', params=params)
empty = []
return [Location(x, _new=False) for x in query.get("results", empty)]
def get_location(uuid):
return Location(api_utils.get('/api/locations/' + uuid), _new=False)
def create_location(document):
return Location(document).save()
""" Data """
def get_data(key, group):
key = urllib.quote(key, safe='')
group = urllib.quote(group, safe='')
return Data(**api_utils.get('/api/data/' + group + '/' + key))
def find_data(**params):
query = api_utils.get('/api/data', params=params)
return [Data(**x) for x in query.get('results', [])]
def create_data(**params):
return Data(**params).save()
""" Feeds """
def find_feeds(**params):
query = api_utils.get('/api/connectors/feeds', params=params)
empty = []
return [Feed(x, _new=False) for x in query.get("results", empty)]
def get_feed(uuid):
return Feed(api_utils.get('/api/connectors/feeds/' + uuid), _new=False)
def create_feed(document):
return Feed(document).save()