Merge "Reorder modifiers"
[so.git] / cloudify-client / src / main / java / org / openecomp / mso / cloudify / v3 / model / Deployment.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.mso.cloudify.v3.model;
22
23 import java.io.IOException;
24 import java.io.Serializable;
25 import java.util.Date;
26 import java.util.List;
27 import java.util.Map;
28
29 import com.fasterxml.jackson.annotation.JsonIgnore;
30 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
31 import com.fasterxml.jackson.annotation.JsonProperty;
32 import com.fasterxml.jackson.databind.ObjectMapper;
33
34 @JsonIgnoreProperties(ignoreUnknown = true)
35 //@JsonRootName("deployment")
36 public class Deployment implements Serializable {
37
38         private static final long serialVersionUID = 1L;
39         
40     @JsonProperty("blueprint_id")
41     private String blueprintId;
42
43     @JsonProperty("created_at")
44     private Date createdAt;
45
46     @JsonProperty("created_by")
47     private String createdBy;
48
49     @JsonProperty("description")
50     private String description;
51
52     @JsonProperty("groups")
53     private Map<String, Group> groups = null;
54     
55     @JsonProperty("id")
56     private String id;
57     
58     @JsonProperty("inputs")
59     private Map<String, Object> inputs = null;
60     
61     // TODO: Expand the definition of a PolicyTrigger
62     @JsonProperty("policy_triggers")
63     private List<Object> policyTriggers;
64
65     // TODO: Expand the definition of a PolicyType
66     @JsonProperty("policy_types")
67     private List<Object> policyTypes;
68
69     @JsonProperty("scaling_groups")
70     private Map<String, ScalingGroup> scalingGroups = null;
71     
72     @JsonProperty("tenant_name")
73     private String tenantName;
74
75     @JsonProperty("updated_at")
76     private Date updatedAt;
77
78     @JsonProperty("workflows")
79     private List<Workflow> workflows;
80
81     public List<Object> getPolicyTriggers() {
82         return policyTriggers;
83     }
84     
85     public void setPolicyTriggers(List<Object> policyTriggers) {
86         this.policyTriggers = policyTriggers;
87     }
88     
89     public List<Object> getPolicyTypes() {
90         return policyTypes;
91     }
92     
93     public void setPolicyTypes(List<Object> policyTypes) {
94         this.policyTypes = policyTypes;
95     }
96     
97     public String getBlueprintId() {
98         return blueprintId;
99     }
100
101     public void setBlueprintId(String blueprintId) {
102         this.blueprintId = blueprintId;
103     }
104    
105     public Date getCreatedAt() {
106         return createdAt;
107     }
108
109     public void setCreatedAt(Date createdAt) {
110         this.createdAt = createdAt;
111     }
112
113     public String getCreatedBy() {
114         return createdBy;
115     }
116
117     public void setCreatedBy(String createdBy) {
118         this.createdBy = createdBy;
119     }
120
121     public String getDescription() {
122         return description;
123     }
124
125     public void setDescription(String description) {
126         this.description = description;
127     }
128     
129     public Map<String, Group> getGroups() {
130         return this.groups;
131     }
132     
133     public void setGroups(Map<String, Group> groups) {
134         this.groups = groups;
135     }
136
137     public String getId() {
138         return id;
139     }
140
141     public void setId(String id) {
142         this.id = id;
143     }
144
145     public Map<String, Object> getInputs() {
146         return this.inputs;
147     }
148     public void setInputs(Map<String, Object> inputs) {
149         this.inputs = inputs;
150     }
151
152     public String getTenantName() {
153         return tenantName;
154     }
155
156     public void setTenantName(String tenantName) {
157         this.tenantName = tenantName;
158     }
159
160     public Map<String, ScalingGroup> getScalingGroups() {
161                 return scalingGroups;
162         }
163
164         public void setScalingGroups(Map<String, ScalingGroup> scalingGroups) {
165                 this.scalingGroups = scalingGroups;
166         }
167
168         public Date getUpdatedAt() {
169         return updatedAt;
170     }
171
172     public void setUpdatedAt(Date updatedAt) {
173         this.updatedAt = updatedAt;
174     }
175
176     public List<Workflow> getWorkflows() {
177         return workflows;
178     }
179
180     public void setWorkflows(List<Workflow> workflows) {
181         this.workflows = workflows;
182     }
183
184     /*
185      * Nested subclasses for Group definitions
186      */
187     public static final class Group {
188         @JsonProperty ("policies")
189         Object policies;
190         
191         @JsonProperty("members")
192         List<String> members;
193
194                 public Object getPolicies() {
195                         return policies;
196                 }
197
198                 public void setPolicies(Object policies) {
199                         this.policies = policies;
200                 }
201
202                 public List<String> getMembers() {
203                         return members;
204                 }
205
206                 public void setMembers(List<String> members) {
207                         this.members = members;
208                 }
209     }
210
211     /*
212      * Nested subclasses for Scaling Group definitions
213      */
214     public static final class ScalingGroup {
215         @JsonProperty ("properties")
216         ScalingGroupProperties properties;
217         
218         @JsonProperty("members")
219         List<String> members;
220
221                 public ScalingGroupProperties getProperties() {
222                         return properties;
223                 }
224
225                 public void setProperties(ScalingGroupProperties properties) {
226                         this.properties = properties;
227                 }
228
229                 public List<String> getMembers() {
230                         return members;
231                 }
232
233                 public void setMembers(List<String> members) {
234                         this.members = members;
235                 }
236     }
237
238     public static final class ScalingGroupProperties {
239         @JsonProperty("current_instances")
240         int currentInstances;
241         
242         @JsonProperty("default_instances")
243         int defaultInstances;
244         
245         @JsonProperty("max_instances")
246         int maxInstances;
247         
248         @JsonProperty("min_instances")
249         int minInstances;
250         
251         @JsonProperty("planned_instances")
252         int plannedInstances;
253
254                 public int getCurrentInstances() {
255                         return currentInstances;
256                 }
257
258                 public void setCurrentInstances(int currentInstances) {
259                         this.currentInstances = currentInstances;
260                 }
261
262                 public int getDefaultInstances() {
263                         return defaultInstances;
264                 }
265
266                 public void setDefaultInstances(int defaultInstances) {
267                         this.defaultInstances = defaultInstances;
268                 }
269
270                 public int getMaxInstances() {
271                         return maxInstances;
272                 }
273
274                 public void setMaxInstances(int maxInstances) {
275                         this.maxInstances = maxInstances;
276                 }
277
278                 public int getMinInstances() {
279                         return minInstances;
280                 }
281
282                 public void setMinInstances(int minInstances) {
283                         this.minInstances = minInstances;
284                 }
285
286                 public int getPlannedInstances() {
287                         return plannedInstances;
288                 }
289
290                 public void setPlannedInstances(int plannedInstances) {
291                         this.plannedInstances = plannedInstances;
292                 }
293     }
294     
295     /*
296      * Nested subclass for Deployment Workflow entities.
297      * Note that Blueprint class also contains a slightly different Workflow structure.
298      */
299     public static final class Workflow {
300         @JsonProperty("name")
301         private String name;
302         @JsonProperty("created_at")
303         private Date createdAt;
304         @JsonProperty("parameters")
305         private Map<String,ParameterDefinition> parameters;
306         
307         public Workflow() {}
308         
309                 public String getName() {
310                         return name;
311                 }
312                 public void setName(String name) {
313                         this.name = name;
314                 }
315                 public Date getCreatedAt() {
316                         return createdAt;
317                 }
318                 public void setCreatedAt(Date createdAt) {
319                         this.createdAt = createdAt;
320                 }
321                 public Map<String, ParameterDefinition> getParameters() {
322                         return parameters;
323                 }
324                 public void setParameters(Map<String, ParameterDefinition> parameters) {
325                         this.parameters = parameters;
326                 }
327     }
328     
329         /*
330          * Return an  output as a Json-mapped Object of the provided type.
331          * This is useful for json-object outputs.
332          */
333         public <T> T getMapValue (Map<String,Object> map, String key, Class<T> type)
334         {
335
336                 ObjectMapper mapper = new ObjectMapper();
337                 if (map.containsKey(key)) {
338                         try {
339                                 String s = mapper.writeValueAsString(map.get(key));
340                                 return (mapper.readValue(s, type));
341                         }
342                         catch (IOException e) {
343                                 return null;
344                         }
345                 }
346                 return null;
347         }
348
349         @Override
350     public String toString() {
351         return "Deployment{" +
352                 "id='" + id + '\'' +
353                 ", description='" + description + '\'' +
354                 ", blueprintId='" + blueprintId + '\'' +
355                 ", createdBy='" + createdBy + '\'' +
356                 ", tenantName='" + tenantName + '\'' +
357                 ", createdAt=" + createdAt +
358                 ", updatedAt=" + updatedAt +
359                 ", inputs='" + inputs + '\'' +
360                 ", workflows=" + workflows +
361                 ", groups=" + groups +
362                 '}';
363     }
364
365 }