Browse Source

Take away the ability to patch certain fields

Michael James Hoppal 3 years ago
parent
commit
9113a2cbbe
1 changed files with 10 additions and 2 deletions
  1. 10
    2
      monasca_events_api/common/repositories/mysql/streams_repository.py

+ 10
- 2
monasca_events_api/common/repositories/mysql/streams_repository.py View File

@@ -208,8 +208,8 @@ class StreamsRepository(mysql_repository.MySQLRepository,
208 208
             return stream_definition_id
209 209
 
210 210
     @mysql_repository.mysql_try_catch_block
211
-    def patch_stream_definition(self, tenant_id, stream_definition_id, name, description, select, group_by, fire_criteria, expiration,
212
-                                 fire_actions, expire_actions):
211
+    def patch_stream_definition(self, tenant_id, stream_definition_id, name, description, select, group_by,
212
+                                fire_criteria, expiration, fire_actions, expire_actions):
213 213
 
214 214
         cnxn, cursor = self._get_cnxn_cursor_tuple()
215 215
 
@@ -256,11 +256,19 @@ class StreamsRepository(mysql_repository.MySQLRepository,
256 256
             else:
257 257
                 new_select = json.dumps(select).encode('utf8')
258 258
 
259
+            if new_select != original_definition['select_by']:
260
+                msg = "select_by must not change".encode('utf8')
261
+                raise exceptions.InvalidUpdateException(msg)
262
+
259 263
             if group_by is None:
260 264
                 new_group_by = original_definition['group_by']
261 265
             else:
262 266
                 new_group_by = json.dumps(group_by).encode('utf8')
263 267
 
268
+            if new_group_by != original_definition['group_by']:
269
+                msg = "group_by must not change".encode('utf8')
270
+                raise exceptions.InvalidUpdateException(msg)
271
+
264 272
             if fire_criteria is None:
265 273
                 new_fire_criteria = original_definition['fire_criteria']
266 274
             else:

Loading…
Cancel
Save