X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fvalidation.py;h=6e43be59c053e6c8d2b027993a5988fd1f0d6f14;hp=a081ffa449b761ce3f1f5b4e58b43be7a2798163;hb=16db949804909ad4e68bea83cc546124eaf562a0;hpb=cf042d30e8b7a1a9cbd1b2064e83c5d20ffcec9b diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index a081ffa..6e43be5 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -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