ffd412f38f4abd68718df03a15cd2e47e387f269
[sdc.git] / catalog-be / src / main / resources / scripts / sdcBePy / tosca / models / normativeElementsList.py
1 from os import path
2 from sdcBePy.tosca.models.normativeElementCandidate import NormativeElementCandidate
3
4 def get_normative_element_candidate_list(base_file_location):
5     return [
6         get_data(base_file_location),
7         get_capability(base_file_location),
8         get_relationship(base_file_location),
9         get_interface_lifecycle(base_file_location),
10         get_categories(base_file_location)
11     ]
12
13 def get_normative_element_with_metadata_list(base_file_location):
14     return [
15         get_group(base_file_location),
16         get_policy(base_file_location)
17     ]
18
19 def get_normative_candidate(base_file_location, url, filename, zip_name, with_metadata=False):
20     if path.isdir(base_file_location):
21         return NormativeElementCandidate(base_file_location, url, filename, zip_name, with_metadata=with_metadata)
22
23 def get_data(base_file_location="/"):
24     return get_normative_candidate(base_file_location + "data-types/",
25                                      "/sdc2/rest/v1/catalog/uploadType/datatypes",
26                                      "dataTypes",
27                                      "dataTypesZip")
28
29
30 def get_capability(base_file_location="/"):
31     return get_normative_candidate(base_file_location + "capability-types/",
32                                      "/sdc2/rest/v1/catalog/uploadType/capability",
33                                      "capabilityTypes",
34                                      "capabilityTypeZip")
35
36
37 def get_relationship(base_file_location="/"):
38     return get_normative_candidate(base_file_location + "relationship-types/",
39                                      "/sdc2/rest/v1/catalog/uploadType/relationship",
40                                      "relationshipTypes",
41                                      "relationshipTypeZip")
42
43
44 def get_interface_lifecycle(base_file_location="../../../import/tosca/"):
45     return get_normative_candidate(base_file_location + "interface-lifecycle-types/",
46                                      "/sdc2/rest/v1/catalog/uploadType/interfaceLifecycle",
47                                      "interfaceLifecycleTypes",
48                                      "interfaceLifecycleTypeZip")
49
50
51 def get_categories(base_file_location="/"):
52     return get_normative_candidate(base_file_location + "categories/",
53                                      "/sdc2/rest/v1/catalog/uploadType/categories",
54                                      "categoryTypes",
55                                      "categoriesZip")
56
57
58 def get_group(base_file_location="/"):
59     return get_normative_candidate(base_file_location + "group-types/",
60                                      "/sdc2/rest/v1/catalog/uploadType/grouptypes",
61                                      "groupTypes",
62                                      "groupTypesZip",
63                                      with_metadata=True)
64
65
66 def get_policy(base_file_location="/"):
67     return get_normative_candidate(base_file_location + "policy-types/",
68                                      "/sdc2/rest/v1/catalog/uploadType/policytypes",
69                                      "policyTypes",
70                                      "policyTypesZip",
71                                      with_metadata=True)
72
73
74 def get_annotation(base_file_location="/"):
75     return get_normative_candidate(base_file_location + "annotation-types/",
76                                      "/sdc2/rest/v1/catalog/uploadType/annotationtypes",
77                                      "annotationTypes",
78                                      "annotationTypesZip")