howler-api 2.12.0.dev313__py3-none-any.whl → 2.12.0.dev316__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.
howler/api/v1/view.py CHANGED
@@ -108,13 +108,13 @@ def create_view(**kwargs):
108
108
 
109
109
 
110
110
  @generate_swagger_docs()
111
- @view_api.route("/<id>", methods=["DELETE"])
111
+ @view_api.route("/<view_id>", methods=["DELETE"])
112
112
  @api_login(required_priv=["W"])
113
- def delete_view(id: str, user: User, **kwargs):
113
+ def delete_view(view_id: str, user: User, **kwargs):
114
114
  """Delete a view
115
115
 
116
116
  Variables:
117
- id => The id of the view to delete
117
+ view_id => The id of the view to delete
118
118
 
119
119
  Optional Arguments:
120
120
  None
@@ -129,7 +129,7 @@ def delete_view(id: str, user: User, **kwargs):
129
129
  """
130
130
  storage = datastore()
131
131
 
132
- existing_view: View = storage.view.get_if_exists(id)
132
+ existing_view: View = storage.view.get_if_exists(view_id)
133
133
  if not existing_view:
134
134
  return not_found(err="This view does not exist")
135
135
 
@@ -139,7 +139,7 @@ def delete_view(id: str, user: User, **kwargs):
139
139
  if existing_view.type == "readonly":
140
140
  return forbidden(err="You cannot delete built-in views.")
141
141
 
142
- success = storage.view.delete(id)
142
+ success = storage.view.delete(view_id)
143
143
 
144
144
  storage.view.commit()
145
145
 
@@ -147,13 +147,13 @@ def delete_view(id: str, user: User, **kwargs):
147
147
 
148
148
 
149
149
  @generate_swagger_docs()
150
- @view_api.route("/<id>", methods=["PUT"])
150
+ @view_api.route("/<view_id>", methods=["PUT"])
151
151
  @api_login(required_priv=["R", "W"])
152
- def update_view(id: str, user: User, **kwargs):
152
+ def update_view(view_id: str, user: User, **kwargs):
153
153
  """Update a view
154
154
 
155
155
  Variables:
156
- id => The id of the view to modify
156
+ view_id => The view_id of the view to modify
157
157
 
158
158
  Optional Arguments:
159
159
  None
@@ -178,7 +178,7 @@ def update_view(id: str, user: User, **kwargs):
178
178
  if set(new_data.keys()) & {"view_id", "owner"}:
179
179
  return bad_request(err="You cannot change the owner or id of a view.")
180
180
 
181
- existing_view: View = storage.view.get_if_exists(id)
181
+ existing_view: View = storage.view.get_if_exists(view_id)
182
182
  if not existing_view:
183
183
  return not_found(err="This view does not exist")
184
184
 
@@ -210,13 +210,13 @@ def update_view(id: str, user: User, **kwargs):
210
210
 
211
211
 
212
212
  @generate_swagger_docs()
213
- @view_api.route("/<id>/favourite", methods=["POST"])
213
+ @view_api.route("/<view_id>/favourite", methods=["POST"])
214
214
  @api_login(required_priv=["R", "W"])
215
- def set_as_favourite(id: str, **kwargs):
215
+ def set_as_favourite(view_id: str, **kwargs):
216
216
  """Add a view to a list of the user's favourites
217
217
 
218
218
  Variables:
219
- id => The id of the view to add as a favourite
219
+ view_id => The id of the view to add as a favourite
220
220
 
221
221
  Optional Arguments:
222
222
  None
@@ -231,7 +231,7 @@ def set_as_favourite(id: str, **kwargs):
231
231
  """
232
232
  storage = datastore()
233
233
 
234
- existing_view: View = storage.view.get_if_exists(id)
234
+ existing_view: View = storage.view.get_if_exists(view_id)
235
235
  if not existing_view:
236
236
  return not_found(err="This view does not exist")
237
237
 
@@ -243,7 +243,7 @@ def set_as_favourite(id: str, **kwargs):
243
243
  try:
244
244
  current_user = storage.user.get_if_exists(kwargs["user"]["uname"])
245
245
 
246
- current_user["favourite_views"] = list(set(current_user.get("favourite_views", []) + [id]))
246
+ current_user["favourite_views"] = list(set(current_user.get("favourite_views", []) + [view_id]))
247
247
 
248
248
  storage.user.save(current_user["uname"], current_user)
249
249
 
@@ -253,9 +253,9 @@ def set_as_favourite(id: str, **kwargs):
253
253
 
254
254
 
255
255
  @generate_swagger_docs()
256
- @view_api.route("/<id>/favourite", methods=["DELETE"])
256
+ @view_api.route("/<view_id>/favourite", methods=["DELETE"])
257
257
  @api_login(required_priv=["R", "W"])
258
- def remove_as_favourite(id, **kwargs):
258
+ def remove_as_favourite(view_id: str, **kwargs):
259
259
  """Remove a view from a list of the user's favourites
