DCAE-D be initial commit
[sdc/dcae-d/dt-be-main.git] / dcaedt_validator / checker / src / main / resources / tosca / tosca_simple_yaml_1_0.grammar
1 _status_values: &status_values  
2   enum:
3     - supported
4     - unsupported
5     - experimental
6     - deprecated
7
8 #I do not know that the lists and maps qualify as 'primitive' ..
9 _primitive_types: &primitive_types
10   enum: [string,integer,float,boolean,timestamp,list,map,version,range,scalar-unit.size,scalar_unit.frequency,scalar_unit.time]
11
12 #needs custom validation as we have to make sure there are 2 elements and allow for the
13 #UNBOUNDED keyword as second element
14 _range_definition: &range_definition
15   type: seq
16   name: range_definition
17   sequence:
18     - type: scalar
19
20 #see A.5.2
21 #this is where the need of verifying the size of a collection (sequence/map) came from
22 #this is specified as a sequence where each entry is a map with one entry??
23 _constraints_sequence: &constraints_sequence
24   name: constraints_sequence
25   short: 0
26   type: seq
27   sequence:
28     - type: map
29 #      length: 1
30       mapping:
31         equal:
32           desc: "Constrains a property or parameter to a value equal to the value declared."
33           type: any
34           required: no
35         greater_than:
36           desc: "Constrains a property or parameter to a value greater than the value declared"
37           type: scalar
38           required: no
39         greater_or_equal:
40           desc: "Constrains a property or parameter to a value greater than or equal to the value declared."
41           type: scalar
42           required: no
43         less_than:
44           desc: "Constrains a property or parameter to a value less than the value declared"
45           type: scalar
46           required: no
47         less_or_equal:
48           desc: "Constrains a property or parameter to a value less than or equal to the value declared."
49           type: scalar
50           required: no
51         in_range:
52           desc: "Constrains a property or parameter to a value in range of (inclusive) the two values declared.
53 "
54           type: seq
55 #          length: 2
56           sequence:
57             - type: scalar
58           required: no
59         valid_values:
60           desc: "Constrains a property or parameter to a value that is in the list of declared values"
61           type: seq
62           sequence:
63             - type: scalar
64           required: no
65         length:
66           desc: "Constrains the property or parameter to a value of a given length."
67           type: int
68           required: no
69         min_length:
70           desc: "Constrains the property or parameter to a value to a minimum length"
71           type: scalar
72           required: no
73         max_length:
74           desc: "Constrains the property or parameter to a value to a maximum length"
75           type: scalar
76           required: no
77         pattern:    
78           desc: "Constrains the property or parameter to a value that is allowed by the provided regular expression."
79           type: str
80           required: no
81
82 # section A.5.3 property_filter_definition
83 # it is a constraints sequence that gets attached to a property ..
84 _property_filter_definition: &property_filter_definition
85   name: property_filter_definition
86   type: map
87   mapping:
88     =:
89       *constraints_sequence
90
91 #section A.5.4 node_filter_definition
92 _node_filter_definition: &node_filter_definition
93   type: map
94   name: node_filter_definition
95   mapping:
96     properties:
97       desc: "property names to constraints to be applied to those properties"
98       required: no
99       type: seq
100       sequence:
101          - *property_filter_definition
102 #        - type: map
103 #          mapping: 
104 #            =:
105 #              *constraints_sequence
106     capabilities:
107       desc: ""
108       required: no
109       type: seq
110       sequence:
111         - type: map
112           name: node_filter_capabilities_sequence
113           desc: "the key is a capability name or type"
114           mapping:
115             =: 
116               name: node_filter_capabilities_entry
117               type: map
118               mapping:
119                 properties:
120                   desc: "the capability properties and their constraints"
121                   name: node_filter_capabilities_properties
122                   type: seq        
123                   sequence:
124                     - type: map
125                       name: node_filter_capabilities_property
126                       mapping:
127                         =: *constraints_sequence
128
129 #used in property and attribute definitions
130 _entry_schema_definition: &entry_schema_definition
131   desc: "The optional key that is used to declare the name of the Datatype definition for entries of set types such as the TOSCA list or map"
132   name: entry_schema_definition
133   required: no
134   type: map
135   short: type
136   mapping: 
137     "type":
138       desc: "collection element type"
139       required: yes
140       type: str
141     description:
142       required: no
143       type: str
144     constraints:
145       *constraints_sequence
146
147 # see section A.5.5
148 _artifact_definition: &artifact_definition
149   type: map
150   name: artifact_definition
151   short: implementation # assumes type can be inferred ..
152   mapping:
153     "type":
154       desc: "The required artifact type for the artifact definition"
155       required: yes
156       type: str
157     description:
158       desc: "The optional description for the artifact definition"
159       required: no
160       type: str
161     implementation:
162       desc: "The optional URI string (relative or absolute) which can be used to locate the artifacts file.
163 "
164       required: no
165       type: str
166     repository:
167       desc: "The optional name of the repository definition which contains the location of the external repository that contains the artifact"
168       required: no
169       type: str
170     deploy_path:    
171       desc: "The file path the associated file would be deployed into within the target nodes container."
172       required: no
173       type: str
174
175 # see section A.5.6
176 _repository_definition: &repository_definition
177   type: map
178   name: repository_definition
179   short: url
180   mapping:
181     description:
182       desc: "The optional description for the repository."
183       required: no
184       type: str
185     url:
186       desc: "The required URL or network address used to access the repository"
187       required: yes
188       type: str
189     credential:
190       desc: "The optional Credential used to authorize access to the repository"
191       required: no
192       type: str
193
194 #see section 3.5.7
195 _import_definition: &import_definition
196   type: map
197   name: import_definition
198   short: file
199   mapping:
200     file:
201       desc: "file URI"
202       required: yes
203       type: str
204     repository:
205       desc: "symbolic name of the repository definition where the imported file can be found"
206       required: no
207       type: str
208     namespace_uri:
209       desc: "namespace URI to that will be applied to type definitions found within the imported file"
210       required: no
211       type: str
212     namespace_prefix:
213       desc: "optional namespace prefix (alias) that will be used to indicate the namespace_uri when forming a qualified name (i.e., qname) when referencing type definitions from the imported"
214       required: no
215       type: str
216
217 #see section A.5.7
218 _property_definition: &property_definition
219   type: map
220   name: property_definition
221   mapping:
222     "type":
223       type: str
224       required: yes
225 #not as easy, it can be an user defined data type
226 #      <<: *primitive_types
227     description:
228       type: str
229       required: no
230     constraints:
231       desc: "The optional list of sequenced constraint clauses for the Data Type."
232       required: no
233       <<: *constraints_sequence
234     default:
235       type: any
236       required: no
237     "required":
238       type: bool
239       required: no
240     status:
241       type: str
242       required: no
243       <<: *status_values
244     entry_schema:
245       <<: *entry_schema_definition
246 #      desc: "used to declare the name of the Datatype definition for entries of set types such as the TOSCA list or map."
247 #      type: str
248 #      required: no
249
250 #see section A.5.8
251 #_property_assignment_definition: &property_assignment_definition
252
253 #see A.5.9
254 _attribute_definition: &attribute_definition
255   type: map
256   name: attribute_definition
257   mapping:
258     "type":
259       type: str
260       required: yes
261 #      <<: *primitive_types
262     description:
263       type: str
264       required: no
265     default:
266       type: any
267       required: no
268     status:
269       desc: "The optional status of the attribute relative to the specification or implementation"
270       type: str
271       required: no
272       <<: *status_values
273     entry_schema:
274       <<: *entry_schema_definition
275
276 #see section A.5.10
277 #here again, we must support the short form which is the most common
278 _attribute_assignment_definition: &attribute_assignment_definition
279   type: map
280   name: attribute_assignment_definition
281   mapping:
282     description:
283       desc: "The optional description of the attribute."
284       required: no
285       type: str
286     value:
287 #actually 'value | value_expression'
288       desc: "represent the type-compatible value to assign to the named attribute. Attribute values may be provided as the result from the evaluation of an expression or a function"
289       required: yes
290       type: any
291
292
293 # see spec section A.5.11
294
295 # see spec section A.5.11.1: variant to be used in node or relationship type definitions 
296 _type_operation_definition: &type_operation_definition
297   type: map
298   name: type_operation_definition
299   short: implementation
300   mapping:
301     description:
302       desc: "The optional description string for the associated named operation."
303       required: no
304       type: str
305     implementation:
306       desc: "The optional implementation artifact name (e.g., a script file name within a TOSCA CSAR file)"
307       required: no
308       type: str
309     inputs:
310       desc: ""
311       required: no
312       type: map
313       mapping:
314         =:
315           desc: "a property value or an expression providing a input value"
316           name: property_assignment
317           type: any
318
319 # from A.5.11.2
320 _template_operation_definition: &template_operation_definition
321   type: map
322   name: template_operation_definition
323   short: implementation
324   mapping:
325     description:
326       desc: "The optional description string for the associated named operation."
327       required: no
328       type: str
329     implementation:
330       desc: "The optional implementation artifact name (e.g., a script file name within a TOSCA CSAR file)"
331       name: template_operation_implementation_definition
332       required: no
333       short: primary
334       type: map
335       mapping:
336         primary:
337           desc: "The optional implementation artifact name (e.g., the primary script file name within a TOSCA CSAR file). "
338           required: no
339           type: str
340         dependencies:
341           desc: "The optional list of one or more dependent or secondary implementation artifact name which are referenced by the primary implementation artifact (e.g., a library the script installs or a secondary script)"
342           required: no
343           type: seq
344           sequence: 
345             - type: str
346     inputs:
347       desc: ""
348       required: no
349       type: map
350       mapping:
351         =:
352           desc: "a property value or an expression providing a input value"
353           name: property_assignment
354           type: any
355
356
357 # see section A.5.12, specifically A.5.12.2.1 : definition to be used in node or relationship type definition
358 _type_interface_definition: &type_interface_definition
359   type: map
360   name: type_interface_definition
361   mapping:
362     "type":
363       desc: "represents the required name of the Interface Type for the interface definition
364 "
365       required: yes
366       type: str
367     inputs:
368       desc: "The optional list of input property definitions available to all defined operations"
369       type: map
370       mapping:
371         =:
372           *property_definition
373     =:
374       *type_operation_definition
375
376 # see section A.5.12.2.2, extended notation to be used in node or relationship template definitions
377 _template_interface_definition: &template_interface_definition
378   type: map
379   name: template_interface_definition
380   mapping:
381     inputs:
382       desc: "The optional list of input property definitions available to all defined operations"
383       type: map
384       mapping:
385         =:
386           desc: "a property value or an expression providing a property value"
387           name: property_assignment
388           type: any
389     =:
390       *template_operation_definition
391
392
393 # A.6 section: type specific definitions
394
395 # see section A.6.1
396 _capability_definition: &capability_definition
397   type: map
398   name: capability_definition
399   short: type
400   mapping:
401     "type":
402       desc: "The required name of the Capability Type the capability definition is based upon"
403       required: yes
404       type: str
405     description:
406       desc: "The optional description of the Capability definition"
407       required: no
408       type: str
409     properties:
410       desc: ""
411       required: no
412       type: map
413       mapping:
414        =:
415           *property_definition
416     attributes:
417       desc: "An optional list of property definitions for the Capability definition"
418       required: no
419       type: map
420       mapping:
421         =:
422           *attribute_definition
423     valid_source_types:
424       desc: ""
425       required: no
426       type: seq
427       sequence:
428         - type: str
429     occurrences:
430       desc: "The optional minimum and maximum occurrences for the capability."
431       required: no
432       <<: *range_definition
433
434 # see section A.6.2
435 #
436 _requirement_definition: &requirement_definition
437   type: map
438   name: requirement_definition
439   short: capability  #as per A.6.2.2.1
440   mapping:
441     capability:
442       desc: "The required reserved keyname used that can be used to provide the name of a valid Capability Type that can fulfil the requirement"
443       required: yes
444       type: str
445     node:
446       desc: "The optional reserved keyname used to provide the name of a valid Node Type that contains the capability definition that can be used to fulfil the requirement. "
447       required: no
448       type: str
449     relationship:
450 # and from section A.6.2.1, this one is an oddball
451       desc: "The optional reserved keyname used to provide the name of a valid Relationship Type to construct when fulfilling the requirement."
452       required: no
453       name: requirement_relationship_definition
454       short: type
455       type: map
456       mapping:
457         type:
458           desc: "The optional reserved keyname used to provide the name of the Relationship Type for the requirement definitions relationship keyname.
459 "
460           required: yes
461           type: str
462         interfaces:
463           #not clear which interface definition is to be used here
464           desc: "allows augmentation (additional properties and operations) of the interfaces defined by the relationship type indicated above"
465           required: no
466           type: map
467           mapping:
468             =:
469               *type_interface_definition
470     occurrences:
471       desc: "The optional minimum and maximum occurrences for the requirement."
472       required: no
473       <<: *range_definition
474
475 # see section A.6.3
476 _artifact_type_definition: &artifact_type_definition
477   type: map
478   name: artifact_type_definition
479   mapping:
480     derived_from:
481       desc: "An optional parent Artifact Type name the Artifact Type derives from"
482       required: no
483       type: str
484     description:
485       desc: "An optional description for the Artifact Type."
486       required: no
487       type: str
488     mime_type:
489       desc: "The required mime type property for the Artifact Type."
490       required: no
491       type: str
492     file_ext:
493       desc: "The required file extension property for the Artifact Type"
494       required: no
495       type: seq
496       sequence:
497         - type: str
498     properties:
499       desc: "An optional list of property definitions for the Artifact Type"
500       required: no
501       type: map
502       mapping:
503         =:
504           *property_definition
505
506 #see spec section #A.6.4
507 _interface_type_definition: &interface_type_definition
508   type: map
509   name: interface_type_definition
510   mapping:
511     inputs:
512       desc: "The optional list of input property definitions available to all defined operations"
513       type: map
514       mapping:
515         =:
516           type: str
517           desc: "property_name to property_value(_expression) mapping"
518     =:
519       *type_operation_definition
520
521 # A.6.5
522 _data_type_definition: &data_type_definition
523   type: map
524   name: data_type_definition
525   mapping:
526     derived_from:
527       desc: "The optional key used when a datatype is derived from an existing TOSCA Data Type.
528 "
529       required: no
530       type: str
531     description:
532       desc: "The optional description for the Data Type.
533 "
534       required: no
535       type: str
536     constraints:
537       desc: "The optional list of sequenced constraint clauses for the Data Type."
538       <<: *constraints_sequence
539     properties:
540       desc: "The optional list property definitions that comprise the schema for a complex Data Type in TOSCA"
541       type: map
542       mapping:
543         =:
544           *property_definition
545
546 # see section A.6.6
547 _capability_type_definition: &capability_type_definition
548   type: map
549   name: capability_type_definition
550   mapping:
551     derived_from:
552       desc: "An optional parent capability type name this new Capability Type derives from."
553       required: no
554       type: str
555     description:
556       desc: "An optional description for the Capability Type"
557       required: no
558       type: str
559     properties:
560       desc: "An optional list of property definitions for the Capability Type."
561       required: no
562       type: map
563       mapping:
564         =:
565           *property_definition
566     attributes:
567       desc: "An optional list of attribute definitions for the Capability Type"
568       required: no
569       type: map
570       mapping:
571         =:
572           *attribute_definition
573     valid_source_types:
574       desc: "An optional list of one or more valid names of Node Types that are supported as valid sources of any relationship established to the declared Capability Type"
575       required: no
576       type: seq
577       sequence:
578         - type: str
579
580 # section A.6.7 requirement definition: TOSCA YAML profile relies on capability types to 
581 # define requirements 
582
583 # see section A.6.9
584 _relationship_type_definition: &relationship_type_definition
585   type: map
586   name: relationship_type_definition
587   mapping:
588     derived_from:
589       desc: "An optional parent Relationship Type name the Relationship Type derives from"
590       required: no
591       type: str
592     description:
593       desc: "An optional description for the Relationship Type."
594       required: no
595       type: str
596     properties:
597       desc: "An optional list of property definitions for the Relationship Type"
598       required: no
599       type: map
600       mapping:
601         =:
602           *property_definition
603     attributes:
604       desc: "An optional list of attribute definitions for the Relationship Type"
605       required: no
606       type: map
607       mapping:
608         =:
609           *attribute_definition
610     interfaces:
611       desc: "An optional list of interface definitions interfaces supported by the Relationship Type"
612       required: no
613       type: map
614       mapping:
615         =:
616           *type_interface_definition
617     valid_target_types:
618       desc: "An optional list of one or more names of Capability Types that are valid targets for this relationship. "
619       required: no
620       type: seq
621       sequence:
622         - type: str
623
624 #see section 3.6.10
625 _group_type_definition: &group_type_definition
626   type: map
627   name: group_type_definition
628   mapping:
629     derived_from:
630       desc: "An optional parent Group Type name this new Group Type derives from"
631       required: no
632       type: str
633     version:
634       desc: "An optional version for the Group Type definition"
635       required: no
636       type: str
637     description:
638       desc: "An optional description for the Group Type"
639       required: no
640       type: str
641     properties:
642       desc: "An optional list of property definitions for the Group Type."
643       required: no
644       type: map
645       mapping:
646         =:
647           *property_definition
648     targets:
649       desc: "An optional list of one or more names of Node Types that are valid
650 (allowed) as members of the Group Type."
651       required: no
652       type: seq
653       sequence:
654         - type: str
655     interfaces:
656       desc: "An optional list of interface definitions supported by the Group Type"
657       required: no
658       type: map
659       mapping:
660         =:
661           *type_interface_definition
662
663 #see section 3.6.11
664 _policy_type_definition: &policy_type_definition
665   type: map
666   name: policy_type_definition
667   mapping:
668     derived_from:
669       desc: "An optional parent Policy Type name this new Policy Type derives from"
670       required: no
671       type: str
672     version:
673       desc: "An optional version for the Policy Type definition"
674       required: no
675       type: str
676     description:
677       desc: "An optional description for the Policy Type"
678       required: no
679       type: str
680     properties:
681       desc: "An optional list of property definitions for the Policy Type."
682       required: no
683       type: map
684       mapping:
685         =:
686           *property_definition
687     targets:
688       desc: "An optional list of valid Node Types or Group Types the Policy Type
689 can be applied to"
690       required: no
691       type: seq
692       sequence:
693         - type: str
694
695 # see section A.6.8
696 _node_type_definition: &node_type_definition
697   type: map
698   name: node_type_definition
699   mapping:
700     derived_from:
701       desc: "An optional parent Node Type name this new Node Type derives from"
702       required: no
703       type: str
704     description:
705       desc: "An optional description for the Node Type"
706       required: no
707       type: str
708     properties:
709       desc: "An optional list of property definitions for the Node Type."
710       required: no
711       type: map
712       mapping:
713         =:
714           *property_definition
715     attributes:
716       desc: "An optional list of attribute definitions for the Node Type.
717 "
718       required: no
719       type: map
720       mapping:
721         =:
722           *attribute_definition
723     requirements:
724       desc: "An optional sequenced list of requirement definitions for the Node Type.
725 "
726       required: no
727       type: seq
728       sequence:
729         - type: map
730           mapping:
731             =:
732               *requirement_definition
733     capabilities:
734       desc: "An optional list of capability definitions for the Node Type"
735       required: no
736       type: map
737       mapping:
738         =:
739           *capability_definition
740     interfaces:
741       desc: ""
742       required: no
743       type: map
744       mapping:
745         =:
746           *type_interface_definition
747     artifacts:
748       desc: "An optional list of named artifact definitions for the Node Type"
749       required: no
750       type: map
751       mapping:
752         =:
753           *artifact_definition
754
755 # A.7 Template specific definitions
756
757 # see section A.7.1
758 _capability_assignment_definition: &capability_assignment_definition
759   type: map
760   name: capability_assignment_definition
761   mapping:
762     properties:
763       # list of property assignments
764       desc: "An optional list of property definitions for the Capability definition"
765       required: no
766       type: map
767       mapping:
768         =:
769           desc: "a property value or an expression providing a property value"
770           name: property_assignment
771           type: any
772     attributes:
773       # list of attribute assignments
774       desc: "An optional list of attribute definitions for the Capability definition"
775       required: no
776       type: map
777       mapping:
778         =:
779           desc: ""
780           name: attribute_assignment
781           type: any
782
783 # see section A.7.2
784 _requirement_assignment_definition: &requirement_assignment_definition
785   type: map
786   name: requirement_assignment_definition
787   short: node
788   mapping:
789     capability:
790       desc: " used to provide the name of either a: Capability definition within a target node template that can fulfill the requirement or Capability Type that the provider will use to select a type-compatible target node template to fulfill the requirement at runtime."
791       required: no
792       type: str
793     node:
794 #why is this a reference to a node type and not to a node template??
795       desc: "used to identify the target node of a relationship: Node Template name that can fulfil the target node requirement or Node Type name that the provider will use to select a type-compatible node template to fulfil the requirement at runtime"
796       required: no
797       type: str
798     relationship:
799       desc: ""
800       required: no
801 #fins a better name      name: relationship_definition
802       type: map
803       short: type
804       mapping:
805         "type":
806           desc: "The optional reserved keyname used to provide the name of the Relationship Type for the requirement assignments relationship keyname"
807           required: no
808           type: str
809         properties:
810           desc: ""
811           required: no
812           type: map
813           mapping:
814             =:
815               desc: "a property value or an expression providing a property value"
816               name: property_assignment
817               type: any
818         interfaces:
819           desc: "from A.5.12.2.2, right?"
820           required: no
821           type: map
822           mapping:
823             =:
824               *template_interface_definition
825     node_filter:
826       desc: "The optional filter definition that TOSCA orchestrators or providers would use to select a type-compatible target node that can fulfill the associated abstract requirement at runtime."
827       required: no
828       <<: *node_filter_definition
829
830 # see section A.7.3
831 _node_template_definition: &node_template_definition
832   type: map
833   name: node_template_definition
834   mapping:
835     "type":
836       desc: "The required name of the Node Type the Node Template is based upon"
837       required: yes
838       type: str
839     description:
840       desc: "An optional description for the Node Template"
841       required: no
842       type: str
843     directives:
844       desc: "An optional list of directive values to provide processing instructions to orchestrators and tooling."
845       required: no
846       type: seq
847       sequence:
848         - type: str
849     properties:
850 #custom check needs to be added: the value or expression providing the property value
851 #needs to be compatible with the property definition
852       desc: "An optional list of property value assignments for the Node Template."
853       required: no
854       type: map
855       mapping:
856         =:
857           type: any
858           name: property_assignment
859           desc: "a property value or an expression providing a property value"
860     attributes:
861       desc: "An optional list of attribute value assignments for the Node Template"
862       required: no
863       type: map
864       mapping:
865         =:
866           *attribute_assignment_definition
867     requirements:
868       desc: "An optional sequenced list of requirement assignments for the Node Template."
869       required: no
870       type: seq
871       sequence:
872         - type: map
873           mapping:
874             =:
875               *requirement_assignment_definition
876     capabilities:
877       desc: "An optional list of capability assignments for the Node Template."
878       required: no
879       type: map
880       mapping:
881         =:
882           *capability_assignment_definition
883     interfaces:
884       desc: "An optional list of named interface definitions for the Node Template"
885       required: no
886       type: map
887       mapping:
888         =:
889           *template_interface_definition
890     artifacts:
891       desc: "An optional list of named artifact definitions for the Node Template.
892 "
893       required: no
894       type: map
895       mapping:
896         =:
897           *artifact_definition
898     node_filter:
899       desc: "The optional filter definition that TOSCA orchestrators would use to select the correct target node. This keyname is only valid if the directive has the value of 'selectable' set."
900       required: no
901       <<: *node_filter_definition 
902     copy:
903       desc: "The optional (symbolic) name of another node template to copy into (all keynames and values) and use as a basis for this node template."
904       required: no
905       type: str
906
907 # see section A.7.4
908 _relationship_template_definition: &relationship_template_definition
909   type: map
910   name: relationship_template_definition
911   mapping:
912     "type":
913       desc: "The required name of the Relationship Type the Relationship Template is based upon"
914       required: yes
915       type: str
916     alias:
917       desc: "The optional name of a different Relationship Template definition whose values are (effectively) copied into the definition for this Relationship Template (prior to any other overrides)."
918       required: no
919       type: str
920     description:
921       desc: "An optional description for the Relationship Template"
922       required: no
923       type: str
924     properties:
925       desc: "An optional list of property assignments for the Relationship Template."
926       required: no
927       name: properties_assignment_validation
928       type: map
929       mapping:
930         =:
931           type: any
932 #scalar
933           desc: "an expression providing a property value"
934     attributes:
935       desc: "An optional list of attribute value assignments for the Relationship Template"
936       required: no
937       name: attributes_assignment_validation
938       type: map
939       mapping:
940         =: 
941           type: scalar
942           desc: "an expression providing an attribute value"
943     interfaces:
944       desc: "An optional list of named interface definitions for the Relationship Template ('augmentation' is allowed here)"
945       required: no
946       type: map
947       mapping:
948         =:
949           *template_interface_definition
950     copy:
951       desc: "The optional (symbolic) name of another relationship template to copy into (all keynames and values) and use as a basis for this relationship template."
952       required: no
953       type: str
954
955
956 # see section 3.7.5
957 _group_definition: &group_definition
958   type: map
959   name: group_definition
960   mapping:
961     "type":
962       desc: "The required name of the group type the group definition is based upon"
963       required: yes
964       type: str
965     description:
966       desc: "The optional description for the group definition"
967       required: no
968     properties:
969       desc: " represents the optional list of property assignments for the group definition that provide values for properties defined in its declared Group Type"
970       required: no
971       type: map
972       mapping:
973         =:
974           type: any
975           name: property_assignment
976     targets:
977       desc: "contains the required list of one or more node template names (within the same topology template) that are members of this logical group"
978       required: yes
979       type: seq
980       sequence:
981         - type: str
982     interfaces:
983       desc: "represents the optional list of interface definitions for the group definition that augment those provided by its declared Group Type"
984       required: no
985       type: map
986       mapping:
987         =:
988           *template_interface_definition
989
990 # see section 3.7.6
991 _policy_template_definition: &policy_template_definition
992   type: map
993   name: policy_definition
994   mapping:
995     "type":
996       desc: "The required name of the policy type the policy definition is based upon"
997       required: yes
998       type: str
999     description:
1000       desc: "The optional description for the policy definition"
1001       required: no
1002     properties:
1003       desc: "represents the optional list of property assignments for the policy definition that provide values for properties defined in its declared Policy Type"
1004       required: no
1005       type: map
1006       mapping:
1007         =:
1008           type: any
1009           name: property_assignment
1010     targets:
1011       desc: "represents the optional list of names of node templates or groups that the policy is to applied to"
1012       required: no
1013       type: seq
1014       sequence:
1015         - type: str
1016
1017 # see section 3.8 Topology Template definition:  defines the topology template of a cloud application.
1018 # described as a a reusable grammar as it can be a part of a service template definition 
1019 _topology_template_definition: &topology_template_definition
1020   type: map
1021   name: topology_template_definition
1022   mapping:
1023     description:
1024       desc: "a description of the topology template"
1025       required: no
1026       type: str
1027     inputs:
1028       desc: "definition of input parameters for the topology template"
1029       name: inputs
1030       required: no
1031       type: map
1032       mapping:
1033         =:
1034           *property_definition
1035     node_templates:
1036       desc: "definition of the node templates of the topology"
1037       name: node_templates
1038       required: no
1039       type: map
1040       mapping:
1041         =:
1042           *node_template_definition
1043     relationship_templates:
1044       desc: "definition of the relationship templates of the topology"
1045       required: no
1046       name: relationship_templates
1047       type: map
1048       mapping:
1049         =:
1050           *relationship_template_definition
1051     outputs:
1052       desc: "definition of output parameters for the topology template"
1053       name: outputs
1054       required: no
1055       type: map
1056       mapping:
1057         =:
1058           *attribute_assignment_definition
1059     groups:
1060       desc: "An optional list of Group definitions whose members are node templates defined within this same Topology Template"
1061       name: groups
1062       required: no
1063       type: map
1064       mapping:
1065         =:
1066           *group_definition
1067     policies:
1068  # see 8.2.3, initially the list is not described as sequenced but then the grammar shows it as such !?
1069       desc: "An optional sequenced?? list of Policy definitions for the Topology Template."
1070       name: policies
1071       required: no
1072       type: seq
1073       sequence:
1074         - type: map
1075           mapping:
1076             =:
1077               *policy_template_definition
1078     substitution_mappings:
1079 # one possible short-coming that is visible here is that the definition of the capability
1080 # and requirements mappings are given in the spec only with the short/inline version of a 
1081 # YAML list/sequence, which cannot be enforced here .. 
1082       desc: " a description of the topology template"
1083       name: substitution_mappings
1084       required: no
1085       type: map
1086       mapping:
1087         node_type:
1088           desc: "node type name"
1089           required: yes
1090           type: str
1091         capabilities:
1092           desc: "map_of_capability_mappings_to_expose"
1093           type: map
1094           mapping:
1095             =:
1096               type: seq
1097               sequence:
1098                 - type: str
1099         requirements:      
1100           desc: "map_of_requirement_mapping_to_expose"
1101           type: map
1102           mapping:
1103             =:
1104               type: seq
1105               sequence:
1106                 - type: str
1107
1108
1109 # see A.9 Service Template definition: A TOSCA Service Template (YAML) document contains
1110 # element definitions of building blocks for cloud application, or complete models of cloud applications. 
1111
1112 type: map
1113 name: service_template_definition
1114 mapping:
1115   tosca_definitions_version:
1116     desc: "Required TOSCA Definitions version string"
1117     required: yes
1118     type: str
1119     enum: [tosca_simple_yaml_1_0_0]
1120
1121   tosca_default_namespace:
1122     desc: "Optional. default namespace (for type schema)"
1123     required: no
1124     type: str
1125
1126   metadata:
1127     desc: "Optional metadata keyname: value pairs"
1128     name: metadata
1129     required: no
1130     type: map
1131     mapping:
1132       template_name:
1133         desc: "Optional name of this service template"
1134         required: no
1135         type: str
1136       template_author:
1137         desc: "Optional author of this service template"
1138         required: no
1139         type: str
1140       template_version:
1141         desc: "Optional version of this service template"
1142         required: no
1143         type: str
1144       =:
1145         desc: "User defined entry"
1146         required: no
1147         type: str
1148
1149 #to add, the spec says: "Optional list of domain or profile specific metadata keynames"
1150
1151   description:
1152     desc: "Optional description of the definitions inside the file"
1153     required: no
1154     type: str
1155
1156   imports:
1157     desc: "ordered list of import statements for importing other definitions files"
1158     name: imports
1159     required: no
1160     type: seq
1161     sequence:
1162       - type: map
1163         mapping:
1164           =:
1165             *import_definition
1166
1167   dsl_definitions:
1168     desc: "list of YAML alias anchors (or macros)"
1169     name: dsl_definitions
1170     required: no
1171     type: map
1172     mapping:
1173       =:
1174         desc: "some piece of valid yaml that makes the anchor/alias definition" 
1175         type: any
1176         required: no
1177
1178   repositories:
1179     desc: "list of external repository definitions which host TOSCA artifacts"
1180     name: repositories
1181     required: no
1182     type: map
1183     mapping:
1184       =:
1185         *repository_definition
1186
1187   data_types:
1188     desc: "list of TOSCA datatype definitions"
1189     name: data_types
1190     required: no
1191     type: map
1192     mapping:
1193       =:
1194         *data_type_definition
1195
1196   node_types:
1197     desc: "list of node type definitions"
1198     name: node_types
1199     required: no
1200     type: map
1201     mapping:
1202       =:
1203         *node_type_definition
1204
1205   capability_types:
1206     desc: "list of capability type definitions"
1207     name: capability_types
1208     required: no
1209     type: map
1210     mapping:
1211       =:
1212         *capability_type_definition
1213
1214   relationship_types:
1215     desc: "list of relationship type definitions"
1216     name: relationship_types
1217     required: no
1218     type: map
1219     mapping:
1220       =:
1221         *relationship_type_definition
1222
1223   artifact_types:
1224     desc: "list of artifact type definitions"
1225     name: artifact_types
1226     required: no
1227     type: map
1228     mapping:
1229       =:
1230         *artifact_type_definition
1231
1232   interface_types:
1233     desc: "list of interface type definitions"
1234     name: interface_types
1235     required: no
1236     type: map
1237     mapping:
1238       =:
1239         *interface_type_definition
1240
1241   group_types:
1242     desc: "list of group type definitions"
1243     name: group_types
1244     required: no
1245     type: map
1246     mapping:
1247       =:
1248         *group_type_definition
1249
1250   policy_types:
1251     desc: "list of policy type definitions"
1252     name: policy_types
1253     required: no
1254     type: map
1255     mapping:
1256       =:
1257         *policy_type_definition
1258
1259   topology_template:
1260     desc: "topology template definition of the cloud application or service"
1261     required: no
1262     <<: *topology_template_definition