3d87ab20d106020676a6995bef2950988dea89ea
[vfc/nfvo/catalog.git] /
1 /**
2  * Copyright 2016 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.openo.commontosca.catalog.model.parser.yaml.aria.entity;
17
18 import java.util.HashMap;
19 import java.util.Map;
20 import java.util.Map.Entry;
21
22 import lombok.AllArgsConstructor;
23 import lombok.Data;
24 import lombok.NoArgsConstructor;
25
26 @Data
27 @NoArgsConstructor
28 @AllArgsConstructor
29 public class AriaParserResult {
30   private String description;
31   private Map<String, String> metadata;
32   private Node[] nodes;
33   private Group[] groups;
34   private Policy[] policies;
35   private Substitution substitution;
36   private Map<String, Input> inputs;
37   private Map<String, Output> outpus;
38   
39   
40   @Data
41   public class Node {
42     private String id;
43     private String type_name;
44     private String template_name;
45     private Map<String, Property> properties;
46     private Interface[] interfaces;
47     private Artifact[] artifacts;
48     private Capability[] capabilities;
49     private Relationship[] relationships;
50     
51     @Data
52     public class Artifact {
53       private String name;
54       private String type_name;
55       private String source_path;
56       private String target_path;
57       private String repository_url;
58       private Credential repository_credential;
59       private Map<String, Property> properties;
60       
61       @Data
62       public class Credential {
63         private String protocol;
64         private String token_type;
65         private Map<String, String> keys;
66         private String user;
67       }
68     }
69     
70     @Data
71     public class Capability {
72       private String name;
73       private String type_name;
74       private Map<String, Property> properties;
75     }
76
77     @Data
78     public class Relationship {
79       private String target_node_id;
80       private String target_capability_name;
81       private String type_name;
82       private String template_name;
83       private Map<String, Property> properties;
84       private Interface[] source_interfaces;
85       private Interface[] target_interfaces;
86     }
87
88     /**
89      * @return
90      */
91     public Map<String, Object> getPropertyAssignments() {
92       if (this.properties == null || this.properties.isEmpty()) {
93         return new HashMap<String, Object>();
94       }
95       
96       Map<String, Object> ret = new HashMap<String, Object>();
97       for (Entry<String, Property> e : this.properties.entrySet()) {
98         ret.put(e.getKey(), e.getValue().getValue());
99       }
100
101       return ret;
102     }
103   }
104   
105   @Data
106   public class Group {
107     private String id;
108     private String type_name;
109     private String template_name;
110     private Map<String, Property> properties;
111     private Interface[] interfaces;
112     private GroupPolicy[] policies;
113     private String[] member_node_ids;
114     
115     @Data
116     public class GroupPolicy {
117       private String id;
118       private String type_name;
119       private Map<String, Property> properties;
120       private Trigger[] triggers;
121       
122       @Data
123       public class Trigger {
124         private String name;
125         private String implementation;
126         private Map<String, Property> properties;
127       }
128     }
129     
130   }
131
132   
133   @Data
134   public class Policy {
135     private String name;
136     private String type_name;
137     private Map<String, Property> properties;
138     private String[] target_node_ids;
139     private String[] target_group_ids;
140   }
141   
142   @Data
143   public class Substitution {
144     private String node_type_name;
145     private Mapping[] requirement;
146     private Mapping[] capabilities;
147     
148     @Data
149     public class Mapping {
150       private String mapped_name;
151       private String node_id;
152       private String name;
153       
154     }
155   }
156
157   @Data
158   public class Input {
159     private String type_name;
160     private Object value;
161     private String description;
162   }
163   
164   @Data
165   public class Output {
166     private String type_name;
167     private Object value;
168     private String description;
169   }
170 }
171
172
173 @Data
174 class Property {
175   private String type_name;
176   private Object value;
177   private String description;
178 }
179
180 @Data
181 class Interface {
182   private String name;
183   private String type_name;
184   private Map<String, Property> inputs;
185   private Operation[] operation;
186   
187   @Data
188   class Operation {
189     private String name;
190     private String implementation;
191     private String[] dependencies;
192     private String executor;
193     private int max_retries;
194     private int retry_interval;
195     private Map<String, Property> inputs;
196   }
197 }
198