blob: 9cd5e4f9c1453e7cfb0f7c55f0b1318aad8470ea [file] [log] [blame]
Ralph Knag1fca6ac2017-12-05 12:05:57 -05001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
4.. _dcae-component-schema:
5
6DCAE Component JSON Schema
7==========================
8
9::
10
11 {
12 "$schema": "http://json-schema.org/draft-04/schema#",
13 "title": "Component specification schema",
14 "type": "object",
15 "properties": {
16 "self": {
17 "type": "object",
18 "properties": {
19 "version": {
20 "$ref": "#/definitions/version"
21 },
22 "description": {
23 "type": "string"
24 },
25 "component_type": {
26 "type": "string",
27 "enum": [
28 "docker",
29 "cdap"
30 ]
31 },
32 "name": {
33 "$ref": "#/definitions/name"
34 }
35 },
36 "required": [
37 "version",
38 "name",
39 "description",
40 "component_type"
41 ]
42 },
43 "streams": {
44 "type": "object",
45 "properties": {
46 "publishes": {
47 "type": "array",
48 "uniqueItems": true,
49 "items": {
50 "oneOf": [
51 { "$ref": "#/definitions/publisher_http" },
52 { "$ref": "#/definitions/publisher_message_router" },
53 { "$ref": "#/definitions/publisher_data_router" }
54 ]
55 }
56 },
57 "subscribes": {
58 "type": "array",
59 "uniqueItems": true,
60 "items": {
61 "oneOf": [
62 { "$ref": "#/definitions/subscriber_http" },
63 { "$ref": "#/definitions/subscriber_message_router" },
64 { "$ref": "#/definitions/subscriber_data_router" }
65 ]
66 }
67 }
68 },
69 "required": [
70 "publishes",
71 "subscribes"
72 ]
73 },
74 "services": {
75 "type": "object",
76 "properties": {
77 "calls": {
78 "type": "array",
79 "uniqueItems": true,
80 "items": {
81 "$ref": "#/definitions/caller"
82 }
83 },
84 "provides": {
85 "type": "array",
86 "uniqueItems": true,
87 "items": {
88 "$ref": "#/definitions/provider"
89 }
90 }
91 },
92 "required": [
93 "calls",
94 "provides"
95 ]
96 },
97 "parameters" : {
98 "anyOf" : [
99 {"$ref": "#/definitions/docker-parameters"},
100 {"$ref": "#/definitions/cdap-parameters"}
101 ]
102 },
103 "auxilary": {
104 "oneOf" : [
105 {"$ref": "#/definitions/auxilary_cdap"},
106 {"$ref": "#/definitions/auxilary_docker"}
107 ]
108 },
109 "artifacts": {
110 "type": "array",
111 "description": "List of component artifacts",
112 "items": {
113 "$ref": "#/definitions/artifact"
114 }
115 }
116 },
117 "required": [
118 "self",
119 "streams",
120 "services",
121 "parameters",
122 "auxilary",
123 "artifacts"
124 ],
125 "additionalProperties": false,
126 "definitions": {
127 "cdap-parameters": {
128 "description" : "There are three seperate ways to pass parameters to CDAP: app config, app preferences, program preferences. These are all treated as optional.",
129 "type": "object",
130 "properties" : {
131 "program_preferences": {
132 "description" : "A list of {program_id, program_type, program_preference} objects where program_preference is an object passed into program_id of type program_type",
133 "type": "array",
134 "uniqueItems": true,
135 "items": {
136 "$ref": "#/definitions/program_preference"
137 }
138 },
139 "app_preferences" : {
140 "description" : "Parameters Passed down to the CDAP preference API",
141 "type": "array",
142 "uniqueItems": true,
143 "items": {
144 "$ref": "#/definitions/parameter"
145 }
146 },
147 "app_config" : {
148 "description" : "Parameters Passed down to the CDAP App Config",
149 "type": "array",
150 "uniqueItems": true,
151 "items": {
152 "$ref": "#/definitions/parameter"
153 }
154 }
155 }
156 },
157 "program_preference": {
158 "type": "object",
159 "properties": {
160 "program_type": {
161 "$ref": "#/definitions/program_type"
162 },
163 "program_id": {
164 "type": "string"
165 },
166 "program_pref":{
167 "description" : "Parameters that the CDAP developer wants pushed to this program's preferences API. Optional",
168 "type": "array",
169 "uniqueItems": true,
170 "items": {
171 "$ref": "#/definitions/parameter"
172 }
173 }
174 },
175 "required": ["program_type", "program_id", "program_pref"]
176 },
177 "program_type": {
178 "type": "string",
179 "enum": ["flows","mapreduce","schedules","spark","workflows","workers","services"]
180 },
181 "docker-parameters": {
182 "type": "array",
183 "uniqueItems": true,
184 "items": {
185 "$ref": "#/definitions/parameter"
186 }
187 },
188 "parameter": {
189 "type": "object",
190 "properties": {
191 "name": {
192 "type": "string"
193 },
194 "value": {
195 "description": "Default value for the parameter"
196 },
197 "description": {
198 "description": "Description for the parameter.",
199 "type": "string"
200 },
201 "type": {
202 "description": "The required data type for the parameter.",
203 "type": "string",
204 "enum": [ "string", "number", "boolean", "datetime" ]
205 },
206 "required": {
207 "description": "An optional key that declares a parameter as required (true) or not (false). Default is true.",
208 "type": "boolean",
209 "default": true
210 },
211 "constraints": {
212 "description": "The optional list of sequenced constraint clauses for the parameter.",
213 "type": "array",
214 "items": {
215 "$ref": "#/definitions/parameter-constraints"
216 }
217 },
218 "entry_schema": {
219 "description": "used for complex data type in the future. 'type' must be map or array for entry_schema to kick_in. ",
220 "type": "string"
221 },
222 "designer_editable": {
223 "description": "An optional key that declares a parameter to be editable by designer (true) or not (false). Default is true.",
224 "type": "boolean",
225 "default": true
226 },
227 "policy_editable": {
228 "description": "An optional key that declares a parameter to be editable by policy (true) or not (false). Default is true.",
229 "type": "boolean",
230 "default": false
231 },
232 "sourced_at_deployment": {
233 "description": "An optional key that declares a parameter's value to be assigned at deployment time (true). Default is false.",
234 "type": "boolean",
235 "default": false
236 },
237 "policy_schema" :{
238 "type": "array",
239 "uniqueItems": true,
240 "items": {"$ref": "#/definitions/policy_schema_parameter"}
241 }
242 },
243 "required": [
244 "name",
245 "value",
246 "description"
247 ],
248 "additionalProperties": false,
249 "dependencies": { "policy_schema": ["policy_editable"]}
250 },
251 "policy_schema_parameter": {
252 "type": "object",
253 "properties": {
254 "name": {
255 "type": "string"
256 },
257 "value": {
258 "description": "Default value for the parameter"
259 },
260 "description": {
261 "description": "Description for the parameter.",
262 "type": "string"
263 },
264 "type": {
265 "description": "The required data type for the parameter.",
266 "type": "string",
267 "enum": [ "string", "number", "boolean", "datetime", "list", "map" ]
268 },
269 "required": {
270 "description": "An optional key that declares a parameter as required (true) or not (false). Default is true.",
271 "type": "boolean",
272 "default": true
273 },
274 "constraints": {
275 "description": "The optional list of sequenced constraint clauses for the parameter.",
276 "type": "array",
277 "items": {
278 "$ref": "#/definitions/parameter-constraints"
279 }
280 },
281 "entry_schema": {
282 "description": "The optional key that is used to declare the name of the Datatype definition for entries of certain types. entry_schema must be defined when the type is either list or map. If the type is list and the entry type is a simple type (string, number, boolean, datetime), follow with a simple string to describe the entry type. If the type is list and the entry type is a map, follow with an array to describe the keys for the entry map. If the type is list and the entry type is also list, this is not currently supported here. If the type is map, then follow with an array to describe the keys for this map. ",
283 "type": "array", "uniqueItems": true, "items": {"$ref": "#/definitions/policy_schema_parameter"}
284 }
285 },
286 "required": [
287 "name",
288 "type"
289 ],
290 "additionalProperties": false
291 },
292 "parameter-constraints": {
293 "type": "object",
294 "additionalProperties": false,
295 "properties": {
296 "equal": {
297 "description": "Constrains a property or parameter to a value equal to (‘=’) the value declared."
298 },
299 "greater_than": {
300 "description": "Constrains a property or parameter to a value greater than (‘>’) the value declared.",
301 "type": "number"
302 },
303 "greater_or_equal": {
304 "description": "Constrains a property or parameter to a value greater than or equal to (‘>=’) the value declared.",
305 "type": "number"
306 },
307 "less_than": {
308 "description": "Constrains a property or parameter to a value less than (‘<’) the value declared.",
309 "type": "number"
310 },
311 "less_or_equal": {
312 "description": "Constrains a property or parameter to a value less than or equal to (‘<=’) the value declared.",
313 "type": "number"
314 },
315 "valid_values": {
316 "description": "Constrains a property or parameter to a value that is in the list of declared values.",
317 "type": "array"
318 },
319 "length": {
320 "description": "Constrains the property or parameter to a value of a given length.",
321 "type": "number"
322 },
323 "min_length": {
324 "description": "Constrains the property or parameter to a value to a minimum length.",
325 "type": "number"
326 },
327 "max_length": {
328 "description": "Constrains the property or parameter to a value to a maximum length.",
329 "type": "number"
330 }
331 }
332 },
333 "stream_message_router": {
334 "type": "object",
335 "properties": {
336 "format": {
337 "$ref": "#/definitions/name"
338 },
339 "version": {
340 "$ref": "#/definitions/version"
341 },
342 "config_key": {
343 "type": "string"
344 },
345 "type": {
346 "description": "Type of stream to be used",
347 "type": "string",
348 "enum": [
349 "message router", "message_router"
350 ]
351 }
352 },
353 "required": [
354 "format",
355 "version",
356 "config_key",
357 "type"
358 ]
359 },
360 "publisher_http": {
361 "type": "object",
362 "properties": {
363 "format": {
364 "$ref": "#/definitions/name"
365 },
366 "version": {
367 "$ref": "#/definitions/version"
368 },
369 "config_key": {
370 "type": "string"
371 },
372 "type": {
373 "description": "Type of stream to be used",
374 "type": "string",
375 "enum": [
376 "http",
377 "https"
378 ]
379 }
380 },
381 "required": [
382 "format",
383 "version",
384 "config_key",
385 "type"
386 ]
387 },
388 "publisher_message_router": {
389 "$ref": "#/definitions/stream_message_router"
390 },
391 "publisher_data_router": {
392 "type": "object",
393 "properties": {
394 "format": {
395 "$ref": "#/definitions/name"
396 },
397 "version": {
398 "$ref": "#/definitions/version"
399 },
400 "config_key": {
401 "type": "string"
402 },
403 "type": {
404 "description": "Type of stream to be used",
405 "type": "string",
406 "enum": [
407 "data router", "data_router"
408 ]
409 }
410 },
411 "required": [
412 "format",
413 "version",
414 "config_key",
415 "type"
416 ]
417 },
418 "subscriber_http": {
419 "type": "object",
420 "properties": {
421 "format": {
422 "$ref": "#/definitions/name"
423 },
424 "version": {
425 "$ref": "#/definitions/version"
426 },
427 "route": {
428 "type": "string"
429 },
430 "type": {
431 "description": "Type of stream to be used",
432 "type": "string",
433 "enum": [
434 "http",
435 "https"
436 ]
437 }
438 },
439 "required": [
440 "format",
441 "version",
442 "route",
443 "type"
444 ]
445 },
446 "subscriber_message_router": {
447 "$ref": "#/definitions/stream_message_router"
448 },
449 "subscriber_data_router": {
450 "type": "object",
451 "properties": {
452 "format": {
453 "$ref": "#/definitions/name"
454 },
455 "version": {
456 "$ref": "#/definitions/version"
457 },
458 "route": {
459 "type": "string"
460 },
461 "type": {
462 "description": "Type of stream to be used",
463 "type": "string",
464 "enum": [
465 "data router", "data_router"
466 ]
467 },
468 "config_key": {
469 "description": "Data router subscribers require config info to setup their endpoints to handle requests. For example, needs username and password",
470 "type": "string"
471 }
472 },
473 "required": [
474 "format",
475 "version",
476 "route",
477 "type",
478 "config_key"
479 ]
480 },
481 "provider" : {
482 "oneOf" : [
483 {"$ref": "#/definitions/docker-provider"},
484 {"$ref": "#/definitions/cdap-provider"}
485 ]
486 },
487 "cdap-provider" : {
488 "type": "object",
489 "properties" : {
490 "request": {
491 "$ref": "#/definitions/formatPair"
492 },
493 "response": {
494 "$ref": "#/definitions/formatPair"
495 },
496 "service_name" : {
497 "type" : "string"
498 },
499 "service_endpoint" : {
500 "type" : "string"
501 },
502 "verb" : {
503 "type": "string",
504 "enum": ["GET", "PUT", "POST", "DELETE"]
505 }
506 },
507 "required" : [
508 "request",
509 "response",
510 "service_name",
511 "service_endpoint",
512 "verb"
513 ]
514 },
515 "docker-provider": {
516 "type": "object",
517 "properties": {
518 "request": {
519 "$ref": "#/definitions/formatPair"
520 },
521 "response": {
522 "$ref": "#/definitions/formatPair"
523 },
524 "route": {
525 "type": "string"
526 },
527 "verb": {
528 "type": "string",
529 "enum": ["GET", "PUT", "POST", "DELETE"]
530 }
531 },
532 "required": [
533 "request",
534 "response",
535 "route"
536 ]
537 },
538 "caller": {
539 "type": "object",
540 "properties": {
541 "request": {
542 "$ref": "#/definitions/formatPair"
543 },
544 "response": {
545 "$ref": "#/definitions/formatPair"
546 },
547 "config_key": {
548 "type": "string"
549 }
550 },
551 "required": [
552 "request",
553 "response",
554 "config_key"
555 ]
556 },
557 "formatPair": {
558 "type": "object",
559 "properties": {
560 "format": {
561 "$ref": "#/definitions/name"
562 },
563 "version": {
564 "$ref": "#/definitions/version"
565 }
566 }
567 },
568 "name": {
569 "type": "string"
570 },
571 "version": {
572 "type": "string",
573 "pattern": "^(\\d+\\.)(\\d+\\.)(\\*|\\d+)$"
574 },
575 "artifact": {
576 "type": "object",
577 "description": "Component artifact object",
578 "properties": {
579 "uri": {
580 "type": "string",
581 "description": "Uri to artifact"
582 },
583 "type": {
584 "type": "string",
585 "enum": ["jar", "docker image"]
586 }
587 },
588 "required": ["uri", "type"]
589 },
590
591 "auxilary_cdap": {
592 "title": "cdap component specification schema",
593 "type": "object",
594 "properties": {
595 "streamname": {
596 "type": "string"
597 },
598 "artifact_name" : {
599 "type": "string"
600 },
601 "artifact_version" : {
602 "type": "string",
603 "pattern": "^(\\d+\\.)(\\d+\\.)(\\*|\\d+)$"
604 },
605 "namespace":{
606 "type": "string",
607 "description" : "optional"
608 },
609 "programs": {
610 "type": "array",
611 "uniqueItems": true,
612 "items": {
613 "$ref": "#/definitions/cdap_program"
614 }
615 }
616 },
617 "required": [
618 "streamname",
619 "programs",
620 "artifact_name",
621 "artifact_version"
622 ]
623 },
624 "cdap_program_type": {
625 "type": "string",
626 "enum": ["flows","mapreduce","schedules","spark","workflows","workers","services"]
627 },
628 "cdap_program": {
629 "type": "object",
630 "properties": {
631 "program_type": {
632 "$ref": "#/definitions/cdap_program_type"
633 },
634 "program_id": {
635 "type": "string"
636 }
637 },
638 "required": ["program_type", "program_id"]
639 },
640
641 "auxilary_docker": {
642 "title": "Docker component specification schema",
643 "type": "object",
644 "properties": {
645 "healthcheck": {
646 "description": "Define the health check that Consul should perfom for this component",
647 "type": "object",
648 "oneOf": [
649 { "$ref": "#/definitions/docker_healthcheck_http" },
650 { "$ref": "#/definitions/docker_healthcheck_script" }
651 ]
652 },
653 "ports": {
654 "description": "Port mapping to be used for Docker containers. Each entry is of the format <container port>:<host port>.",
655 "type": "array",
656 "items": {
657 "type": "string"
658 }
659 },
660 "volumes": {
661 "description": "Volume mapping to be used for Docker containers. Each entry is of the format below",
662 "type": "array",
663 "items": {
664 "type": "object",
665 "properties": {
666 "host":{
667 "type":"object",
668 "path": {"type": "string"}
669 },
670 "container":{
671 "type":"object",
672 "bind": { "type": "string"},
673 "mode": { "type": "string"}
674 }
675 }
676 }
677 }
678 },
679 "required": [
680 "healthcheck"
681 ],
682 "additionalProperties": false
683 },
684 "docker_healthcheck_http": {
685 "properties": {
686 "type": {
687 "description": "Consul health check type",
688 "type": "string",
689 "enum": [
690 "http",
691 "https"
692 ]
693 },
694 "interval": {
695 "description": "Interval duration in seconds i.e. 10s",
696 "default": "15s",
697 "type": "string"
698 },
699 "timeout": {
700 "description": "Timeout in seconds i.e. 10s",
701 "default": "1s",
702 "type": "string"
703 },
704 "endpoint": {
705 "description": "Relative endpoint used by Consul to check health by making periodic HTTP GET calls",
706 "type": "string"
707 }
708 },
709 "required": [
710 "type",
711 "endpoint"
712 ]
713 },
714 "docker_healthcheck_script": {
715 "properties": {
716 "type": {
717 "description": "Consul health check type",
718 "type": "string",
719 "enum": [
720 "script",
721 "docker"
722 ]
723 },
724 "interval": {
725 "description": "Interval duration in seconds i.e. 10s",
726 "default": "15s",
727 "type": "string"
728 },
729 "timeout": {
730 "description": "Timeout in seconds i.e. 10s",
731 "default": "1s",
732 "type": "string"
733 },
734 "script": {
735 "description": "Script command that will be executed by Consul to check health",
736 "type": "string"
737 }
738 },
739 "required": [
740 "type",
741 "script"
742 ]
743 }
744 }
745 }