2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 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.vid.mso.model;
23 import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY;
24 import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
26 import com.fasterxml.jackson.annotation.JsonInclude;
27 import com.fasterxml.jackson.annotation.JsonProperty;
28 import com.fasterxml.jackson.annotation.JsonTypeInfo;
29 import com.fasterxml.jackson.annotation.JsonTypeName;
30 import java.util.List;
32 @JsonInclude(NON_NULL)
33 public class BaseResourceInstantiationRequestDetails {
35 @JsonProperty("modelInfo")
36 protected ModelInfo modelInfo;
38 @JsonProperty("cloudConfiguration")
39 protected CloudConfiguration cloudConfiguration;
41 @JsonProperty("requestInfo")
42 protected RequestInfo requestInfo;
44 @JsonProperty("platform")
45 protected Platform platform;
47 @JsonProperty("lineOfBusiness")
48 protected LineOfBusiness lineOfBusiness;
50 @JsonProperty("relatedInstanceList")
51 protected List<RelatedInstance> relatedInstanceList;
53 @JsonProperty("requestParameters")
54 protected RequestParameters requestParameters;
56 public BaseResourceInstantiationRequestDetails(@JsonProperty(value = "modelInfo", required = true) ModelInfo modelInfo,
57 @JsonProperty(value = "cloudConfiguration", required = true) CloudConfiguration cloudConfiguration,
58 @JsonProperty(value = "requestInfo", required = true) RequestInfo requestInfo,
59 @JsonProperty(value = "platform", required = true) Platform platform,
60 @JsonProperty(value = "lineOfBusiness", required = true) LineOfBusiness lineOfBusiness,
61 @JsonProperty(value = "relatedInstanceList", required = true) List<RelatedInstance> relatedInstanceList,
62 @JsonProperty(value = "requestParameters", required = true) RequestParameters requestParameters)
64 this.modelInfo = modelInfo;
65 this.cloudConfiguration = cloudConfiguration;
66 this.requestInfo = requestInfo;
67 this.platform = platform;
68 this.lineOfBusiness = lineOfBusiness;
69 this.relatedInstanceList = relatedInstanceList;
70 this.requestParameters = requestParameters;
73 public BaseResourceInstantiationRequestDetails(@JsonProperty(value = "modelInfo", required = true) ModelInfo modelInfo,
74 @JsonProperty(value = "cloudConfiguration", required = true) CloudConfiguration cloudConfiguration,
75 @JsonProperty(value = "requestInfo", required = true) RequestInfo requestInfo,
76 @JsonProperty(value = "relatedInstanceList", required = true) List<RelatedInstance> relatedInstanceList,
77 @JsonProperty(value = "requestParameters", required = true) RequestParameters requestParameters)
79 this.modelInfo = modelInfo;
80 this.cloudConfiguration = cloudConfiguration;
81 this.requestInfo = requestInfo;
82 this.relatedInstanceList = relatedInstanceList;
83 this.requestParameters = requestParameters;
86 public static class RequestInfo {
88 @JsonInclude(NON_EMPTY) public final String instanceName;
89 @JsonInclude(NON_EMPTY) public final String productFamilyId;
90 public final String source;
91 @JsonInclude(NON_NULL) public final Boolean suppressRollback;
92 public final String requestorId;
94 public RequestInfo(String instanceName, String productFamilyId, String source, Boolean rollbackOnFailure, String requestorId) {
95 this.instanceName = instanceName;
96 this.productFamilyId = productFamilyId;
98 this.requestorId = requestorId;
99 // in the FE we are asking for "RollbackOnFailure" but to MSO we are passing the negative value "suppressRollback"
100 this.suppressRollback = rollbackOnFailure != null ? (!rollbackOnFailure) : null;
104 public static class Project{
105 public final String projectName;
107 public Project(String projectName) {
108 this.projectName = projectName;
112 public static class Platform{
113 public final String platformName;
115 public Platform(String platformName) {
116 this.platformName = platformName;
120 public static class LineOfBusiness{
121 public final String lineOfBusinessName;
123 private LineOfBusiness(String lineOfBusiness) {
124 this.lineOfBusinessName = lineOfBusiness;
127 public static LineOfBusiness of(String lineOfBusiness) {
128 return lineOfBusiness==null ? null : new LineOfBusiness(lineOfBusiness);
132 @JsonTypeName("relatedInstance")
133 @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
134 public static class RelatedInstance{
135 public ModelInfo modelInfo;
136 @JsonInclude(NON_NULL) public String instanceId; //TODO ask Eylon - is this needed, and if yes, for other fields as well?
137 @JsonInclude(NON_NULL) public String instanceName;
139 public RelatedInstance (@JsonProperty(value = "modelInfo", required = true) ModelInfo modelInfo,
140 @JsonProperty (value = "instanceId", required = true) String instanceId){
141 this.modelInfo = modelInfo;
142 this.instanceId = instanceId;
145 public RelatedInstance (@JsonProperty(value = "modelInfo", required = true) ModelInfo modelInfo,
146 @JsonProperty (value = "instanceId", required = true) String instanceId,
147 @JsonProperty (value = "instanceName", required = true) String instanceName){
148 this.modelInfo = modelInfo;
149 this.instanceId = instanceId;
150 this.instanceName = instanceName;
154 public static class RequestParameters {
155 public final List<? extends UserParamTypes> userParams;
157 @JsonInclude(NON_NULL) public final String testApi;
158 public RequestParameters(List<? extends UserParamTypes> userParams, String testApi) {
159 this.userParams = userParams;
160 this.testApi = testApi;
163 public List<? extends UserParamTypes> getUserParams() {
166 public String getTestApi() {