bug 864 fix operation (created/edited) published to kafka
[osm/NBI.git] / osm_nbi / validation.py
index a081ffa..6e43be5 100644 (file)
@@ -631,6 +631,7 @@ user_edit_schema = {
 }
 
 # PROJECTS
+topics_with_quota = ["vnfds", "nsds", "nsts", "pdus", "nsrs", "nsis", "vim_accounts", "wim_accounts", "sdns"]
 project_new_schema = {
     "$schema": "http://json-schema.org/draft-04/schema#",
     "title": "New project schema for administrators",
@@ -638,6 +639,11 @@ project_new_schema = {
     "properties": {
         "name": shortname_schema,
         "admin": bool_schema,
+        "quotas": {
+            "type": "object",
+            "properties": {topic: integer0_schema for topic in topics_with_quota},
+            "additionalProperties": False
+        },
     },
     "required": ["name"],
     "additionalProperties": False
@@ -649,6 +655,11 @@ project_edit_schema = {
     "properties": {
         "admin": bool_schema,
         "name": shortname_schema,     # To allow Project Name modification
+        "quotas": {
+            "type": "object",
+            "properties": {topic: {"oneOf": [integer0_schema, null_schema]} for topic in topics_with_quota},
+            "additionalProperties": False
+        },
     },
     "additionalProperties": False,
     "minProperties": 1
@@ -661,20 +672,34 @@ roles_new_schema = {
     "type": "object",
     "properties": {
         "name": shortname_schema,
-        "root": bool_schema,
+        "permissions": {
+            "type": "object",
+            "patternProperties": {
+                ".": bool_schema,
+            },
+            # "minProperties": 1,
+        }
     },
-    "required": ["name", "root"],
-    "additionalProperties": True
+    "required": ["name"],
+    "additionalProperties": False
 }
 roles_edit_schema = {
     "$schema": "http://json-schema.org/draft-04/schema#",
     "title": "Roles edit schema for administrators",
     "type": "object",
     "properties": {
-        "root": bool_schema,
+        "name": shortname_schema,
+        "permissions": {
+            "type": "object",
+            "patternProperties": {
+                ".": {
+                    "oneOf": [bool_schema, null_schema]
+                }
+            },
+            # "minProperties": 1,
+        }
     },
-    "required": ["root"],
-    "additionalProperties": True,
+    "additionalProperties": False,
     "minProperties": 1
 }
 
@@ -793,5 +818,5 @@ def is_valid_uuid(x):
     try:
         if UUID(x):
             return True
-    except (TypeError, ValueError):
+    except (TypeError, ValueError, AttributeError):
         return False