2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.mso.cloudify.v3.model;
23 import java.io.IOException;
24 import java.io.Serializable;
25 import java.util.Date;
26 import java.util.List;
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;
34 @JsonIgnoreProperties(ignoreUnknown = true)
35 //@JsonRootName("deployment")
36 public class Deployment implements Serializable {
38 private static final long serialVersionUID = 1L;
40 @JsonProperty("blueprint_id")
41 private String blueprintId;
43 @JsonProperty("created_at")
44 private Date createdAt;
46 @JsonProperty("created_by")
47 private String createdBy;
49 @JsonProperty("description")
50 private String description;
52 @JsonProperty("groups")
53 private Map<String, Group> groups = null;
58 @JsonProperty("inputs")
59 private Map<String, Object> inputs = null;
61 // TODO: Expand the definition of a PolicyTrigger
62 @JsonProperty("policy_triggers")
63 private List<Object> policyTriggers;
65 // TODO: Expand the definition of a PolicyType
66 @JsonProperty("policy_types")
67 private List<Object> policyTypes;
69 @JsonProperty("scaling_groups")
70 private Map<String, ScalingGroup> scalingGroups = null;
72 @JsonProperty("tenant_name")
73 private String tenantName;
75 @JsonProperty("updated_at")
76 private Date updatedAt;
78 @JsonProperty("workflows")
79 private List<Workflow> workflows;
81 public List<Object> getPolicyTriggers() {
82 return policyTriggers;
85 public void setPolicyTriggers(List<Object> policyTriggers) {
86 this.policyTriggers = policyTriggers;
89 public List<Object> getPolicyTypes() {
93 public void setPolicyTypes(List<Object> policyTypes) {
94 this.policyTypes = policyTypes;
97 public String getBlueprintId() {
101 public void setBlueprintId(String blueprintId) {
102 this.blueprintId = blueprintId;
105 public Date getCreatedAt() {
109 public void setCreatedAt(Date createdAt) {
110 this.createdAt = createdAt;
113 public String getCreatedBy() {
117 public void setCreatedBy(String createdBy) {
118 this.createdBy = createdBy;
121 public String getDescription() {
125 public void setDescription(String description) {
126 this.description = description;
129 public Map<String, Group> getGroups() {
133 public void setGroups(Map<String, Group> groups) {
134 this.groups = groups;
137 public String getId() {
141 public void setId(String id) {
145 public Map<String, Object> getInputs() {
148 public void setInputs(Map<String, Object> inputs) {
149 this.inputs = inputs;
152 public String getTenantName() {
156 public void setTenantName(String tenantName) {
157 this.tenantName = tenantName;
160 public Map<String, ScalingGroup> getScalingGroups() {
161 return scalingGroups;
164 public void setScalingGroups(Map<String, ScalingGroup> scalingGroups) {
165 this.scalingGroups = scalingGroups;
168 public Date getUpdatedAt() {
172 public void setUpdatedAt(Date updatedAt) {
173 this.updatedAt = updatedAt;
176 public List<Workflow> getWorkflows() {
180 public void setWorkflows(List<Workflow> workflows) {
181 this.workflows = workflows;
185 * Nested subclasses for Group definitions
187 public static final class Group {
188 @JsonProperty ("policies")
191 @JsonProperty("members")
192 List<String> members;
194 public Object getPolicies() {
198 public void setPolicies(Object policies) {
199 this.policies = policies;
202 public List<String> getMembers() {
206 public void setMembers(List<String> members) {
207 this.members = members;
212 * Nested subclasses for Scaling Group definitions
214 public static final class ScalingGroup {
215 @JsonProperty ("properties")
216 ScalingGroupProperties properties;
218 @JsonProperty("members")
219 List<String> members;
221 public ScalingGroupProperties getProperties() {
225 public void setProperties(ScalingGroupProperties properties) {
226 this.properties = properties;
229 public List<String> getMembers() {
233 public void setMembers(List<String> members) {
234 this.members = members;
238 public static final class ScalingGroupProperties {
239 @JsonProperty("current_instances")
240 int currentInstances;
242 @JsonProperty("default_instances")
243 int defaultInstances;
245 @JsonProperty("max_instances")
248 @JsonProperty("min_instances")
251 @JsonProperty("planned_instances")
252 int plannedInstances;
254 public int getCurrentInstances() {
255 return currentInstances;
258 public void setCurrentInstances(int currentInstances) {
259 this.currentInstances = currentInstances;
262 public int getDefaultInstances() {
263 return defaultInstances;
266 public void setDefaultInstances(int defaultInstances) {
267 this.defaultInstances = defaultInstances;
270 public int getMaxInstances() {
274 public void setMaxInstances(int maxInstances) {
275 this.maxInstances = maxInstances;
278 public int getMinInstances() {
282 public void setMinInstances(int minInstances) {
283 this.minInstances = minInstances;
286 public int getPlannedInstances() {
287 return plannedInstances;
290 public void setPlannedInstances(int plannedInstances) {
291 this.plannedInstances = plannedInstances;
296 * Nested subclass for Deployment Workflow entities.
297 * Note that Blueprint class also contains a slightly different Workflow structure.
299 public static final class Workflow {
300 @JsonProperty("name")
302 @JsonProperty("created_at")
303 private Date createdAt;
304 @JsonProperty("parameters")
305 private Map<String,ParameterDefinition> parameters;
309 public String getName() {
312 public void setName(String name) {
315 public Date getCreatedAt() {
318 public void setCreatedAt(Date createdAt) {
319 this.createdAt = createdAt;
321 public Map<String, ParameterDefinition> getParameters() {
324 public void setParameters(Map<String, ParameterDefinition> parameters) {
325 this.parameters = parameters;
330 * Return an output as a Json-mapped Object of the provided type.
331 * This is useful for json-object outputs.
333 public <T> T getMapValue (Map<String,Object> map, String key, Class<T> type)
336 ObjectMapper mapper = new ObjectMapper();
337 if (map.containsKey(key)) {
339 String s = mapper.writeValueAsString(map.get(key));
340 return (mapper.readValue(s, type));
342 catch (IOException e) {
350 public String toString() {
351 return "Deployment{" +
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 +