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.model.serviceInstantiation;
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import org.apache.commons.lang3.ObjectUtils;
25 import org.onap.vid.job.JobAdapter;
26 import org.onap.vid.job.JobType;
27 import org.onap.vid.model.VidNotions;
28 import org.onap.vid.mso.model.ModelInfo;
30 import java.util.Collection;
31 import java.util.Collections;
32 import java.util.List;
34 import java.util.stream.Collectors;
35 import java.util.stream.Stream;
37 public class ServiceInstantiation extends BaseResource implements JobAdapter.AsyncJobRequest {
39 private final String owningEntityId;
41 private final String owningEntityName;
43 private final String projectName;
45 private final String subscriberName;
47 private final String globalSubscriberId;
49 private final String productFamilyId;
51 private final String subscriptionServiceType;
53 private final String tenantName;
55 private final String aicZoneId;
57 private final String aicZoneName;
59 private final Map<String, Vnf> vnfs;
61 private final Map<String, Network> networks;
63 private final Map<String, InstanceGroup> vnfGroups;
65 private final boolean isPause;
69 private final String testApi;
71 private final boolean isALaCarte;
73 private final VidNotions vidNotions;
74 private Map<String, VrfEntry> vrfs;
76 public ServiceInstantiation(@JsonProperty("modelInfo") ModelInfo modelInfo,
77 @JsonProperty("owningEntityId") String owningEntityId,
78 @JsonProperty("owningEntityName") String owningEntityName,
79 @JsonProperty("projectName") String projectName,
80 @JsonProperty("globalSubscriberId") String globalSubscriberId,
81 @JsonProperty("subscriberName") String subscriberName,
82 @JsonProperty("productFamilyId") String productFamilyId,
83 @JsonProperty("instanceName") String instanceName,
84 @JsonProperty("subscriptionServiceType") String subscriptionServiceType,
85 @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
86 @JsonProperty("legacyRegion") String legacyRegion,
87 @JsonProperty("tenantId") String tenantId,
88 @JsonProperty("tenantName") String tenantName,
89 @JsonProperty("aicZoneId") String aicZoneId,
90 @JsonProperty("aicZoneName") String aicZoneName,
91 @JsonProperty("vnfs") Map<String, Vnf> vnfs,
92 @JsonProperty("networks") Map<String, Network> networks,
93 @JsonProperty("vnfGroups") Map<String, InstanceGroup> vnfGroups,
94 @JsonProperty("vrfs") Map<String, VrfEntry> vrfs,
95 @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
96 @JsonProperty("pause") boolean isPause,
97 @JsonProperty("bulkSize") int bulkSize,
98 @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
99 @JsonProperty("isALaCarte") boolean isALaCarte,
100 @JsonProperty("testApi") String testApi,
101 @JsonProperty("instanceId") String instanceId,
102 @JsonProperty("action") String action,
103 @JsonProperty("trackById") String trackById,
104 @JsonProperty("isFailed") Boolean isFailed,
105 @JsonProperty("statusMessage") String statusMessage,
106 @JsonProperty("vidNotions") VidNotions vidNotions) {
107 super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
109 this.owningEntityId = owningEntityId;
110 this.owningEntityName = owningEntityName;
111 this.projectName = projectName;
112 this.globalSubscriberId = globalSubscriberId;
113 this.subscriberName = subscriberName;
114 this.productFamilyId = productFamilyId;
115 this.subscriptionServiceType = subscriptionServiceType;
116 this.tenantName = tenantName;
117 this.aicZoneId = aicZoneId;
118 this.aicZoneName = aicZoneName;
120 this.networks = networks;
121 this.vnfGroups = vnfGroups;
123 this.isPause = isPause;
124 this.bulkSize = bulkSize;
125 this.isALaCarte = isALaCarte;
126 this.testApi = isALaCarte ? testApi : null;
127 this.vidNotions = vidNotions;
131 public String getOwningEntityId() {
132 return owningEntityId;
135 public String getOwningEntityName() {
136 return owningEntityName;
139 public String getProjectName() {
143 public String getGlobalSubscriberId() {
144 return globalSubscriberId;
147 public String getSubscriberName() {
148 return subscriberName;
151 public String getProductFamilyId() {
152 return productFamilyId;
155 public String getSubscriptionServiceType() {
156 return subscriptionServiceType;
159 public String getTenantName() {
163 public String getAicZoneId() {
167 public String getAicZoneName() {
171 public Map<String, Vnf> getVnfs() {
172 return emptyMapIfNull(vnfs);
175 public Map<String, Network> getNetworks() {
176 return emptyMapIfNull(networks);
179 public Map<String, InstanceGroup> getVnfGroups() {
180 return emptyMapIfNull(vnfGroups);
183 public Map<String, VrfEntry> getVrfs() {
184 return emptyMapIfNull(vrfs);
187 public boolean isPause() {
191 public int getBulkSize() { return bulkSize; }
193 public void setBulkSize(int bulkSize) {
194 this.bulkSize = bulkSize;
197 public VidNotions getVidNotions() {
202 protected String getModelType() {
207 public Collection<BaseResource> getChildren() {
208 return Stream.of(getNetworks().values(), getVnfs().values(), getVnfGroups().values()).flatMap(Collection::stream).collect(Collectors.toList());
211 @JsonProperty("isALaCarte")
212 public boolean isALaCarte() {
216 public String getTestApi() {
221 public JobType getJobType() {
222 return JobType.ALaCarteService;
225 private <T> Map<String, T> emptyMapIfNull(Map<String, T> map) {
226 return ObjectUtils.defaultIfNull(map, Collections.emptyMap());