summaryrefslogtreecommitdiffstats
path: root/dcaedt_catalog/db/src/main/resources/tosca-schema.yaml
blob: 5944e22e95aec698f9995ec114cdeef32ff09f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
_status_values: &status_values  
  enum:
    - supported
    - unsupported
    - experimental
    - deprecated

#I do not know that the lists and maps qualify as 'primitive' ..
_primitive_types: &primitive_types
  enum: [string,integer,float,boolean,timestamp,list,map,version,range,scalar-unit.size,scalar_unit.frequency,scalar_unit.time]

#needs custom validation as we have to make sure there are 2 elements and allow for the
#UNBOUNDED keyword as second element
_range_definition: &range_definition
  type: seq
  name: range_definition
  sequence:
    - type: scalar

#see A.5.2
#this is where the need of verifying the size of a collection (sequence/map) came from
#this is specified as a sequence where each entry is a map with one entry??
_constraints_sequence: &constraints_sequence
  name: constraints_sequence
#  short: "0"
  type: seq
  sequence:
    - type: map
#      length: 1
      mapping:
        equal:
          desc: "Constrains a property or parameter to a value equal to the value declared."
          type: any
          required: no
        greater_than:
          desc: "Constrains a property or parameter to a value greater than the value declared"
          type: scalar
          required: no
        greater_or_equal:
          desc: "Constrains a property or parameter to a value greater than or equal to the value declared."
          type: scalar
          required: no
        less_than:
          desc: "Constrains a property or parameter to a value less than the value declared"
          type: scalar
          required: no
        less_or_equal:
          desc: "Constrains a property or parameter to a value less than or equal to the value declared."
          type: scalar
          required: no
        in_range:
          desc: "Constrains a property or parameter to a value in range of (inclusive) the two values declared.
"
          type: seq
#          length: 2
          sequence:
            - type: scalar
          required: no
        valid_values:
          desc: "Constrains a property or parameter to a value that is in the list of declared values"
          type: seq
          sequence:
            - type: scalar
          required: no
        length:
          desc: "Constrains the property or parameter to a value of a given length."
          type: int
          required: no
        min_length:
          desc: "Constrains the property or parameter to a value to a minimum length"
          type: scalar
          required: no
        max_length:
          desc: "Constrains the property or parameter to a value to a maximum length"
          type: scalar
          required: no
        pattern:    
          desc: "Constrains the property or parameter to a value that is allowed by the provided regular expression."
          type: str
          required: no

# section A.5.3 property_filter_definition
# it is a constraints sequence that gets attached to a property ..
_property_filter_definition: &property_filter_definition
  name: property_filter_definition
  type: map
  mapping:
    =:
      *constraints_sequence

#section A.5.4 node_filter_definition
_node_filter_definition: &node_filter_definition
  type: map
  name: node_filter_definition
  mapping:
    properties:
      desc: "property names to constraints to be applied to those properties"
      required: no
      type: seq
      sequence:
         - *property_filter_definition
#        - type: map
#          mapping: 
#            =:
#              *constraints_sequence
    capabilities:
      desc: ""
      required: no
      type: seq
      sequence:
        - type: map
          name: node_filter_capabilities_sequence
          desc: "the key is a capability name or type"
          mapping:
            =: 
              name: node_filter_capabilities_entry
              type: map
              mapping:
                properties:
                  desc: "the capability properties and their constraints"
                  name: node_filter_capabilities_properties
                  type: seq        
                  sequence:
                    - type: map
                      name: node_filter_capabilities_property
                      mapping:
                        =: *constraints_sequence

#used in property and attribute definitions
_entry_schema_definition: &entry_schema_definition
  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"
  name: entry_schema_definition
  required: no
  type: map
  short: type
  mapping: 
    "type":
      desc: "collection element type"
      required: yes
      type: str
    description:
      required: no
      type: str
    constraints:
      *constraints_sequence

