hydroserverpy 0.2.3__py3-none-any.whl → 0.3.0__py3-none-any.whl
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.
Potentially problematic release.
This version of hydroserverpy might be problematic. Click here for more details.
- hydroserverpy/__init__.py +6 -15
- hydroserverpy/core/endpoints/__init__.py +9 -0
- hydroserverpy/core/endpoints/base.py +133 -0
- hydroserverpy/core/endpoints/data_loaders.py +92 -0
- hydroserverpy/core/endpoints/data_sources.py +92 -0
- hydroserverpy/core/endpoints/datastreams.py +188 -0
- hydroserverpy/core/endpoints/observed_properties.py +93 -0
- hydroserverpy/core/endpoints/processing_levels.py +93 -0
- hydroserverpy/core/endpoints/result_qualifiers.py +93 -0
- hydroserverpy/core/endpoints/sensors.py +93 -0
- hydroserverpy/core/endpoints/things.py +240 -0
- hydroserverpy/core/endpoints/units.py +93 -0
- hydroserverpy/{components → core/schemas}/__init__.py +1 -2
- hydroserverpy/core/schemas/base.py +117 -0
- hydroserverpy/core/schemas/data_loaders.py +71 -0
- hydroserverpy/core/schemas/data_sources.py +206 -0
- hydroserverpy/core/schemas/datastreams.py +299 -0
- hydroserverpy/core/schemas/observed_properties.py +35 -0
- hydroserverpy/core/schemas/processing_levels.py +27 -0
- hydroserverpy/core/schemas/result_qualifiers.py +23 -0
- hydroserverpy/core/schemas/sensors.py +53 -0
- hydroserverpy/core/schemas/things.py +309 -0
- hydroserverpy/core/schemas/units.py +30 -0
- hydroserverpy/core/service.py +186 -0
- hydroserverpy/etl/__init__.py +0 -0
- hydroserverpy/{etl.py → etl/service.py} +32 -47
- hydroserverpy/quality/__init__.py +1 -0
- hydroserverpy/quality/service.py +391 -0
- {hydroserverpy-0.2.3.dist-info → hydroserverpy-0.3.0.dist-info}/METADATA +6 -3
- hydroserverpy-0.3.0.dist-info/RECORD +36 -0
- {hydroserverpy-0.2.3.dist-info → hydroserverpy-0.3.0.dist-info}/WHEEL +1 -1
- hydroserverpy/components/data_loaders.py +0 -67
- hydroserverpy/components/data_sources.py +0 -98
- hydroserverpy/components/datastreams.py +0 -47
- hydroserverpy/components/observed_properties.py +0 -48
- hydroserverpy/components/processing_levels.py +0 -48
- hydroserverpy/components/result_qualifiers.py +0 -48
- hydroserverpy/components/sensors.py +0 -48
- hydroserverpy/components/things.py +0 -48
- hydroserverpy/components/units.py +0 -48
- hydroserverpy/components/users.py +0 -28
- hydroserverpy/main.py +0 -62
- hydroserverpy/models.py +0 -218
- hydroserverpy/schemas/data_loaders.py +0 -27
- hydroserverpy/schemas/data_sources.py +0 -58
- hydroserverpy/schemas/datastreams.py +0 -56
- hydroserverpy/schemas/observed_properties.py +0 -33
- hydroserverpy/schemas/processing_levels.py +0 -33
- hydroserverpy/schemas/result_qualifiers.py +0 -32
- hydroserverpy/schemas/sensors.py +0 -39
- hydroserverpy/schemas/things.py +0 -108
- hydroserverpy/schemas/units.py +0 -32
- hydroserverpy/schemas/users.py +0 -28
- hydroserverpy/service.py +0 -170
- hydroserverpy/utils.py +0 -37
- hydroserverpy-0.2.3.dist-info/RECORD +0 -35
- /hydroserverpy/{schemas → core}/__init__.py +0 -0
- /hydroserverpy/{exceptions.py → etl/exceptions.py} +0 -0
- {hydroserverpy-0.2.3.dist-info → hydroserverpy-0.3.0.dist-info}/LICENSE +0 -0
- {hydroserverpy-0.2.3.dist-info → hydroserverpy-0.3.0.dist-info}/top_level.txt +0 -0
- {hydroserverpy-0.2.3.dist-info → hydroserverpy-0.3.0.dist-info}/zip-safe +0 -0
hydroserverpy/service.py
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import json
|
|
3
|
-
import frost_sta_client as fsc
|
|
4
|
-
from typing import Optional, Union, Tuple
|
|
5
|
-
from pydantic import AnyHttpUrl
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class BaseService:
|
|
9
|
-
|
|
10
|
-
def __init__(
|
|
11
|
-
self,
|
|
12
|
-
host: Union[AnyHttpUrl, str],
|
|
13
|
-
sta_path: str,
|
|
14
|
-
api_path: str,
|
|
15
|
-
auth: Optional[Tuple[str, str]] = None,
|
|
16
|
-
):
|
|
17
|
-
self.host = host.strip('/')
|
|
18
|
-
self.auth = auth
|
|
19
|
-
self.sensorthings = None
|
|
20
|
-
self._sta_path = sta_path.strip('/')
|
|
21
|
-
self._api_path = api_path.strip('/')
|
|
22
|
-
self._session = None
|
|
23
|
-
self._timeout = 60
|
|
24
|
-
self._initialize_session()
|
|
25
|
-
|
|
26
|
-
def _initialize_session(self):
|
|
27
|
-
"""
|
|
28
|
-
The _initialize_session function is used to initialize the session object.
|
|
29
|
-
|
|
30
|
-
:param self
|
|
31
|
-
:return: None
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
if self._session is not None:
|
|
35
|
-
self._session.close()
|
|
36
|
-
|
|
37
|
-
self._session = requests.Session()
|
|
38
|
-
|
|
39
|
-
if self.auth and self.auth[0] == '__token__':
|
|
40
|
-
self._session.headers.update(
|
|
41
|
-
{'Authorization': f'Bearer {self.auth[1]}'}
|
|
42
|
-
)
|
|
43
|
-
elif self.auth:
|
|
44
|
-
self._session.auth = self.auth
|
|
45
|
-
|
|
46
|
-
self.sensorthings = fsc.SensorThingsService(
|
|
47
|
-
url=f'{self.host}/{self._sta_path}',
|
|
48
|
-
auth_handler=fsc.service.auth_handler.AuthHandler(
|
|
49
|
-
username=self.auth[0],
|
|
50
|
-
password=self.auth[1]
|
|
51
|
-
)
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
def _request(self, method, path, *args, **kwargs):
|
|
55
|
-
"""
|
|
56
|
-
The _request function is a helper function that makes it easier to make requests to the API.
|
|
57
|
-
It takes in a method, path, and any other arguments you want to pass into the request.
|
|
58
|
-
The method argument should be one of 'get', 'post', or 'delete'. The path argument should be
|
|
59
|
-
the endpoint you are trying to reach (e.g., '/users/me'). Any additional arguments will be passed
|
|
60
|
-
into the request as-is.
|
|
61
|
-
|
|
62
|
-
:param self
|
|
63
|
-
:param method: Specify the type of request that is being made
|
|
64
|
-
:param path: Specify the path of the request
|
|
65
|
-
:return: A response object
|
|
66
|
-
"""
|
|
67
|
-
|
|
68
|
-
for attempt in range(2):
|
|
69
|
-
try:
|
|
70
|
-
return getattr(self._session, method)(
|
|
71
|
-
f'{self.host}/{self._api_path}/{path.strip("/")}',
|
|
72
|
-
timeout=self._timeout,
|
|
73
|
-
*args, **kwargs
|
|
74
|
-
)
|
|
75
|
-
except requests.exceptions.ConnectionError as e:
|
|
76
|
-
if attempt == 0:
|
|
77
|
-
self._initialize_session()
|
|
78
|
-
continue
|
|
79
|
-
else:
|
|
80
|
-
raise e
|
|
81
|
-
|
|
82
|
-
def get(self, path, response_schema=None, *args, **kwargs):
|
|
83
|
-
"""
|
|
84
|
-
The get function accepts a path and any other arguments that are passed to it,
|
|
85
|
-
and then calls the _request function with the 'get' method. If the request is successful,
|
|
86
|
-
the response content is parsed and added to the response object to be returned.
|
|
87
|
-
|
|
88
|
-
:param self: Represent the instance of the class
|
|
89
|
-
:param path: Specify the url of the request
|
|
90
|
-
:param response_schema: Specify the schema of the response
|
|
91
|
-
:return: A response object
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
response = self._request('get', path, *args, **kwargs)
|
|
95
|
-
|
|
96
|
-
if response.status_code == 200:
|
|
97
|
-
if not response_schema:
|
|
98
|
-
response.data = json.loads(response.content)
|
|
99
|
-
elif getattr(response_schema, '__origin__', None) == list:
|
|
100
|
-
response.data = [
|
|
101
|
-
response_schema.__args__[0](**entity)
|
|
102
|
-
for entity in json.loads(response.content)
|
|
103
|
-
]
|
|
104
|
-
else:
|
|
105
|
-
response.data = response_schema(**json.loads(response.content))
|
|
106
|
-
|
|
107
|
-
else:
|
|
108
|
-
response.data = None
|
|
109
|
-
|
|
110
|
-
return response
|
|
111
|
-
|
|
112
|
-
def post(self, path, response_schema=None, *args, **kwargs):
|
|
113
|
-
"""
|
|
114
|
-
The post function accepts a path and any other arguments that are passed to it,
|
|
115
|
-
and then calls the _request function with the 'post' method. If the request is successful,
|
|
116
|
-
the response content is parsed and added to the response object to be returned.
|
|
117
|
-
|
|
118
|
-
:param self: Represent the instance of the class
|
|
119
|
-
:param path: Specify the url of the request
|
|
120
|
-
:param response_schema: Specify the schema of the response
|
|
121
|
-
:return: A response object
|
|
122
|
-
"""
|
|
123
|
-
|
|
124
|
-
response = self._request('post', path, *args, **kwargs)
|
|
125
|
-
|
|
126
|
-
if response.status_code == 201:
|
|
127
|
-
if not response_schema:
|
|
128
|
-
response.data = json.loads(response.content)
|
|
129
|
-
else:
|
|
130
|
-
response.data = response_schema(**json.loads(response.content))
|
|
131
|
-
else:
|
|
132
|
-
response.data = None
|
|
133
|
-
|
|
134
|
-
return response
|
|
135
|
-
|
|
136
|
-
def patch(self, path, response_schema=None, *args, **kwargs):
|
|
137
|
-
"""
|
|
138
|
-
The patch function accepts a path and any other arguments that are passed to it,
|
|
139
|
-
and then calls the _request function with the 'patch' method. If the request is successful,
|
|
140
|
-
the response content is parsed and added to the response object to be returned.
|
|
141
|
-
|
|
142
|
-
:param self: Represent the instance of the class
|
|
143
|
-
:param path: Specify the url of the request
|
|
144
|
-
:param response_schema: Specify the schema of the response
|
|
145
|
-
:return: A response object
|
|
146
|
-
"""
|
|
147
|
-
|
|
148
|
-
response = self._request('patch', path, *args, **kwargs)
|
|
149
|
-
|
|
150
|
-
if response.status_code == 203:
|
|
151
|
-
if not response_schema:
|
|
152
|
-
response.data = json.loads(response.content)
|
|
153
|
-
else:
|
|
154
|
-
response.data = response_schema(**json.loads(response.content))
|
|
155
|
-
else:
|
|
156
|
-
response.data = None
|
|
157
|
-
|
|
158
|
-
return response
|
|
159
|
-
|
|
160
|
-
def delete(self, path, *args, **kwargs):
|
|
161
|
-
"""
|
|
162
|
-
The patch function accepts a path and any other arguments that are passed to it,
|
|
163
|
-
and then calls the _request function with the 'delete' method.
|
|
164
|
-
|
|
165
|
-
:param self: Represent the instance of the class
|
|
166
|
-
:param path: Specify the url of the request
|
|
167
|
-
:return: A response object
|
|
168
|
-
"""
|
|
169
|
-
|
|
170
|
-
return self._request('delete', path, *args, **kwargs)
|
hydroserverpy/utils.py
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import inspect
|
|
2
|
-
from pydantic import BaseModel
|
|
3
|
-
from typing import Callable
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def allow_partial(*fields) -> Callable:
|
|
7
|
-
"""
|
|
8
|
-
The allow_partial function is a decorator that allows you to mark fields as not required.
|
|
9
|
-
This means that the field will be allowed to be missing from the input data, and if it is missing,
|
|
10
|
-
the default value for the field will be used instead. This can also be done by setting required=False on each field.
|
|
11
|
-
|
|
12
|
-
:return: A decorator that can be applied to a class
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
def dec(_cls):
|
|
16
|
-
for field in fields:
|
|
17
|
-
_cls.__fields__[field].required = False
|
|
18
|
-
return _cls
|
|
19
|
-
|
|
20
|
-
if fields and inspect.isclass(fields[0]) and issubclass(fields[0], BaseModel):
|
|
21
|
-
cls = fields[0]
|
|
22
|
-
fields = cls.__fields__
|
|
23
|
-
return dec(cls)
|
|
24
|
-
|
|
25
|
-
return dec
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def entity_path(self, entity_id):
|
|
29
|
-
"""
|
|
30
|
-
The entity_path function returns the path to a specific entity.
|
|
31
|
-
|
|
32
|
-
:param self: Represent the instance of the class
|
|
33
|
-
:param entity_id: Specify the entity id of the entity to be retrieved
|
|
34
|
-
:return: The entity type and the id of the entity
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
|
-
return "{}({})".format(self.entitytype_plural, entity_id)
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
hydroserverpy/__init__.py,sha256=iZcBLrXpuWr7SYUIgIT3ngDKcI63LgfRNCwCIiv_CW4,616
|
|
2
|
-
hydroserverpy/etl.py,sha256=3cczra-7m1WxdHXm3yZO3hlz-OkWUJdQkA8mdhF8bi0,13229
|
|
3
|
-
hydroserverpy/exceptions.py,sha256=0UY8YUlNepG0y6FfH36hJyR1bOhwYHSZIdUSSMTg7GA,314
|
|
4
|
-
hydroserverpy/main.py,sha256=UD8l4wFvJbLWA07r0kR5tYPW3dnD7OCQoB4PJVpHkeo,1421
|
|
5
|
-
hydroserverpy/models.py,sha256=IxQrSEHM344Bn6qtwjGFdY7bqyH_-lc8TJggVqDsvdg,8174
|
|
6
|
-
hydroserverpy/service.py,sha256=wMuOi4TwZbaB0kPgTOzdfP0HLwmlHTVREuksyxJJ1YQ,6150
|
|
7
|
-
hydroserverpy/utils.py,sha256=VWnd1ffMaiQDVNAKBCr3HhiWMe1YxAmbkb7UNcHSA6k,1173
|
|
8
|
-
hydroserverpy/components/__init__.py,sha256=raT0GabQrFf6lHRW0nm0GYbnQgpScP6FocKCFWwii3w,356
|
|
9
|
-
hydroserverpy/components/data_loaders.py,sha256=83a4oYNGxn5QkJmiOPbk0cx713RvNpyoBSz9genWu3M,2066
|
|
10
|
-
hydroserverpy/components/data_sources.py,sha256=UEdTBU2V5HWqptVk7eZWpKon0osDhq99CgHV7foan6k,3262
|
|
11
|
-
hydroserverpy/components/datastreams.py,sha256=rXdKjSH21IT6cVY3kP0GWS22CYL0I3oeZaInzqwju3w,1365
|
|
12
|
-
hydroserverpy/components/observed_properties.py,sha256=D2yvdDgJc4cNr5H73kb1QZ4Ju4IcsrBubp-4yYn8_fA,1551
|
|
13
|
-
hydroserverpy/components/processing_levels.py,sha256=0bVYp3WJv3MaBz_mqCNirHMu25W6pVg4u0THbTHElVs,1518
|
|
14
|
-
hydroserverpy/components/result_qualifiers.py,sha256=JmAF1gfSz0mPtXHptWxaZvlTonZ363-bBwXwiKAjgX4,1522
|
|
15
|
-
hydroserverpy/components/sensors.py,sha256=V6tQi4i4Amoy1o0HFYx-YdELVfQQomJV4hzdUsvj38I,1268
|
|
16
|
-
hydroserverpy/components/things.py,sha256=-XCkoQj_VdvADGOwbi6czjr6vCdaXhFEZhPvmClG4bw,1246
|
|
17
|
-
hydroserverpy/components/units.py,sha256=2nHmJgd97loHjh6jt84PQPjD7XzztECWbCr4o8VwHD8,1216
|
|
18
|
-
hydroserverpy/components/users.py,sha256=jpZ6TGOImK_j3ghwTFoAxpD9WMBG9DzIC0vcsb2G1w0,622
|
|
19
|
-
hydroserverpy/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
-
hydroserverpy/schemas/data_loaders.py,sha256=5YIXryh1LaVgjRetruyZHvBivsCS1XqOnT6lbcMCIMg,459
|
|
21
|
-
hydroserverpy/schemas/data_sources.py,sha256=cYnhKUaKqirhJjxo9niSgtOdokv98Fah635rOywosAE,2053
|
|
22
|
-
hydroserverpy/schemas/datastreams.py,sha256=wOY3O8UBLjfJXlVJI18rkcPNFApGDteKmFGsCbCv4s4,2266
|
|
23
|
-
hydroserverpy/schemas/observed_properties.py,sha256=-DpFuo4UYY5dx7mAxRSyN6EqjHGp9-CT5AapzSOE2RQ,698
|
|
24
|
-
hydroserverpy/schemas/processing_levels.py,sha256=MWy7fRIP-hDJtjwmSB1PK27agx9U2UFpjhl5lrYMIHA,686
|
|
25
|
-
hydroserverpy/schemas/result_qualifiers.py,sha256=m2OfJHefO1jFfRqV-Klgv6b50jOM0X1UtNCrSon3Znc,652
|
|
26
|
-
hydroserverpy/schemas/sensors.py,sha256=mUilTxc61zkrL2GULhJTO-q3P58Rkh2leHyCSZl1-Ug,918
|
|
27
|
-
hydroserverpy/schemas/things.py,sha256=kolNbZ-JxNcIK3uNXBCNy7k1BTDbTpjlHa3v_YPrQvU,3359
|
|
28
|
-
hydroserverpy/schemas/units.py,sha256=_28zmCz9TDuNfHa4Ycj1RKkxwUB_J832NSWIO3cBK9k,550
|
|
29
|
-
hydroserverpy/schemas/users.py,sha256=TauiaArJ4LVjAKq80KvjKjxex5DAwQekc_nDXHyaU3U,675
|
|
30
|
-
hydroserverpy-0.2.3.dist-info/LICENSE,sha256=xVqFxDw3QOEJukakL7gQCqIMTQ1dlSCTo6Oc1otNW80,1508
|
|
31
|
-
hydroserverpy-0.2.3.dist-info/METADATA,sha256=M7f0ECACJA2u6EVhnGJseeEyhbHw7HtqQ6S3zO-lIZY,419
|
|
32
|
-
hydroserverpy-0.2.3.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
|
33
|
-
hydroserverpy-0.2.3.dist-info/top_level.txt,sha256=Zf37hrncXLOYvXhgCrf5mZdeq81G9fShdE2LfYbtb7w,14
|
|
34
|
-
hydroserverpy-0.2.3.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
35
|
-
hydroserverpy-0.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|