elementapi 0.4__tar.gz → 0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {elementapi-0.4 → elementapi-0.6}/PKG-INFO +1 -1
- {elementapi-0.4 → elementapi-0.6}/elementapi/__init__.py +31 -8
- {elementapi-0.4 → elementapi-0.6}/elementapi.egg-info/PKG-INFO +1 -1
- {elementapi-0.4 → elementapi-0.6}/setup.py +1 -1
- {elementapi-0.4 → elementapi-0.6}/elementapi.egg-info/SOURCES.txt +0 -0
- {elementapi-0.4 → elementapi-0.6}/elementapi.egg-info/dependency_links.txt +0 -0
- {elementapi-0.4 → elementapi-0.6}/elementapi.egg-info/requires.txt +0 -0
- {elementapi-0.4 → elementapi-0.6}/elementapi.egg-info/top_level.txt +0 -0
- {elementapi-0.4 → elementapi-0.6}/setup.cfg +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
try:
|
|
2
|
-
import
|
|
3
|
-
except:
|
|
4
|
-
|
|
2
|
+
import orjson as json
|
|
3
|
+
except ImportError:
|
|
4
|
+
try:
|
|
5
|
+
import ujson as json
|
|
6
|
+
except:
|
|
7
|
+
import json
|
|
5
8
|
|
|
6
9
|
import logging
|
|
7
10
|
import re
|
|
@@ -33,7 +36,7 @@ class ElementAPIException(Exception):
|
|
|
33
36
|
)
|
|
34
37
|
|
|
35
38
|
def __repr__(self):
|
|
36
|
-
|
|
39
|
+
return self._str()
|
|
37
40
|
|
|
38
41
|
def __str__(self):
|
|
39
42
|
return self._str()
|
|
@@ -54,7 +57,6 @@ def get_body(resp):
|
|
|
54
57
|
return r
|
|
55
58
|
|
|
56
59
|
|
|
57
|
-
|
|
58
60
|
class ElementAPI:
|
|
59
61
|
apitoken = None
|
|
60
62
|
baseurl = "element-iot.com"
|
|
@@ -63,9 +65,22 @@ class ElementAPI:
|
|
|
63
65
|
apiversion = "/"
|
|
64
66
|
sync = False
|
|
65
67
|
proxies = None
|
|
68
|
+
custom_ca = None
|
|
69
|
+
https_no_verify = False
|
|
66
70
|
headers = {'Accept': 'application/json'}
|
|
67
71
|
|
|
68
|
-
def __init__(
|
|
72
|
+
def __init__(
|
|
73
|
+
self,
|
|
74
|
+
apitoken,
|
|
75
|
+
baseurl=None,
|
|
76
|
+
https=True,
|
|
77
|
+
port=None,
|
|
78
|
+
apiversion=1,
|
|
79
|
+
sync=False,
|
|
80
|
+
proxies=None,
|
|
81
|
+
custom_ca=None,
|
|
82
|
+
https_no_verify=False
|
|
83
|
+
):
|
|
69
84
|
if baseurl:
|
|
70
85
|
self.baseurl = baseurl
|
|
71
86
|
|
|
@@ -87,12 +102,20 @@ class ElementAPI:
|
|
|
87
102
|
elif type(proxies) is str:
|
|
88
103
|
# TODO: check if string ?
|
|
89
104
|
self.proxies = {'http%s' % ('s' if https else ''): proxies}
|
|
90
|
-
|
|
105
|
+
|
|
106
|
+
self.custom_ca = custom_ca
|
|
107
|
+
self.https_no_verify = https_no_verify
|
|
108
|
+
|
|
91
109
|
self.requestargs = {
|
|
92
110
|
'headers': self.headers,
|
|
93
111
|
'proxies': self.proxies
|
|
94
112
|
}
|
|
95
113
|
|
|
114
|
+
if self.custom_ca:
|
|
115
|
+
self.requestargs['verify'] = self.custom_ca
|
|
116
|
+
|
|
117
|
+
if self.https_no_verify:
|
|
118
|
+
self.requestargs['verify'] = False
|
|
96
119
|
|
|
97
120
|
# TODO: allow plain string paths !
|
|
98
121
|
def genurl(self, _path=None, **opts):
|
|
@@ -167,7 +190,7 @@ class ElementAPI:
|
|
|
167
190
|
|
|
168
191
|
if resp.status_code >= 400:
|
|
169
192
|
if resp.status_code == 429 and not raise_rl:
|
|
170
|
-
# hit
|
|
193
|
+
# hit create-limit
|
|
171
194
|
|
|
172
195
|
# sleep|block
|
|
173
196
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|