# see section A.5.5
_artifact_definition: &artifact_definition
  type: map
  name: artifact_definition
  short: implementation # assumes type can be inferred ..
  mapping:
    "type":
      desc: "The required artifact type for the artifact definition"
      required: yes
      type: str
    description:
      desc: "The optional description for the artifact definition"
      required: no
      type: str
    implementation:
      desc: "The optional URI string (relative or absolute) which can be used to locate the artifacts file.
"
      required: no
      type: str
    repository:
      desc: "The optional name of the repository definition which contains the location of the external repository that contains the artifact"
      required: no
      type: str
    deploy_path:    
      desc: "The file path the associated file would be deployed into within the target nodes container."
      required: no
      type: str

# see section A.5.6
_repository_definition: &repository_definition
  type: map
  name: repository_definition
  short: url
  mapping:
    description:
      desc: "The optional description for the repository.
"
      required: no
      type: str
    url:
      desc: "The required URL or network address used to access the repository"
      required: yes
      type: str
    credential:
      desc: "The optional Credential used to authorize access to the repository"
      required: no
      type: str

#see section A.5.7
_property_definition: &property_definition
  type: map
  name: property_definition
  mapping:
    "type":
      type: str
      required: yes
#not as easy, it can be an user defined data type
#      <<: *primitive_types
    description:
      type: str
      required: no
    constraints:
      desc: "The optional list of sequenced constraint clauses for the Data Type."
      required: no
      <<: *constraints_sequence
    default:
      type: any
      required: no
    "required":
      type: bool
      required: no
    status:
      type: str
      required: no
      <<: *status_values
    entry_schema:
      <<: *entry_schema_definition
#      desc: "used to declare the name of the Datatype definition for entries of set types such as the TOSCA list or map."
#      type: str
#      required: no

#see section A.5.8
#_property_assignment_definition: &property_assignment_definition

#see A.5.9
_attribute_definition: &attribute_definition
  type: map
  name: attribute_definition
  mapping:
    "type":
      type: str
      required: yes
#      <<: *primitive_types
    description:
      type: str
      required: no
    default:
      type: any
      required: no
    status:
      desc: "The optional status of the attribute relative to the specification or implementation"
      type: str
      required: no
      <<: *status_values
    entry_schema:
      <<: *entry_schema_definition

#see section A.5.10
#here again, we must support the short form which is the most common
_attribute_assignment_definition: &attribute_assignment_definition
  type: map
  name: attribute_assignment_definition
  mapping:
    description:
      desc: "The optional description of the attribute."
      required: no
      type: str
    value:
#actually 'value | value_expression'
      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"
      required: yes
      type: any


# see spec section A.5.11

# see spec section A.5.11.1: variant to be used in node or relationship type definitions 
_type_operation_definition: &type_operation_definition
  type: map
  name: type_operation_definition
  short: implementation
  mapping:
    description:
      desc: "The optional description string for the associated named operation."
      required: no
      type: str
    implementation:
      desc: "The optional implementation artifact name (e.g., a script file name within a TOSCA CSAR file)"
      required: no
      type: str
    inputs:
      desc: ""
      required: no
      type: map
      mapping:
        =:
          desc: "a property value or an expression providing a input value"
          name: property_assignment
          type: any

# from A.5.11.2
_template_operation_definition: &template_operation_definition
  type: map
  name: template_operation_definition
  short: implementation
  mapping:
    description:
      desc: "The optional description string for the associated named operation."
      required: no
      type: str
    implementation:
      desc: "The optional implementation artifact name (e.g., a script file name within a TOSCA CSAR file)"
      name: template_operation_implementation_definition
      required: no
      short: primary
      type: map
      mapping:
        primary:
          desc: "The optional implementation artifact name (e.g., the primary script file name within a TOSCA CSAR file). "
          required: no
          type: str
        dependencies:
          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)"
          required: no
          type: seq
          sequence: 
            - type: str
    inputs:
      desc: ""
      required: no
      type: map
      mapping:
        =:
          desc: "a property value or an expression providing a input value"
          name: property_assignment
          type: any


