Add pause after completion for vfModule
[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 final PauseInstantiation pauseInstantiation;
53
54         @JsonInclude(NON_NULL)
55         private Boolean retainAssignments;
56
57         public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo,
58                 @JsonProperty("instanceName") String instanceName,
59                 @JsonProperty("volumeGroupName") @JsonAlias("volumeGroupInstanceName") String volumeGroupInstanceName,
60                 @JsonProperty("action") String action,
61                 @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
62                 @JsonProperty("legacyRegion") String legacyRegion,
63                 @JsonProperty("tenantId") String tenantId,
64                 @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
65                 @JsonProperty("supplementaryFileContent") List<UserParamNameAndValue> supplementaryParams,
66                 @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
67                 @JsonProperty("sdncPreLoad") @JsonAlias("usePreload") Boolean usePreload,
68                 @JsonProperty("instanceId") String instanceId,
69                 @JsonProperty("trackById") String trackById,
70                 @JsonProperty("isFailed") Boolean isFailed,
71                 @JsonProperty("statusMessage") String statusMessage,
72                 @Nullable @JsonProperty("retainAssignments") Boolean retainAssignments,
73                 @Nullable @JsonProperty("retainVolumeGroups") Boolean retainVolumeGroups,
74                 @JsonProperty("position") Integer position,
75                 @JsonProperty("pauseInstantiation") PauseInstantiation pauseInstantiation,
76                 @JsonProperty("originalName") String originalName) {
77                 super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
78                         position, originalName);
79                 this.volumeGroupInstanceName = volumeGroupInstanceName;
80                 this.usePreload = usePreload;
81                 this.supplementaryParams = supplementaryParams;
82                 this.retainAssignments = retainAssignments;
83                 this.retainVolumeGroups = retainVolumeGroups;
84                 this.pauseInstantiation = pauseInstantiation;
85         }
86
87         public String getVolumeGroupInstanceName() {
88                 return volumeGroupInstanceName;
89         }
90
91         public Boolean isUsePreload() {
92
93                 return usePreload;
94         }
95
96         public enum PauseInstantiation {
97                 afterCompletion
98         }
99
100         public List<UserParamNameAndValue> getSupplementaryParams() {
101                 return supplementaryParams;
102         }
103
104         @Override
105         protected String getModelType() {
106                 return "vfModule";
107         }
108
109         @Override
110         public Collection<BaseResource> getChildren() {
111                 return Collections.emptyList();
112         }
113
114         @Override
115         public JobType getJobType() {
116                 return JobType.VfmoduleInstantiation;
117         }
118
119         @Nullable
120         public Boolean isRetainAssignments() {
121                 return retainAssignments;
122         }
123
124         @Nullable
125         public Boolean isRetainVolumeGroups() {
126                 return retainVolumeGroups;
127         }
128
129         @Nullable
130         public PauseInstantiation getPauseInstantiation() {return pauseInstantiation;}
131
132         public VfModule cloneWith(ModelInfo modelInfo) {
133                 return new VfModule(
134                                 modelInfo,
135                                 this.getInstanceName(),
136                                 this.getVolumeGroupInstanceName(),
137                                 this.getAction().toString(),
138                                 this.getLcpCloudRegionId(),
139                                 this.getLcpCloudRegionId(),
140                                 this.getTenantId(),
141                                 this.getInstanceParams(),
142                                 this.getSupplementaryParams(),
143                                 this.isRollbackOnFailure(),
144                                 this.isUsePreload(),
145                                 this.getInstanceId(),
146                                 this.getTrackById(),
147                                 this.getIsFailed(),
148                                 this.getStatusMessage(),
149                                 this.isRetainAssignments(),
150                                 this.isRetainVolumeGroups(),
151                                 this.getPosition(),
152                             this.getPauseInstantiation(),
153                             this.getOriginalName()
154                 );
155         }
156
157         public VfModule cloneWith(String lcpCloudRegionId, String tenantId) {
158                 return new VfModule(
159                         this.getModelInfo(),
160                         this.getInstanceName(),
161                         this.getVolumeGroupInstanceName(),
162                         this.getAction().toString(),
163                         lcpCloudRegionId,
164                         lcpCloudRegionId,
165                         tenantId,
166                         this.getInstanceParams(),
167                         this.getSupplementaryParams(),
168                         this.isRollbackOnFailure(),
169                         this.isUsePreload(),
170                         this.getInstanceId(),
171                         this.getTrackById(),
172                         this.getIsFailed(),
173                         this.getStatusMessage(),
174                         this.isRetainAssignments(),
175                         this.isRetainVolumeGroups(),
176                         this.getPosition(),
177                         this.getPauseInstantiation(),
178                         this.getOriginalName()
179                 );
180         }
181 }