Skip to content

Commit aadf3d0

Browse files
committed
✏️ Fix type and improve usability
set default for site networks agg to hourly
1 parent db747b7 commit aadf3d0

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/client.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_authenticated_user(self):
6464
if response.status_code == 200:
6565
return response.json()
6666
else:
67-
raise Exception(f'Error retrieving authenticated user: {response.sttaus_code}')
67+
raise Exception(f'Error retrieving authenticated user: {response.status_code}')
6868

6969
def get_sites(self):
7070
"""
@@ -87,14 +87,14 @@ def get_sites(self):
8787
if response.status_code == 200:
8888
return response.json()
8989
else:
90-
raise Exception(f'Error retrieving sites: {response.sttaus_code}')
90+
raise Exception(f'Error retrieving sites: {response.status_code}')
9191

9292

9393
def get_site_networks_ts_time_ago(self, site_id,
94-
measure_kind = "VIRTUAL_QUANTITY",
95-
aggregation_level = "HOUR",
96-
aggregation_type = "SUM",
97-
time_ago_unit = "DAY",
94+
measure_kind = "FLOW",
95+
aggregation_level = "NONE",
96+
aggregation_type = None,
97+
time_ago_unit = "HOUR",
9898
time_ago_value = 1):
9999
"""
100100
Retrieves the time series data for the networks of a specific site, based on the provided parameters.
@@ -103,7 +103,7 @@ def get_site_networks_ts_time_ago(self, site_id,
103103
site_id (str): The ID of the site.
104104
measure_kind (str): The kind of measure (default: "VIRTUAL_QUANTITY").
105105
aggregation_level (str): The aggregation level (default: "HOUR").
106-
aggregation_type (str): The aggregation type (default: "SUM").
106+
aggregation_type (str): The aggregation type (default: None, can be : None, "SUM", "MAX").
107107
time_ago_unit (str): The unit of time ago (default: "DAY").
108108
time_ago_value (int): The value of time ago (default: 1).
109109
@@ -119,10 +119,12 @@ def get_site_networks_ts_time_ago(self, site_id,
119119
f'siteId={site_id}&'
120120
f'measureKind={measure_kind}&'
121121
f'aggregationLevel={aggregation_level}&'
122-
f'aggregationType={aggregation_type}&'
123122
f'timeAgoUnit={time_ago_unit}&'
124123
f'timeAgoValue={time_ago_value}')
125124

125+
if aggregation_type != None:
126+
url += f'&aggregationType={aggregation_type}'
127+
126128
response = self.session.get(url)
127129
if response.status_code == 200:
128130
return response.json()
@@ -183,7 +185,7 @@ def get_devices(self, site_id):
183185
if response.status_code == 200:
184186
return response.json()
185187
else:
186-
raise Exception(f'Error retrieving sites: {response.sttaus_code}')
188+
raise Exception(f'Error retrieving sites: {response.status_code}')
187189

188190
def get_device_ts_time_ago(self, device_id,
189191
measure_kind = "FLOW",

0 commit comments

Comments
 (0)