update SDC-TOSCA package names
[sdc/sdc-tosca.git] / src / main / java / org / onap / sdc / tosca / parser / api / ISdcCsarHelper.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdc-distribution-client
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * ============LICENSE_END=========================================================
18  */
19 package org.onap.sdc.tosca.parser.api;
20
21
22 import java.util.List;
23 import java.util.Map;
24
25 import org.apache.commons.lang3.tuple.Pair;
26 import org.onap.sdc.tosca.parser.impl.SdcTypes;
27 import org.onap.sdc.tosca.parser.impl.FilterType;
28 import org.onap.sdc.toscaparser.api.*;
29 import org.onap.sdc.toscaparser.api.elements.Metadata;
30 import org.onap.sdc.toscaparser.api.parameters.Input;
31
32
33 public interface ISdcCsarHelper {
34
35         /**
36          * Get all node templates by node_type for this CSAR service.
37          *  
38          * @param nodeType - the TOSCA type of the node.
39          * @return service node templates of this type.
40          */
41         public List<NodeTemplate> getServiceNodeTemplatesByType(String nodeType);
42
43         /**
44          * Get all node templates for this CSAR service.
45          *
46          * @return service node templates.
47          */
48         public List<NodeTemplate> getServiceNodeTemplates();
49
50         /**
51          * Get groups of a VF with type "org.onap.groups.VfModule".
52          * 
53          * @param vfCustomizationUuid - customizationUuid of VF instance.
54          * @return list of vfModule groups.
55          */
56         public List<Group> getVfModulesByVf(String vfCustomizationUuid);
57
58
59         /**
60          * Get any property leaf value for node template by full path separated by #.<br>
61          * For example, for node template with this property:<br><br>
62          *   network_assignments:<br>
63           &nbsp;&nbsp;ecomp_generated_network_assignment: true<br>
64           &nbsp;&nbsp;is_shared_network: false<br>
65           &nbsp;&nbsp;is_external_network: false<br>
66           &nbsp;&nbsp;ipv4_subnet_default_assignments:<br>
67             &nbsp;&nbsp;&nbsp;&nbsp;use_ipv4: true<br>
68             &nbsp;&nbsp;&nbsp;&nbsp;ip_network_address_plan: 1.2.3.4<br>
69             &nbsp;&nbsp;&nbsp;&nbsp;dhcp_enabled: true<br>
70             &nbsp;&nbsp;&nbsp;&nbsp;ip_version: 4<br>
71             &nbsp;&nbsp;&nbsp;&nbsp;cidr_mask: 24<br>
72             &nbsp;&nbsp;&nbsp;&nbsp;min_subnets_count: 1<br>
73           &nbsp;&nbsp;ipv6_subnet_default_assignments:<br>
74             &nbsp;&nbsp;&nbsp;&nbsp;use_ipv6: false<br><br>
75             
76          * calling<br> 
77          * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br> 
78          * will return "false".
79          * @param nodeTemplate - nodeTemplate where the property should be looked up.
80          * @param pathToPropertyLeafValue - the full path of the required property.
81          * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
82          */
83         public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
84
85         /**
86          * Get any property leaf value for node template by full path separated by #.<br>
87          * For example, for node template with this property:<br><br>
88          *   network_assignments:<br>
89          &nbsp;&nbsp;ecomp_generated_network_assignment: true<br>
90          &nbsp;&nbsp;is_shared_network: false<br>
91          &nbsp;&nbsp;is_external_network: false<br>
92          &nbsp;&nbsp;ipv4_subnet_default_assignments:<br>
93          &nbsp;&nbsp;&nbsp;&nbsp;use_ipv4: true<br>
94          &nbsp;&nbsp;&nbsp;&nbsp;ip_network_address_plan: 1.2.3.4<br>
95          &nbsp;&nbsp;&nbsp;&nbsp;dhcp_enabled: true<br>
96          &nbsp;&nbsp;&nbsp;&nbsp;ip_version: 4<br>
97          &nbsp;&nbsp;&nbsp;&nbsp;cidr_mask: 24<br>
98          &nbsp;&nbsp;&nbsp;&nbsp;min_subnets_count: 1<br>
99          &nbsp;&nbsp;ipv6_subnet_default_assignments:<br>
100          &nbsp;&nbsp;&nbsp;&nbsp;use_ipv6: false<br><br>
101
102          * calling<br>
103          * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
104          * will return "false".
105          * @param nodeTemplate - nodeTemplate where the property should be looked up.
106          * @param pathToPropertyLeafValue - the full path of the required property.
107          * @return the leaf value as Object, or null if there's no such property. It's up to the caller to cast it to a proper type.
108          */
109         public Object getNodeTemplatePropertyAsObject(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
110
111         /**
112          * Get any property leaf value for a group definition by full path separated by #.
113          * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
114          * @param group - group where the property should be looked up.
115          * @param propertyName - the name of the required property.
116          * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
117          */
118         public String getGroupPropertyLeafValue(Group group, String propertyName);
119
120         /**
121          * Get any property value for a group definition by full path separated by #.
122          * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
123          * @param group - group where the property should be looked up.
124          * @param propertyName - the name of the required property.
125          * @return the leaf value as Object, or null if there's no such property. It's up to the caller to cast it to a proper type.
126          */
127         public Object getGroupPropertyAsObject(Group group, String propertyName);
128
129         /**
130          * Get all VL node templates of the CSAR service.
131          * @return - all VL node templates.
132          */
133         public List<NodeTemplate> getServiceVlList();
134
135         /**
136          * Get all VF node templates of the CSAR service.
137          * @return - all VF node templates.
138          */
139         public List<NodeTemplate> getServiceVfList();
140
141
142         /**
143          * 
144          * Get a property from a metadata object.<br>
145          * This is just sugaring method, same as calling metadata.getMetadataPropertyValue(metadataPropertyName).<br>
146          * 
147          * For metadata object representing the below: <br><br>
148          * 
149          *  metadata:<br>
150         &nbsp;&nbsp;invariantUUID: 4598a404-00e1-42a6-8767-0bda343e2066<br>
151         &nbsp;&nbsp;UUID: e17940d6-42f8-4989-bad0-31de5addc619<br>
152         &nbsp;&nbsp;customizationUUID: 83d086b2-a861-4d3b-aa84-3bfbb9b2ec20<br>
153         &nbsp;&nbsp;version: '0.1'<br>
154         &nbsp;&nbsp;name: vIPR_ATM<br>
155         &nbsp;&nbsp;description: vIPR_ATM<br>
156         &nbsp;&nbsp;type: VF<br>
157         &nbsp;&nbsp;category: category1<br>
158         &nbsp;&nbsp;subcategory: subCategory1<br><br>
159         
160         calling<br> 
161         getMetadataPropertyValue(metadata,"invariantUUID")<br>
162         will return "4598a404-00e1-42a6-8767-0bda343e2066".
163         
164          * @param metadata - metadata object.
165          * @param metadataPropertyName - the name of the metadata property.
166          * @return metadata property value
167          */
168         public String getMetadataPropertyValue(Metadata metadata, String metadataPropertyName);
169         
170         
171         /**
172          * Get input leaf value for the CSAR service, by full path separated by #.<br>
173          * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
174          * The expected format is "input_name#default[optionally #rest_of_path]"
175          * @param inputLeafValuePath by full path separated by #.
176          * @return input leaf value for the service.
177          */
178         public String getServiceInputLeafValueOfDefault(String inputLeafValuePath);
179
180         /**
181          * Get input leaf value for the CSAR service, by full path separated by #.<br>
182          * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
183          * The expected format is "input_name#default[optionally #rest_of_path]"
184          * @param inputLeafValuePath by full path separated by #.
185          * @return input value for the service as Object. It's up to the caller to cast it to a proper type.
186          */
187         public Object getServiceInputLeafValueOfDefaultAsObject(String inputLeafValuePath);
188
189         /**
190          * Get the type name of the CSAR service's substitution mappings element.<br> 
191          * 
192          * For the below:<br><br>
193          * 
194          * substitution_mappings:<br>
195        &nbsp;&nbsp;type: org.onap.services.ViprATM<br>
196
197         calling<br> 
198         getServiceSubstitutionMappingsTypeName()<br>
199          will return "org.onap.services.ViprATM"
200          * @return - the type name of the CSAR service's substitution mappings element
201          */
202         public String getServiceSubstitutionMappingsTypeName();
203         
204         /**
205          * Get service Metadata object.<br>
206          * This object represents the "metadata" section of a CSAR service.
207          * @return - the service Metadata object.
208          */
209         public Metadata getServiceMetadata();
210
211         /**
212          * Get the CSAR service metadata as map.
213          * @return - the service metadata object as Map.
214          * @deprecated This function is deprecated since its not tosca compliant. <br>
215          * Tosca defines the Metadata section as map of string (not map of object).<br>
216          *  This function is targeted to be removed as part of 1802.<br>
217          * Please use {@link #getServiceMetadataAllProperties() getServiceMetadataAllProperties()}.
218          */
219         @Deprecated
220         public Map<String, Object> getServiceMetadataProperties();
221
222         /**
223          * Get the CSAR service metadata as map
224          * @return - the service metadata object as Map
225          */
226         public Map<String, String> getServiceMetadataAllProperties();
227
228         /**
229          * Get all VFC node templates from a specified VF.
230          * @param vfCustomizationId - customizationUuid of the VF node template.
231          * @return all VFC node templates from a specified VF
232          */
233         public List<NodeTemplate> getVfcListByVf(String vfCustomizationId);
234         
235         /**
236          * Get all CP node templates from a specified VF.
237          * @param vfCustomizationId - customizationUuid of the VF node template.
238          * @return all CP node templates from a specified VF
239          */
240         public List<NodeTemplate> getCpListByVf(String vfCustomizationId);
241         
242         /**
243          * Get all members of this group definition.<br>
244          * 
245          * For example, for this group definition:<br><br>
246          * 
247          *   ViprAtm..vIPR-ATM-Base..module-0:<br>   
248       &nbsp;&nbsp;type: org.onap.groups.VfModule<br>      
249       &nbsp;&nbsp;.................<br>
250       &nbsp;&nbsp;members: [vIPR_ATM_Ha_Two, vIPR_ATM_Ha_One, vIPR_ATM_OAM_SG, vIPR_ATM_HA_TWO_SG, vIPR_ATM_HA_ONE_SG]<br><br>
251       
252       calling<br> 
253       getMembersOfVfModule(NoteTemplate vfNodeTemplate, Group group)<br>
254       will return List of the following Node templates in the vfNodeTemplate: "vIPR_ATM_Ha_Two, vIPR_ATM_Ha_One, vIPR_ATM_OAM_SG, vIPR_ATM_HA_TWO_SG, vIPR_ATM_HA_ONE_SG"<br>
255          * @param vf - VF to return the node templates from.
256          * @param vfModule - group to return the members from.
257          * @return node templates from vf with the names as in members section.
258      * 
259          */
260         public List<NodeTemplate> getMembersOfVfModule(NodeTemplate vf, Group vfModule);
261         
262         
263         /**
264          * Get list of node template pairs, where for each pair,<br> 
265          * the left node template in pair has requirement with name reqName, <br>
266          * which should be satisfied with respective capability by the right node template in pair.<br>
267          * 
268          * For example, if we have the below two node templates in the vIPR VF:<br><br>
269          * 
270          * oam_extCP:<br>
271       &nbsp;&nbsp;type: org.onap.resources.cp.extCP<br> 
272       &nbsp;&nbsp;requirements:<br>
273         &nbsp;&nbsp;&nbsp;&nbsp;- virtualBinding: vipr_atm_firewall<br><br>
274          * 
275          * vipr_atm_firewall: <br>
276       &nbsp;&nbsp;type: org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
277       ........<br><br>
278          * 
279         
280      * calling<br>
281      * getNodeTemplatePairsByReqName(getCpListByVf(viprCustomUuid), getVfcListByVf(viprCustomUuid), "virtualBinding")<br>
282      * will return a list with one Pair - where left element of pair will be "oam_extCP" node template,<br>
283      * and right element will be "vipr_atm_firewall" node template.<br>
284      * 
285          * @param listOfReqNodeTemplates - list of node templates in which the "reqName" requirement should be looked.
286          * @param listOfCapNodeTemplates - list of node templates in which the capability matching the "reqName" requirement should be looked.
287          * @param reqName - the name of a requirement definition to match by.
288          * @return pairs of node templates according to described above.
289          */
290         public List<Pair<NodeTemplate,NodeTemplate>> getNodeTemplatePairsByReqName(List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName);
291         
292         /**
293          * Get all allotted node templates from this service.
294          * @return all allotted node templates from this service.
295          */
296         public List<NodeTemplate> getAllottedResources();
297         
298         /**
299          * Get node_type of a node template.<br>
300          * 
301          * For this node template:<br>
302          * 
303          * vipr_atm_firewall: <br>
304       &nbsp;&nbsp;type: org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
305       ........<br><br>
306      * 
307      * the function will return "org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm"
308      *  
309          * @param nodeTemplate - node template object
310          * @return - node type string.
311          */
312         public String getTypeOfNodeTemplate(NodeTemplate nodeTemplate);
313
314         /**
315          * Get the CSAR service inputs list.
316          * @return - the service inputs list.
317          */
318         public List<Input> getServiceInputs();
319
320         
321         /**
322          * Get the conformance level of this CSAR. <br>
323          * The conformance level value of the CSAR is located in csar.meta file at the top level of the CSAR file.<br>
324          * For 1707 CSARs, the conformance level is 3.0.
325          * @return the conformance level of the CSAR. 
326          */
327         public String getConformanceLevel();
328         
329         
330         /**
331          * Get the map of CP-related props from a VFC node template. <br>
332          * Let's say there are 5 CPs related to this VFC. Then the output will look like this: <br><br>
333          * {port_fe1_sigtran={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4, subnetpoolid="subnet_1", network_role_tag="SIGNET_vrf_B1_direct"},<br> 
334          *  port_fe_cluster={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
335          *  port_fe_slan={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br> 
336          *  port_fe_interce={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br> 
337          *  port_fe_oam={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4, subnetpoolid="subnet_2", network_role_tag="Mobility_OAM_protected"}}<br><br>
338          * @param vfc - VFC node template to look for CP-related props.
339          * @return map <b>CP node template name</b>  to a map of <b>full path to a property on this CP</b> - <b> value of this property on this CP</b>.
340          * @deprecated This function is deprecated since its flattened form doesn't provide solution for cp properties of type List.
341          * Will be removed in 1802.
342          */
343         @Deprecated 
344         public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc);
345         
346     /**
347     * Get the map of CP-related props from a VFC node template. <br>
348     * Let's say there are 2 CPs (ports) related to this VFC. Then the output will look like this: <br><br>
349     * {port_fe_sigtran={ip_requirements={ip_count_required: {count: 1}, dhcp_enabled: true, ip_version: 4}, subnetpoolid: "subnet_1", network_role_tag: "SIGNET_vrf_B1_direct"}<br>
350     *  port_fe_cluster={ip_requirements={ip_count_required: {count: 2}, dhcp_enabled: true, ip_version: 4}}<br>
351     * @param vfc - VFC node template to look for CP-related props.
352     * @return map <b>CP node template name</b>  to a map of <b>property name</b> - <b> property value as object</b>.
353     */
354     public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate vfc);
355         
356         /**
357          * Get customization UUID of a node template
358          * @param nt - node template
359          * @return customization UUID of a node template.
360          */
361         public String getNodeTemplateCustomizationUuid(NodeTemplate nt);
362
363     /**
364      * Filter Node Template property values by equals/contains operator and a pattern
365      * @param nodeTemplate Node Template to filter its properties
366      * @param filterType filter type - equals or contains
367      * @param pattern value to filter with it
368      * @return Map <b>full path to a property</b> mapped to <b>property value</b> filtered by type and pattern
369      */
370     public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate nodeTemplate, FilterType filterType, String pattern);
371     
372         /**
373          * Get all node templates by sdcType for parent Node Template.
374          *
375          * @param parentNodeTemplate - parent node template
376          * @param sdcType - the SDC type of the node.
377          * @return node templates of this SDC type.
378          */
379         public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType);
380
381         /**
382          * Get all node templates by SDC type enum for this CSAR service.
383          *
384          * @param sdcType - the SDC type of the node (for example, CP, VF...).
385          * @return service node templates of this SDC type.
386          */
387         public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType);
388         
389         /**
390          * Get all node templates  for this CSAR service.
391          * @param vfCustomizationUuid - the Customization UUID of the node.
392          * @return VNF Configuration Node Template.
393          */
394         public NodeTemplate getVnfConfig(String vfCustomizationUuid);
395
396         /**
397          * Check if Node Template has Topology Template
398          * @param nodeTemplate - Node Template to check
399          * @return true if node template has topology template, false if not.
400          */
401         public boolean hasTopology(NodeTemplate nodeTemplate);
402
403         /**
404          * Get children node templates for node template.
405          * @param nodeTemplate - Node Template to get its children
406          * @return return list of children node templates for node template.
407          */
408         public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate);
409
410         /**
411          * Get node template on service level by node template name.
412          * @param nodeName - the name of the node template.
413          * @return service-level node template with this name, or null if no such node template was found.
414          */
415         public NodeTemplate getServiceNodeTemplateByNodeName(String nodeName);
416
417         /**
418          * Get node template Metadata object.<br>
419          * This object represents the "metadata" section of node template.
420          * @param nt - Node template to get its Metadata object.
421          * @return Metadata for this node template, or null if not found.
422          */
423         public Metadata getNodeTemplateMetadata(NodeTemplate nt);
424
425         /**
426          * Get CapabilityAssignments object for this node template.<br>
427          * This should be an entry point function for working with capability assignments of node template.<br>
428          * This object allows filtering capability assignments objects.<br>
429          * @param nt - Node Template to get its capability assignments.
430          * @return CapabilitiesAssignments that contains list of capability assignments for the node template.<br>
431          * If none found, an empty list will be returned.
432          */
433         public CapabilityAssignments getCapabilitiesOf(NodeTemplate nt);
434
435         /**
436          * Get RequirementAssignments object for this node template.<br>
437          * This should be an entry point function for working with requirement assignments of node template.<br>
438          * This object allows filtering requirement assignments objects.<br>
439          * @param nt - Node Template to get its requirement assignments.
440          * @return RequirementAssignments that contains list of requirement assignments for the node template.
441          * If none found, an empty list will be returned.
442          */
443         public RequirementAssignments getRequirementsOf(NodeTemplate nt);
444
445         /**
446          * Get any property leaf value for capability by full path separated by #.
447          * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a capability assignment.
448          * @param capability - capability assignment where the property should be looked up.
449          * @param pathToPropertyLeafValue - the full path of the required property.
450          * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
451          */
452         public String getCapabilityPropertyLeafValue(CapabilityAssignment capability, String pathToPropertyLeafValue);
453
454 }