# see section A.5.12, specifically A.5.12.2.1 : definition to be used in node or relationship type definition
_type_interface_definition: &type_interface_definition
  type: map
  name: type_interface_definition
  mapping:
    "type":
      desc: "represents the required name of the Interface Type for the interface definition
"
      required: yes
      type: str
    inputs:
      desc: "The optional list of input property definitions available to all defined operations"
      type: map
      mapping:
        =:
          *property_definition
    =:
      *type_operation_definition

# see section A.5.12.2.2, extended notation to be used in node or relationship template definitions
_template_interface_definition: &template_interface_definition
  type: map
  name: template_interface_definition
  mapping:
    inputs:
      desc: "The optional list of input property definitions available to all defined operations"
      type: map
      mapping:
        =:
          desc: "a property value or an expression providing a property value"
          name: property_assignment
          type: any
    =:
      *template_operation_definition


# A.6 section: type specific definitions

# see section A.6.1
_capability_definition: &capability_definition
  type: map
  name: capability_definition
  short: type
  mapping:
    "type":
      desc: "The required name of the Capability Type the capability definition is based upon"
      required: yes
      type: str
    description:
      desc: "The optional description of the Capability definition"
      required: no
      type: str
    properties:
      desc: ""
      required: no
      type: map
      mapping:
       =:
          *property_definition
    attributes:
      desc: "An optional list of property definitions for the Capability definition"
      required: no
      type: map
      mapping:
        =:
          *attribute_definition
    valid_source_types:
      desc: ""
      required: no
      type: seq
      sequence:
        - type: str
    occurrences:
      desc: "The optional minimum and maximum occurrences for the capability."
      required: no
      <<: *range_definition

# see section A.6.2
#
_requirement_definition: &requirement_definition
  type: map
  name: requirement_definition
  short: capability  #as per A.6.2.2.1
  mapping:
    capability:
      desc: "The required reserved keyname used that can be used to provide the name of a valid Capability Type that can fulfil the requirement"
      required: yes
      type: str
    node:
      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. "
      required: no
      type: str
    relationship:
# and from section A.6.2.1, this one is an oddball
      desc: "The optional reserved keyname used to provide the name of a valid Relationship Type to construct when fulfilling the requirement."
      required: no
      name: requirement_relationship_definition
      short: type
      type: map
      mapping:
        type:
          desc: "The optional reserved keyname used to provide the name of the Relationship Type for the requirement definitions relationship keyname.
"
          required: yes
          type: str
        interfaces:
          #not clear which interface definition is to be used here
          desc: "allows augmentation (additional properties and operations) of the interfaces defined by the relationship type indicated above"
          required: no
          type: map
          mapping:
            =:
              *type_interface_definition
    occurrences:
      desc: "The optional minimum and maximum occurrences for the requirement."
      required: no
      <<: *range_definition

# see section A.6.3
_artifact_type_definition: &artifact_type_definition
  type: map
  name: artifact_type_definition
  mapping:
    derived_from:
      desc: "An optional parent Artifact Type name the Artifact Type derives from"
      required: no
      type: str
    description:
      desc: "An optional description for the Artifact Type."
      required: no
      type: str
    mime_type:
      desc: "The required mime type property for the Artifact Type."
      required: no
      type: str
    file_ext:
      desc: "The required file extension property for the Artifact Type"
      required: no
      type: seq
      sequence:
        - type: str
    properties:
      desc: "An optional list of property definitions for the Artifact Type"
      required: no
      type: map
      mapping:
        =:
          *property_definition

#see spec section #A.6.4
_interface_type_definition: &interface_type_definition
  type: map
  name: interface_type_definition
  mapping:
    inputs:
      desc: "The optional list of input property definitions available to all defined operations"
      type: map
      mapping:
        =:
          type: str
          desc: "property_name to property_value(_expression) mapping"
    =:
      *type_operation_definition

