| 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 | 6d83f8f | 2023-06-19 22:34:49 +0200 | [diff] [blame] | 38 | user_passwd_schema = { |
| 39 | "type": "string", |
| 40 | "pattern": "^.*(?=.{8,})((?=.*[!@#$%^&*()\\-_=+{};:,<.>]){1})(?=.*\\d)((?=.*[a-z]){1})((?=.*[A-Z]){1}).*$", |
| 41 | } |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 42 | name_schema = { |
| 43 | "type": "string", |
| 44 | "minLength": 1, |
| 45 | "maxLength": 255, |
| 46 | "pattern": "^[^,;()'\"]+$", |
| 47 | } |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 48 | string_schema = {"type": "string", "minLength": 1, "maxLength": 255} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 49 | xml_text_schema = { |
| 50 | "type": "string", |
| 51 | "minLength": 1, |
| 52 | "maxLength": 1000, |
| 53 | "pattern": "^[^']+$", |
| 54 | } |
| 55 | description_schema = { |
| 56 | "type": ["string", "null"], |
| 57 | "maxLength": 255, |
| 58 | "pattern": "^[^'\"]+$", |
| 59 | } |
| 60 | long_description_schema = { |
| 61 | "type": ["string", "null"], |
| 62 | "maxLength": 3000, |
| 63 | "pattern": "^[^'\"]+$", |
| 64 | } |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 65 | id_schema_fake = {"type": "string", "minLength": 2, "maxLength": 36} |
| 66 | bool_schema = {"type": "boolean"} |
| 67 | null_schema = {"type": "null"} |
| tierno | 2236d20 | 2018-05-16 19:05:16 +0200 | [diff] [blame] | 68 | # "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] | 69 | id_schema = { |
| 70 | "type": "string", |
| 71 | "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$", |
| 72 | } |
| 73 | time_schema = { |
| 74 | "type": "string", |
| 75 | "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}", |
| 76 | } |
| 77 | pci_schema = { |
| 78 | "type": "string", |
| 79 | "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\\.[0-9a-fA-F]$", |
| 80 | } |
| tierno | 42fce59 | 2018-11-02 09:23:43 +0100 | [diff] [blame] | 81 | # allows [] for wildcards. For that reason huge length limit is set |
| 82 | 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] | 83 | http_schema = {"type": "string", "pattern": "^(https?|http)://[^'\"=]+$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 84 | bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"} |
| 85 | memory_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]i?[Bb])?$"} |
| 86 | integer0_schema = {"type": "integer", "minimum": 0} |
| 87 | integer1_schema = {"type": "integer", "minimum": 1} |
| tierno | 8700604 | 2018-10-24 12:50:20 +0200 | [diff] [blame] | 88 | path_schema = {"type": "string", "pattern": "^(\\.){0,2}(/[^/\"':{}\\(\\)]+)+$"} |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 89 | vlan_schema = {"type": "integer", "minimum": 1, "maximum": 4095} |
| 90 | vlan1000_schema = {"type": "integer", "minimum": 1000, "maximum": 4095} |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 91 | mac_schema = { |
| 92 | "type": "string", |
| 93 | "pattern": "^[0-9a-fA-F][02468aceACE](:[0-9a-fA-F]{2}){5}$", |
| 94 | } # must be unicast: LSB bit of MSB byte ==0 |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 95 | 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] | 96 | # 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] | 97 | ip_schema = { |
| 98 | "type": "string", |
| 99 | "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]?)$", |
| 100 | } |
| garciadeblas | 1a01e1f | 2021-10-26 17:27:35 +0200 | [diff] [blame] | 101 | ipv6_schema = { |
| 102 | "type": "string", |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 103 | "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]))", # noqa: W605 |
| garciadeblas | 1a01e1f | 2021-10-26 17:27:35 +0200 | [diff] [blame] | 104 | } |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 105 | ip_prefix_schema = { |
| 106 | "type": "string", |
| 107 | "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}" |
| 108 | "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$", |
| 109 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 110 | port_schema = {"type": "integer", "minimum": 1, "maximum": 65534} |
| 111 | object_schema = {"type": "object"} |
| 112 | schema_version_2 = {"type": "integer", "minimum": 2, "maximum": 2} |
| 113 | # 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] | 114 | log_level_schema = { |
| 115 | "type": "string", |
| 116 | "enum": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], |
| 117 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 118 | checksum_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{32}$"} |
| 119 | size_schema = {"type": "integer", "minimum": 1, "maximum": 100} |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 120 | array_edition_schema = { |
| 121 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 122 | "patternProperties": {"^\\$": {}}, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 123 | "additionalProperties": False, |
| 124 | "minProperties": 1, |
| 125 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 126 | nameshort_list_schema = { |
| 127 | "type": "array", |
| 128 | "minItems": 1, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 129 | "items": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 130 | } |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 131 | |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 132 | description_list_schema = { |
| 133 | "type": "array", |
| 134 | "minItems": 1, |
| 135 | "items": description_schema, |
| 136 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 137 | |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 138 | ns_instantiate_vdu = { |
| 139 | "title": "ns action instantiate input schema for vdu", |
| 140 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 141 | "type": "object", |
| 142 | "properties": { |
| 143 | "id": name_schema, |
| Gabriel Cuba | e88401b | 2023-04-05 15:24:52 -0500 | [diff] [blame] | 144 | "vim-flavor-id": name_schema, |
| kayal2001 | 6a3bce7 | 2024-06-27 11:14:59 +0530 | [diff] [blame] | 145 | "instance_name": name_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 146 | "volume": { |
| 147 | "type": "array", |
| 148 | "minItems": 1, |
| 149 | "items": { |
| 150 | "type": "object", |
| 151 | "properties": { |
| 152 | "name": name_schema, |
| 153 | "vim-volume-id": name_schema, |
| 154 | }, |
| 155 | "required": ["name", "vim-volume-id"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 156 | "additionalProperties": False, |
| 157 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 158 | }, |
| 159 | "interface": { |
| 160 | "type": "array", |
| 161 | "minItems": 1, |
| 162 | "items": { |
| 163 | "type": "object", |
| 164 | "properties": { |
| 165 | "name": name_schema, |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame] | 166 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 167 | "mac-address": mac_schema, |
| 168 | "floating-ip-required": bool_schema, |
| 169 | }, |
| 170 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 171 | "additionalProperties": False, |
| 172 | }, |
| 173 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 174 | }, |
| 175 | "required": ["id"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 176 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | ip_profile_dns_schema = { |
| 180 | "type": "array", |
| 181 | "minItems": 1, |
| 182 | "items": { |
| 183 | "type": "object", |
| 184 | "properties": { |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame] | 185 | "address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 186 | }, |
| 187 | "required": ["address"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 188 | "additionalProperties": False, |
| 189 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | ip_profile_dhcp_schema = { |
| 193 | "type": "object", |
| 194 | "properties": { |
| 195 | "enabled": {"type": "boolean"}, |
| 196 | "count": integer1_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 197 | "start-address": ip_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 198 | }, |
| 199 | "additionalProperties": False, |
| 200 | } |
| 201 | |
| 202 | ip_profile_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 203 | "title": "ip profile validation schema", |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 204 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 205 | "type": "object", |
| 206 | "properties": { |
| 207 | "ip-version": {"enum": ["ipv4", "ipv6"]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 208 | "subnet-address": {"oneOf": [null_schema, ip_prefix_schema]}, |
| 209 | "gateway-address": {"oneOf": [null_schema, ip_schema]}, |
| 210 | "dns-server": {"oneOf": [null_schema, ip_profile_dns_schema]}, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 211 | "dhcp-params": {"oneOf": [null_schema, ip_profile_dhcp_schema]}, |
| 212 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 213 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 214 | } |
| 215 | |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 216 | provider_network_schema = { |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 217 | "title": "provider network validation schema", |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 218 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 219 | "type": "object", |
| 220 | "properties": { |
| 221 | "physical-network": name_schema, |
| 222 | "segmentation-id": name_schema, |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 223 | "sdn-ports": { # external ports to append to the SDN-assist network |
| 224 | "type": "array", |
| 225 | "items": { |
| 226 | "type": "object", |
| 227 | "properties": { |
| 228 | "switch_id": shortname_schema, |
| 229 | "switch_port": shortname_schema, |
| 230 | "mac_address": mac_schema, |
| 231 | "vlan": vlan_schema, |
| 232 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 233 | "additionalProperties": True, |
| 234 | }, |
| tierno | 2a92904 | 2020-03-10 16:34:25 +0000 | [diff] [blame] | 235 | }, |
| 236 | "network-type": shortname_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 237 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 238 | "additionalProperties": True, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 241 | ns_instantiate_internal_vld = { |
| garciadeblas | 9fb3271 | 2022-04-04 16:33:59 +0200 | [diff] [blame] | 242 | "title": "ns action instantiate input schema for vld", |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 243 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 244 | "type": "object", |
| 245 | "properties": { |
| 246 | "name": name_schema, |
| 247 | "vim-network-name": name_schema, |
| gcalvino | 17d5b73 | 2018-12-17 16:26:21 +0100 | [diff] [blame] | 248 | "vim-network-id": name_schema, |
| garciadeblas | 120105b | 2023-02-22 16:52:24 +0100 | [diff] [blame] | 249 | "ip-profile": ip_profile_schema, |
| kbsub | 21f03f5 | 2019-10-17 16:26:56 +0000 | [diff] [blame] | 250 | "provider-network": provider_network_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 251 | "internal-connection-point": { |
| 252 | "type": "array", |
| 253 | "minItems": 1, |
| 254 | "items": { |
| 255 | "type": "object", |
| 256 | "properties": { |
| 257 | "id-ref": name_schema, |
| 258 | "ip-address": ip_schema, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 259 | # "mac-address": mac_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 260 | }, |
| tierno | b7c6f2a | 2018-09-03 14:32:10 +0200 | [diff] [blame] | 261 | "required": ["id-ref"], |
| 262 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 263 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 264 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 265 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 266 | }, |
| 267 | "required": ["name"], |
| 268 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 269 | "additionalProperties": False, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 270 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 271 | |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 272 | additional_params_for_vnf = { |
| 273 | "type": "array", |
| 274 | "items": { |
| 275 | "type": "object", |
| 276 | "properties": { |
| 277 | "member-vnf-index": name_schema, |
| 278 | "additionalParams": object_schema, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 279 | "k8s-namespace": name_schema, |
| tierno | f62ac6a | 2020-04-29 13:46:13 +0000 | [diff] [blame] | 280 | "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] | 281 | "additionalParamsForVdu": { |
| 282 | "type": "array", |
| 283 | "items": { |
| 284 | "type": "object", |
| 285 | "properties": { |
| 286 | "vdu_id": name_schema, |
| 287 | "additionalParams": object_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 288 | "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] | 289 | }, |
| tierno | f62ac6a | 2020-04-29 13:46:13 +0000 | [diff] [blame] | 290 | "required": ["vdu_id"], |
| 291 | "minProperties": 2, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 292 | "additionalProperties": False, |
| 293 | }, |
| 294 | }, |
| 295 | "additionalParamsForKdu": { |
| 296 | "type": "array", |
| 297 | "items": { |
| 298 | "type": "object", |
| 299 | "properties": { |
| 300 | "kdu_name": name_schema, |
| 301 | "additionalParams": object_schema, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 302 | "kdu_model": name_schema, |
| 303 | "k8s-namespace": name_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 304 | "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] | 305 | "kdu-deployment-name": name_schema, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 306 | }, |
| tierno | 54db2e4 | 2020-04-06 15:29:42 +0000 | [diff] [blame] | 307 | "required": ["kdu_name"], |
| 308 | "minProperties": 2, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 309 | "additionalProperties": False, |
| 310 | }, |
| 311 | }, |
| Alexis Romero | ee31f53 | 2022-04-26 19:10:21 +0200 | [diff] [blame] | 312 | "affinity-or-anti-affinity-group": { |
| 313 | "type": "array", |
| 314 | "items": { |
| 315 | "type": "object", |
| 316 | "properties": { |
| 317 | "id": name_schema, |
| 318 | "vim-affinity-group-id": name_schema, |
| 319 | }, |
| 320 | "required": ["id"], |
| 321 | "minProperties": 2, |
| 322 | "additionalProperties": False, |
| 323 | }, |
| 324 | }, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 325 | }, |
| tierno | 714954e | 2019-11-29 13:43:26 +0000 | [diff] [blame] | 326 | "required": ["member-vnf-index"], |
| 327 | "minProperties": 2, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 328 | "additionalProperties": False, |
| 329 | }, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| kayal2001 | f71c2e8 | 2024-06-25 15:26:24 +0530 | [diff] [blame] | 332 | vnf_schema = { |
| 333 | "type": "array", |
| 334 | "minItems": 1, |
| 335 | "items": { |
| 336 | "type": "object", |
| 337 | "properties": { |
| 338 | "member-vnf-index": name_schema, |
| 339 | "vimAccountId": id_schema, |
| 340 | "vdu": { |
| 341 | "type": "array", |
| 342 | "minItems": 1, |
| 343 | "items": ns_instantiate_vdu, |
| 344 | }, |
| 345 | "internal-vld": { |
| 346 | "type": "array", |
| 347 | "minItems": 1, |
| 348 | "items": ns_instantiate_internal_vld, |
| 349 | }, |
| 350 | }, |
| 351 | "required": ["member-vnf-index"], |
| 352 | "minProperties": 2, |
| 353 | "additionalProperties": False, |
| 354 | }, |
| 355 | } |
| 356 | |
| 357 | vld_schema = { |
| 358 | "type": "array", |
| 359 | "minItems": 1, |
| 360 | "items": { |
| 361 | "type": "object", |
| 362 | "properties": { |
| 363 | "name": string_schema, |
| 364 | "vim-network-name": {"oneOf": [string_schema, object_schema]}, |
| 365 | "vim-network-id": {"oneOf": [string_schema, object_schema]}, |
| 366 | "ns-net": object_schema, |
| 367 | "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
| 368 | "ip-profile": ip_profile_schema, |
| 369 | "provider-network": provider_network_schema, |
| 370 | "vnfd-connection-point-ref": { |
| 371 | "type": "array", |
| 372 | "minItems": 1, |
| 373 | "items": { |
| 374 | "type": "object", |
| 375 | "properties": { |
| 376 | "member-vnf-index-ref": name_schema, |
| 377 | "vnfd-connection-point-ref": name_schema, |
| 378 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| 379 | # "mac-address": mac_schema, |
| 380 | }, |
| 381 | "required": [ |
| 382 | "member-vnf-index-ref", |
| 383 | "vnfd-connection-point-ref", |
| 384 | ], |
| 385 | "minProperties": 3, |
| 386 | "additionalProperties": False, |
| 387 | }, |
| 388 | }, |
| 389 | }, |
| 390 | "required": ["name"], |
| 391 | "additionalProperties": False, |
| 392 | }, |
| 393 | } |
| 394 | |
| 395 | ns_config_template = { |
| 396 | "title": " ns config template input schema", |
| 397 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 398 | "type": "object", |
| 399 | "properties": { |
| 400 | "name": string_schema, |
| 401 | "nsdId": id_schema, |
| 402 | "config": object_schema, |
| 403 | }, |
| 404 | "required": ["name", "nsdId", "config"], |
| 405 | "additionalProperties": False, |
| 406 | } |
| 407 | |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 408 | ns_instantiate = { |
| 409 | "title": "ns action instantiate input schema", |
| 410 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 411 | "type": "object", |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 412 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 413 | "lcmOperationType": string_schema, |
| 414 | "nsInstanceId": id_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 415 | "netsliceInstanceId": id_schema, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 416 | "nsName": name_schema, |
| tierno | 4f9d4ae | 2019-03-20 17:24:11 +0000 | [diff] [blame] | 417 | "nsDescription": {"oneOf": [description_schema, null_schema]}, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 418 | "nsdId": id_schema, |
| 419 | "vimAccountId": id_schema, |
| kayal2001 | f71c2e8 | 2024-06-25 15:26:24 +0530 | [diff] [blame] | 420 | "nsConfigTemplateId": id_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 421 | "wimAccountId": {"oneOf": [id_schema, bool_schema, null_schema]}, |
| magnussonl | f318b30 | 2020-01-20 18:38:18 +0100 | [diff] [blame] | 422 | "placement-engine": string_schema, |
| 423 | "placement-constraints": object_schema, |
| tierno | bee085c | 2018-12-12 17:03:04 +0000 | [diff] [blame] | 424 | "additionalParamsForNs": object_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 425 | "additionalParamsForVnf": additional_params_for_vnf, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 426 | "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] | 427 | "k8s-namespace": name_schema, |
| tierno | fc5089c | 2018-10-31 09:28:11 +0100 | [diff] [blame] | 428 | "ssh_keys": {"type": "array", "items": {"type": "string"}}, |
| tierno | a8186a5 | 2020-01-14 15:54:48 +0000 | [diff] [blame] | 429 | "timeout_ns_deploy": integer1_schema, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 430 | "nsr_id": id_schema, |
| tierno | cc10343 | 2018-10-19 14:10:35 +0200 | [diff] [blame] | 431 | "vduImage": name_schema, |
| kayal2001 | f71c2e8 | 2024-06-25 15:26:24 +0530 | [diff] [blame] | 432 | "vnf": vnf_schema, |
| 433 | "vld": vld_schema, |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 434 | }, |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 435 | "required": ["nsName", "nsdId", "vimAccountId"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 436 | "additionalProperties": False, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 437 | } |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 438 | |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 439 | ns_terminate = { |
| 440 | "title": "ns terminate input schema", |
| 441 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 442 | "type": "object", |
| 443 | "properties": { |
| 444 | "lcmOperationType": string_schema, |
| 445 | "nsInstanceId": id_schema, |
| 446 | "autoremove": bool_schema, |
| 447 | "timeout_ns_terminate": integer1_schema, |
| 448 | "skip_terminate_primitives": bool_schema, |
| tierno | 0b8752f | 2020-05-12 09:42:02 +0000 | [diff] [blame] | 449 | "netsliceInstanceId": id_schema, |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 450 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 451 | "additionalProperties": False, |
| tierno | 1c38f2f | 2020-03-24 11:51:39 +0000 | [diff] [blame] | 452 | } |
| 453 | |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 454 | ns_update = { |
| 455 | "title": "ns update input schema", |
| 456 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 457 | "type": "object", |
| 458 | "properties": { |
| 459 | "lcmOperationType": string_schema, |
| 460 | "nsInstanceId": id_schema, |
| garciadeblas | eab1507 | 2022-05-19 10:31:52 +0200 | [diff] [blame] | 461 | "timeout_ns_update": integer1_schema, |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 462 | "updateType": { |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 463 | "enum": [ |
| 464 | "CHANGE_VNFPKG", |
| 465 | "REMOVE_VNF", |
| 466 | "MODIFY_VNF_INFORMATION", |
| 467 | "OPERATE_VNF", |
| Rahul Kumar | a30391b | 2024-05-24 14:40:23 +0530 | [diff] [blame] | 468 | "VERTICAL_SCALE", |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 469 | ] |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 470 | }, |
| 471 | "modifyVnfInfoData": { |
| 472 | "type": "object", |
| 473 | "properties": { |
| 474 | "vnfInstanceId": id_schema, |
| 475 | "vnfdId": id_schema, |
| 476 | }, |
| 477 | "required": ["vnfInstanceId", "vnfdId"], |
| 478 | }, |
| 479 | "removeVnfInstanceId": id_schema, |
| 480 | "changeVnfPackageData": { |
| 481 | "type": "object", |
| 482 | "properties": { |
| 483 | "vnfInstanceId": id_schema, |
| 484 | "vnfdId": id_schema, |
| 485 | }, |
| 486 | "required": ["vnfInstanceId", "vnfdId"], |
| 487 | }, |
| k4.rahul | e3dca38 | 2022-04-29 12:30:36 +0000 | [diff] [blame] | 488 | "operateVnfData": { |
| 489 | "type": "object", |
| 490 | "properties": { |
| 491 | "vnfInstanceId": id_schema, |
| 492 | "changeStateTo": name_schema, |
| 493 | "additionalParam": { |
| 494 | "type": "object", |
| 495 | "properties": { |
| 496 | "run-day1": bool_schema, |
| 497 | "vdu_id": name_schema, |
| 498 | "count-index": integer0_schema, |
| 499 | }, |
| 500 | "required": ["vdu_id", "count-index"], |
| 501 | "additionalProperties": False, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 502 | }, |
| k4.rahul | e3dca38 | 2022-04-29 12:30:36 +0000 | [diff] [blame] | 503 | }, |
| 504 | "required": ["vnfInstanceId", "changeStateTo"], |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 505 | }, |
| Rahul Kumar | a30391b | 2024-05-24 14:40:23 +0530 | [diff] [blame] | 506 | "verticalScaleVnf": { |
| 507 | "type": "object", |
| 508 | "properties": { |
| 509 | "vnfInstanceId": id_schema, |
| 510 | "vnfdId": id_schema, |
| 511 | "vduId": name_schema, |
| 512 | "countIndex": integer0_schema, |
| 513 | }, |
| 514 | "required": ["vnfInstanceId", "vnfdId", "vduId"], |
| 515 | }, |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 516 | }, |
| 517 | "required": ["updateType"], |
| 518 | "additionalProperties": False, |
| 519 | } |
| 520 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 521 | 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] | 522 | "title": "ns action input schema", |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 523 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 524 | "type": "object", |
| 525 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 526 | "lcmOperationType": string_schema, |
| 527 | "nsInstanceId": id_schema, |
| tierno | f5298be | 2018-05-16 14:43:57 +0200 | [diff] [blame] | 528 | "member_vnf_index": name_schema, |
| 529 | "vnf_member_index": name_schema, # TODO for backward compatibility. To remove in future |
| tierno | 7ce1db9 | 2018-07-25 12:50:52 +0200 | [diff] [blame] | 530 | "vdu_id": name_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 531 | "vdu_count_index": integer0_schema, |
| tierno | 9cb7d67 | 2019-10-30 12:13:48 +0000 | [diff] [blame] | 532 | "kdu_name": name_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 533 | "primitive": name_schema, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 534 | "timeout_ns_action": integer1_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 535 | "primitive_params": {"type": "object"}, |
| 536 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 537 | "required": ["primitive", "primitive_params"], # TODO add member_vnf_index |
| 538 | "additionalProperties": False, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 539 | } |
| garciadeblas | 0964edf | 2022-02-11 00:43:44 +0100 | [diff] [blame] | 540 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 541 | ns_scale = { # TODO for the moment it is only VDU-scaling |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 542 | "title": "ns scale input schema", |
| 543 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 544 | "type": "object", |
| 545 | "properties": { |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 546 | "lcmOperationType": string_schema, |
| 547 | "nsInstanceId": id_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 548 | "scaleType": {"enum": ["SCALE_VNF"]}, |
| tierno | 50c8e6e | 2020-04-02 15:40:12 +0000 | [diff] [blame] | 549 | "timeout_ns_scale": integer1_schema, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 550 | "scaleVnfData": { |
| 551 | "type": "object", |
| 552 | "properties": { |
| 553 | "vnfInstanceId": name_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 554 | "scaleVnfType": {"enum": ["SCALE_OUT", "SCALE_IN"]}, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 555 | "scaleByStepData": { |
| 556 | "type": "object", |
| 557 | "properties": { |
| 558 | "scaling-group-descriptor": name_schema, |
| 559 | "member-vnf-index": name_schema, |
| 560 | "scaling-policy": name_schema, |
| 561 | }, |
| 562 | "required": ["scaling-group-descriptor", "member-vnf-index"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 563 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 564 | }, |
| 565 | }, |
| 566 | "required": ["scaleVnfType", "scaleByStepData"], # vnfInstanceId |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 567 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 568 | }, |
| 569 | "scaleTime": time_schema, |
| 570 | }, |
| 571 | "required": ["scaleType", "scaleVnfData"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 572 | "additionalProperties": False, |
| tierno | f759d82 | 2018-06-11 18:54:54 +0200 | [diff] [blame] | 573 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 574 | |
| elumalai | 8e3806c | 2022-04-28 17:26:24 +0530 | [diff] [blame] | 575 | ns_migrate = { |
| 576 | "title": "ns migrate input schema", |
| 577 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 578 | "type": "object", |
| 579 | "properties": { |
| 580 | "lcmOperationType": string_schema, |
| 581 | "nsInstanceId": id_schema, |
| 582 | "vnfInstanceId": id_schema, |
| 583 | "migrateToHost": string_schema, |
| 584 | "vdu": { |
| 585 | "type": "object", |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 586 | "properties": { |
| 587 | "vduId": name_schema, |
| 588 | "vduCountIndex": integer0_schema, |
| 589 | }, |
| 590 | "required": ["vduId"], |
| 591 | "additionalProperties": False, |
| elumalai | 8e3806c | 2022-04-28 17:26:24 +0530 | [diff] [blame] | 592 | }, |
| 593 | }, |
| 594 | "required": ["vnfInstanceId"], |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 595 | "additionalProperties": False, |
| elumalai | 8e3806c | 2022-04-28 17:26:24 +0530 | [diff] [blame] | 596 | } |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 597 | |
| garciadeblas | 0964edf | 2022-02-11 00:43:44 +0100 | [diff] [blame] | 598 | ns_heal = { |
| 599 | "title": "ns heal input schema", |
| 600 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 601 | "type": "object", |
| 602 | "properties": { |
| 603 | "lcmOperationType": string_schema, |
| 604 | "nsInstanceId": id_schema, |
| 605 | "timeout_ns_heal": integer1_schema, |
| 606 | "healVnfData": { |
| 607 | "type": "array", |
| 608 | "items": { |
| 609 | "type": "object", |
| 610 | "properties": { |
| 611 | "vnfInstanceId": id_schema, |
| 612 | "cause": description_schema, |
| 613 | "additionalParams": { |
| 614 | "type": "object", |
| 615 | "properties": { |
| 616 | "run-day1": bool_schema, |
| 617 | "vdu": { |
| 618 | "type": "array", |
| 619 | "items": { |
| 620 | "type": "object", |
| 621 | "properties": { |
| 622 | "run-day1": bool_schema, |
| 623 | "vdu-id": name_schema, |
| 624 | "count-index": integer0_schema, |
| 625 | }, |
| 626 | "required": ["vdu-id"], |
| 627 | "additionalProperties": False, |
| 628 | }, |
| 629 | }, |
| 630 | }, |
| 631 | "additionalProperties": False, |
| 632 | }, |
| 633 | }, |
| 634 | "required": ["vnfInstanceId"], |
| 635 | "additionalProperties": False, |
| 636 | }, |
| 637 | }, |
| 638 | }, |
| 639 | "required": ["healVnfData"], |
| 640 | "additionalProperties": False, |
| 641 | } |
| 642 | |
| Gabriel Cuba | 84a60df | 2023-10-30 14:01:54 -0500 | [diff] [blame] | 643 | nslcmop_cancel = { |
| 644 | "title": "Cancel nslcmop input schema", |
| 645 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 646 | "type": "object", |
| 647 | "properties": { |
| 648 | "nsLcmOpOccId": id_schema, |
| 649 | "cancelMode": { |
| 650 | "enum": [ |
| 651 | "GRACEFUL", |
| 652 | "FORCEFUL", |
| 653 | ] |
| 654 | }, |
| 655 | }, |
| 656 | "required": ["cancelMode"], |
| 657 | "additionalProperties": False, |
| 658 | } |
| 659 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 660 | schema_version = {"type": "string", "enum": ["1.0"]} |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 661 | schema_type = {"type": "string"} |
| tierno | b3d0a0e | 2019-11-13 15:57:51 +0000 | [diff] [blame] | 662 | vim_type = shortname_schema # {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws", "azure", "fos"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 663 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 664 | vim_account_edit_schema = { |
| 665 | "title": "vim_account edit input schema", |
| 666 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 667 | "type": "object", |
| 668 | "properties": { |
| 669 | "name": name_schema, |
| 670 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 671 | "vim": name_schema, |
| 672 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 673 | "vim_type": vim_type, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 674 | "vim_url": description_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 675 | # "vim_url_admin": description_schema, |
| 676 | # "vim_tenant": name_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 677 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame] | 678 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 679 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 680 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 681 | "config": {"type": "object"}, |
| vegall | 5c59aab | 2022-04-27 15:31:49 +0000 | [diff] [blame] | 682 | "prometheus-config": {"type": "object"}, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 683 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 684 | "additionalProperties": False, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 685 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 686 | |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 687 | vim_account_new_schema = { |
| 688 | "title": "vim_account creation input schema", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 689 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 690 | "type": "object", |
| 691 | "properties": { |
| 692 | "schema_version": schema_version, |
| 693 | "schema_type": schema_type, |
| 694 | "name": name_schema, |
| 695 | "description": description_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 696 | "vim": name_schema, |
| 697 | "datacenter": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 698 | "vim_type": vim_type, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 699 | "vim_url": description_schema, |
| 700 | # "vim_url_admin": description_schema, |
| 701 | # "vim_tenant": name_schema, |
| 702 | "vim_tenant_name": name_schema, |
| sousaedu | f2feafd | 2021-07-12 10:21:06 +0200 | [diff] [blame] | 703 | "vim_user": string_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 704 | "vim_password": passwd_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 705 | "vca": id_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 706 | "config": {"type": "object"}, |
| vegall | 5c59aab | 2022-04-27 15:31:49 +0000 | [diff] [blame] | 707 | "prometheus-config": {"type": "object"}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 708 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 709 | "required": [ |
| 710 | "name", |
| 711 | "vim_url", |
| 712 | "vim_type", |
| 713 | "vim_user", |
| 714 | "vim_password", |
| 715 | "vim_tenant_name", |
| 716 | ], |
| 717 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 718 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 719 | |
| tierno | 8580772 | 2019-12-20 14:11:35 +0000 | [diff] [blame] | 720 | wim_type = shortname_schema # {"enum": ["ietfl2vpn", "onos", "odl", "dynpac", "fake"]} |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 721 | |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 722 | wim_account_edit_schema = { |
| 723 | "title": "wim_account edit input schema", |
| 724 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 725 | "type": "object", |
| 726 | "properties": { |
| 727 | "name": name_schema, |
| 728 | "description": description_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 729 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 730 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 731 | "wim_url": description_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 732 | "user": string_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 733 | "password": passwd_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 734 | "config": {"type": "object"}, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 735 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 736 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | wim_account_new_schema = { |
| 740 | "title": "wim_account creation input schema", |
| 741 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 742 | "type": "object", |
| 743 | "properties": { |
| 744 | "schema_version": schema_version, |
| 745 | "schema_type": schema_type, |
| 746 | "name": name_schema, |
| 747 | "description": description_schema, |
| 748 | "wim": name_schema, |
| delacruzramo | 3a144c9 | 2019-10-25 09:46:33 +0200 | [diff] [blame] | 749 | "wim_type": wim_type, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 750 | "wim_url": description_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 751 | "user": string_schema, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 752 | "password": passwd_schema, |
| tierno | f063705 | 2019-03-07 16:26:47 +0000 | [diff] [blame] | 753 | "config": { |
| 754 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 755 | "patternProperties": {".": {"not": {"type": "null"}}}, |
| 756 | }, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 757 | }, |
| 758 | "required": ["name", "wim_url", "wim_type"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 759 | "additionalProperties": False, |
| tierno | 55ba2e6 | 2018-12-11 17:22:22 +0000 | [diff] [blame] | 760 | } |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 761 | |
| 762 | sdn_properties = { |
| 763 | "name": name_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 764 | "type": {"type": "string"}, |
| 765 | "url": {"type": "string"}, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 766 | "user": string_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 767 | "password": passwd_schema, |
| 768 | "config": {"type": "object"}, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 769 | "description": description_schema, |
| tierno | 7adaeb0 | 2019-12-17 16:46:12 +0000 | [diff] [blame] | 770 | # The folowing are deprecated. Maintanied for backward compatibility |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 771 | "dpid": dpid_Schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 772 | "ip": ip_schema, |
| 773 | "port": port_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 774 | "version": {"type": "string", "minLength": 1, "maxLength": 12}, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 775 | } |
| 776 | sdn_new_schema = { |
| 777 | "title": "sdn controller information schema", |
| 778 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 779 | "type": "object", |
| 780 | "properties": sdn_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 781 | "required": ["name", "type"], |
| 782 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 783 | } |
| 784 | sdn_edit_schema = { |
| 785 | "title": "sdn controller update information schema", |
| 786 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 787 | "type": "object", |
| 788 | "properties": sdn_properties, |
| tierno | cfb07c6 | 2018-05-10 18:30:51 +0200 | [diff] [blame] | 789 | # "required": ["name", "port", 'ip', 'dpid', 'type'], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 790 | "additionalProperties": False, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 791 | } |
| 792 | sdn_port_mapping_schema = { |
| 793 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 794 | "title": "sdn port mapping information schema", |
| 795 | "type": "array", |
| 796 | "items": { |
| 797 | "type": "object", |
| 798 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 799 | "compute_node": shortname_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 800 | "ports": { |
| 801 | "type": "array", |
| 802 | "items": { |
| 803 | "type": "object", |
| 804 | "properties": { |
| tierno | 42fce59 | 2018-11-02 09:23:43 +0100 | [diff] [blame] | 805 | "pci": pci_extended_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 806 | "switch_port": shortname_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 807 | "switch_mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 808 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 809 | "required": ["pci"], |
| 810 | }, |
| 811 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 812 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 813 | "required": ["compute_node", "ports"], |
| 814 | }, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 815 | } |
| 816 | sdn_external_port_schema = { |
| 817 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 818 | "title": "External port information", |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 819 | "type": "object", |
| 820 | "properties": { |
| 821 | "port": {"type": "string", "minLength": 1, "maxLength": 60}, |
| 822 | "vlan": vlan_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 823 | "mac": mac_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 824 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 825 | "required": ["port"], |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 826 | } |
| 827 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 828 | # K8s Clusters |
| Gabriel Cuba | 50e815b | 2022-03-22 14:01:26 -0500 | [diff] [blame] | 829 | k8scluster_deploy_method_schema = { |
| 830 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 831 | "title": "Deployment methods for K8s cluster", |
| 832 | "type": "object", |
| 833 | "properties": { |
| Gabriel Cuba | 50e815b | 2022-03-22 14:01:26 -0500 | [diff] [blame] | 834 | "juju-bundle": {"type": "boolean"}, |
| 835 | "helm-chart-v3": {"type": "boolean"}, |
| 836 | }, |
| 837 | "additionalProperties": False, |
| Luis Vega | 0a1efed | 2023-11-28 16:44:30 +0000 | [diff] [blame] | 838 | "minProperties": 2, |
| Gabriel Cuba | 50e815b | 2022-03-22 14:01:26 -0500 | [diff] [blame] | 839 | } |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 840 | k8scluster_nets_schema = { |
| 841 | "title": "k8scluster nets input schema", |
| 842 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 843 | "type": "object", |
| tierno | 8c81ab0 | 2020-02-07 10:18:30 +0000 | [diff] [blame] | 844 | "patternProperties": {".": {"oneOf": [name_schema, null_schema]}}, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 845 | "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 846 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 847 | } |
| 848 | k8scluster_new_schema = { |
| 849 | "title": "k8scluster creation input schema", |
| 850 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 851 | "type": "object", |
| 852 | "properties": { |
| 853 | "schema_version": schema_version, |
| 854 | "schema_type": schema_type, |
| 855 | "name": name_schema, |
| 856 | "description": description_schema, |
| 857 | "credentials": object_schema, |
| 858 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 859 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 860 | "k8s_version": string_schema, |
| 861 | "nets": k8scluster_nets_schema, |
| Gabriel Cuba | 50e815b | 2022-03-22 14:01:26 -0500 | [diff] [blame] | 862 | "deployment_methods": k8scluster_deploy_method_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 863 | "namespace": name_schema, |
| 864 | "cni": nameshort_list_schema, |
| 865 | }, |
| 866 | "required": ["name", "credentials", "vim_account", "k8s_version", "nets"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 867 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 868 | } |
| 869 | k8scluster_edit_schema = { |
| 870 | "title": "vim_account edit input schema", |
| 871 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 872 | "type": "object", |
| 873 | "properties": { |
| 874 | "name": name_schema, |
| 875 | "description": description_schema, |
| 876 | "credentials": object_schema, |
| 877 | "vim_account": id_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 878 | "vca_id": id_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 879 | "k8s_version": string_schema, |
| 880 | "nets": k8scluster_nets_schema, |
| 881 | "namespace": name_schema, |
| 882 | "cni": nameshort_list_schema, |
| 883 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 884 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 885 | } |
| 886 | |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 887 | # VCA |
| 888 | vca_new_schema = { |
| 889 | "title": "vca creation input schema", |
| 890 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 891 | "type": "object", |
| 892 | "properties": { |
| 893 | "schema_version": schema_version, |
| 894 | "schema_type": schema_type, |
| 895 | "name": name_schema, |
| 896 | "description": description_schema, |
| 897 | "endpoints": description_list_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 898 | "user": string_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 899 | "secret": passwd_schema, |
| 900 | "cacert": long_description_schema, |
| 901 | "lxd-cloud": shortname_schema, |
| 902 | "lxd-credentials": shortname_schema, |
| 903 | "k8s-cloud": shortname_schema, |
| 904 | "k8s-credentials": shortname_schema, |
| 905 | "model-config": object_schema, |
| 906 | }, |
| 907 | "required": [ |
| 908 | "name", |
| 909 | "endpoints", |
| 910 | "user", |
| 911 | "secret", |
| 912 | "cacert", |
| 913 | "lxd-cloud", |
| 914 | "lxd-credentials", |
| 915 | "k8s-cloud", |
| 916 | "k8s-credentials", |
| 917 | ], |
| 918 | "additionalProperties": False, |
| 919 | } |
| 920 | vca_edit_schema = { |
| 921 | "title": "vca creation input schema", |
| 922 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 923 | "type": "object", |
| 924 | "properties": { |
| 925 | "name": name_schema, |
| 926 | "description": description_schema, |
| 927 | "endpoints": description_list_schema, |
| 928 | "port": integer1_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 929 | "user": string_schema, |
| David Garcia | ecb4132 | 2021-03-31 19:10:46 +0200 | [diff] [blame] | 930 | "secret": passwd_schema, |
| 931 | "cacert": long_description_schema, |
| 932 | "lxd-cloud": shortname_schema, |
| 933 | "lxd-credentials": shortname_schema, |
| 934 | "k8s-cloud": shortname_schema, |
| 935 | "k8s-credentials": shortname_schema, |
| 936 | "model-config": object_schema, |
| 937 | }, |
| 938 | "additionalProperties": False, |
| 939 | } |
| 940 | |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 941 | # K8s Repos |
| tierno | 332e080 | 2019-12-03 23:50:49 +0000 | [diff] [blame] | 942 | k8srepo_types = {"enum": ["helm-chart", "juju-bundle"]} |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 943 | k8srepo_properties = { |
| 944 | "name": name_schema, |
| 945 | "description": description_schema, |
| 946 | "type": k8srepo_types, |
| 947 | "url": description_schema, |
| Luis Vega | f6574e3 | 2023-07-11 18:47:22 +0000 | [diff] [blame] | 948 | "cacert": long_description_schema, |
| 949 | "user": string_schema, |
| 950 | "password": passwd_schema, |
| garciadeblas | f354389 | 2023-10-20 11:53:51 +0200 | [diff] [blame] | 951 | "oci": bool_schema, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 952 | } |
| 953 | k8srepo_new_schema = { |
| 954 | "title": "k8scluster creation input schema", |
| 955 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 956 | "type": "object", |
| 957 | "properties": k8srepo_properties, |
| 958 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 959 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 960 | } |
| 961 | k8srepo_edit_schema = { |
| 962 | "title": "vim_account edit input schema", |
| 963 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 964 | "type": "object", |
| 965 | "properties": k8srepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 966 | "additionalProperties": False, |
| delacruzramo | fe598fe | 2019-10-23 18:25:11 +0200 | [diff] [blame] | 967 | } |
| 968 | |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 969 | # OSM Repos |
| 970 | osmrepo_types = {"enum": ["osm"]} |
| 971 | osmrepo_properties = { |
| 972 | "name": name_schema, |
| 973 | "description": description_schema, |
| 974 | "type": osmrepo_types, |
| rshri | 2d386cb | 2024-07-05 14:35:51 +0000 | [diff] [blame] | 975 | "url": description_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 976 | # "user": string_schema, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 977 | # "password": passwd_schema |
| 978 | } |
| 979 | osmrepo_new_schema = { |
| 980 | "title": "osm repo creation input schema", |
| 981 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 982 | "type": "object", |
| 983 | "properties": osmrepo_properties, |
| 984 | "required": ["name", "type", "url"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 985 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 986 | } |
| 987 | osmrepo_edit_schema = { |
| 988 | "title": "osm repo edit input schema", |
| 989 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 990 | "type": "object", |
| 991 | "properties": osmrepo_properties, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 992 | "additionalProperties": False, |
| Felipe Vicens | b66b041 | 2020-05-06 10:11:00 +0200 | [diff] [blame] | 993 | } |
| 994 | |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 995 | # PDUs |
| 996 | pdu_interface = { |
| 997 | "type": "object", |
| 998 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 999 | "name": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1000 | "mgmt": bool_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1001 | "type": {"enum": ["overlay", "underlay"]}, |
| garciadeblas | 1a01e1f | 2021-10-26 17:27:35 +0200 | [diff] [blame] | 1002 | "ip-address": {"oneOf": [ip_schema, ipv6_schema]}, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1003 | # TODO, add user, password, ssh-key |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1004 | "mac-address": mac_schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1005 | "vim-network-name": shortname_schema, # interface is connected to one vim network, or switch port |
| 1006 | "vim-network-id": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1007 | # # provide this in case SDN assist must deal with this interface |
| 1008 | # "switch-dpid": dpid_Schema, |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1009 | # "switch-port": shortname_schema, |
| 1010 | # "switch-mac": shortname_schema, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1011 | # "switch-vlan": vlan_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1012 | }, |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1013 | "required": ["name", "mgmt", "ip-address"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1014 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1015 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1016 | pdu_new_schema = { |
| 1017 | "title": "pdu creation input schema", |
| 1018 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1019 | "type": "object", |
| 1020 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1021 | "name": shortname_schema, |
| 1022 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1023 | "description": description_schema, |
| 1024 | "shared": bool_schema, |
| 1025 | "vims": nameshort_list_schema, |
| 1026 | "vim_accounts": nameshort_list_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1027 | "interfaces": {"type": "array", "items": pdu_interface, "minItems": 1}, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1028 | }, |
| 1029 | "required": ["name", "type", "interfaces"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1030 | "additionalProperties": False, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1031 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1032 | pdu_edit_schema = { |
| 1033 | "title": "pdu edit input schema", |
| 1034 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1035 | "type": "object", |
| 1036 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1037 | "name": shortname_schema, |
| 1038 | "type": shortname_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1039 | "description": description_schema, |
| 1040 | "shared": bool_schema, |
| garciadeblas | 84bdd55 | 2018-11-30 22:59:45 +0100 | [diff] [blame] | 1041 | "vims": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| 1042 | "vim_accounts": {"oneOf": [array_edition_schema, nameshort_list_schema]}, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1043 | "interfaces": { |
| 1044 | "oneOf": [ |
| 1045 | array_edition_schema, |
| 1046 | {"type": "array", "items": pdu_interface, "minItems": 1}, |
| 1047 | ] |
| 1048 | }, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1049 | }, |
| 1050 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1051 | "minProperties": 1, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1052 | } |
| 1053 | |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 1054 | # VNF PKG OPERATIONS |
| 1055 | vnfpkgop_new_schema = { |
| 1056 | "title": "VNF PKG operation creation input schema", |
| 1057 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1058 | "type": "object", |
| 1059 | "properties": { |
| 1060 | "lcmOperationType": string_schema, |
| 1061 | "vnfPkgId": id_schema, |
| 1062 | "kdu_name": name_schema, |
| 1063 | "primitive": name_schema, |
| 1064 | "primitive_params": {"type": "object"}, |
| 1065 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1066 | "required": [ |
| 1067 | "lcmOperationType", |
| 1068 | "vnfPkgId", |
| 1069 | "kdu_name", |
| 1070 | "primitive", |
| 1071 | "primitive_params", |
| 1072 | ], |
| 1073 | "additionalProperties": False, |
| delacruzramo | 271d200 | 2019-12-02 21:00:37 +0100 | [diff] [blame] | 1074 | } |
| 1075 | |
| rshri | 2d386cb | 2024-07-05 14:35:51 +0000 | [diff] [blame] | 1076 | clustercreation_new_schema = { |
| 1077 | "title": "cluster creation operation input schema", |
| 1078 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1079 | "type": "object", |
| 1080 | "properties": { |
| 1081 | "name": name_schema, |
| 1082 | "vim_account": string_schema, |
| 1083 | "k8s_version": string_schema, |
| 1084 | "node_size": string_schema, |
| 1085 | "node_count": integer0_schema, |
| 1086 | "description": string_schema, |
| 1087 | "region_name": string_schema, |
| 1088 | "resource_group": string_schema, |
| 1089 | "infra_controller_profiles": shortname_schema, |
| 1090 | "infra_config_profiles": shortname_schema, |
| 1091 | "resource_profiles": shortname_schema, |
| 1092 | "app_profiles": shortname_schema, |
| 1093 | }, |
| 1094 | "required": [ |
| 1095 | "name", |
| 1096 | "vim_account", |
| 1097 | "k8s_version", |
| 1098 | "node_size", |
| 1099 | "node_count", |
| 1100 | "description", |
| 1101 | ], |
| 1102 | "additionalProperties": False, |
| 1103 | } |
| 1104 | |
| 1105 | infra_controller_profile_create_new_schema = { |
| 1106 | "title": "infra profile creation operation input schema", |
| 1107 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1108 | "type": "object", |
| 1109 | "properties": { |
| 1110 | "name": name_schema, |
| 1111 | "description": string_schema, |
| 1112 | }, |
| 1113 | "additionalProperties": False, |
| 1114 | } |
| 1115 | |
| 1116 | infra_controller_profile_create_edit_schema = { |
| 1117 | "title": "infra profile creation operation input schema", |
| 1118 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1119 | "type": "object", |
| 1120 | "properties": { |
| 1121 | "name": name_schema, |
| 1122 | "description": string_schema, |
| 1123 | }, |
| 1124 | "additionalProperties": False, |
| 1125 | } |
| 1126 | |
| 1127 | infra_config_profile_create_new_schema = { |
| 1128 | "title": "infra profile creation operation input schema", |
| 1129 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1130 | "type": "object", |
| 1131 | "properties": { |
| 1132 | "name": name_schema, |
| 1133 | "description": string_schema, |
| 1134 | }, |
| 1135 | "additionalProperties": False, |
| 1136 | } |
| 1137 | |
| 1138 | infra_config_profile_create_edit_schema = { |
| 1139 | "title": "infra profile creation operation input schema", |
| 1140 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1141 | "type": "object", |
| 1142 | "properties": { |
| 1143 | "name": name_schema, |
| 1144 | "description": string_schema, |
| 1145 | }, |
| 1146 | "additionalProperties": False, |
| 1147 | } |
| 1148 | |
| 1149 | app_profile_create_new_schema = { |
| 1150 | "title": "app profile creation operation input schema", |
| 1151 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1152 | "type": "object", |
| 1153 | "properties": { |
| 1154 | "name": name_schema, |
| 1155 | "description": string_schema, |
| 1156 | }, |
| 1157 | "additionalProperties": False, |
| 1158 | } |
| 1159 | app_profile_create_edit_schema = { |
| 1160 | "title": "app profile creation operation input schema", |
| 1161 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1162 | "type": "object", |
| 1163 | "properties": { |
| 1164 | "name": name_schema, |
| 1165 | "description": string_schema, |
| 1166 | }, |
| 1167 | "additionalProperties": False, |
| 1168 | } |
| 1169 | |
| 1170 | resource_profile_create_new_schema = { |
| 1171 | "title": "resource profile creation operation input schema", |
| 1172 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1173 | "type": "object", |
| 1174 | "properties": { |
| 1175 | "name": name_schema, |
| 1176 | "description": string_schema, |
| 1177 | }, |
| 1178 | "additionalProperties": False, |
| 1179 | } |
| 1180 | resource_profile_create_edit_schema = { |
| 1181 | "title": "resource profile creation operation input schema", |
| 1182 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1183 | "type": "object", |
| 1184 | "properties": { |
| 1185 | "name": name_schema, |
| 1186 | "description": string_schema, |
| 1187 | }, |
| 1188 | "additionalProperties": False, |
| 1189 | } |
| 1190 | |
| 1191 | attach_profile = { |
| 1192 | "type": "array", |
| 1193 | "items": { |
| 1194 | "type": "object", |
| 1195 | "properties": {"id": id_schema}, |
| 1196 | "additionalProperties": False, |
| 1197 | }, |
| 1198 | } |
| 1199 | remove_profile = { |
| 1200 | "type": "array", |
| 1201 | "items": { |
| 1202 | "type": "object", |
| 1203 | "properties": {"id": id_schema}, |
| 1204 | "additionalProperties": False, |
| 1205 | }, |
| 1206 | } |
| 1207 | attach_dettach_profile_schema = { |
| 1208 | "title": "attach/dettach profiles", |
| 1209 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1210 | "type": "object", |
| 1211 | "properties": { |
| 1212 | "add_profile": attach_profile, |
| 1213 | "remove_profile": remove_profile, |
| 1214 | }, |
| 1215 | "additionalProperties": False, |
| 1216 | } |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1217 | # USERS |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1218 | project_role_mappings = { |
| 1219 | "title": "list pf projects/roles", |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1220 | "$schema": "http://json-schema.org/draft-04/schema#", |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1221 | "type": "array", |
| 1222 | "items": { |
| 1223 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1224 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1225 | "required": ["project", "role"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1226 | "additionalProperties": False, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1227 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1228 | "minItems": 1, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1229 | } |
| rshri | 2d386cb | 2024-07-05 14:35:51 +0000 | [diff] [blame] | 1230 | |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1231 | project_role_mappings_optional = { |
| 1232 | "title": "list of projects/roles or projects only", |
| 1233 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1234 | "type": "array", |
| 1235 | "items": { |
| 1236 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1237 | "properties": {"project": shortname_schema, "role": shortname_schema}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1238 | "required": ["project"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1239 | "additionalProperties": False, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1240 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1241 | "minItems": 1, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1242 | } |
| rshri | 2d386cb | 2024-07-05 14:35:51 +0000 | [diff] [blame] | 1243 | |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1244 | user_new_schema = { |
| 1245 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1246 | "title": "New user schema", |
| 1247 | "type": "object", |
| 1248 | "properties": { |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 1249 | "username": string_schema, |
| tierno | ad6d533 | 2020-02-19 14:29:49 +0000 | [diff] [blame] | 1250 | "domain_name": shortname_schema, |
| garciadeblas | 6d83f8f | 2023-06-19 22:34:49 +0200 | [diff] [blame] | 1251 | "password": user_passwd_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1252 | "projects": nameshort_list_schema, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1253 | "project_role_mappings": project_role_mappings, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1254 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1255 | "required": ["username", "password"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1256 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1257 | } |
| 1258 | user_edit_schema = { |
| 1259 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1260 | "title": "User edit schema for administrators", |
| 1261 | "type": "object", |
| 1262 | "properties": { |
| garciadeblas | 6d83f8f | 2023-06-19 22:34:49 +0200 | [diff] [blame] | 1263 | "password": user_passwd_schema, |
| selvi.j | a9a1fc8 | 2022-04-04 06:54:30 +0000 | [diff] [blame] | 1264 | "old_password": passwd_schema, |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 1265 | "username": string_schema, # To allow User Name modification |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1266 | "projects": {"oneOf": [nameshort_list_schema, array_edition_schema]}, |
| tierno | cf042d3 | 2019-06-13 09:06:40 +0000 | [diff] [blame] | 1267 | "project_role_mappings": project_role_mappings, |
| 1268 | "add_project_role_mappings": project_role_mappings, |
| 1269 | "remove_project_role_mappings": project_role_mappings_optional, |
| garciadeblas | 6d83f8f | 2023-06-19 22:34:49 +0200 | [diff] [blame] | 1270 | "system_admin_id": id_schema, |
| 1271 | "unlock": bool_schema, |
| 1272 | "renew": bool_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1273 | }, |
| 1274 | "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1275 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1276 | } |
| 1277 | |
| 1278 | # PROJECTS |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1279 | topics_with_quota = [ |
| 1280 | "vnfds", |
| 1281 | "nsds", |
| 1282 | "slice_templates", |
| 1283 | "pduds", |
| 1284 | "ns_instances", |
| 1285 | "slice_instances", |
| 1286 | "vim_accounts", |
| 1287 | "wim_accounts", |
| 1288 | "sdn_controllers", |
| 1289 | "k8sclusters", |
| 1290 | "vca", |
| 1291 | "k8srepos", |
| 1292 | "osmrepos", |
| 1293 | "ns_subscriptions", |
| 1294 | ] |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1295 | project_new_schema = { |
| 1296 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1297 | "title": "New project schema for administrators", |
| 1298 | "type": "object", |
| 1299 | "properties": { |
| tierno | fd16057 | 2019-01-21 10:41:37 +0000 | [diff] [blame] | 1300 | "name": shortname_schema, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1301 | "admin": bool_schema, |
| tierno | ad6d533 | 2020-02-19 14:29:49 +0000 | [diff] [blame] | 1302 | "domain_name": shortname_schema, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 1303 | "quotas": { |
| 1304 | "type": "object", |
| 1305 | "properties": {topic: integer0_schema for topic in topics_with_quota}, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1306 | "additionalProperties": False, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 1307 | }, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1308 | }, |
| 1309 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1310 | "additionalProperties": False, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1311 | } |
| 1312 | project_edit_schema = { |
| 1313 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1314 | "title": "Project edit schema for administrators", |
| 1315 | "type": "object", |
| 1316 | "properties": { |
| 1317 | "admin": bool_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1318 | "name": shortname_schema, # To allow Project Name modification |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 1319 | "quotas": { |
| 1320 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1321 | "properties": { |
| 1322 | topic: {"oneOf": [integer0_schema, null_schema]} |
| 1323 | for topic in topics_with_quota |
| 1324 | }, |
| 1325 | "additionalProperties": False, |
| delacruzramo | 32bab47 | 2019-09-13 12:24:22 +0200 | [diff] [blame] | 1326 | }, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1327 | }, |
| 1328 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1329 | "minProperties": 1, |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1330 | } |
| 1331 | |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1332 | # ROLES |
| 1333 | roles_new_schema = { |
| 1334 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1335 | "title": "New role schema for administrators", |
| 1336 | "type": "object", |
| 1337 | "properties": { |
| 1338 | "name": shortname_schema, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1339 | "permissions": { |
| 1340 | "type": "object", |
| 1341 | "patternProperties": { |
| 1342 | ".": bool_schema, |
| 1343 | }, |
| 1344 | # "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1345 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1346 | }, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1347 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1348 | "additionalProperties": False, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1349 | } |
| 1350 | roles_edit_schema = { |
| 1351 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1352 | "title": "Roles edit schema for administrators", |
| 1353 | "type": "object", |
| 1354 | "properties": { |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1355 | "name": shortname_schema, |
| 1356 | "permissions": { |
| 1357 | "type": "object", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1358 | "patternProperties": {".": {"oneOf": [bool_schema, null_schema]}}, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1359 | # "minProperties": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1360 | }, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1361 | }, |
| tierno | 1f029d8 | 2019-06-13 22:37:04 +0000 | [diff] [blame] | 1362 | "additionalProperties": False, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1363 | "minProperties": 1, |
| Eduardo Sousa | 5c01e19 | 2019-05-08 02:35:47 +0100 | [diff] [blame] | 1364 | } |
| 1365 | |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1366 | # GLOBAL SCHEMAS |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1367 | |
| 1368 | nbi_new_input_schemas = { |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1369 | "users": user_new_schema, |
| 1370 | "projects": project_new_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 1371 | "vim_accounts": vim_account_new_schema, |
| tierno | 65acb4d | 2018-04-06 16:42:40 +0200 | [diff] [blame] | 1372 | "sdns": sdn_new_schema, |
| 1373 | "ns_instantiate": ns_instantiate, |
| 1374 | "ns_action": ns_action, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1375 | "ns_scale": ns_scale, |
| aticig | 544a2ae | 2022-04-05 09:00:17 +0300 | [diff] [blame] | 1376 | "ns_update": ns_update, |
| garciadeblas | 0964edf | 2022-02-11 00:43:44 +0100 | [diff] [blame] | 1377 | "ns_heal": ns_heal, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1378 | "pdus": pdu_new_schema, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1379 | } |
| 1380 | |
| 1381 | nbi_edit_input_schemas = { |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1382 | "users": user_edit_schema, |
| 1383 | "projects": project_edit_schema, |
| tierno | 09c073e | 2018-04-26 13:36:48 +0200 | [diff] [blame] | 1384 | "vim_accounts": vim_account_edit_schema, |
| tierno | cb83c94 | 2018-09-24 17:28:13 +0200 | [diff] [blame] | 1385 | "sdns": sdn_edit_schema, |
| 1386 | "pdus": pdu_edit_schema, |
| kayal2001 | f71c2e8 | 2024-06-25 15:26:24 +0530 | [diff] [blame] | 1387 | "vnf": vnf_schema, |
| 1388 | "vld": vld_schema, |
| 1389 | "additionalParamsForVnf": additional_params_for_vnf, |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1390 | } |
| 1391 | |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1392 | # NETSLICE SCHEMAS |
| tierno | 032916c | 2019-03-22 13:27:12 +0000 | [diff] [blame] | 1393 | nsi_subnet_instantiate = deepcopy(ns_instantiate) |
| 1394 | nsi_subnet_instantiate["title"] = "netslice subnet instantiation params input schema" |
| 1395 | nsi_subnet_instantiate["properties"]["id"] = name_schema |
| 1396 | del nsi_subnet_instantiate["required"] |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1397 | |
| 1398 | nsi_vld_instantiate = { |
| 1399 | "title": "netslice vld instantiation params input schema", |
| 1400 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1401 | "type": "object", |
| 1402 | "properties": { |
| 1403 | "name": string_schema, |
| tierno | 195a36c | 2020-09-18 14:18:55 +0000 | [diff] [blame] | 1404 | "vim-network-name": {"oneOf": [string_schema, object_schema]}, |
| 1405 | "vim-network-id": {"oneOf": [string_schema, object_schema]}, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1406 | "ip-profile": object_schema, |
| 1407 | }, |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1408 | "required": ["name"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1409 | "additionalProperties": False, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1410 | } |
| 1411 | |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1412 | nsi_instantiate = { |
| 1413 | "title": "netslice action instantiate input schema", |
| 1414 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 1415 | "type": "object", |
| 1416 | "properties": { |
| 1417 | "lcmOperationType": string_schema, |
| Felipe Vicens | 126af57 | 2019-06-05 19:13:04 +0200 | [diff] [blame] | 1418 | "netsliceInstanceId": id_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1419 | "nsiName": name_schema, |
| tierno | 4f9d4ae | 2019-03-20 17:24:11 +0000 | [diff] [blame] | 1420 | "nsiDescription": {"oneOf": [description_schema, null_schema]}, |
| tierno | 9e5eea3 | 2018-11-29 09:42:09 +0000 | [diff] [blame] | 1421 | "nstId": string_schema, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1422 | "vimAccountId": id_schema, |
| tierno | a8186a5 | 2020-01-14 15:54:48 +0000 | [diff] [blame] | 1423 | "timeout_nsi_deploy": integer1_schema, |
| Felipe Vicens | 26202bb | 2020-05-24 18:57:33 +0200 | [diff] [blame] | 1424 | "ssh_keys": {"type": "array", "items": {"type": "string"}}, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1425 | "nsi_id": id_schema, |
| tierno | 032916c | 2019-03-22 13:27:12 +0000 | [diff] [blame] | 1426 | "additionalParamsForNsi": object_schema, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1427 | "netslice-subnet": { |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1428 | "type": "array", |
| 1429 | "minItems": 1, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1430 | "items": nsi_subnet_instantiate, |
| garciadeblas | daf8cc5 | 2018-11-30 14:17:20 +0100 | [diff] [blame] | 1431 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1432 | "netslice-vld": {"type": "array", "minItems": 1, "items": nsi_vld_instantiate}, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1433 | }, |
| Felipe Vicens | c8bbaaa | 2018-12-01 04:42:40 +0100 | [diff] [blame] | 1434 | "required": ["nsiName", "nstId", "vimAccountId"], |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1435 | "additionalProperties": False, |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1436 | } |
| 1437 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1438 | nsi_action = {} |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1439 | |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1440 | nsi_terminate = {} |
| Felipe Vicens | 07f3172 | 2018-10-29 15:16:44 +0100 | [diff] [blame] | 1441 | |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1442 | nsinstancesubscriptionfilter_schema = { |
| 1443 | "title": "instance identifier schema", |
| 1444 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1445 | "type": "object", |
| 1446 | "properties": { |
| 1447 | "nsdIds": {"type": "array"}, |
| 1448 | "vnfdIds": {"type": "array"}, |
| 1449 | "pnfdIds": {"type": "array"}, |
| 1450 | "nsInstanceIds": {"type": "array"}, |
| 1451 | "nsInstanceNames": {"type": "array"}, |
| 1452 | }, |
| 1453 | } |
| 1454 | |
| 1455 | nslcmsub_schema = { |
| 1456 | "title": "nslcmsubscription input schema", |
| 1457 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1458 | "type": "object", |
| 1459 | "properties": { |
| 1460 | "nsInstanceSubscriptionFilter": nsinstancesubscriptionfilter_schema, |
| 1461 | "notificationTypes": { |
| 1462 | "type": "array", |
| 1463 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1464 | "enum": [ |
| 1465 | "NsLcmOperationOccurrenceNotification", |
| 1466 | "NsChangeNotification", |
| 1467 | "NsIdentifierCreationNotification", |
| 1468 | "NsIdentifierDeletionNotification", |
| 1469 | ] |
| 1470 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1471 | }, |
| 1472 | "operationTypes": { |
| 1473 | "type": "array", |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1474 | "items": {"enum": ["INSTANTIATE", "SCALE", "TERMINATE", "UPDATE", "HEAL"]}, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1475 | }, |
| 1476 | "operationStates": { |
| 1477 | "type": "array", |
| 1478 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1479 | "enum": [ |
| 1480 | "PROCESSING", |
| 1481 | "COMPLETED", |
| 1482 | "PARTIALLY_COMPLETED", |
| 1483 | "FAILED", |
| 1484 | "FAILED_TEMP", |
| 1485 | "ROLLING_BACK", |
| 1486 | "ROLLED_BACK", |
| 1487 | ] |
| 1488 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1489 | }, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1490 | "nsComponentTypes": {"type": "array", "items": {"enum": ["VNF", "NS", "PNF"]}}, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1491 | "lcmOpNameImpactingNsComponent": { |
| 1492 | "type": "array", |
| 1493 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1494 | "enum": [ |
| 1495 | "VNF_INSTANTIATE", |
| 1496 | "VNF_SCALE", |
| 1497 | "VNF_SCALE_TO_LEVEL", |
| 1498 | "VNF_CHANGE_FLAVOUR", |
| 1499 | "VNF_TERMINATE", |
| 1500 | "VNF_HEAL", |
| 1501 | "VNF_OPERATE", |
| 1502 | "VNF_CHANGE_EXT_CONN", |
| 1503 | "VNF_MODIFY_INFO", |
| 1504 | "NS_INSTANTIATE", |
| 1505 | "NS_SCALE", |
| 1506 | "NS_UPDATE", |
| 1507 | "NS_TERMINATE", |
| 1508 | "NS_HEAL", |
| 1509 | ] |
| 1510 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1511 | }, |
| 1512 | "lcmOpOccStatusImpactingNsComponent": { |
| 1513 | "type": "array", |
| 1514 | "items": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1515 | "enum": [ |
| 1516 | "START", |
| 1517 | "COMPLETED", |
| 1518 | "PARTIALLY_COMPLETED", |
| 1519 | "FAILED", |
| 1520 | "ROLLED_BACK", |
| 1521 | ] |
| 1522 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1523 | }, |
| 1524 | }, |
| 1525 | "allOf": [ |
| 1526 | { |
| 1527 | "if": { |
| 1528 | "properties": { |
| 1529 | "notificationTypes": { |
| 1530 | "contains": {"const": "NsLcmOperationOccurrenceNotification"} |
| 1531 | } |
| 1532 | }, |
| 1533 | }, |
| 1534 | "then": { |
| 1535 | "anyOf": [ |
| 1536 | {"required": ["operationTypes"]}, |
| 1537 | {"required": ["operationStates"]}, |
| 1538 | ] |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1539 | }, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1540 | }, |
| 1541 | { |
| 1542 | "if": { |
| 1543 | "properties": { |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1544 | "notificationTypes": {"contains": {"const": "NsChangeNotification"}} |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1545 | }, |
| 1546 | }, |
| 1547 | "then": { |
| 1548 | "anyOf": [ |
| 1549 | {"required": ["nsComponentTypes"]}, |
| 1550 | {"required": ["lcmOpNameImpactingNsComponent"]}, |
| 1551 | {"required": ["lcmOpOccStatusImpactingNsComponent"]}, |
| 1552 | ] |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1553 | }, |
| 1554 | }, |
| 1555 | ], |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1556 | } |
| 1557 | |
| 1558 | authentication_schema = { |
| 1559 | "title": "authentication schema for subscription", |
| 1560 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1561 | "type": "object", |
| 1562 | "properties": { |
| 1563 | "authType": {"enum": ["basic"]}, |
| 1564 | "paramsBasic": { |
| 1565 | "type": "object", |
| 1566 | "properties": { |
| sousaedu | 80b6fed | 2021-10-07 15:17:32 +0100 | [diff] [blame] | 1567 | "userName": string_schema, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1568 | "password": passwd_schema, |
| 1569 | }, |
| 1570 | }, |
| 1571 | }, |
| 1572 | } |
| 1573 | |
| 1574 | subscription = { |
| 1575 | "title": "subscription input schema", |
| 1576 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1577 | "type": "object", |
| 1578 | "properties": { |
| 1579 | "filter": nslcmsub_schema, |
| 1580 | "CallbackUri": description_schema, |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1581 | "authentication": authentication_schema, |
| preethika.p | 329b818 | 2020-04-22 12:25:39 +0530 | [diff] [blame] | 1582 | }, |
| 1583 | "required": ["CallbackUri"], |
| 1584 | } |
| 1585 | |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1586 | vnflcmsub_schema = { |
| 1587 | "title": "vnflcmsubscription input schema", |
| 1588 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1589 | "type": "object", |
| 1590 | "properties": { |
| 1591 | "VnfInstanceSubscriptionFilter": { |
| 1592 | "type": "object", |
| 1593 | "properties": { |
| 1594 | "vnfdIds": {"type": "array"}, |
| 1595 | "vnfInstanceIds": {"type": "array"}, |
| 1596 | }, |
| 1597 | }, |
| 1598 | "notificationTypes": { |
| 1599 | "type": "array", |
| 1600 | "items": { |
| 1601 | "enum": [ |
| 1602 | "VnfIdentifierCreationNotification", |
| 1603 | "VnfLcmOperationOccurrenceNotification", |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1604 | "VnfIdentifierDeletionNotification", |
| 1605 | ] |
| 1606 | }, |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1607 | }, |
| 1608 | "operationTypes": { |
| 1609 | "type": "array", |
| 1610 | "items": { |
| 1611 | "enum": [ |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1612 | "INSTANTIATE", |
| 1613 | "SCALE", |
| 1614 | "SCALE_TO_LEVEL", |
| 1615 | "CHANGE_FLAVOUR", |
| 1616 | "TERMINATE", |
| 1617 | "HEAL", |
| 1618 | "OPERATE", |
| 1619 | "CHANGE_EXT_CONN", |
| 1620 | "MODIFY_INFO", |
| 1621 | "CREATE_SNAPSHOT", |
| 1622 | "REVERT_TO_SNAPSHOT", |
| 1623 | "CHANGE_VNFPKG", |
| 1624 | ] |
| 1625 | }, |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1626 | }, |
| 1627 | "operationStates": { |
| 1628 | "type": "array", |
| 1629 | "items": { |
| 1630 | "enum": [ |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1631 | "STARTING", |
| 1632 | "PROCESSING", |
| 1633 | "COMPLETED", |
| 1634 | "FAILED_TEMP", |
| 1635 | "FAILED", |
| 1636 | "ROLLING_BACK", |
| 1637 | "ROLLED_BACK", |
| 1638 | ] |
| 1639 | }, |
| 1640 | }, |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1641 | }, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1642 | "required": ["VnfInstanceSubscriptionFilter", "notificationTypes"], |
| 1643 | } |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1644 | |
| 1645 | vnf_subscription = { |
| 1646 | "title": "vnf subscription input schema", |
| 1647 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1648 | "type": "object", |
| 1649 | "properties": { |
| 1650 | "filter": vnflcmsub_schema, |
| 1651 | "CallbackUri": description_schema, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1652 | "authentication": authentication_schema, |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1653 | }, |
| garciadeblas | f2af4a1 | 2023-01-24 16:56:54 +0100 | [diff] [blame] | 1654 | "required": ["filter", "CallbackUri"], |
| selvi.j | f100459 | 2022-04-29 05:42:35 +0000 | [diff] [blame] | 1655 | } |
| 1656 | |
| yshah | 53cc9eb | 2024-07-05 13:06:31 +0000 | [diff] [blame] | 1657 | oka_schema = { |
| 1658 | "title": "Create OKA package input schema", |
| 1659 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1660 | "type": "object", |
| 1661 | "properties": { |
| 1662 | "name": name_schema, |
| 1663 | "description": description_schema, |
| 1664 | }, |
| 1665 | "additionalProperties": False, |
| 1666 | } |
| 1667 | |
| 1668 | ksu_schema = { |
| 1669 | "title": "ksu schema", |
| 1670 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 1671 | "type": "object", |
| 1672 | "properties": { |
| 1673 | "name": name_schema, |
| 1674 | "description": description_schema, |
| 1675 | "profile": { |
| 1676 | "type": "object", |
| 1677 | "properties": { |
| 1678 | "profile_type": string_schema, |
| 1679 | "_id": id_schema, |
| 1680 | }, |
| 1681 | "additionalProperties": False, |
| 1682 | }, |
| 1683 | "oka": { |
| 1684 | "type": "array", |
| 1685 | "items": { |
| 1686 | "type": "object", |
| 1687 | "properties": { |
| 1688 | "_id": id_schema, |
| 1689 | "sw_catalog_path": string_schema, |
| 1690 | "transformation": object_schema, |
| 1691 | }, |
| 1692 | "additionalProperties": False, |
| 1693 | }, |
| 1694 | }, |
| 1695 | }, |
| 1696 | "additionalProperties": False, |
| 1697 | } |
| 1698 | |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1699 | |
| 1700 | class ValidationError(Exception): |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1701 | def __init__(self, message, http_code=HTTPStatus.UNPROCESSABLE_ENTITY): |
| 1702 | self.http_code = http_code |
| 1703 | Exception.__init__(self, message) |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1704 | |
| 1705 | |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1706 | def validate_input(indata, schema_to_use): |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1707 | """ |
| tierno | cd54a4a | 2018-09-12 16:40:35 +0200 | [diff] [blame] | 1708 | Validates input data against json schema |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1709 | :param indata: user input data. Should be a dictionary |
| tierno | b24258a | 2018-10-04 18:39:49 +0200 | [diff] [blame] | 1710 | :param schema_to_use: jsonschema to test |
| 1711 | :return: None if ok, raises ValidationError exception on error |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1712 | """ |
| 1713 | try: |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1714 | if schema_to_use: |
| 1715 | js_v(indata, schema_to_use) |
| 1716 | return None |
| 1717 | except js_e.ValidationError as e: |
| 1718 | if e.path: |
| tierno | 0da5225 | 2018-06-27 15:47:22 +0200 | [diff] [blame] | 1719 | error_pos = "at '" + ":".join(map(str, e.path)) + "'" |
| tierno | 0f98af5 | 2018-03-19 10:28:22 +0100 | [diff] [blame] | 1720 | else: |
| 1721 | error_pos = "" |
| tierno | 441dbbf | 2018-07-10 12:52:48 +0200 | [diff] [blame] | 1722 | raise ValidationError("Format error {} '{}' ".format(error_pos, e.message)) |
| tierno | 36ec860 | 2018-11-02 17:27:11 +0100 | [diff] [blame] | 1723 | except js_e.SchemaError: |
| garciadeblas | 4568a37 | 2021-03-24 09:19:48 +0100 | [diff] [blame] | 1724 | raise ValidationError( |
| 1725 | "Bad json schema {}".format(schema_to_use), |
| 1726 | http_code=HTTPStatus.INTERNAL_SERVER_ERROR, |
| 1727 | ) |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1728 | |
| 1729 | |
| 1730 | def is_valid_uuid(x): |
| 1731 | """ |
| 1732 | Test for a valid UUID |
| 1733 | :param x: string to test |
| 1734 | :return: True if x is a valid uuid, False otherwise |
| 1735 | """ |
| 1736 | try: |
| 1737 | if UUID(x): |
| 1738 | return True |
| tierno | bdebce9 | 2019-07-01 15:36:49 +0000 | [diff] [blame] | 1739 | except (TypeError, ValueError, AttributeError): |
| delacruzramo | c061f56 | 2019-04-05 11:00:02 +0200 | [diff] [blame] | 1740 | return False |