| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| tierno | d125caf | 2018-11-22 16:05:54 +0000 | [diff] [blame] | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 12 | # implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 16 | from jsonschema import validate as js_v, exceptions as js_e |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 17 | from http import HTTPStatus |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 18 | from copy import deepcopy |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 19 | from uuid import UUID # To test for valid UUID |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 20 | |
| 21 | __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>" |
| 22 | __version__ = "0.1" |
| 23 | version_date = "Mar 2018" |
| 24 | |
| 25 | """ |
| 26 | Validator of input data using JSON schemas for those items that not contains an OSM yang information model |
| 27 | """ |
| 28 | |
| 29 | # Basis schemas |
| 30 | patern_name = "^[ -~]+$" |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 31 | shortname_schema = { |
| 32 | "type": "string", |
| 33 | "minLength": 1, |
| 34 | "maxLength": 60, |
| 35 | "pattern": "^[^,;()\\.\\$'\"]+$", |
| 36 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 37 | passwd_schema = {"type": "string", "minLength": 1, "maxLength": 60} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 38 | name_schema = { |
| 39 | "type": "string", |
| 40 | "minLength": 1, |
| 41 | "maxLength": 255, |
| 42 | "pattern": "^[^,;()'\"]+$", |
| 43 | } |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 44 | string_schema = {"type": "string", "minLength": 1, "maxLength": 255} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 45 | xml_text_schema = { |
| 46 | "type": "string", |
| 47 | "minLength": 1, |
| 48 | "maxLength": 1000, |
| 49 | "pattern": "^[^']+$", |
| 50 | } |
| 51 | description_schema = { |
| 52 | "type": ["string", "null"], |
| 53 | "maxLength": 255, |
| 54 | "pattern": "^[^'\"]+$", |
| 55 | } |
| 56 | long_description_schema = { |
| 57 | "type": ["string", "null"], |
| 58 | "maxLength": 3000, |
| 59 | "pattern": "^[^'\"]+$", |
| 60 | } |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 61 | id_schema_fake = {"type": "string", "minLength": 2, "maxLength": 36} |
| 62 | bool_schema = {"type": "boolean"} |
| 63 | null_schema = {"type": "null"} |
| tierno | 2236d20 | 2018-05-16 19:05:16 +0200 | [diff] [blame] | 64 | # "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 65 | id_schema = { |
| 66 | "type": "string", |
| 67 | "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$", |
| 68 | } |
| 69 | time_schema = { |
| 70 | "type": "string", |
| 71 | "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}", |
| 72 | } |
| 73 | pci_schema = { |
| 74 | "type": "string", |
| 75 | "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\\.[0-9a-fA-F]$", |
| 76 | } |
| tierno | 42fce59 | 2018-11-02 09:23:43 +0100 | [diff] [blame] | 77 | # allows [] for wildcards. For that reason huge length limit is set |
| 78 | pci_extended_schema = {"type": "string", "pattern": "^[0-9a-fA-F.:-\\[\\]]{12,40}$"} |
| K Sai Kiran | 990ac46 | 2020-05-20 12:25:12 +0530 | [diff] [blame] | 79 | http_schema = {"type": "string", "pattern": "^(https?|http)://[^'\"=]+$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 80 | bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"} |
| 81 | memory_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]i?[Bb])?$"} |
| 82 | integer0_schema = {"type": "integer", "minimum": 0} |
| 83 | integer1_schema = {"type": "integer", "minimum": 1} |
| tierno | 8700604 | 2018-10-24 12:50:20 +0200 | [diff] [blame] | 84 | path_schema = {"type": "string", "pattern": "^(\\.){0,2}(/[^/\"':{}\\(\\)]+)+$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 85 | vlan_schema = {"type": "integer", "minimum": 1, "maximum": 4095} |
| 86 | vlan1000_schema = {"type": "integer", "minimum": 1000, "maximum": 4095} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 87 | mac_schema = { |
| 88 | "type": "string", |
| 89 | "pattern": "^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$", |
| 90 | } # must be unicast: LSB bit of MSB byte ==0 |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 91 | dpid_Schema = {"type": "string", "pattern": "^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){7}$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 92 | # mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 93 | ip_schema = { |
| 94 | "type": "string", |
| 95 | "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", |
| 96 | } |
| garciadeblas | 1a01e1f | 2021-10-26 17:27:35 +0200 | [diff] [blame] | 97 | ipv6_schema = { |
| 98 | "type": "string", |
| 99 | "pattern": "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))", |
| 100 | } |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 101 | ip_prefix_schema = { |
| 102 | "type": "string", |
| 103 | "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}" |
| 104 | "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$", |
| 105 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 106 | port_schema = {"type": "integer", "minimum": 1, "maximum": 65534} |
| 107 | object_schema = {"type": "object"} |
| 108 | schema_version_2 = {"type": "integer", "minimum": 2, "maximum": 2} |
| 109 | # schema_version_string={"type":"string","enum": ["0.1", "2", "0.2", "3", "0.3"]} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 110 | log_level_schema = { |
| 111 | "type": "string", |
| 112 | "enum": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], |
| 113 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 114 | checksum_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{32}$"} |
| 115 | size_schema = {"type": "integer", "minimum": 1, "maximum": 100} |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 116 | array_edition_schema = { |
| 117 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 118 | "patternProperties": {"^\\$": {}}, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 119 | "additionalProperties": False, |
| 120 | "minProperties": 1, |
| 121 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 122 | nameshort_list_schema = { |
| 123 | "type": "array", |
| 124 | "minItems": 1, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 125 | "items": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 126 | } |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 127 | |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 128 | description_list_schema = { |
| 129 | "type": "array", |
| 130 | "minItems": 1, |
| 131 | "items": description_schema, |
| 132 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 133 | |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 134 | ns_instantiate_vdu = { |
| 135 | "title": "ns action instantiate input schema for vdu", |
| 136 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 137 | "type": "object", |
| 138 | "properties": { |
| 139 | "id": name_schema, |
| 140 | "volume": { |
| 141 | "type": "array", |
| 142 | "minItems": 1, |
| 143 | "items": { |
| 144 | "type": "object", |
| 145 | "properties": { |
| 146 | "name": name_schema, |
| 147 | "vim-volume-id": name_schema, |
| 148 | }, |
| 149 | "required": ["name", "vim-volume-id"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 150 | "additionalProperties": False, |
| 151 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 152 | }, |
| 153 | "interface": { |
| 154 | "type": "array", |
| 155 | "minItems": 1, |
| 156 | "items": { |
| 157 | "type": "object", |
| 158 | "properties": { |
| 159 | "name": name_schema, |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame^] | 160 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 161 | "mac-address": mac_schema, |
| 162 | "floating-ip-required": bool_schema, |
| 163 | }, |
| 164 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 165 | "additionalProperties": False, |
| 166 | }, |
| 167 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 168 | }, |
| 169 | "required": ["id"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 170 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | ip_profile_dns_schema = { |
| 174 | "type": "array", |
| 175 | "minItems": 1, |
| 176 | "items": { |
| 177 | "type": "object", |
| 178 | "properties": { |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame^] | 179 | "address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 180 | }, |
| 181 | "required": ["address"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 182 | "additionalProperties": False, |
| 183 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | ip_profile_dhcp_schema = { |
| 187 | "type": "object", |
| 188 | "properties": { |
| 189 | "enabled": {"type": "boolean"}, |
| 190 | "count": integer1_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 191 | "start-address": ip_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 192 | }, |
| 193 | "additionalProperties": False, |
| 194 | } |
| 195 | |
| 196 | ip_profile_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 197 | "title": "ip profile validation schema", |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 198 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 199 | "type": "object", |
| 200 | "properties": { |
| 201 | "ip-version": {"enum": ["ipv4", "ipv6"]}, |
| 202 | "subnet-address": ip_prefix_schema, |
| 203 | "gateway-address": ip_schema, |
| 204 | "dns-server": ip_profile_dns_schema, |
| 205 | "dhcp-params": ip_profile_dhcp_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 206 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | ip_profile_update_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 210 | "title": "ip profile validation schema", |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 211 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 212 | "type": "object", |
| 213 | "properties": { |
| 214 | "ip-version": {"enum": ["ipv4", "ipv6"]}, |
| 215 | "subnet-address": {"oneOf": [null_schema, ip_prefix_schema]}, |
| 216 | "gateway-address": {"oneOf": [null_schema, ip_schema]}, |
| 217 | "dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 218 | "dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]}, |
| 219 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 220 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 221 | } |
| 222 | |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 223 | provider_network_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 224 | "title": "provider network validation schema", |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 225 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 226 | "type": "object", |
| 227 | "properties": { |
| 228 | "physical-network": name_schema, |
| 229 | "segmentation-id": name_schema, |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 230 | "sdn-ports": { # external ports to append to the SDN-assist network |
| 231 | "type": "array", |
| 232 | "items": { |
| 233 | "type": "object", |
| 234 | "properties": { |
| 235 | "switch_id": shortname_schema, |
| 236 | "switch_port": shortname_schema, |
| 237 | "mac_address": mac_schema, |
| 238 | "vlan": vlan_schema, |
| 239 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 240 | "additionalProperties": True, |
| 241 | }, |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 242 | }, |
| 243 | "network-type": shortname_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 244 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 245 | "additionalProperties": True, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 246 | } |
| 247 | |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 248 | ns_instantiate_internal_vld = { |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame^] | 249 | "title": "ns action instantiate input schema for vld", |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 250 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 251 | "type": "object", |
| 252 | "properties": { |
| 253 | "name": name_schema, |
| 254 | "vim-network-name": name_schema, |
| gcalvino | 17d5b73 | 2018-12-17 16:26:21 +0100 | [diff] [blame] | 255 | "vim-network-id": name_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 256 | "ip-profile": ip_profile_update_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 257 | "provider-network": provider_network_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 258 | "internal-connection-point": { |
| 259 | "type": "array", |
| 260 | "minItems": 1, |
| 261 | "items": { |
| 262 | "type": "object", |
| 263 | "properties": { |
| 264 | "id-ref": name_schema, |
| 265 | "ip-address": ip_schema, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 266 | # "mac-address": mac_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 267 | }, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 268 | "required": ["id-ref"], |
| 269 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 270 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 271 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 272 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 273 | }, |
| 274 | "required": ["name"], |
| 275 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 276 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 277 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 278 | |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 279 | additional_params_for_vnf = { |
| 280 | "type": "array", |
| 281 | "items": { |
| 282 | "type": "object", |
| 283 | "properties": { |
| 284 | "member-vnf-index": name_schema, |
| 285 | "additionalParams": object_schema, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 286 | "k8s-namespace": name_schema, |
| tierno | f62ac6a | 2020-04-29 13:46:13 +0000 | [diff] [blame] | 287 | "config-units": integer1_schema, # number of configuration units of this vnf, by default 1 |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 288 | "additionalParamsForVdu": { |
| 289 | "type": "array", |
| 290 | "items": { |
| 291 | "type": "object", |
| 292 | "properties": { |
| 293 | "vdu_id": name_schema, |
| 294 | "additionalParams": object_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 295 | "config-units": integer1_schema, # number of configuration units of this vdu, by default 1 |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 296 | }, |
| tierno | f62ac6a | 2020-04-29 13:46:13 +0000 | [diff] [blame] | 297 | "required": ["vdu_id"], |
| 298 | "minProperties": 2, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 299 | "additionalProperties": False, |
| 300 | }, |
| 301 | }, |
| 302 | "additionalParamsForKdu": { |
| 303 | "type": "array", |
| 304 | "items": { |
| 305 | "type": "object", |
| 306 | "properties": { |
| 307 | "kdu_name": name_schema, |
| 308 | "additionalParams": object_schema, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 309 | "kdu_model": name_schema, |
| 310 | "k8s-namespace": name_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 311 | "config-units": integer1_schema, # number of configuration units of this knf, by default 1 |
| romeromonser | bfebfc0 | 2021-05-28 10:51:35 +0200 | [diff] [blame] | 312 | "kdu-deployment-name": name_schema, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 313 | }, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 314 | "required": ["kdu_name"], |
| 315 | "minProperties": 2, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 316 | "additionalProperties": False, |
| 317 | }, |
| 318 | }, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 319 | }, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 320 | "required": ["member-vnf-index"], |
| 321 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 322 | "additionalProperties": False, |
| 323 | }, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 324 | } |
| 325 | |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 326 | ns_instantiate = { |
| 327 | "title": "ns action instantiate input schema", |
| 328 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 329 | "type": "object", |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 330 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 331 | "lcmOperationType": string_schema, |
| 332 | "nsInstanceId": id_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 333 | "netsliceInstanceId": id_schema, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 334 | "nsName": name_schema, |
| tierno | 4f9d4ae | 2019-03-20 17:24:11 +0000 | [diff] [blame] | 335 | "nsDescription": {"oneOf": [description_schema, null_schema]}, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 336 | "nsdId": id_schema, |
| 337 | "vimAccountId": id_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 338 | "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
| magnussonl | f318b30 | 2020-01-20 18:38:18 +0100 | [diff] [blame] | 339 | "placement-engine": string_schema, |
| 340 | "placement-constraints": object_schema, |
| tierno | bee085c | 2018-12-12 17:03:04 +0000 | [diff] [blame] | 341 | "additionalParamsForNs": object_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 342 | "additionalParamsForVnf": additional_params_for_vnf, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 343 | "config-units": integer1_schema, # number of configuration units of this ns, by default 1 |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 344 | "k8s-namespace": name_schema, |
| tierno | fc5089c | 2018-10-31 09:28:11 +0100 | [diff] [blame] | 345 | "ssh_keys": {"type": "array", "items": {"type": "string"}}, |
| tierno | a8186a5 | 2020-01-14 15:54:48 +0000 | [diff] [blame] | 346 | "timeout_ns_deploy": integer1_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 347 | "nsr_id": id_schema, |
| tierno | cc10343 | 2018-10-19 14:10:35 +0200 | [diff] [blame] | 348 | "vduImage": name_schema, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 349 | "vnf": { |
| 350 | "type": "array", |
| 351 | "minItems": 1, |
| 352 | "items": { |
| 353 | "type": "object", |
| 354 | "properties": { |
| 355 | "member-vnf-index": name_schema, |
| 356 | "vimAccountId": id_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 357 | "vdu": { |
| 358 | "type": "array", |
| 359 | "minItems": 1, |
| 360 | "items": ns_instantiate_vdu, |
| 361 | }, |
| 362 | "internal-vld": { |
| 363 | "type": "array", |
| 364 | "minItems": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 365 | "items": ns_instantiate_internal_vld, |
| 366 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 367 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 368 | "required": ["member-vnf-index"], |
| 369 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 370 | "additionalProperties": False, |
| 371 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 372 | }, |
| 373 | "vld": { |
| 374 | "type": "array", |
| 375 | "minItems": 1, |
| 376 | "items": { |
| 377 | "type": "object", |
| 378 | "properties": { |
| 379 | "name": string_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 380 | "vim-network-name": {"oneOf": [string_schema, object_schema]}, |
| 381 | "vim-network-id": {"oneOf": [string_schema, object_schema]}, |
| Felipe Vicens | 09e6542 | 2019-01-22 15:06:46 +0100 | [diff] [blame] | 382 | "ns-net": object_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 383 | "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 384 | "ip-profile": object_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 385 | "provider-network": provider_network_schema, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 386 | "vnfd-connection-point-ref": { |
| 387 | "type": "array", |
| 388 | "minItems": 1, |
| 389 | "items": { |
| 390 | "type": "object", |
| 391 | "properties": { |
| 392 | "member-vnf-index-ref": name_schema, |
| 393 | "vnfd-connection-point-ref": name_schema, |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame^] | 394 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 395 | # "mac-address": mac_schema, |
| 396 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 397 | "required": [ |
| 398 | "member-vnf-index-ref", |
| 399 | "vnfd-connection-point-ref", |
| 400 | ], |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 401 | "minProperties": 3, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 402 | "additionalProperties": False, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 403 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 404 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 405 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 406 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 407 | "additionalProperties": False, |
| 408 | }, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 409 | }, |
| 410 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 411 | "required": ["nsName", "nsdId", "vimAccountId"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 412 | "additionalProperties": False, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 413 | } |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 414 | |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 415 | ns_terminate = { |
| 416 | "title": "ns terminate input schema", |
| 417 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 418 | "type": "object", |
| 419 | "properties": { |
| 420 | "lcmOperationType": string_schema, |
| 421 | "nsInstanceId": id_schema, |
| 422 | "autoremove": bool_schema, |
| 423 | "timeout_ns_terminate": integer1_schema, |
| 424 | "skip_terminate_primitives": bool_schema, |
| tierno | 0b8752f | 2020-05-12 09:42:02 +0000 | [diff] [blame] | 425 | "netsliceInstanceId": id_schema, |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 426 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 427 | "additionalProperties": False, |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 428 | } |
| 429 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 430 | ns_action = { # TODO for the moment it is only contemplated the vnfd primitive execution |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 431 | "title": "ns action input schema", |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 432 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 433 | "type": "object", |
| 434 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 435 | "lcmOperationType": string_schema, |
| 436 | "nsInstanceId": id_schema, |
| tierno | f5298be | 2018-05-16 14:43:57 +0200 | [diff] [blame] | 437 | "member_vnf_index": name_schema, |
| 438 | "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future |
| tierno | 7ce1db9 | 2018-07-25 12:50:52 +0200 | [diff] [blame] | 439 | "vdu_id": name_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 440 | "vdu_count_index": integer0_schema, |
| tierno | 9cb7d67 | 2019-10-30 12:13:48 +0000 | [diff] [blame] | 441 | "kdu_name": name_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 442 | "primitive": name_schema, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 443 | "timeout_ns_action": integer1_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 444 | "primitive_params": {"type": "object"}, |
| 445 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 446 | "required": ["primitive", "primitive_params"], # TODO add member_vnf_index |
| 447 | "additionalProperties": False, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 448 | } |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 449 | ns_scale = { # TODO for the moment it is only VDU-scaling |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 450 | "title": "ns scale input schema", |
| 451 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 452 | "type": "object", |
| 453 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 454 | "lcmOperationType": string_schema, |
| 455 | "nsInstanceId": id_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 456 | "scaleType": {"enum": ["SCALE_VNF"]}, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 457 | "timeout_ns_scale": integer1_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 458 | "scaleVnfData": { |
| 459 | "type": "object", |
| 460 | "properties": { |
| 461 | "vnfInstanceId": name_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 462 | "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]}, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 463 | "scaleByStepData": { |
| 464 | "type": "object", |
| 465 | "properties": { |
| 466 | "scaling-group-descriptor": name_schema, |
| 467 | "member-vnf-index": name_schema, |
| 468 | "scaling-policy": name_schema, |
| 469 | }, |
| 470 | "required": ["scaling-group-descriptor", "member-vnf-index"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 471 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 472 | }, |
| 473 | }, |
| 474 | "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 475 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 476 | }, |
| 477 | "scaleTime": time_schema, |
| 478 | }, |
| 479 | "required": ["scaleType", "scaleVnfData"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 480 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 481 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 482 | |
| 483 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 484 | schema_version = {"type": "string", "enum": ["1.0"]} |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 485 | schema_type = {"type": "string"} |
| tierno | b3d0a0e | 2019-11-13 15:57:51 +0000 | [diff] [blame] | 486 | vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 487 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 488 | vim_account_edit_schema = { |
| 489 | "title": "vim_account edit input schema", |
| 490 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 491 | "type": "object", |
| 492 | "properties": { |
| 493 | "name": name_schema, |
| 494 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 495 | "vim": name_schema, |
| 496 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 497 | "vim_type": vim_type, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 498 | "vim_url": description_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 499 | # "vim_url_admin": description_schema, |
| 500 | # "vim_tenant": name_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 501 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame] | 502 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 503 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 504 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 505 | "config": {"type": "object"}, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 506 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 507 | "additionalProperties": False, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 508 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 509 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 510 | vim_account_new_schema = { |
| 511 | "title": "vim_account creation input schema", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 512 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 513 | "type": "object", |
| 514 | "properties": { |
| 515 | "schema_version": schema_version, |
| 516 | "schema_type": schema_type, |
| 517 | "name": name_schema, |
| 518 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 519 | "vim": name_schema, |
| 520 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 521 | "vim_type": vim_type, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 522 | "vim_url": description_schema, |
| 523 | # "vim_url_admin": description_schema, |
| 524 | # "vim_tenant": name_schema, |
| 525 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame] | 526 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 527 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 528 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 529 | "config": {"type": "object"}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 530 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 531 | "required": [ |
| 532 | "name", |
| 533 | "vim_url", |
| 534 | "vim_type", |
| 535 | "vim_user", |
| 536 | "vim_password", |
| 537 | "vim_tenant_name", |
| 538 | ], |
| 539 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 540 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 541 | |
| tierno | 8580772 | 2019-12-20 14:11:35 +0000 | [diff] [blame] | 542 | wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 543 | |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 544 | wim_account_edit_schema = { |
| 545 | "title": "wim_account edit input schema", |
| 546 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 547 | "type": "object", |
| 548 | "properties": { |
| 549 | "name": name_schema, |
| 550 | "description": description_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 551 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 552 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 553 | "wim_url": description_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 554 | "user": string_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 555 | "password": passwd_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 556 | "config": {"type": "object"}, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 557 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 558 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | wim_account_new_schema = { |
| 562 | "title": "wim_account creation input schema", |
| 563 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 564 | "type": "object", |
| 565 | "properties": { |
| 566 | "schema_version": schema_version, |
| 567 | "schema_type": schema_type, |
| 568 | "name": name_schema, |
| 569 | "description": description_schema, |
| 570 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 571 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 572 | "wim_url": description_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 573 | "user": string_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 574 | "password": passwd_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 575 | "config": { |
| 576 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 577 | "patternProperties": {".": {"not": {"type": "null"}}}, |
| 578 | }, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 579 | }, |
| 580 | "required": ["name", "wim_url", "wim_type"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 581 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 582 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 583 | |
| 584 | sdn_properties = { |
| 585 | "name": name_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 586 | "type": {"type": "string"}, |
| 587 | "url": {"type": "string"}, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 588 | "user": string_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 589 | "password": passwd_schema, |
| 590 | "config": {"type": "object"}, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 591 | "description": description_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 592 | # The folowing are deprecated. Maintanied for backward compatibility |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 593 | "dpid": dpid_Schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 594 | "ip": ip_schema, |
| 595 | "port": port_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 596 | "version": {"type": "string", "minLength": 1, "maxLength": 12}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 597 | } |
| 598 | sdn_new_schema = { |
| 599 | "title": "sdn controller information schema", |
| 600 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 601 | "type": "object", |
| 602 | "properties": sdn_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 603 | "required": ["name", "type"], |
| 604 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 605 | } |
| 606 | sdn_edit_schema = { |
| 607 | "title": "sdn controller update information schema", |
| 608 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 609 | "type": "object", |
| 610 | "properties": sdn_properties, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 611 | # "required": ["name", "port", 'ip', 'dpid', 'type'], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 612 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 613 | } |
| 614 | sdn_port_mapping_schema = { |
| 615 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 616 | "title": "sdn port mapping information schema", |
| 617 | "type": "array", |
| 618 | "items": { |
| 619 | "type": "object", |
| 620 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 621 | "compute_node": shortname_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 622 | "ports": { |
| 623 | "type": "array", |
| 624 | "items": { |
| 625 | "type": "object", |
| 626 | "properties": { |
| tierno | 42fce59 | 2018-11-02 09:23:43 +0100 | [diff] [blame] | 627 | "pci": pci_extended_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 628 | "switch_port": shortname_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 629 | "switch_mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 630 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 631 | "required": ["pci"], |
| 632 | }, |
| 633 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 634 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 635 | "required": ["compute_node", "ports"], |
| 636 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 637 | } |
| 638 | sdn_external_port_schema = { |
| 639 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 640 | "title": "External port information", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 641 | "type": "object", |
| 642 | "properties": { |
| 643 | "port": {"type": "string", "minLength": 1, "maxLength": 60}, |
| 644 | "vlan": vlan_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 645 | "mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 646 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 647 | "required": ["port"], |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 648 | } |
| 649 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 650 | # K8s Clusters |
| 651 | k8scluster_nets_schema = { |
| 652 | "title": "k8scluster nets input schema", |
| 653 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 654 | "type": "object", |
| tierno | 8c81ab0 | 2020-02-07 10:18:30 +0000 | [diff] [blame] | 655 | "patternProperties": {".": {"oneOf": [name_schema, null_schema]}}, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 656 | "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 657 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 658 | } |
| 659 | k8scluster_new_schema = { |
| 660 | "title": "k8scluster creation input schema", |
| 661 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 662 | "type": "object", |
| 663 | "properties": { |
| 664 | "schema_version": schema_version, |
| 665 | "schema_type": schema_type, |
| 666 | "name": name_schema, |
| 667 | "description": description_schema, |
| 668 | "credentials": object_schema, |
| 669 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 670 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 671 | "k8s_version": string_schema, |
| 672 | "nets": k8scluster_nets_schema, |
| 673 | "namespace": name_schema, |
| 674 | "cni": nameshort_list_schema, |
| 675 | }, |
| 676 | "required": ["name", "credentials", "vim_account", "k8s_version", "nets"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 677 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 678 | } |
| 679 | k8scluster_edit_schema = { |
| 680 | "title": "vim_account edit input schema", |
| 681 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 682 | "type": "object", |
| 683 | "properties": { |
| 684 | "name": name_schema, |
| 685 | "description": description_schema, |
| 686 | "credentials": object_schema, |
| 687 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 688 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 689 | "k8s_version": string_schema, |
| 690 | "nets": k8scluster_nets_schema, |
| 691 | "namespace": name_schema, |
| 692 | "cni": nameshort_list_schema, |
| 693 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 694 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 695 | } |
| 696 | |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 697 | # VCA |
| 698 | vca_new_schema = { |
| 699 | "title": "vca creation input schema", |
| 700 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 701 | "type": "object", |
| 702 | "properties": { |
| 703 | "schema_version": schema_version, |
| 704 | "schema_type": schema_type, |
| 705 | "name": name_schema, |
| 706 | "description": description_schema, |
| 707 | "endpoints": description_list_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 708 | "user": string_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 709 | "secret": passwd_schema, |
| 710 | "cacert": long_description_schema, |
| 711 | "lxd-cloud": shortname_schema, |
| 712 | "lxd-credentials": shortname_schema, |
| 713 | "k8s-cloud": shortname_schema, |
| 714 | "k8s-credentials": shortname_schema, |
| 715 | "model-config": object_schema, |
| 716 | }, |
| 717 | "required": [ |
| 718 | "name", |
| 719 | "endpoints", |
| 720 | "user", |
| 721 | "secret", |
| 722 | "cacert", |
| 723 | "lxd-cloud", |
| 724 | "lxd-credentials", |
| 725 | "k8s-cloud", |
| 726 | "k8s-credentials", |
| 727 | ], |
| 728 | "additionalProperties": False, |
| 729 | } |
| 730 | vca_edit_schema = { |
| 731 | "title": "vca creation input schema", |
| 732 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 733 | "type": "object", |
| 734 | "properties": { |
| 735 | "name": name_schema, |
| 736 | "description": description_schema, |
| 737 | "endpoints": description_list_schema, |
| 738 | "port": integer1_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 739 | "user": string_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 740 | "secret": passwd_schema, |
| 741 | "cacert": long_description_schema, |
| 742 | "lxd-cloud": shortname_schema, |
| 743 | "lxd-credentials": shortname_schema, |
| 744 | "k8s-cloud": shortname_schema, |
| 745 | "k8s-credentials": shortname_schema, |
| 746 | "model-config": object_schema, |
| 747 | }, |
| 748 | "additionalProperties": False, |
| 749 | } |
| 750 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 751 | # K8s Repos |
| tierno | 332e080 | 2019-12-03 23:50:49 +0000 | [diff] [blame] | 752 | k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]} |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 753 | k8srepo_properties = { |
| 754 | "name": name_schema, |
| 755 | "description": description_schema, |
| 756 | "type": k8srepo_types, |
| 757 | "url": description_schema, |
| 758 | } |
| 759 | k8srepo_new_schema = { |
| 760 | "title": "k8scluster creation input schema", |
| 761 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 762 | "type": "object", |
| 763 | "properties": k8srepo_properties, |
| 764 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 765 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 766 | } |
| 767 | k8srepo_edit_schema = { |
| 768 | "title": "vim_account edit input schema", |
| 769 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 770 | "type": "object", |
| 771 | "properties": k8srepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 772 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 773 | } |
| 774 | |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 775 | # OSM Repos |
| 776 | osmrepo_types = {"enum": ["osm"]} |
| 777 | osmrepo_properties = { |
| 778 | "name": name_schema, |
| 779 | "description": description_schema, |
| 780 | "type": osmrepo_types, |
| 781 | "url": description_schema |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 782 | # "user": string_schema, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 783 | # "password": passwd_schema |
| 784 | } |
| 785 | osmrepo_new_schema = { |
| 786 | "title": "osm repo creation input schema", |
| 787 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 788 | "type": "object", |
| 789 | "properties": osmrepo_properties, |
| 790 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 791 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 792 | } |
| 793 | osmrepo_edit_schema = { |
| 794 | "title": "osm repo edit input schema", |
| 795 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 796 | "type": "object", |
| 797 | "properties": osmrepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 798 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 799 | } |
| 800 | |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 801 | # PDUs |
| 802 | pdu_interface = { |
| 803 | "type": "object", |
| 804 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 805 | "name": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 806 | "mgmt": bool_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 807 | "type": {"enum": ["overlay", "underlay"]}, |
| garciadeblas | 1a01e1f | 2021-10-26 17:27:35 +0200 | [diff] [blame] | 808 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 809 | # TODO, add user, password, ssh-key |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 810 | "mac-address": mac_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 811 | "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port |
| 812 | "vim-network-id": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 813 | # # provide this in case SDN assist must deal with this interface |
| 814 | # "switch-dpid": dpid_Schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 815 | # "switch-port": shortname_schema, |
| 816 | # "switch-mac": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 817 | # "switch-vlan": vlan_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 818 | }, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 819 | "required": ["name", "mgmt", "ip-address"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 820 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 821 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 822 | pdu_new_schema = { |
| 823 | "title": "pdu creation input schema", |
| 824 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 825 | "type": "object", |
| 826 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 827 | "name": shortname_schema, |
| 828 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 829 | "description": description_schema, |
| 830 | "shared": bool_schema, |
| 831 | "vims": nameshort_list_schema, |
| 832 | "vim_accounts": nameshort_list_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 833 | "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1}, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 834 | }, |
| 835 | "required": ["name", "type", "interfaces"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 836 | "additionalProperties": False, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 837 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 838 | pdu_edit_schema = { |
| 839 | "title": "pdu edit input schema", |
| 840 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 841 | "type": "object", |
| 842 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 843 | "name": shortname_schema, |
| 844 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 845 | "description": description_schema, |
| 846 | "shared": bool_schema, |
| garciadeblas | 84bdd55 | 2018-11-30 22:59:45 +0100 | [diff] [blame] | 847 | "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| 848 | "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 849 | "interfaces": { |
| 850 | "oneOf": [ |
| 851 | array_edition_schema, |
| 852 | {"type": "array", "items": pdu_interface, "minItems": 1}, |
| 853 | ] |
| 854 | }, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 855 | }, |
| 856 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 857 | "minProperties": 1, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 858 | } |
| 859 | |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 860 | # VNF PKG OPERATIONS |
| 861 | vnfpkgop_new_schema = { |
| 862 | "title": "VNF PKG operation creation input schema", |
| 863 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 864 | "type": "object", |
| 865 | "properties": { |
| 866 | "lcmOperationType": string_schema, |
| 867 | "vnfPkgId": id_schema, |
| 868 | "kdu_name": name_schema, |
| 869 | "primitive": name_schema, |
| 870 | "primitive_params": {"type": "object"}, |
| 871 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 872 | "required": [ |
| 873 | "lcmOperationType", |
| 874 | "vnfPkgId", |
| 875 | "kdu_name", |
| 876 | "primitive", |
| 877 | "primitive_params", |
| 878 | ], |
| 879 | "additionalProperties": False, |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 880 | } |
| 881 | |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 882 | # USERS |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 883 | project_role_mappings = { |
| 884 | "title": "list pf projects/roles", |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 885 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 886 | "type": "array", |
| 887 | "items": { |
| 888 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 889 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 890 | "required": ["project", "role"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 891 | "additionalProperties": False, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 892 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 893 | "minItems": 1, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 894 | } |
| 895 | project_role_mappings_optional = { |
| 896 | "title": "list of projects/roles or projects only", |
| 897 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 898 | "type": "array", |
| 899 | "items": { |
| 900 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 901 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 902 | "required": ["project"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 903 | "additionalProperties": False, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 904 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 905 | "minItems": 1, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 906 | } |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 907 | user_new_schema = { |
| 908 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 909 | "title": "New user schema", |
| 910 | "type": "object", |
| 911 | "properties": { |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 912 | "username": string_schema, |
| tierno | ad6d533 | 2020-02-19 14:29:49 +0000 | [diff] [blame] | 913 | "domain_name": shortname_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 914 | "password": passwd_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 915 | "projects": nameshort_list_schema, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 916 | "project_role_mappings": project_role_mappings, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 917 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 918 | "required": ["username", "password"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 919 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 920 | } |
| 921 | user_edit_schema = { |
| 922 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 923 | "title": "User edit schema for administrators", |
| 924 | "type": "object", |
| 925 | "properties": { |
| 926 | "password": passwd_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 927 | "username": string_schema, # To allow User Name modification |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 928 | "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 929 | "project_role_mappings": project_role_mappings, |
| 930 | "add_project_role_mappings": project_role_mappings, |
| 931 | "remove_project_role_mappings": project_role_mappings_optional, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 932 | }, |
| 933 | "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 934 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 935 | } |
| 936 | |
| 937 | # PROJECTS |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 938 | topics_with_quota = [ |
| 939 | "vnfds", |
| 940 | "nsds", |
| 941 | "slice_templates", |
| 942 | "pduds", |
| 943 | "ns_instances", |
| 944 | "slice_instances", |
| 945 | "vim_accounts", |
| 946 | "wim_accounts", |
| 947 | "sdn_controllers", |
| 948 | "k8sclusters", |
| 949 | "vca", |
| 950 | "k8srepos", |
| 951 | "osmrepos", |
| 952 | "ns_subscriptions", |
| 953 | ] |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 954 | project_new_schema = { |
| 955 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 956 | "title": "New project schema for administrators", |
| 957 | "type": "object", |
| 958 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 959 | "name": shortname_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 960 | "admin": bool_schema, |
| tierno | ad6d533 | 2020-02-19 14:29:49 +0000 | [diff] [blame] | 961 | "domain_name": shortname_schema, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 962 | "quotas": { |
| 963 | "type": "object", |
| 964 | "properties": {topic: integer0_schema for topic in topics_with_quota}, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 965 | "additionalProperties": False, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 966 | }, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 967 | }, |
| 968 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 969 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 970 | } |
| 971 | project_edit_schema = { |
| 972 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 973 | "title": "Project edit schema for administrators", |
| 974 | "type": "object", |
| 975 | "properties": { |
| 976 | "admin": bool_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 977 | "name": shortname_schema, # To allow Project Name modification |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 978 | "quotas": { |
| 979 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 980 | "properties": { |
| 981 | topic: {"oneOf": [integer0_schema, null_schema]} |
| 982 | for topic in topics_with_quota |
| 983 | }, |
| 984 | "additionalProperties": False, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 985 | }, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 986 | }, |
| 987 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 988 | "minProperties": 1, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 989 | } |
| 990 | |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 991 | # ROLES |
| 992 | roles_new_schema = { |
| 993 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 994 | "title": "New role schema for administrators", |
| 995 | "type": "object", |
| 996 | "properties": { |
| 997 | "name": shortname_schema, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 998 | "permissions": { |
| 999 | "type": "object", |
| 1000 | "patternProperties": { |
| 1001 | ".": bool_schema, |
| 1002 | }, |
| 1003 | # "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1004 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1005 | }, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1006 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1007 | "additionalProperties": False, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1008 | } |
| 1009 | roles_edit_schema = { |
| 1010 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1011 | "title": "Roles edit schema for administrators", |
| 1012 | "type": "object", |
| 1013 | "properties": { |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1014 | "name": shortname_schema, |
| 1015 | "permissions": { |
| 1016 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1017 | "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}}, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1018 | # "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1019 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1020 | }, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1021 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1022 | "minProperties": 1, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1023 | } |
| 1024 | |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1025 | # GLOBAL SCHEMAS |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1026 | |
| 1027 | nbi_new_input_schemas = { |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1028 | "users": user_new_schema, |
| 1029 | "projects": project_new_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 1030 | "vim_accounts": vim_account_new_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 1031 | "sdns": sdn_new_schema, |
| 1032 | "ns_instantiate": ns_instantiate, |
| 1033 | "ns_action": ns_action, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1034 | "ns_scale": ns_scale, |
| 1035 | "pdus": pdu_new_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | nbi_edit_input_schemas = { |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1039 | "users": user_edit_schema, |
| 1040 | "projects": project_edit_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 1041 | "vim_accounts": vim_account_edit_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1042 | "sdns": sdn_edit_schema, |
| 1043 | "pdus": pdu_edit_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1044 | } |
| 1045 | |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1046 | # NETSLICE SCHEMAS |
| tierno | 032916c | 2019-03-22 13:27:12 +0000 | [diff] [blame] | 1047 | nsi_subnet_instantiate = deepcopy(ns_instantiate) |
| 1048 | nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema" |
| 1049 | nsi_subnet_instantiate["properties"]["id"] = name_schema |
| 1050 | del nsi_subnet_instantiate["required"] |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1051 | |
| 1052 | nsi_vld_instantiate = { |
| 1053 | "title": "netslice vld instantiation params input schema", |
| 1054 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1055 | "type": "object", |
| 1056 | "properties": { |
| 1057 | "name": string_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 1058 | "vim-network-name": {"oneOf": [string_schema, object_schema]}, |
| 1059 | "vim-network-id": {"oneOf": [string_schema, object_schema]}, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1060 | "ip-profile": object_schema, |
| 1061 | }, |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1062 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1063 | "additionalProperties": False, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1064 | } |
| 1065 | |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1066 | nsi_instantiate = { |
| 1067 | "title": "netslice action instantiate input schema", |
| 1068 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1069 | "type": "object", |
| 1070 | "properties": { |
| 1071 | "lcmOperationType": string_schema, |
| Felipe Vicens | 126af57 | 2019-06-05 19:13:04 +0200 | [diff] [blame] | 1072 | "netsliceInstanceId": id_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1073 | "nsiName": name_schema, |
| tierno | 4f9d4ae | 2019-03-20 17:24:11 +0000 | [diff] [blame] | 1074 | "nsiDescription": {"oneOf": [description_schema, null_schema]}, |
| tierno | 9e5eea3 | 2018-11-29 09:42:09 +0000 | [diff] [blame] | 1075 | "nstId": string_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1076 | "vimAccountId": id_schema, |
| tierno | a8186a5 | 2020-01-14 15:54:48 +0000 | [diff] [blame] | 1077 | "timeout_nsi_deploy": integer1_schema, |
| Felipe Vicens | 26202bb | 2020-05-24 18:57:33 +0200 | [diff] [blame] | 1078 | "ssh_keys": {"type": "array", "items": {"type": "string"}}, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1079 | "nsi_id": id_schema, |
| tierno | 032916c | 2019-03-22 13:27:12 +0000 | [diff] [blame] | 1080 | "additionalParamsForNsi": object_schema, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1081 | "netslice-subnet": { |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1082 | "type": "array", |
| 1083 | "minItems": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1084 | "items": nsi_subnet_instantiate, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1085 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1086 | "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate}, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1087 | }, |
| Felipe Vicens | c8bbaaa | 2018-12-01 04:42:40 +0100 | [diff] [blame] | 1088 | "required": ["nsiName", "nstId", "vimAccountId"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1089 | "additionalProperties": False, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1090 | } |
| 1091 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1092 | nsi_action = {} |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1093 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1094 | nsi_terminate = {} |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1095 | |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1096 | nsinstancesubscriptionfilter_schema = { |
| 1097 | "title": "instance identifier schema", |
| 1098 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1099 | "type": "object", |
| 1100 | "properties": { |
| 1101 | "nsdIds": {"type": "array"}, |
| 1102 | "vnfdIds": {"type": "array"}, |
| 1103 | "pnfdIds": {"type": "array"}, |
| 1104 | "nsInstanceIds": {"type": "array"}, |
| 1105 | "nsInstanceNames": {"type": "array"}, |
| 1106 | }, |
| 1107 | } |
| 1108 | |
| 1109 | nslcmsub_schema = { |
| 1110 | "title": "nslcmsubscription input schema", |
| 1111 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1112 | "type": "object", |
| 1113 | "properties": { |
| 1114 | "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema, |
| 1115 | "notificationTypes": { |
| 1116 | "type": "array", |
| 1117 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1118 | "enum": [ |
| 1119 | "NsLcmOperationOccurrenceNotification", |
| 1120 | "NsChangeNotification", |
| 1121 | "NsIdentifierCreationNotification", |
| 1122 | "NsIdentifierDeletionNotification", |
| 1123 | ] |
| 1124 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1125 | }, |
| 1126 | "operationTypes": { |
| 1127 | "type": "array", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1128 | "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]}, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1129 | }, |
| 1130 | "operationStates": { |
| 1131 | "type": "array", |
| 1132 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1133 | "enum": [ |
| 1134 | "PROCESSING", |
| 1135 | "COMPLETED", |
| 1136 | "PARTIALLY_COMPLETED", |
| 1137 | "FAILED", |
| 1138 | "FAILED_TEMP", |
| 1139 | "ROLLING_BACK", |
| 1140 | "ROLLED_BACK", |
| 1141 | ] |
| 1142 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1143 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1144 | "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}}, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1145 | "lcmOpNameImpactingNsComponent": { |
| 1146 | "type": "array", |
| 1147 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1148 | "enum": [ |
| 1149 | "VNF_INSTANTIATE", |
| 1150 | "VNF_SCALE", |
| 1151 | "VNF_SCALE_TO_LEVEL", |
| 1152 | "VNF_CHANGE_FLAVOUR", |
| 1153 | "VNF_TERMINATE", |
| 1154 | "VNF_HEAL", |
| 1155 | "VNF_OPERATE", |
| 1156 | "VNF_CHANGE_EXT_CONN", |
| 1157 | "VNF_MODIFY_INFO", |
| 1158 | "NS_INSTANTIATE", |
| 1159 | "NS_SCALE", |
| 1160 | "NS_UPDATE", |
| 1161 | "NS_TERMINATE", |
| 1162 | "NS_HEAL", |
| 1163 | ] |
| 1164 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1165 | }, |
| 1166 | "lcmOpOccStatusImpactingNsComponent": { |
| 1167 | "type": "array", |
| 1168 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1169 | "enum": [ |
| 1170 | "START", |
| 1171 | "COMPLETED", |
| 1172 | "PARTIALLY_COMPLETED", |
| 1173 | "FAILED", |
| 1174 | "ROLLED_BACK", |
| 1175 | ] |
| 1176 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1177 | }, |
| 1178 | }, |
| 1179 | "allOf": [ |
| 1180 | { |
| 1181 | "if": { |
| 1182 | "properties": { |
| 1183 | "notificationTypes": { |
| 1184 | "contains": {"const": "NsLcmOperationOccurrenceNotification"} |
| 1185 | } |
| 1186 | }, |
| 1187 | }, |
| 1188 | "then": { |
| 1189 | "anyOf": [ |
| 1190 | {"required": ["operationTypes"]}, |
| 1191 | {"required": ["operationStates"]}, |
| 1192 | ] |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1193 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1194 | }, |
| 1195 | { |
| 1196 | "if": { |
| 1197 | "properties": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1198 | "notificationTypes": {"contains": {"const": "NsChangeNotification"}} |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1199 | }, |
| 1200 | }, |
| 1201 | "then": { |
| 1202 | "anyOf": [ |
| 1203 | {"required": ["nsComponentTypes"]}, |
| 1204 | {"required": ["lcmOpNameImpactingNsComponent"]}, |
| 1205 | {"required": ["lcmOpOccStatusImpactingNsComponent"]}, |
| 1206 | ] |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1207 | }, |
| 1208 | }, |
| 1209 | ], |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1210 | } |
| 1211 | |
| 1212 | authentication_schema = { |
| 1213 | "title": "authentication schema for subscription", |
| 1214 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1215 | "type": "object", |
| 1216 | "properties": { |
| 1217 | "authType": {"enum": ["basic"]}, |
| 1218 | "paramsBasic": { |
| 1219 | "type": "object", |
| 1220 | "properties": { |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 1221 | "userName": string_schema, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1222 | "password": passwd_schema, |
| 1223 | }, |
| 1224 | }, |
| 1225 | }, |
| 1226 | } |
| 1227 | |
| 1228 | subscription = { |
| 1229 | "title": "subscription input schema", |
| 1230 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1231 | "type": "object", |
| 1232 | "properties": { |
| 1233 | "filter": nslcmsub_schema, |
| 1234 | "CallbackUri": description_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1235 | "authentication": authentication_schema, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1236 | }, |
| 1237 | "required": ["CallbackUri"], |
| 1238 | } |
| 1239 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1240 | |
| 1241 | class ValidationError(Exception): |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1242 | def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY): |
| 1243 | self.http_code = http_code |
| 1244 | Exception.__init__(self, message) |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1245 | |
| 1246 | |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1247 | def validate_input(indata, schema_to_use): |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1248 | """ |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1249 | Validates input data against json schema |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1250 | :param indata: user input data. Should be a dictionary |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1251 | :param schema_to_use: jsonschema to test |
| 1252 | :return: None if ok, raises ValidationError exception on error |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1253 | """ |
| 1254 | try: |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1255 | if schema_to_use: |
| 1256 | js_v(indata, schema_to_use) |
| 1257 | return None |
| 1258 | except js_e.ValidationError as e: |
| 1259 | if e.path: |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 1260 | error_pos = "at '" + ":".join(map(str, e.path)) + "'" |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1261 | else: |
| 1262 | error_pos = "" |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 1263 | raise ValidationError("Format error {} '{}' ".format(error_pos, e.message)) |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1264 | except js_e.SchemaError: |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1265 | raise ValidationError( |
| 1266 | "Bad json schema {}".format(schema_to_use), |
| 1267 | http_code=HTTPStatus.INTERNAL_SERVER_ERROR, |
| 1268 | ) |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1269 | |
| 1270 | |
| 1271 | def is_valid_uuid(x): |
| 1272 | """ |
| 1273 | Test for a valid UUID |
| 1274 | :param x: string to test |
| 1275 | :return: True if x is a valid uuid, False otherwise |
| 1276 | """ |
| 1277 | try: |
| 1278 | if UUID(x): |
| 1279 | return True |
| tierno | bdebce9 | 2019-07-01 15:36:49 +0000 | [diff] [blame] | 1280 | except (TypeError, ValueError, AttributeError): |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1281 | return False |