# A.6.5
_data_type_definition: &data_type_definition
  type: map
  name: data_type_definition
  mapping:
    derived_from:
      desc: "The optional key used when a datatype is derived from an existing TOSCA Data Type.
"
      required: no
      type: str
    description:
      desc: "The optional description for the Data Type.
"
      required: no
      type: str
    constraints:
      desc: "The optional list of sequenced constraint clauses for the Data Type."
      <<: *constraints_sequence
    properties:
      desc: "The optional list property definitions that comprise the schema for a complex Data Type in TOSCA"
      type: map
      mapping:
        =:
          *property_definition

# see section A.6.6
_capability_type_definition: &capability_type_definition
  type: map
  name: capability_type_definition
  mapping:
    derived_from:
      desc: "An optional parent capability type name this new Capability Type derives from."
      required: no
      type: str
    description:
      desc: "An optional description for the Capability Type"
      required: no
      type: str
    properties:
      desc: "An optional list of property definitions for the Capability Type."
      required: no
      type: map
      mapping:
        =:
          *property_definition
    attributes:
      desc: "An optional list of attribute definitions for the Capability Type"
      required: no
      type: map
      mapping:
        =:
          *attribute_definition
    valid_source_types:
      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"
      required: no
      type: seq
      sequence:
        - type: str

# section A.6.7 requirement definition: TOSCA YAML profile relies on capability types to 
# define requirements 

# see section A.6.9
_relationship_type_definition: &relationship_type_definition
  type: map
  name: relationship_type_definition
  mapping:
    derived_from:
      desc: "An optional parent Relationship Type name the Relationship Type derives from"
      required: no
      type: str
    description:
      desc: "An optional description for the Relationship Type."
      required: no
      type: str
    properties:
      desc: "An optional list of property definitions for the Relationship Type"
      required: no
      type: map
      mapping:
        =:
          *property_definition
    attributes:
      desc: "An optional list of attribute definitions for the Relationship Type"
      required: no
      type: map
      mapping:
        =:
          *attribute_definition
    interfaces:
      desc: "An optional list of interface definitions interfaces supported by the Relationship Type"
      required: no
      type: map
      mapping:
        =:
          *type_interface_definition
    valid_target_types:
      desc: "An optional list of one or more names of Capability Types that are valid targets for this relationship. "
      required: no
      type: seq
      sequence:
        - type: str

#see section 3.6.10
_group_type_definition: &group_type_definition
  type: map
  name: group_type_definition
  mapping:
    derived_from:
      desc: "An optional parent Group Type name this new Group Type derives from"
      required: no
      type: str
    version:
      desc: "An optional version for the Group Type definition"
      required: no
      type: str
    description:
      desc: "An optional description for the Group Type"
      required: no
      type: str
    properties:
      desc: "An optional list of property definitions for the Group Type."
      required: no
      type: map
      mapping:
        =:
          *property_definition
    targets:
      desc: "An optional list of one or more names of Node Types that are valid
(allowed) as members of the Group Type."
      required: no
      type: seq
      sequence:
        - type: str
    interfaces:
      desc: "An optional list of interface definitions supported by the Group Type"
      required: no
      type: map
      mapping:
        =:
          *type_interface_definition

#see section 3.6.11
_policy_type_definition: &policy_type_definition
  type: map
  name: policy_type_definition
  mapping:
    derived_from:
      desc: "An optional parent Policy Type name this new Policy Type derives from"
      required: no
      type: str
    version:
      desc: "An optional version for the Policy Type definition"
      required: no
      type: str
    description:
      desc: "An optional description for the Policy Type"
      required: no
      type: str
    properties:
      desc: "An optional list of property definitions for the Policy Type."
      required: no
      type: map
      mapping:
        =:
          *property_definition
    targets:
      desc: "An optional list of valid Node Types or Group Types the Policy Type
can be applied to"
      required: no
      type: seq
      sequence:
        - type: str

