Replaced all tabs with spaces in java and pom.xml
[so.git] / cloudify-client / src / main / java / org / onap / so / 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.onap.so.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 import com.fasterxml.jackson.annotation.JsonIgnore;
29 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
30 import com.fasterxml.jackson.annotation.JsonProperty;
31 import com.fasterxml.jackson.databind.ObjectMapper;
32
33 @JsonIgnoreProperties(ignoreUnknown = true)
34 // @JsonRootName("deployment")
35 public class Deployment implements Serializable {
36
37     private static final long serialVersionUID = 1L;
38
39     @JsonProperty("blueprint_id")
40     private String blueprintId;
41
42     @JsonProperty("created_at")
43     private Date createdAt;
44
45     @JsonProperty("created_by")
46     private String createdBy;
47
48     @JsonProperty("description")
49     private String description;
50
51     @JsonProperty("groups")
52     private Map<String, Group> groups = null;
53
54     @JsonProperty("id")
55     private String id;
56
57     @JsonProperty("inputs")
58     private Map<String, Object> inputs = null;
59
60     // TODO: Expand the definition of a PolicyTrigger
61     @JsonProperty("policy_triggers")
62     private List<Object> policyTriggers;
63
64     // TODO: Expand the definition of a PolicyType
65     @JsonProperty("policy_types")
66     private List<Object> policyTypes;
67
68     @JsonProperty("scaling_groups")
69     private Map<String, ScalingGroup> scalingGroups = null;
70
71     @JsonProperty("tenant_name")
72     private String tenantName;
73
74     @JsonProperty("updated_at")
75     private Date updatedAt;
76
77     @JsonProperty("workflows")
78     private List<Workflow> workflows;
79
80     public List<Object> getPolicyTriggers() {
81         return policyTriggers;
82     }
83
84     public void setPolicyTriggers(List<Object> policyTriggers) {
85         this.policyTriggers = policyTriggers;
86     }
87
88     public List<Object> getPolicyTypes() {
89         return policyTypes;
90     }
91
92     public void setPolicyTypes(List<Object> policyTypes) {
93         this.policyTypes = policyTypes;
94     }
95
96     public String getBlueprintId() {
97         return blueprintId;
98     }
99
100     public void setBlueprintId(String blueprintId) {
101         this.blueprintId = blueprintId;
102     }
103
104     public Date getCreatedAt() {
105         return createdAt;
106     }
107
108     public void setCreatedAt(Date createdAt) {
109         this.createdAt = createdAt;
110     }
111
112     public String getCreatedBy() {
113         return createdBy;
114     }
115
116     public void setCreatedBy(String createdBy) {
117         this.createdBy = createdBy;
118     }
119
120     public String getDescription() {
121         return description;
122     }
123
124     public void setDescription(String description) {
125         this.description = description;
126     }
127
128     public Map<String, Group> getGroups() {
129         return this.groups;
130     }
131
132     public void setGroups(Map<String, Group> groups) {
133         this.groups = groups;
134     }
135
136     public String getId() {
137         return id;
138     }
139
140     public void setId(String id) {
141         this.id = id;
142     }
143
144     public Map<String, Object> getInputs() {
145         return this.inputs;
146     }
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. Note that Blueprint class also contains a slightly different
297      * 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
313         public void setName(String name) {
314             this.name = name;
315         }
316
317         public Date getCreatedAt() {
318             return createdAt;
319         }
320
321         public void setCreatedAt(Date createdAt) {
322             this.createdAt = createdAt;
323         }
324
325         public Map<String, ParameterDefinition> getParameters() {
326             return parameters;
327         }
328
329         public void setParameters(Map<String, ParameterDefinition> parameters) {
330             this.parameters = parameters;
331         }
332     }
333
334     /*
335      * Return an output as a Json-mapped Object of the provided type. This is useful for json-object outputs.
336      */
337     public <T> T getMapValue(Map<String, Object> map, String key, Class<T> type) {
338
339         ObjectMapper mapper = new ObjectMapper();
340         if (map.containsKey(key)) {
341             try {
342                 String s = mapper.writeValueAsString(map.get(key));
343                 return (mapper.readValue(s, type));
344             } catch (IOException e) {
345                 return null;
346             }
347         }
348         return null;
349     }
350
351     @Override
352     public String toString() {
353         return "Deployment{" + "id='" + id + '\'' + ", description='" + description + '\'' + ", blueprintId='"
354                 + blueprintId + '\'' + ", createdBy='" + createdBy + '\'' + ", tenantName='" + tenantName + '\''
355                 + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + ", inputs='" + inputs + '\''
356                 + ", workflows=" + workflows + ", groups=" + groups + '}';
357     }
358
359 }