260
260
 
261
261
  Variables:
@@ -271,13 +271,15 @@ def remove_as_favourite(id, **kwargs):
271
271
  """
272
272
  storage = datastore()
273
273
 
274
- if not storage.view.exists(id):
275
- return not_found(err="This view does not exist")
276
-
277
274
  try:
278
275
  current_user = storage.user.get_if_exists(kwargs["user"]["uname"])
279
276
 
280
- current_user["favourite_views"] = list(filter(lambda f: f != id, current_user.get("favourite_views", [])))
277
+ current_favourites: list[str] = current_user.get("favourite_views", [])
278
+
279
+ if view_id not in current_favourites:
280
+ return not_found(err="View is not favourited.")
281
+
282
+ current_user["favourite_views"] = [favourite for favourite in current_favourites if favourite != view_id]
281
283
 
282
284
  storage.user.save(current_user["uname"], current_user)
283
285
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: howler-api
3
- Version: 2.12.0.dev313
3
+ Version: 2.12.0.dev316
4
4
  Summary: Howler - API server
5
5
  License: MIT
6
6
  Keywords: howler,alerting,gc,canada,cse-cst,cse,cst,cyber,cccs
@@ -30,7 +30,7 @@ howler/api/v1/tool.py,sha256=6CN5LIXgxaAvxEHE6s4IFtAEhQo_zBLtl6ghbM8whjE,6737
30
30
  howler/api/v1/user.py,sha256=YQh6eCAi4bsC_w9eGX0ZgnLoFL4z4efEc1knJsZhj4k,13842
31
31
  howler/api/v1/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  howler/api/v1/utils/etag.py,sha256=IGB4WUkecHbBt0KKLQFCxCn0mN3T_aSPG0y45l_zT9I,3431
33
- howler/api/v1/view.py,sha256=an0OO8Vnmco5gGEzrNGX8pNWJ3sRgTQLGSwyLo3W6rU,8045
33
+ howler/api/v1/view.py,sha256=VyizfGehsuoPyn7iswGPKCLcbSQoO1ipRsbr91nSDKk,8228
34
34
  howler/app.py,sha256=AJJ8TGMSi9hJGc7IR7xKsZuVwg-ih85-t0PRO0-ntHw,7063
35
35
  howler/common/README.md,sha256=lgnrAdgnOADmmfRplhbfYD7jU627nr3zO-fJ6N4Nbcs,6577
36
36
  howler/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -194,7 +194,7 @@ howler/utils/path.py,sha256=DfOU4i4zSs4wchHoE8iE7aWVLkTxiC_JRGepF2hBYBk,690
194
194
  howler/utils/socket_utils.py,sha256=nz1SklC9xBHUSfHyTJjpq3mbozX1GDf01WzdGxfaUII,2212
195
195
  howler/utils/str_utils.py,sha256=HE8Hqh2HlOLaj16w0H9zKOyDJLp-f1LQ50y_WeGZaEk,8389
196
196
  howler/utils/uid.py,sha256=p9dsqyvZ-lpiAuzZWCPCeEM99kdk0Ly9czf04HNdSuw,1341
197
- howler_api-2.12.0.dev313.dist-info/METADATA,sha256=idGxd04XB8llwrLDSUxL8QwD_gvjOW6AUyVxM7RA-98,2815
198
- howler_api-2.12.0.dev313.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
199
- howler_api-2.12.0.dev313.dist-info/entry_points.txt,sha256=Lu9SBGvwe0wczJHmc-RudC24lmQk7tv3ZBXon9RIihg,259
200
- howler_api-2.12.0.dev313.dist-info/RECORD,,
197
+ howler_api-2.12.0.dev316.dist-info/METADATA,sha256=QaWRVrzS2LNqHob-DDq7hIv3pxAbMBsbEuA77yba4lo,2815
198
+ howler_api-2.12.0.dev316.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
199
+ howler_api-2.12.0.dev316.dist-info/entry_points.txt,sha256=Lu9SBGvwe0wczJHmc-RudC24lmQk7tv3ZBXon9RIihg,259
200
+ howler_api-2.12.0.dev316.dist-info/RECORD,,