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.onap.so.cloudify.v3.model;
23 import java.io.IOException;
24 import java.io.Serializable;
25 import java.util.Date;
26 import java.util.List;
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;
33 @JsonIgnoreProperties(ignoreUnknown = true)
34 // @JsonRootName("deployment")
35 public class Deployment implements Serializable {
37 private static final long serialVersionUID = 1L;
39 @JsonProperty("blueprint_id")
40 private String blueprintId;
42 @JsonProperty("created_at")
43 private Date createdAt;
45 @JsonProperty("created_by")
46 private String createdBy;
48 @JsonProperty("description")
49 private String description;
51 @JsonProperty("groups")
52 private Map<String, Group> groups = null;
57 @JsonProperty("inputs")
58 private Map<String, Object> inputs = null;
60 // TODO: Expand the definition of a PolicyTrigger
61 @JsonProperty("policy_triggers")
62 private List<Object> policyTriggers;
64 // TODO: Expand the definition of a PolicyType
65 @JsonProperty("policy_types")
66 private List<Object> policyTypes;
68 @JsonProperty("scaling_groups")
69 private Map<String, ScalingGroup> scalingGroups = null;
71 @JsonProperty("tenant_name")
72 private String tenantName;
74 @JsonProperty("updated_at")
75 private Date updatedAt;
77 @JsonProperty("workflows")
78 private List<Workflow> workflows;
80 public List<Object> getPolicyTriggers() {
81 return policyTriggers;
84 public void setPolicyTriggers(List<Object> policyTriggers) {
85 this.policyTriggers = policyTriggers;
88 public List<Object> getPolicyTypes() {
92 public void setPolicyTypes(List<Object> policyTypes) {
93 this.policyTypes = policyTypes;
96 public String getBlueprintId() {
100 public void setBlueprintId(String blueprintId) {
101 this.blueprintId = blueprintId;
104 public Date getCreatedAt() {
108 public void setCreatedAt(Date createdAt) {
109 this.createdAt = createdAt;
112 public String getCreatedBy() {
116 public void setCreatedBy(String createdBy) {
117 this.createdBy = createdBy;
120 public String getDescription() {
124 public void setDescription(String description) {
125 this.description = description;
128 public Map<String, Group> getGroups() {
132 public void setGroups(Map<String, Group> groups) {
133 this.groups = groups;
136 public String getId() {
140 public void setId(String id) {
144 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. Note that Blueprint class also contains a slightly different
297 * 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() {
313 public void setName(String name) {
317 public Date getCreatedAt() {
321 public void setCreatedAt(Date createdAt) {
322 this.createdAt = createdAt;
325 public Map<String, ParameterDefinition> getParameters() {
329 public void setParameters(Map<String, ParameterDefinition> parameters) {
330 this.parameters = parameters;
335 * Return an output as a Json-mapped Object of the provided type. This is useful for json-object outputs.
337 public <T> T getMapValue(Map<String, Object> map, String key, Class<T> type) {
339 ObjectMapper mapper = new ObjectMapper();
340 if (map.containsKey(key)) {
342 String s = mapper.writeValueAsString(map.get(key));
343 return (mapper.readValue(s, type));
344 } catch (IOException e) {
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 + '}';