# see section A.6.8
_node_type_definition: &node_type_definition
  type: map
  name: node_type_definition
  mapping:
    derived_from:
      desc: "An optional parent Node Type name this new Node Type derives from"
      required: no
      type: str
    description:
      desc: "An optional description for the Node Type"
      required: no
      type: str
    properties:
      desc: "An optional list of property definitions for the Node Type."
      required: no
      type: map
      mapping:
        =:
          *property_definition
    attributes:
      desc: "An optional list of attribute definitions for the Node Type.
"
      required: no
      type: map
      mapping:
        =:
          *attribute_definition
    requirements:
      desc: "An optional sequenced list of requirement definitions for the Node Type.
"
      required: no
      type: seq
      sequence:
        - type: map
          mapping:
            =:
              *requirement_definition
    capabilities:
      desc: "An optional list of capability definitions for the Node Type"
      required: no
      type: map
      mapping:
        =:
          *capability_definition
    interfaces:
      desc: ""
      required: no
      type: map
      mapping:
        =:
          *type_interface_definition
    artifacts:
      desc: "An optional list of named artifact definitions for the Node Type"
      required: no
      type: map
      mapping:
        =:
          *artifact_definition

# A.7 Template specific definitions

# see section A.7.1
_capability_assignment_definition: &capability_assignment_definition
  type: map
  name: capability_assignment_definition
  mapping:
    properties:
      # list of property assignments
      desc: "An optional list of property definitions for the Capability definition"
      required: no
      type: map
      mapping:
        =:
          desc: "a property value or an expression providing a property value"
          name: property_assignment
          type: any
    attributes:
      # list of attribute assignments
      desc: "An optional list of attribute definitions for the Capability definition"
      required: no
      type: map
      mapping:
        =:
          desc: ""
          name: attribute_assignment
          type: any

# see section A.7.2
_requirement_assignment_definition: &requirement_assignment_definition
  type: map
  name: requirement_assignment_definition
  short: node
  mapping:
    capability:
      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."
      required: no
      type: str
    node:
#why is this a reference to a node type and not to a node template??
      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"
      required: no
      type: str
    relationship:
      desc: ""
      required: no
#fins a better name      name: relationship_definition
      type: map
      short: type
      mapping:
        "type":
          desc: "The optional reserved keyname used to provide the name of the Relationship Type for the requirement assignments relationship keyname"
          required: no
          type: str
        properties:
          desc: ""
          required: no
          type: map
          mapping:
            =:
              desc: "a property value or an expression providing a property value"
              name: property_assignment
              type: any
        interfaces:
          desc: "from A.5.12.2.2, right?"
          required: no
          type: map
          mapping:
            =:
              *template_interface_definition
    node_filter:
      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."
      required: no
      <<: *node_filter_definition

# see section A.7.3
_node_template_definition: &node_template_definition
  type: map
  name: node_template_definition
  mapping:
    "type":
      desc: "The required name of the Node Type the Node Template is based upon"
      required: yes
      type: str
    description:
      desc: "An optional description for the Node Template"
      required: no
      type: str
    directives:
      desc: "An optional list of directive values to provide processing instructions to orchestrators and tooling."
      required: no
      type: seq
      sequence:
        - type: str
    properties:
#custom check needs to be added: the value or expression providing the property value
#needs to be compatible with the property definition
      desc: "An optional list of property value assignments for the Node Template."
      required: no
      type: map
      mapping:
        =:
          type: any
          name: property_assignment
          desc: "a property value or an expression providing a property value"
    attributes:
      desc: "An optional list of attribute value assignments for the Node Template"
      required: no
      type: map
      mapping:
        =:
          *attribute_assignment_definition
    requirements:
      desc: "An optional sequenced list of requirement assignments for the Node Template."
      required: no
      type: seq
      sequence:
        - type: map
          mapping:
            =:
              *requirement_assignment_definition
    capabilities:
      desc: "An optional list of capability assignments for the Node Template."
      required: no
      type: map
      mapping:
        =:
          *capability_assignment_definition
    interfaces:
      desc: "An optional list of named interface definitions for the Node Template"
      required: no
      type: map
      mapping:
        =:
          *template_interface_definition
    artifacts:
      desc: "An optional list of named artifact definitions for the Node Template.
