vfmodule tenant and region are dictated by parent VNF values
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / serviceInstantiation / VfModule.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
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.vid.model.serviceInstantiation;
22
23 import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
24
25 import com.fasterxml.jackson.annotation.JsonAlias;
26 import com.fasterxml.jackson.annotation.JsonInclude;
27 import com.fasterxml.jackson.annotation.JsonProperty;
28 import java.util.Collection;
29 import java.util.Collections;
30 import java.util.List;
31 import java.util.Map;
32 import javax.annotation.Nullable;
33 import org.onap.vid.job.JobAdapter;
34 import org.onap.vid.job.JobType;
35 import org.onap.vid.mso.model.ModelInfo;
36 import org.onap.vid.mso.model.ServiceInstantiationRequestDetails.UserParamNameAndValue;
37
38 /**
39  * The Class VfModule.
40  */
41 @JsonInclude(NON_NULL)
42 public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest {
43
44         @JsonInclude(NON_NULL) @JsonProperty("volumeGroupName") private final String volumeGroupInstanceName;
45         @JsonInclude(NON_NULL) @JsonProperty("sdncPreLoad") private Boolean usePreload;
46         private List<UserParamNameAndValue> supplementaryParams;
47
48         @JsonInclude(NON_NULL)
49         private final Boolean retainVolumeGroups;
50
51         @JsonInclude(NON_NULL)
52         private Boolean retainAssignments;
53
54         public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo,
55                 @JsonProperty("instanceName") String instanceName,
56                 @JsonProperty("volumeGroupName") @JsonAlias("volumeGroupInstanceName") String volumeGroupInstanceName,
57                 @JsonProperty("action") String action,
58                 @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
59                 @JsonProperty("legacyRegion") String legacyRegion,
60                 @JsonProperty("tenantId") String tenantId,
61                 @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
62                 @JsonProperty("supplementaryFileContent") List<UserParamNameAndValue> supplementaryParams,
63                 @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
64                 @JsonProperty("sdncPreLoad") @JsonAlias("usePreload") Boolean usePreload,
65                 @JsonProperty("instanceId") String instanceId,
66                 @JsonProperty("trackById") String trackById,
67                 @JsonProperty("isFailed") Boolean isFailed,
68                 @JsonProperty("statusMessage") String statusMessage,
69                 @Nullable @JsonProperty("retainAssignments") Boolean retainAssignments,
70                 @Nullable @JsonProperty("retainVolumeGroups") Boolean retainVolumeGroups,
71                 @JsonProperty("position") Integer position,
72                 @JsonProperty("originalName") String originalName) {
73                 super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
74                         position, originalName);
75                 this.volumeGroupInstanceName = volumeGroupInstanceName;
76                 this.usePreload = usePreload;
77                 this.supplementaryParams = supplementaryParams;
78                 this.retainAssignments = retainAssignments;
79                 this.retainVolumeGroups = retainVolumeGroups;
80         }
81
82         public String getVolumeGroupInstanceName() {
83                 return volumeGroupInstanceName;
84         }
85
86         public Boolean isUsePreload() {
87
88                 return usePreload;
89         }
90
91         public List<UserParamNameAndValue> getSupplementaryParams() {
92                 return supplementaryParams;
93         }
94
95         @Override
96         protected String getModelType() {
97                 return "vfModule";
98         }
99
100         @Override
101         public Collection<BaseResource> getChildren() {
102                 return Collections.emptyList();
103         }
104
105         @Override
106         public JobType getJobType() {
107                 return JobType.VfmoduleInstantiation;
108         }
109
110         @Nullable
111         public Boolean isRetainAssignments() {
112                 return retainAssignments;
113         }
114
115         @Nullable
116         public Boolean isRetainVolumeGroups() {
117                 return retainVolumeGroups;
118         }
119
120         public VfModule cloneWith(ModelInfo modelInfo) {
121                 return new VfModule(
122                                 modelInfo,
123                                 this.getInstanceName(),
124                                 this.getVolumeGroupInstanceName(),
125                                 this.getAction().toString(),
126                                 this.getLcpCloudRegionId(),
127                                 this.getLcpCloudRegionId(),
128                                 this.getTenantId(),
129                                 this.getInstanceParams(),
130                                 this.getSupplementaryParams(),
131                                 this.isRollbackOnFailure(),
132                                 this.isUsePreload(),
133                                 this.getInstanceId(),
134                                 this.getTrackById(),
135                                 this.getIsFailed(),
136                                 this.getStatusMessage(),
137                                 this.isRetainAssignments(),
138                                 this.isRetainVolumeGroups(),
139                                 this.getPosition(),
140                             this.getOriginalName()
141                 );
142         }
143
144         public VfModule cloneWith(String lcpCloudRegionId, String tenantId) {
145                 return new VfModule(
146                         this.getModelInfo(),
147                         this.getInstanceName(),
148                         this.getVolumeGroupInstanceName(),
149                         this.getAction().toString(),
150                         lcpCloudRegionId,
151                         lcpCloudRegionId,
152                         tenantId,
153                         this.getInstanceParams(),
154                         this.getSupplementaryParams(),
155                         this.isRollbackOnFailure(),
156                         this.isUsePreload(),
157                         this.getInstanceId(),
158                         this.getTrackById(),
159                         this.getIsFailed(),
160                         this.getStatusMessage(),
161                         this.isRetainAssignments(),
162                         this.isRetainVolumeGroups(),
163                         this.getPosition(),
164                         this.getOriginalName()
165                 );
166         }
167 }