Implement the new xApp descriptor format
[it/dev.git] / xapp_onboarder / xapp_onboarder / helm_controller / xapp_schema.py
1 ################################################################################
2 #   Copyright (c) 2020 AT&T Intellectual Property.                             #
3 #                                                                              #
4 #   Licensed under the Apache License, Version 2.0 (the "License");            #
5 #   you may not use this file except in compliance with the License.           #
6 #   You may obtain a copy of the License at                                    #
7 #                                                                              #
8 #       http://www.apache.org/licenses/LICENSE-2.0                             #
9 #                                                                              #
10 #   Unless required by applicable law or agreed to in writing, software        #
11 #   distributed under the License is distributed on an "AS IS" BASIS,          #
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
13 #   See the License for the specific language governing permissions and        #
14 #   limitations under the License.                                             #
15 ################################################################################
16
17 schema = {
18     "$schema": "http://json-schema.org/draft-07/schema#",
19     "$id": "http://o-ran-sc.org/xapp_root.json",
20     "type": "object",
21     "title": "The xApp Root Schema",
22     "required": [
23         "xapp_name",
24         "version",
25         "containers"
26     ],
27     "properties": {
28         "xapp_name": {
29             "$id": "#/properties/xapp_name",
30             "type": "string",
31             "title": "The xApp Name",
32             "default": "xapp",
33             "examples": [
34                 "example_xapp"
35             ]
36         },
37         "version": {
38             "$id": "#/properties/version",
39             "type": "string",
40             "title": "The xApp version",
41             "default": "1.0.0",
42             "examples": [
43                 "1.0.0"
44             ],
45             "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
46         },
47         "containers": {
48             "$id": "#/properties/containers",
49             "type": "array",
50             "title": "The Container Schema",
51             "items": {
52                 "$id": "#/properties/containers/items",
53                 "type": "object",
54                 "title": "The Container Items Schema",
55                 "required": [
56                     "name",
57                     "image"
58                 ],
59                 "properties": {
60                     "name": {
61                         "$id": "#/properties/containers/items/properties/name",
62                         "type": "string",
63                         "title": "The xApp Container Name",
64                         "default": "xapp",
65                         "examples": [
66                             "xapp"
67                         ]
68                     },
69                     "image": {
70                         "$id": "#/properties/containers/items/properties/image",
71                         "type": "object",
72                         "title": "The Container Image",
73                         "required": [
74                             "registry",
75                             "name",
76                             "tag"
77                         ],
78                         "properties": {
79                             "registry": {
80                                 "$id": "#/properties/containers/items/properties/image/properties/registry",
81                                 "type": "string",
82                                 "title": "The xApp Image Registry",
83                                 "default": "nexus3.o-ran-sc.org:10002",
84                                 "examples": [
85                                     "nexus3.o-ran-sc.org:10002"
86                                 ],
87                                 "pattern": "^[A-Za-z0-9\\.-]{1,}\\.[A-Za-z]{1,}(?:\\:\\d+)?$"
88                             },
89                             "name": {
90                                 "$id": "#/properties/containers/items/properties/image/properties/name",
91                                 "type": "string",
92                                 "title": "The xApp Image Name",
93                                 "default": "xapp",
94                                 "examples": [
95                                     "xapp"
96                                 ]
97                             },
98                             "tag": {
99                                 "$id": "#/properties/containers/items/properties/image/properties/tag",
100                                 "type": "string",
101                                 "title": "The xApp Image Tag",
102                                 "default": "latest",
103                                 "examples": [
104                                     "latest"
105                                 ]
106                             }
107                         }
108                     },
109                     "command": {
110                         "$id": "#/properties/containers/items/properties/command",
111                         "type": "string",
112                         "title": "Command To Run The xApp Container",
113                         "default": "command",
114                         "examples": [
115                             "command"
116                         ]
117                     }
118                 }
119             }
120         },
121         "livenessProbe": {
122             "$id": "#/properties/livenessprobe",
123             "type": "object",
124             "title": "The Liveness Probe Definition",
125             "properties": {
126                 "exec": {
127                     "$id": "#/properties/livenessprobe/exec",
128                     "type": "object",
129                     "title": "Script of Liveness Probe",
130                     "properties": {
131                         "command": {
132                             "$id": "#/properties/livenessprobe/exec/command",
133                             "type": "array",
134                             "items": [
135                                 {
136                                     "$id": "#/properties/livenessprobe/exec/command/item",
137                                     "type": "string",
138                                     "title": "The Command Item",
139                                     "default": "/bin/sh",
140                                     "examples": [
141                                         "/bin/sh"
142                                     ]
143                                 }
144                             ]
145                         }
146                     },
147                     "required": [
148                         "command"
149                     ]
150                 },
151                 "httpGet": {
152                     "$id": "#/properties/livenessprobe/httpget",
153                     "type": "object",
154                     "title": "Http of Liveness Probe",
155                     "properties": {
156                         "path": {
157                             "$id": "#/properties/livenessprobe/httpget/path",
158                             "type": "string",
159                             "title": "The Path of Http Liveness Probe",
160                             "default": "/health",
161                             "examples": [
162                                 "/health"
163                             ]
164                         },
165                         "port": {
166                             "$id": "#/properties/livenessprobe/httpget/port",
167                             "type": "integer",
168                             "title": "The Port of Http Liveness Probe",
169                             "default": 80,
170                             "examples": [
171                                 80
172                             ]
173                         }
174                     },
175                     "required": [
176                         "path",
177                         "port"
178                     ]
179                 },
180                 "initialDelaySeconds": {
181                     "$id": "#/properties/livenessprobe/initialdelayseconds",
182                     "type": "integer",
183                     "title": "Initial Delay of Liveness Probe",
184                     "default": 5,
185                     "examples": [
186                         5
187                     ]
188                 },
189                 "periodSeconds": {
190                     "$id": "#/properties/livenessprobe/periodseconds",
191                     "type": "integer",
192                     "title": "Period of Liveness Probe",
193                     "default": 15,
194                     "examples": [
195                         15
196                     ]
197                 }
198             },
199             "oneOf": [
200                 {
201                     "$id": "#/properties/livenessprobe/oneof/exec",
202                     "required": ["exec", "initialDelaySeconds", "periodSeconds"]
203                 },
204                 {
205                     "$id": "#/properties/livenessprobe/oneof/httpget",
206                     "required": ["httpGet", "initialDelaySeconds", "periodSeconds"]
207                 }
208             ]
209         },
210         "readinessProbe": {
211             "$id": "#/properties/readinessprobe",
212             "type": "object",
213             "title": "The Readiness Probe Definition",
214             "properties": {
215                 "exec": {
216                     "$id": "#/properties/readinessprobe/exec",
217                     "type": "object",
218                     "title": "Script of Readiness Probe",
219                     "properties": {
220                         "command": {
221                             "$id": "#/properties/readinessprobe/exec/command",
222                             "type": "array",
223                             "items": [
224                                 {
225                                     "type": "string"
226                                 }
227                             ]
228                         }
229                     },
230                     "required": [
231                         "command"
232                     ]
233                 },
234                 "httpGet": {
235                     "$id": "#/properties/readinessprobe/httpget",
236                     "type": "object",
237                     "title": "Http of Readiness Probe",
238                     "properties": {
239                         "path": {
240                             "$id": "#/properties/readinessprobe/httpget/path",
241                             "type": "string",
242                             "title": "The Path of Http Readiness Probe",
243                             "default": "/health",
244                             "examples": [
245                                 "/health"
246                             ]
247                         },
248                         "port": {
249                             "$id": "#/properties/readinessprobe/httpget/port",
250                             "type": "integer",
251                             "title": "The Port of Http Readiness Probe",
252                             "default": 80,
253                             "examples": [
254                                 80
255                             ]
256                         }
257                     },
258                     "required": [
259                         "path",
260                         "port"
261                     ]
262                 },
263                 "initialDelaySeconds": {
264                     "$id": "#/properties/readinessprobe/initialdelayseconds",
265                     "type": "integer",
266                     "title": "Initial Delay of Readiness Probe",
267                     "default": 5,
268                     "examples": [
269                         5
270                     ]
271                 },
272                 "periodSeconds": {
273                     "$id": "#/properties/readinessprobe/periodseconds",
274                     "type": "integer",
275                     "title": "Period of Readiness Probe",
276                     "default": 15,
277                     "examples": [
278                         15
279                     ]
280                 }
281             },
282             "oneOf": [
283                 {
284                     "$id": "#/properties/readinessprobe/oneof/exec",
285                     "required": ["exec", "initialDelaySeconds", "periodSeconds"]
286                 },
287                 {
288                     "$id": "#/properties/readinessprobe/oneof/httpget",
289                     "required": ["httpGet", "initialDelaySeconds", "periodSeconds"]
290                 }
291             ]
292         },
293         "messaging": {
294             "type": "object",
295             "$id": "#/properties/messaging",
296             "title": "The Messaging Schema",
297             "properties": {
298                 "ports": {
299                     "$id": "#/properties/messaging/ports",
300                     "type": "array",
301                     "title": "The Ports for Messaging",
302                     "items": {
303                         "$id": "#/properties/messaging/ports/items",
304                         "type": "object",
305                         "title": "The Item of Port",
306                         "required": ["name", "container", "port"],
307                         "dependencies": {
308                             "txMessages": ["rxMessages", "policies"],
309                             "rxMessages": ["txMessages", "policies"],
310                             "policies": ["rxMessages", "txMessages"]
311                         },
312                         "properties": {
313                             "name": {
314                                 "$id": "#/properties/messaging/ports/items/name",
315                                 "type": "string",
316                                 "title": "The Name of the Port",
317                                 "default": "App",
318                                 "examples": [
319                                     "App"
320                                 ]
321                             },
322                             "container": {
323                                 "$id": "#/properties/messaging/ports/items/container",
324                                 "type": "string",
325                                 "title": "The Container of the Port",
326                                 "default": "xapp",
327                                 "examples": [
328                                     "xapp"
329                                 ]
330                             },
331                             "port": {
332                                 "$id": "#/properties/messaging/ports/items/port",
333                                 "type": "integer",
334                                 "title": "The Port Number",
335                                 "default": 8080,
336                                 "examples": [
337                                     8080
338                                 ]
339                             },
340                             "description": {
341                                 "$id": "#/properties/messaging/ports/items/description",
342                                 "type": "string",
343                                 "title": "The description for the port",
344                                 "default": "port description",
345                                 "examples": [
346                                     "port description"
347                                 ]
348                             },
349                             "txMessages": {
350                                 "$id": "#/properties/messaging/ports/items/txmessages",
351                                 "type": "array",
352                                 "title": "The txMessage Types",
353                                 "items": {
354                                     "$id": "#/properties/messaging/ports/items//txmessages/item",
355                                     "type": "string",
356                                     "title": "The txMessage Types Item",
357                                     "default": "RIC_SUB",
358                                     "examples": [
359                                         "RIC_SUB"
360                                     ]
361                                 }
362                             },
363                             "rxMessages": {
364                                 "$id": "#/properties/messaging/ports/items/rxmessages",
365                                 "type": "array",
366                                 "title": "The rxMessage Types",
367                                 "items": {
368                                     "$id": "#/properties/messaging/ports/items/rxmessages/item",
369                                     "type": "string",
370                                     "title": "The rxMessage Types Item",
371                                     "default": "RIC_SUB",
372                                     "examples": [
373                                         "RIC_SUB"
374                                     ]
375                                 }
376                             },
377                             "policies": {
378                                 "$id": "#/properties/messaging/ports/items/policies",
379                                 "type": "array",
380                                 "title": "The Policies Types",
381                                 "items": {
382                                     "$id": "#/properties/messaging/ports/items/policies/item",
383                                     "type": "integer",
384                                     "title": "The Policy Types Item",
385                                     "default": 1,
386                                     "examples": [
387                                         1
388                                     ]
389                                 }
390                             }
391                         }
392                     }
393                 }
394             },
395             "required": [
396                 "ports"
397             ]
398
399         },
400         "metrics": {
401             "type": "array",
402             "$id": "#/properties/metrics",
403             "title": "The Metrics Schema",
404             "items": {
405                 "$id": "#/properties/metrics/items",
406                 "type": "object",
407                 "title": "The Metrics Items Schema",
408                 "required": [
409                     "objectName",
410                     "objectInstance",
411                     "name",
412                     "type",
413                     "description"
414                 ],
415                 "properties": {
416                     "objectName": {
417                         "$id": "#/properties/metrics/items/objectname",
418                         "type": "string",
419                         "title": "The Object Name"
420                     },
421                     "objectInstance": {
422                         "$id": "#/properties/metrics/items/objectinstance",
423                         "type": "string",
424                         "title": "The Object Instance"
425                     },
426                     "name": {
427                         "$id": "#/properties/metrics/items/name",
428                         "type": "string",
429                         "title": "The Object Name"
430                     },
431                     "type": {
432                         "$id": "#/properties/metrics/items/type",
433                         "type": "string",
434                         "title": "The Object Type"
435                     },
436                     "description": {
437                         "$id": "#/properties/metrics/items/description",
438                         "type": "string",
439                         "title": "The Object Description"
440                     }
441                 }
442             }
443         },
444         "controls": {
445             "required": [
446                 "__empty_control_section__"
447             ]
448         }
449
450     }
451 }