"
      required: no
      type: map
      mapping:
        =:
          *artifact_definition
    node_filter:
      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."
      required: no
      <<: *node_filter_definition 
    copy:
      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."
      required: no
      type: str

# see section A.7.4
_relationship_template_definition: &relationship_template_definition
  type: map
  name: relationship_template_definition
  mapping:
    "type":
      desc: "The required name of the Relationship Type the Relationship Template is based upon"
      required: yes
      type: str
    alias:
      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)."
      required: no
      type: str
    description:
      desc: "An optional description for the Relationship Template"
      required: no
      type: str
    properties:
      desc: "An optional list of property assignments for the Relationship Template."
      required: no
      name: properties_assignment_validation
      type: map
      mapping:
        =:
          type: any
#scalar
          desc: "an expression providing a property value"
    attributes:
      desc: "An optional list of attribute value assignments for the Relationship Template"
      required: no
      name: attributes_assignment_validation
      type: map
      mapping:
        =: 
          type: scalar
          desc: "an expression providing an attribute value"
    interfaces:
      desc: "An optional list of named interface definitions for the Relationship Template ('augmentation' is allowed here)"
      required: no
      type: map
      mapping:
        =:
          *template_interface_definition
    copy:
      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."
      required: no
      type: str


# see section 3.7.5
_group_definition: &group_definition
  type: map
  name: group_definition
  mapping:
    "type":
      desc: "The required name of the group type the group definition is based upon"
      required: yes
      type: str
    description:
      desc: "The optional description for the group definition"
      required: no
    properties:
      desc: " represents the optional list of property assignments for the group definition that provide values for properties defined in its declared Group Type"
      required: no
      type: map
      mapping:
        =:
          type: any
          name: property_assignment
    targets:
      desc: "contains the required list of one or more node template names (within the same topology template) that are members of this logical group"
      required: yes
      type: seq
      sequence:
        - type: str
    interfaces:
      desc: "represents the optional list of interface definitions for the group definition that augment those provided by its declared Group Type"
      required: no
      type: map
      mapping:
        =:
          *template_interface_definition

# see section 3.7.6
_policy_template_definition: &policy_template_definition
  type: map
  name: policy_definition
  mapping:
    "type":
      desc: "The required name of the policy type the policy definition is based upon"
      required: yes
      type: str
    description:
      desc: "The optional description for the policy definition"
      required: no
    properties:
      desc: "represents the optional list of property assignments for the policy definition that provide values for properties defined in its declared Policy Type"
      required: no
      type: map
      mapping:
        =:
          type: any
          name: property_assignment
    targets:
      desc: "represents the optional list of names of node templates or groups that the policy is to applied to"
      required: no
      type: seq
      sequence:
        - type: str

# see section 3.8 Topology Template definition:  defines the topology template of a cloud application.
# described as a a reusable grammar as it can be a part of a service template definition 
_topology_template_definition: &topology_template_definition
  type: map
  name: topology_template_definition
  mapping:
    description:
      desc: "a description of the topology template"
      required: no
      type: str
    inputs:
      desc: "definition of input parameters for the topology template"
      name: inputs
      required: no
      type: map
      mapping:
        =:
          *property_definition
    node_templates:
      desc: "definition of the node templates of the topology"
      name: node_templates
      required: no
      type: map
      mapping:
        =:
          *node_template_definition
    relationship_templates:
      desc: "definition of the relationship templates of the topology"
      required: no
      name: relationship_templates
      type: map
      mapping:
        =:
          *relationship_template_definition
    outputs:
      desc: "definition of output parameters for the topology template"
      name: outputs
      required: no
      type: map
      mapping:
        =:
          *attribute_assignment_definition
    groups:
      desc: "An optional list of Group definitions whose members are node templates defined within this same Topology Template"
      name: groups
      required: no
      type: map
      mapping:
        =:
          *group_definition
    policies:
 # see 8.2.3, initially the list is not described as sequenced but then the grammar shows it as such !?
      desc: "An optional sequenced?? list of Policy definitions for the Topology Template."
      name: policies
      required: no
      type: seq
      sequence:
        - type: map
          mapping:
            =:
              *policy_template_definition
    substitution_mappings:
