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 // ObjectMapper instance to parse Json object outputs
83 private static ObjectMapper mapper = new ObjectMapper();
85 public String getBlueprintId() {
89 public void setBlueprintId(String blueprintId) {
90 this.blueprintId = blueprintId;
93 public Date getCreatedAt() {
97 public void setCreatedAt(Date createdAt) {
98 this.createdAt = createdAt;
101 public String getCreatedBy() {
105 public void setCreatedBy(String createdBy) {
106 this.createdBy = createdBy;
109 public String getDescription() {
113 public void setDescription(String description) {
114 this.description = description;
117 public Map<String, Group> getGroups() {
121 public void setGroups(Map<String, Group> groups) {
122 this.groups = groups;
125 public String getId() {
129 public void setId(String id) {
133 public Map<String, Object> getInputs() {
136 public void setInputs(Map<String, Object> inputs) {
137 this.inputs = inputs;
140 public String getTenantName() {
144 public void setTenantName(String tenantName) {
145 this.tenantName = tenantName;
148 public Map<String, ScalingGroup> getScalingGroups() {
149 return scalingGroups;
152 public void setScalingGroups(Map<String, ScalingGroup> scalingGroups) {
153 this.scalingGroups = scalingGroups;
156 public Date getUpdatedAt() {
160 public void setUpdatedAt(Date updatedAt) {
161 this.updatedAt = updatedAt;
164 public List<Workflow> getWorkflows() {
168 public void setWorkflows(List<Workflow> workflows) {
169 this.workflows = workflows;
173 * Nested subclasses for Group definitions
175 public static final class Group {
176 @JsonProperty ("policies")
179 @JsonProperty("members")
180 List<String> members;
182 public Object getPolicies() {
186 public void setPolicies(Object policies) {
187 this.policies = policies;
190 public List<String> getMembers() {
194 public void setMembers(List<String> members) {
195 this.members = members;
200 * Nested subclasses for Scaling Group definitions
202 public static final class ScalingGroup {
203 @JsonProperty ("properties")
204 ScalingGroupProperties properties;
206 @JsonProperty("members")
207 List<String> members;
209 public ScalingGroupProperties getProperties() {
213 public void setProperties(ScalingGroupProperties properties) {
214 this.properties = properties;
217 public List<String> getMembers() {
221 public void setMembers(List<String> members) {
222 this.members = members;
226 public static final class ScalingGroupProperties {
227 @JsonProperty("current_instances")
228 int currentInstances;
230 @JsonProperty("default_instances")
231 int defaultInstances;
233 @JsonProperty("max_instances")
236 @JsonProperty("min_instances")
239 @JsonProperty("planned_instances")
240 int plannedInstances;
242 public int getCurrentInstances() {
243 return currentInstances;
246 public void setCurrentInstances(int currentInstances) {
247 this.currentInstances = currentInstances;
250 public int getDefaultInstances() {
251 return defaultInstances;
254 public void setDefaultInstances(int defaultInstances) {
255 this.defaultInstances = defaultInstances;
258 public int getMaxInstances() {
262 public void setMaxInstances(int maxInstances) {
263 this.maxInstances = maxInstances;
266 public int getMinInstances() {
270 public void setMinInstances(int minInstances) {
271 this.minInstances = minInstances;
274 public int getPlannedInstances() {
275 return plannedInstances;
278 public void setPlannedInstances(int plannedInstances) {
279 this.plannedInstances = plannedInstances;
284 * Nested subclass for Deployment Workflow entities.
285 * Note that Blueprint class also contains a slightly different Workflow structure.
287 public static final class Workflow {
288 @JsonProperty("name")
290 @JsonProperty("created_at")
291 private Date createdAt;
292 @JsonProperty("parameters")
293 private Map<String,ParameterDefinition> parameters;
297 public String getName() {
300 public void setName(String name) {
303 public Date getCreatedAt() {
306 public void setCreatedAt(Date createdAt) {
307 this.createdAt = createdAt;
309 public Map<String, ParameterDefinition> getParameters() {
312 public void setParameters(Map<String, ParameterDefinition> parameters) {
313 this.parameters = parameters;
318 * Return an output as a Json-mapped Object of the provided type.
319 * This is useful for json-object outputs.
321 public <T> T getMapValue (Map<String,Object> map, String key, Class<T> type)
323 if (map.containsKey(key)) {
325 String s = mapper.writeValueAsString(map.get(key));
326 return (mapper.readValue(s, type));
328 catch (IOException e) {
336 public String toString() {
337 return "Deployment{" +
339 ", description='" + description + '\'' +
340 ", blueprintId='" + blueprintId + '\'' +
341 ", createdBy='" + createdBy + '\'' +
342 ", tenantName='" + tenantName + '\'' +
343 ", createdAt=" + createdAt +
344 ", updatedAt=" + updatedAt +
345 ", inputs='" + inputs + '\'' +
346 ", workflows=" + workflows +
347 ", groups=" + groups +