hydroserverpy 0.3.0__py3-none-any.whl → 0.4.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 +1 -1
- hydroserverpy/core/endpoints/base.py +44 -31
- hydroserverpy/core/endpoints/data_loaders.py +6 -5
- hydroserverpy/core/endpoints/data_sources.py +6 -5
- hydroserverpy/core/endpoints/datastreams.py +89 -52
- hydroserverpy/core/endpoints/observed_properties.py +36 -18
- hydroserverpy/core/endpoints/processing_levels.py +36 -18
- hydroserverpy/core/endpoints/result_qualifiers.py +37 -19
- hydroserverpy/core/endpoints/sensors.py +37 -19
- hydroserverpy/core/endpoints/things.py +58 -37
- hydroserverpy/core/endpoints/units.py +37 -19
- hydroserverpy/core/schemas/base.py +13 -6
- hydroserverpy/core/schemas/data_loaders.py +6 -4
- hydroserverpy/core/schemas/data_sources.py +73 -56
- hydroserverpy/core/schemas/datastreams.py +101 -70
- hydroserverpy/core/schemas/observed_properties.py +18 -10
- hydroserverpy/core/schemas/processing_levels.py +10 -6
- hydroserverpy/core/schemas/result_qualifiers.py +7 -4
- hydroserverpy/core/schemas/sensors.py +33 -18
- hydroserverpy/core/schemas/things.py +97 -60
- hydroserverpy/core/schemas/units.py +7 -8
- hydroserverpy/core/service.py +31 -17
- hydroserverpy/etl/__init__.py +21 -0
- hydroserverpy/etl/extractors/__init__.py +0 -0
- hydroserverpy/etl/extractors/base.py +13 -0
- hydroserverpy/etl/extractors/ftp_extractor.py +50 -0
- hydroserverpy/etl/extractors/http_extractor.py +84 -0
- hydroserverpy/etl/extractors/local_file_extractor.py +25 -0
- hydroserverpy/etl/hydroserver_etl.py +40 -0
- hydroserverpy/etl/loaders/__init__.py +0 -0
- hydroserverpy/etl/loaders/base.py +13 -0
- hydroserverpy/etl/loaders/hydroserver_loader.py +68 -0
- hydroserverpy/etl/transformers/__init__.py +0 -0
- hydroserverpy/etl/transformers/base.py +52 -0
- hydroserverpy/etl/transformers/csv_transformer.py +88 -0
- hydroserverpy/etl/transformers/json_transformer.py +62 -0
- hydroserverpy/etl/types.py +7 -0
- hydroserverpy/etl_csv/__init__.py +0 -0
- hydroserverpy/{etl/service.py → etl_csv/hydroserver_etl_csv.py} +92 -54
- hydroserverpy/quality/service.py +84 -70
- hydroserverpy-0.4.0.dist-info/METADATA +18 -0
- hydroserverpy-0.4.0.dist-info/RECORD +51 -0
- {hydroserverpy-0.3.0.dist-info → hydroserverpy-0.4.0.dist-info}/WHEEL +1 -1
- hydroserverpy-0.3.0.dist-info/METADATA +0 -18
- hydroserverpy-0.3.0.dist-info/RECORD +0 -36
- /hydroserverpy/{etl → etl_csv}/exceptions.py +0 -0
- {hydroserverpy-0.3.0.dist-info → hydroserverpy-0.4.0.dist-info}/LICENSE +0 -0
- {hydroserverpy-0.3.0.dist-info → hydroserverpy-0.4.0.dist-info}/top_level.txt +0 -0
- {hydroserverpy-0.3.0.dist-info → hydroserverpy-0.4.0.dist-info}/zip-safe +0 -0
hydroserverpy/__init__.py
CHANGED
|
@@ -6,23 +6,26 @@ if TYPE_CHECKING:
|
|
|
6
6
|
from hydroserverpy import HydroServer
|
|
7
7
|
from hydroserverpy.core.schemas.base import HydroServerCoreModel
|
|
8
8
|
|
|
9
|
-
HydroServerModelType = TypeVar(
|
|
9
|
+
HydroServerModelType = TypeVar("HydroServerModelType", bound=HydroServerCoreModel)
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def expand_docstring(
|
|
12
|
+
def expand_docstring(
|
|
13
|
+
model: Optional[Type["HydroServerCoreModel"]] = None, include_uid: bool = False
|
|
14
|
+
):
|
|
13
15
|
def decorator(func):
|
|
14
16
|
docstring = func.__doc__
|
|
15
17
|
if model is not None or include_uid is True:
|
|
16
|
-
docstring +=
|
|
18
|
+
docstring += "\n"
|
|
17
19
|
if include_uid is True:
|
|
18
|
-
docstring += f
|
|
19
|
-
docstring += f
|
|
20
|
+
docstring += f":param uid: The entity ID.\n"
|
|
21
|
+
docstring += f":type uid: Union[UUID, str]\n"
|
|
20
22
|
if model is not None:
|
|
21
23
|
for field_name, field in model.model_fields.items():
|
|
22
|
-
docstring += f
|
|
24
|
+
docstring += f":param {field_name}: {field.description}\n"
|
|
23
25
|
docstring += f':type {field_name}: {getattr(field.annotation, "__name__", field.annotation)}\n'
|
|
24
26
|
func.__doc__ = docstring
|
|
25
27
|
return func
|
|
28
|
+
|
|
26
29
|
return decorator
|
|
27
30
|
|
|
28
31
|
|
|
@@ -35,11 +38,11 @@ class HydroServerEndpoint:
|
|
|
35
38
|
:ivar _endpoint_route: The specific route of the endpoint.
|
|
36
39
|
"""
|
|
37
40
|
|
|
38
|
-
_model: Type[
|
|
41
|
+
_model: Type["HydroServerCoreModel"]
|
|
39
42
|
_api_route: str
|
|
40
43
|
_endpoint_route: str
|
|
41
44
|
|
|
42
|
-
def __init__(self, service:
|
|
45
|
+
def __init__(self, service: "HydroServer") -> None:
|
|
43
46
|
"""
|
|
44
47
|
Initialize the HydroServerEndpoint.
|
|
45
48
|
|
|
@@ -49,9 +52,9 @@ class HydroServerEndpoint:
|
|
|
49
52
|
|
|
50
53
|
self._service = service
|
|
51
54
|
|
|
52
|
-
def _get(
|
|
53
|
-
|
|
54
|
-
]:
|
|
55
|
+
def _get(
|
|
56
|
+
self, uid: Optional[Union[UUID, str]] = None, params: dict = None
|
|
57
|
+
) -> Union[List["HydroServerModelType"], "HydroServerModelType"]:
|
|
55
58
|
"""
|
|
56
59
|
Fetch an entity collection or single entity from a HydroServer endpoint.
|
|
57
60
|
|
|
@@ -65,20 +68,22 @@ class HydroServerEndpoint:
|
|
|
65
68
|
params = {}
|
|
66
69
|
|
|
67
70
|
path = f'{self._api_route}/data/{self._endpoint_route}{"/" + str(uid) if uid else ""}'
|
|
68
|
-
response = getattr(self._service,
|
|
71
|
+
response = getattr(self._service, "_request")("get", path, params=params)
|
|
69
72
|
|
|
70
73
|
if uid:
|
|
71
74
|
entity = json.loads(response.content)
|
|
72
|
-
result = self._model(
|
|
75
|
+
result = self._model(
|
|
76
|
+
_endpoint=self, _uid=UUID(str(entity.pop("id"))), **entity
|
|
77
|
+
)
|
|
73
78
|
else:
|
|
74
79
|
result = [
|
|
75
|
-
self._model(_endpoint=self, _uid=UUID(str(entity.pop(
|
|
80
|
+
self._model(_endpoint=self, _uid=UUID(str(entity.pop("id"))), **entity)
|
|
76
81
|
for entity in json.loads(response.content)
|
|
77
82
|
]
|
|
78
83
|
|
|
79
84
|
return result
|
|
80
85
|
|
|
81
|
-
def _post(self, **kwargs) ->
|
|
86
|
+
def _post(self, **kwargs) -> "HydroServerModelType":
|
|
82
87
|
"""
|
|
83
88
|
Create a new entity using the endpoint.
|
|
84
89
|
|
|
@@ -87,16 +92,19 @@ class HydroServerEndpoint:
|
|
|
87
92
|
:rtype: HydroServerModelType
|
|
88
93
|
"""
|
|
89
94
|
|
|
90
|
-
response = getattr(self._service,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
response = getattr(self._service, "_request")(
|
|
96
|
+
"post",
|
|
97
|
+
f"{self._api_route}/data/{self._endpoint_route}",
|
|
98
|
+
headers={"Content-type": "application/json"},
|
|
99
|
+
data=self._model(_endpoint=self, **kwargs).json(
|
|
100
|
+
exclude_unset=True, by_alias=True
|
|
101
|
+
),
|
|
94
102
|
)
|
|
95
103
|
entity = json.loads(response.content)
|
|
96
104
|
|
|
97
|
-
return self._model(_endpoint=self, _uid=UUID(str(entity.pop(
|
|
105
|
+
return self._model(_endpoint=self, _uid=UUID(str(entity.pop("id"))), **entity)
|
|
98
106
|
|
|
99
|
-
def _patch(self, uid: Union[UUID, str], **kwargs) ->
|
|
107
|
+
def _patch(self, uid: Union[UUID, str], **kwargs) -> "HydroServerModelType":
|
|
100
108
|
"""
|
|
101
109
|
Update an existing entity in the endpoint.
|
|
102
110
|
|
|
@@ -107,17 +115,21 @@ class HydroServerEndpoint:
|
|
|
107
115
|
:rtype: HydroServerModelType
|
|
108
116
|
"""
|
|
109
117
|
|
|
110
|
-
response = getattr(self._service,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
response = getattr(self._service, "_request")(
|
|
119
|
+
"patch",
|
|
120
|
+
f"{self._api_route}/data/{self._endpoint_route}/{str(uid)}",
|
|
121
|
+
headers={"Content-type": "application/json"},
|
|
122
|
+
data=json.dumps(
|
|
123
|
+
{
|
|
124
|
+
self._model.model_fields[key].serialization_alias: value
|
|
125
|
+
for key, value in kwargs.items()
|
|
126
|
+
},
|
|
127
|
+
default=str,
|
|
128
|
+
),
|
|
117
129
|
)
|
|
118
130
|
entity = json.loads(response.content)
|
|
119
131
|
|
|
120
|
-
return self._model(_endpoint=self, _uid=UUID(str(entity.pop(
|
|
132
|
+
return self._model(_endpoint=self, _uid=UUID(str(entity.pop("id"))), **entity)
|
|
121
133
|
|
|
122
134
|
def _delete(self, uid: Union[UUID, str]) -> None:
|
|
123
135
|
"""
|
|
@@ -128,6 +140,7 @@ class HydroServerEndpoint:
|
|
|
128
140
|
:returns: None
|
|
129
141
|
"""
|
|
130
142
|
|
|
131
|
-
getattr(self._service,
|
|
132
|
-
|
|
143
|
+
getattr(self._service, "_request")(
|
|
144
|
+
"delete",
|
|
145
|
+
f"{self._api_route}/data/{self._endpoint_route}/{str(uid)}",
|
|
133
146
|
)
|
|
@@ -18,7 +18,7 @@ class DataLoaderEndpoint(HydroServerEndpoint):
|
|
|
18
18
|
:ivar _endpoint_route: The specific route of the endpoint, set to `'data-loaders'`.
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
|
-
def __init__(self, service:
|
|
21
|
+
def __init__(self, service: "HydroServer") -> None:
|
|
22
22
|
"""
|
|
23
23
|
Initialize the DataLoaderEndpoint.
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ class DataLoaderEndpoint(HydroServerEndpoint):
|
|
|
29
29
|
super().__init__(service)
|
|
30
30
|
self._model = DataLoader
|
|
31
31
|
self._api_route = self._service.api_route
|
|
32
|
-
self._endpoint_route =
|
|
32
|
+
self._endpoint_route = "data-loaders"
|
|
33
33
|
|
|
34
34
|
def list(self) -> List[DataLoader]:
|
|
35
35
|
"""
|
|
@@ -80,13 +80,14 @@ class DataLoaderEndpoint(HydroServerEndpoint):
|
|
|
80
80
|
:rtype: List[DataSource]
|
|
81
81
|
"""
|
|
82
82
|
|
|
83
|
-
response = getattr(self._service,
|
|
84
|
-
|
|
83
|
+
response = getattr(self._service, "_request")(
|
|
84
|
+
"get",
|
|
85
|
+
f"{self._api_route}/data/{self._endpoint_route}/{str(uid)}/data-sources",
|
|
85
86
|
)
|
|
86
87
|
|
|
87
88
|
endpoint = DataSourceEndpoint(self._service)
|
|
88
89
|
|
|
89
90
|
return [
|
|
90
|
-
DataSource(_endpoint=endpoint, _uid=UUID(str(entity.pop(
|
|
91
|
+
DataSource(_endpoint=endpoint, _uid=UUID(str(entity.pop("id"))), **entity)
|
|
91
92
|
for entity in json.loads(response.content)
|
|
92
93
|
]
|
|
@@ -18,7 +18,7 @@ class DataSourceEndpoint(HydroServerEndpoint):
|
|
|
18
18
|
:ivar _endpoint_route: The specific route of the endpoint, set to `'data-sources'`.
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
|
-
def __init__(self, service:
|
|
21
|
+
def __init__(self, service: "HydroServer") -> None:
|
|
22
22
|
"""
|
|
23
23
|
Initialize the DataSourceEndpoint.
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ class DataSourceEndpoint(HydroServerEndpoint):
|
|
|
29
29
|
super().__init__(service)
|
|
30
30
|
self._model = DataSource
|
|
31
31
|
self._api_route = self._service.api_route
|
|
32
|
-
self._endpoint_route =
|
|
32
|
+
self._endpoint_route = "data-sources"
|
|
33
33
|
|
|
34
34
|
def list(self) -> List[DataSource]:
|
|
35
35
|
"""
|
|
@@ -80,13 +80,14 @@ class DataSourceEndpoint(HydroServerEndpoint):
|
|
|
80
80
|
:rtype: List[Datastream]
|
|
81
81
|
"""
|
|
82
82
|
|
|
83
|
-
response = getattr(self._service,
|
|
84
|
-
|
|
83
|
+
response = getattr(self._service, "_request")(
|
|
84
|
+
"get",
|
|
85
|
+
f"{self._api_route}/data/{self._endpoint_route}/{str(uid)}/datastreams",
|
|
85
86
|
)
|
|
86
87
|
|
|
87
88
|
endpoint = DatastreamEndpoint(self._service)
|
|
88
89
|
|
|
89
90
|
return [
|
|
90
|
-
Datastream(_endpoint=endpoint, _uid=UUID(str(entity.pop(
|
|
91
|
+
Datastream(_endpoint=endpoint, _uid=UUID(str(entity.pop("id"))), **entity)
|
|
91
92
|
for entity in json.loads(response.content)
|
|
92
93
|
]
|
|
@@ -30,9 +30,11 @@ class DatastreamEndpoint(HydroServerEndpoint):
|
|
|
30
30
|
super().__init__(service)
|
|
31
31
|
self._model = Datastream
|
|
32
32
|
self._api_route = self._service.api_route
|
|
33
|
-
self._endpoint_route =
|
|
33
|
+
self._endpoint_route = "datastreams"
|
|
34
34
|
|
|
35
|
-
def list(
|
|
35
|
+
def list(
|
|
36
|
+
self, owned_only: bool = False, primary_owned_only: bool = False
|
|
37
|
+
) -> List[Datastream]:
|
|
36
38
|
"""
|
|
37
39
|
Retrieve a collection of datastreams owned by the logged-in user.
|
|
38
40
|
|
|
@@ -40,10 +42,12 @@ class DatastreamEndpoint(HydroServerEndpoint):
|
|
|
40
42
|
:param primary_owned_only: Only list datastreams primary owned by the logged-in user.
|
|
41
43
|
"""
|
|
42
44
|
|
|
43
|
-
return super()._get(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
return super()._get(
|
|
46
|
+
params={
|
|
47
|
+
"owned_only": owned_only,
|
|
48
|
+
"primary_owned_only": primary_owned_only,
|
|
49
|
+
}
|
|
50
|
+
)
|
|
47
51
|
|
|
48
52
|
@expand_docstring(include_uid=True)
|
|
49
53
|
def get(self, uid: Union[UUID, str]) -> Datastream:
|
|
@@ -78,14 +82,14 @@ class DatastreamEndpoint(HydroServerEndpoint):
|
|
|
78
82
|
super()._delete(uid=uid)
|
|
79
83
|
|
|
80
84
|
def get_observations(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
self,
|
|
86
|
+
uid: Union[UUID, str],
|
|
87
|
+
start_time: datetime = None,
|
|
88
|
+
end_time: datetime = None,
|
|
89
|
+
page: int = 1,
|
|
90
|
+
page_size: int = 100000,
|
|
91
|
+
include_quality: bool = False,
|
|
92
|
+
fetch_all: bool = False,
|
|
89
93
|
) -> pd.DataFrame:
|
|
90
94
|
"""
|
|
91
95
|
Retrieve observations from a specific datastream.
|
|
@@ -110,9 +114,13 @@ class DatastreamEndpoint(HydroServerEndpoint):
|
|
|
110
114
|
|
|
111
115
|
filters = []
|
|
112
116
|
if start_time:
|
|
113
|
-
filters.append(
|
|
117
|
+
filters.append(
|
|
118
|
+
f'phenomenonTime ge {start_time.strftime("%Y-%m-%dT%H:%M:%S%z")}'
|
|
119
|
+
)
|
|
114
120
|
if end_time:
|
|
115
|
-
filters.append(
|
|
121
|
+
filters.append(
|
|
122
|
+
f'phenomenonTime le {end_time.strftime("%Y-%m-%dT%H:%M:%S%z")}'
|
|
123
|
+
)
|
|
116
124
|
|
|
117
125
|
if fetch_all:
|
|
118
126
|
page = 1
|
|
@@ -120,41 +128,60 @@ class DatastreamEndpoint(HydroServerEndpoint):
|
|
|
120
128
|
observations = []
|
|
121
129
|
|
|
122
130
|
while True:
|
|
123
|
-
response = getattr(self._service,
|
|
124
|
-
|
|
131
|
+
response = getattr(self._service, "_request")(
|
|
132
|
+
"get",
|
|
133
|
+
f"{self._api_route}/sensorthings/v1.1/Datastreams('{str(uid)}')/Observations",
|
|
125
134
|
params={
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
135
|
+
"$resultFormat": "dataArray",
|
|
136
|
+
"$select": f'phenomenonTime,result{",resultQuality" if include_quality else ""}',
|
|
137
|
+
"$count": True,
|
|
138
|
+
"$top": page_size,
|
|
139
|
+
"$skip": (page - 1) * page_size,
|
|
140
|
+
"$filter": " and ".join(filters) if filters else None,
|
|
141
|
+
},
|
|
133
142
|
)
|
|
134
143
|
response_content = json.loads(response.content)
|
|
135
|
-
data_array =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
data_array = (
|
|
145
|
+
response_content["value"][0]["dataArray"]
|
|
146
|
+
if response_content["value"]
|
|
147
|
+
else []
|
|
148
|
+
)
|
|
149
|
+
observations.extend(
|
|
150
|
+
[
|
|
151
|
+
(
|
|
152
|
+
[
|
|
153
|
+
obs[0],
|
|
154
|
+
obs[1],
|
|
155
|
+
obs[2]["qualityCode"] if obs[2]["qualityCode"] else None,
|
|
156
|
+
(
|
|
157
|
+
obs[2]["resultQualifiers"]
|
|
158
|
+
if obs[2]["resultQualifiers"]
|
|
159
|
+
else None
|
|
160
|
+
),
|
|
161
|
+
]
|
|
162
|
+
if include_quality
|
|
163
|
+
else [obs[0], obs[1]]
|
|
164
|
+
)
|
|
165
|
+
for obs in data_array
|
|
166
|
+
]
|
|
167
|
+
)
|
|
141
168
|
if not fetch_all or len(data_array) < page_size:
|
|
142
169
|
break
|
|
143
170
|
page += 1
|
|
144
171
|
|
|
145
|
-
columns = [
|
|
172
|
+
columns = ["timestamp", "value"]
|
|
146
173
|
if include_quality:
|
|
147
|
-
columns.extend([
|
|
174
|
+
columns.extend(["quality_code", "result_quality"])
|
|
148
175
|
|
|
149
176
|
data_frame = pd.DataFrame(observations, columns=columns)
|
|
150
|
-
data_frame[
|
|
177
|
+
data_frame["timestamp"] = pd.to_datetime(data_frame["timestamp"])
|
|
151
178
|
|
|
152
179
|
return data_frame
|
|
153
180
|
|
|
154
181
|
def load_observations(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
182
|
+
self,
|
|
183
|
+
uid: Union[UUID, str],
|
|
184
|
+
observations: pd.DataFrame,
|
|
158
185
|
) -> None:
|
|
159
186
|
"""
|
|
160
187
|
Load observations to a specific datastream.
|
|
@@ -168,21 +195,31 @@ class DatastreamEndpoint(HydroServerEndpoint):
|
|
|
168
195
|
|
|
169
196
|
data_array = [
|
|
170
197
|
[
|
|
171
|
-
row[
|
|
172
|
-
row[
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
198
|
+
row["timestamp"].strftime("%Y-%m-%dT%H:%M:%S%z"),
|
|
199
|
+
row["value"],
|
|
200
|
+
(
|
|
201
|
+
{
|
|
202
|
+
"qualityCode": row.get("quality_code", None),
|
|
203
|
+
"resultQualifiers": row.get("result_qualifiers", []),
|
|
204
|
+
}
|
|
205
|
+
if "quality_code" in row or "result_qualifiers" in row
|
|
206
|
+
else {}
|
|
207
|
+
),
|
|
208
|
+
]
|
|
209
|
+
for _, row in observations.iterrows()
|
|
178
210
|
]
|
|
179
211
|
|
|
180
|
-
getattr(self._service,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
212
|
+
getattr(self._service, "_request")(
|
|
213
|
+
"post",
|
|
214
|
+
f"{self._api_route}/sensorthings/v1.1/CreateObservations",
|
|
215
|
+
headers={"Content-type": "application/json"},
|
|
216
|
+
data=json.dumps(
|
|
217
|
+
[
|
|
218
|
+
{
|
|
219
|
+
"Datastream": {"@iot.id": str(uid)},
|
|
220
|
+
"components": ["phenomenonTime", "result", "resultQuality"],
|
|
221
|
+
"dataArray": data_array,
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
),
|
|
188
225
|
)
|
|
@@ -27,13 +27,13 @@ class ObservedPropertyEndpoint(HydroServerEndpoint):
|
|
|
27
27
|
super().__init__(service)
|
|
28
28
|
self._model = ObservedProperty
|
|
29
29
|
self._api_route = self._service.api_route
|
|
30
|
-
self._endpoint_route =
|
|
30
|
+
self._endpoint_route = "observed-properties"
|
|
31
31
|
|
|
32
32
|
def list(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
self,
|
|
34
|
+
include_owned: bool = True,
|
|
35
|
+
include_unowned: bool = True,
|
|
36
|
+
include_templates: bool = True,
|
|
37
37
|
) -> List[ObservedProperty]:
|
|
38
38
|
"""
|
|
39
39
|
Retrieve a collection of observed properties.
|
|
@@ -43,22 +43,40 @@ class ObservedPropertyEndpoint(HydroServerEndpoint):
|
|
|
43
43
|
:param include_templates: Whether to include template observed properties.
|
|
44
44
|
"""
|
|
45
45
|
|
|
46
|
-
if
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
owner =
|
|
52
|
-
elif
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
if (
|
|
47
|
+
include_owned is True
|
|
48
|
+
and include_unowned is True
|
|
49
|
+
and include_templates is True
|
|
50
|
+
):
|
|
51
|
+
owner = "anyUserOrNoUser"
|
|
52
|
+
elif (
|
|
53
|
+
include_owned is True
|
|
54
|
+
and include_unowned is True
|
|
55
|
+
and include_templates is False
|
|
56
|
+
):
|
|
57
|
+
owner = "anyUser"
|
|
58
|
+
elif (
|
|
59
|
+
include_owned is True
|
|
60
|
+
and include_unowned is False
|
|
61
|
+
and include_templates is True
|
|
62
|
+
):
|
|
63
|
+
owner = "currentUserOrNoUser"
|
|
64
|
+
elif (
|
|
65
|
+
include_owned is True
|
|
66
|
+
and include_unowned is False
|
|
67
|
+
and include_templates is False
|
|
68
|
+
):
|
|
69
|
+
owner = "currentUser"
|
|
70
|
+
elif (
|
|
71
|
+
include_owned is False
|
|
72
|
+
and include_unowned is False
|
|
73
|
+
and include_templates is True
|
|
74
|
+
):
|
|
75
|
+
owner = "noUser"
|
|
56
76
|
else:
|
|
57
77
|
return []
|
|
58
78
|
|
|
59
|
-
return super()._get(params={
|
|
60
|
-
'owner': owner
|
|
61
|
-
})
|
|
79
|
+
return super()._get(params={"owner": owner})
|
|
62
80
|
|
|
63
81
|
@expand_docstring(include_uid=True)
|
|
64
82
|
def get(self, uid: Union[UUID, str]) -> ObservedProperty:
|
|
@@ -27,13 +27,13 @@ class ProcessingLevelEndpoint(HydroServerEndpoint):
|
|
|
27
27
|
super().__init__(service)
|
|
28
28
|
self._model = ProcessingLevel
|
|
29
29
|
self._api_route = self._service.api_route
|
|
30
|
-
self._endpoint_route =
|
|
30
|
+
self._endpoint_route = "processing-levels"
|
|
31
31
|
|
|
32
32
|
def list(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
self,
|
|
34
|
+
include_owned: bool = True,
|
|
35
|
+
include_unowned: bool = True,
|
|
36
|
+
include_templates: bool = True,
|
|
37
37
|
) -> List[ProcessingLevel]:
|
|
38
38
|
"""
|
|
39
39
|
Retrieve a collection of processing levels.
|
|
@@ -43,22 +43,40 @@ class ProcessingLevelEndpoint(HydroServerEndpoint):
|
|
|
43
43
|
:param include_templates: Whether to include template observed properties.
|
|
44
44
|
"""
|
|
45
45
|
|
|
46
|
-
if
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
owner =
|
|
52
|
-
elif
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
if (
|
|
47
|
+
include_owned is True
|
|
48
|
+
and include_unowned is True
|
|
49
|
+
and include_templates is True
|
|
50
|
+
):
|
|
51
|
+
owner = "anyUserOrNoUser"
|
|
52
|
+
elif (
|
|
53
|
+
include_owned is True
|
|
54
|
+
and include_unowned is True
|
|
55
|
+
and include_templates is False
|
|
56
|
+
):
|
|
57
|
+
owner = "anyUser"
|
|
58
|
+
elif (
|
|
59
|
+
include_owned is True
|
|
60
|
+
and include_unowned is False
|
|
61
|
+
and include_templates is True
|
|
62
|
+
):
|
|
63
|
+
owner = "currentUserOrNoUser"
|
|
64
|
+
elif (
|
|
65
|
+
include_owned is True
|
|
66
|
+
and include_unowned is False
|
|
67
|
+
and include_templates is False
|
|
68
|
+
):
|
|
69
|
+
owner = "currentUser"
|
|
70
|
+
elif (
|
|
71
|
+
include_owned is False
|
|
72
|
+
and include_unowned is False
|
|
73
|
+
and include_templates is True
|
|
74
|
+
):
|
|
75
|
+
owner = "noUser"
|
|
56
76
|
else:
|
|
57
77
|
return []
|
|
58
78
|
|
|
59
|
-
return super()._get(params={
|
|
60
|
-
'owner': owner
|
|
61
|
-
})
|
|
79
|
+
return super()._get(params={"owner": owner})
|
|
62
80
|
|
|
63
81
|
@expand_docstring(include_uid=True)
|
|
64
82
|
def get(self, uid: Union[UUID, str]) -> ProcessingLevel:
|
|
@@ -16,7 +16,7 @@ class ResultQualifierEndpoint(HydroServerEndpoint):
|
|
|
16
16
|
:ivar _endpoint_route: The specific route of the endpoint, set to `'result-qualifiers'`.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
def __init__(self, service:
|
|
19
|
+
def __init__(self, service: "HydroServer"):
|
|
20
20
|
"""
|
|
21
21
|
Initialize the ResultQualifierEndpoint.
|
|
22
22
|
|
|
@@ -27,13 +27,13 @@ class ResultQualifierEndpoint(HydroServerEndpoint):
|
|
|
27
27
|
super().__init__(service)
|
|
28
28
|
self._model = ResultQualifier
|
|
29
29
|
self._api_route = self._service.api_route
|
|
30
|
-
self._endpoint_route =
|
|
30
|
+
self._endpoint_route = "result-qualifiers"
|
|
31
31
|
|
|
32
32
|
def list(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
self,
|
|
34
|
+
include_owned: bool = True,
|
|
35
|
+
include_unowned: bool = True,
|
|
36
|
+
include_templates: bool = True,
|
|
37
37
|
) -> List[ResultQualifier]:
|
|
38
38
|
"""
|
|
39
39
|
Retrieve a collection of result qualifiers.
|
|
@@ -43,22 +43,40 @@ class ResultQualifierEndpoint(HydroServerEndpoint):
|
|
|
43
43
|
:param include_templates: Whether to include template observed properties.
|
|
44
44
|
"""
|
|
45
45
|
|
|
46
|
-
if
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
owner =
|
|
52
|
-
elif
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
if (
|
|
47
|
+
include_owned is True
|
|
48
|
+
and include_unowned is True
|
|
49
|
+
and include_templates is True
|
|
50
|
+
):
|
|
51
|
+
owner = "anyUserOrNoUser"
|
|
52
|
+
elif (
|
|
53
|
+
include_owned is True
|
|
54
|
+
and include_unowned is True
|
|
55
|
+
and include_templates is False
|
|
56
|
+
):
|
|
57
|
+
owner = "anyUser"
|
|
58
|
+
elif (
|
|
59
|
+
include_owned is True
|
|
60
|
+
and include_unowned is False
|
|
61
|
+
and include_templates is True
|
|
62
|
+
):
|
|
63
|
+
owner = "currentUserOrNoUser"
|
|
64
|
+
elif (
|
|
65
|
+
include_owned is True
|
|
66
|
+
and include_unowned is False
|
|
67
|
+
and include_templates is False
|
|
68
|
+
):
|
|
69
|
+
owner = "currentUser"
|
|
70
|
+
elif (
|
|
71
|
+
include_owned is False
|
|
72
|
+
and include_unowned is False
|
|
73
|
+
and include_templates is True
|
|
74
|
+
):
|
|
75
|
+
owner = "noUser"
|
|
56
76
|
else:
|
|
57
77
|
return []
|
|
58
78
|
|
|
59
|
-
return super()._get(params={
|
|
60
|
-
'owner': owner
|
|
61
|
-
})
|
|
79
|
+
return super()._get(params={"owner": owner})
|
|
62
80
|
|
|
63
81
|
@expand_docstring(include_uid=True)
|
|
64
82
|
def get(self, uid: Union[UUID, str]) -> ResultQualifier:
|