# one possible short-coming that is visible here is that the definition of the capability
# and requirements mappings are given in the spec only with the short/inline version of a 
# YAML list/sequence, which cannot be enforced here .. 
      desc: " a description of the topology template"
      name: substitution_mappings
      required: no
      type: map
      mapping:
        node_type:
          desc: "node type name"
          required: yes
          type: str
        capabilities:
          desc: "map_of_capability_mappings_to_expose"
          type: map
          mapping:
            =:
              type: seq
              sequence:
                - type: str
        requirements:      
          desc: "map_of_requirement_mapping_to_expose"
          type: map
          mapping:
            =:
              type: seq
              sequence:
                - type: str


# see A.9 Service Template definition: A TOSCA Service Template (YAML) document contains
# element definitions of building blocks for cloud application, or complete models of cloud applications. 

type: map
name: service_template_definition
mapping:
  tosca_definitions_version:
    desc: "Required TOSCA Definitions version string"
    required: yes
    type: str

  tosca_default_namespace:
    desc: "Optional. default namespace (for type schema)"
    required: no
    type: str

  metadata:
    desc: "Optional metadata keyname: value pairs"
    name: metadata
    required: no
    type: map
    mapping:
      template_name:
        desc: "Optional name of this service template"
        required: no
        type: str
      template_author:
        desc: "Optional author of this service template"
        required: no
        type: str
      template_version:
        desc: "Optional version of this service template"
        required: no
        type: str
#to add, the spec says: "Optional list of domain or profile specific metadata keynames"

  description:
    desc: "Optional description of the definitions inside the file"
    required: no
    type: str

  imports:
    desc: "list of import statements for importing other definitions files"
    name: imports
    required: no
    type: seq
    sequence:
      - type: str

  dsl_definitions:
    desc: "list of YAML alias anchors (or macros)"
    name: dsl_definitions
    required: no
    type: map
    mapping:
      =:
        desc: "some piece of valid yaml that makes the anchor/alias definition" 
        type: any
        required: no

  repositories:
    desc: "list of external repository definitions which host TOSCA artifacts"
    name: repositories
    required: no
    type: map
    mapping:
      =:
        *repository_definition

  data_types:
    desc: "list of TOSCA datatype definitions"
    name: data_types
    required: no
    type: map
    mapping:
      =:
        *data_type_definition

  node_types:
    desc: "list of node type definitions"
    name: node_types
    required: no
    type: map
    mapping:
      =:
        *node_type_definition

  capability_types:
    desc: "list of capability type definitions"
    name: capability_types
    required: no
    type: map
    mapping:
      =:
        *capability_type_definition

  relationship_types:
    desc: "list of relationship type definitions"
    name: relationship_types
    required: no
    type: map
    mapping:
      =:
        *relationship_type_definition

  artifact_types:
    desc: "list of artifact type definitions"
    name: artifact_types
    required: no
    type: map
    mapping:
      =:
        *artifact_type_definition

  interface_types:
    desc: "list of interface type definitions"
    name: interface_types
    required: no
    type: map
    mapping:
      =:
        *interface_type_definition

  group_types:
    desc: "list of group type definitions"
    name: group_types
    required: no
    type: map
    mapping:
      =:
        *group_type_definition

  policy_types:
    desc: "list of policy type definitions"
    name: policy_types
    required: no
    type: map
    mapping:
      =:
        *policy_type_definition

  topology_template:
    desc: "topology template definition of the cloud application or service"
    required: no
    <<: *topology_template_definition