Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame] | 1 | /*-
|
| 2 | * ============LICENSE_START=======================================================
|
| 3 | * OSAM
|
| 4 | * ================================================================================
|
| 5 | * Copyright (C) 2018 AT&T
|
| 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 |
|
| 22 |
|
| 23 | package org.onap.osam.mso.model;
|
| 24 |
|
| 25 | import com.fasterxml.jackson.annotation.JsonInclude;
|
| 26 | import com.fasterxml.jackson.annotation.JsonProperty;
|
| 27 | import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
| 28 | import com.fasterxml.jackson.annotation.JsonTypeName;
|
| 29 | import org.onap.osam.domain.mso.CloudConfiguration;
|
| 30 | import org.onap.osam.domain.mso.ModelInfo;
|
| 31 | import org.onap.osam.domain.mso.SubscriberInfo;
|
| 32 | import org.onap.osam.model.serviceInstantiation.VfModule;
|
| 33 |
|
| 34 | import java.util.List;
|
| 35 | import java.util.Map;
|
| 36 |
|
| 37 | import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY;
|
| 38 | import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
|
| 39 |
|
| 40 | public class ServiceInstantiationRequestDetails {
|
| 41 |
|
| 42 | @JsonProperty("modelInfo")
|
| 43 | private ModelInfo modelInfo;
|
| 44 |
|
| 45 | @JsonProperty("owningEntity")
|
| 46 | private ServiceInstantiationOwningEntity owningEntity;
|
| 47 |
|
| 48 | @JsonProperty("subscriberInfo")
|
| 49 | private SubscriberInfo subscriberInfo;
|
| 50 |
|
| 51 | @JsonProperty("project")
|
| 52 | private Project project;
|
| 53 |
|
| 54 | @JsonProperty("requestParameters")
|
| 55 | private RequestParameters requestParameters;
|
| 56 |
|
| 57 | @JsonProperty("requestInfo")
|
| 58 | private RequestInfo requestInfo;
|
| 59 |
|
| 60 | public ServiceInstantiationRequestDetails(@JsonProperty(value = "modelInfo", required = true) ModelInfo modelInfo,
|
| 61 | @JsonProperty(value = "owningEntity", required = true) ServiceInstantiationOwningEntity owningEntity,
|
| 62 | @JsonProperty(value = "subscriberInfo", required = true) SubscriberInfo subscriberInfo,
|
| 63 | @JsonProperty(value = "project", required = true) Project project,
|
| 64 | @JsonProperty(value = "requestInfo", required = true) RequestInfo requestInfo,
|
| 65 | @JsonProperty(value = "requestParameters", required = true) RequestParameters requestParameters) {
|
| 66 | this.modelInfo = modelInfo;
|
| 67 | this.owningEntity = owningEntity;
|
| 68 | this.subscriberInfo = subscriberInfo;
|
| 69 | this.project = project;
|
| 70 | this.requestInfo = requestInfo;
|
| 71 | this.requestParameters = requestParameters;
|
| 72 | }
|
| 73 |
|
| 74 | public static class ServiceInstantiationOwningEntity{
|
| 75 | public final String owningEntityId;
|
| 76 | public final String owningEntityName;
|
| 77 |
|
| 78 | public ServiceInstantiationOwningEntity(String owningEntityId, String owningEntityName) {
|
| 79 | this.owningEntityId = owningEntityId;
|
| 80 | this.owningEntityName = owningEntityName;
|
| 81 | }
|
| 82 | }
|
| 83 |
|
| 84 | public static class RequestInfo {
|
| 85 |
|
| 86 | @JsonInclude(NON_NULL) public final String instanceName;
|
| 87 | public final String productFamilyId;
|
| 88 | public final String source;
|
| 89 | public final boolean suppressRollback;
|
| 90 | public final String requestorId;
|
| 91 |
|
| 92 | public RequestInfo(String instanceName, String productFamilyId, String source, boolean rollbackOnFailure, String requestorId) {
|
| 93 | this.instanceName = instanceName;
|
| 94 | this.productFamilyId = productFamilyId;
|
| 95 | this.source = source;
|
| 96 | this.requestorId = requestorId;
|
| 97 | // in the FE we are asking for "RollbackOnFailure" but to MSO we are passing the negative value "suppressRollback"
|
| 98 | this.suppressRollback = !rollbackOnFailure;
|
| 99 | }
|
| 100 | }
|
| 101 |
|
| 102 | public static class Project{
|
| 103 | public final String projectName;
|
| 104 |
|
| 105 | public Project(String projectName) {
|
| 106 | this.projectName = projectName;
|
| 107 | }
|
| 108 | }
|
| 109 |
|
| 110 | public static class RequestParameters {
|
| 111 |
|
| 112 | public final String subscriptionServiceType;
|
| 113 | public final boolean aLaCarte;
|
| 114 | public final List<ServiceInstantiationService> userParams;
|
| 115 |
|
| 116 | public RequestParameters(String subscriptionServiceType, boolean aLaCarte, List<ServiceInstantiationService> userParams) {
|
| 117 | this.subscriptionServiceType = subscriptionServiceType;
|
| 118 | this.aLaCarte = aLaCarte;
|
| 119 | this.userParams = userParams;
|
| 120 | }
|
| 121 | }
|
| 122 |
|
| 123 | @JsonTypeName("service")
|
| 124 | @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
|
| 125 | public static class ServiceInstantiationService{
|
| 126 | public ModelInfo modelInfo = new ModelInfo();
|
| 127 | @JsonInclude(NON_NULL) public String instanceName;
|
| 128 | public List<Map<String,String>> instanceParams;
|
| 129 | public ServiceInstantiationVnfList resources;
|
| 130 |
|
| 131 | public ServiceInstantiationService (ModelInfo modelInfo, String instanceName, List<Map<String,String>> instanceParams, ServiceInstantiationVnfList vnfs){
|
| 132 | this.modelInfo.setModelType(modelInfo.getModelType());
|
| 133 | this.modelInfo.setModelName(modelInfo.getModelName());
|
| 134 | this.modelInfo.setModelVersionId(modelInfo.getModelVersionId());
|
| 135 | this.instanceName = instanceName;
|
| 136 | this.instanceParams = instanceParams;
|
| 137 | this.resources = vnfs;
|
| 138 | }
|
| 139 | }
|
| 140 |
|
| 141 | public static class ServiceInstantiationVnfList{
|
| 142 | public final List<ServiceInstantiationVnf> vnfs;
|
| 143 |
|
| 144 | public ServiceInstantiationVnfList(List<ServiceInstantiationVnf> vnfList) {
|
| 145 | this.vnfs = vnfList;
|
| 146 | }
|
| 147 | }
|
| 148 |
|
| 149 | public static class ServiceInstantiationVnf{
|
| 150 | public final ModelInfo modelInfo;
|
| 151 | public final CloudConfiguration cloudConfiguration;
|
| 152 | public final Platform platform;
|
| 153 | public final LineOfBusiness lineOfBusiness;
|
| 154 | public final String productFamilyId;
|
| 155 | public final List<Map<String, String>> instanceParams;
|
| 156 | @JsonInclude(NON_EMPTY) public final List<VfModule> vfModules;
|
| 157 | @JsonInclude(NON_NULL) public final String instanceName;
|
| 158 |
|
| 159 | public ServiceInstantiationVnf(ModelInfo modelInfo, CloudConfiguration cloudConfiguration, String platform, String lineOfBusiness, String productFamilyId, List<Map<String, String>> instanceParams, List<VfModule> vfModules, String instanceName) {
|
| 160 | this.modelInfo = modelInfo;
|
| 161 | this.cloudConfiguration = cloudConfiguration;
|
| 162 | this.platform = new Platform(platform);
|
| 163 | this.lineOfBusiness = new LineOfBusiness(lineOfBusiness);
|
| 164 | this.productFamilyId = productFamilyId;
|
| 165 | this.instanceParams = instanceParams;
|
| 166 | this.vfModules = vfModules;
|
| 167 | this.instanceName = instanceName;
|
| 168 | }
|
| 169 | }
|
| 170 |
|
| 171 | public static class Platform{
|
| 172 | public final String platformName;
|
| 173 |
|
| 174 | public Platform(String platformName) {
|
| 175 | this.platformName = platformName;
|
| 176 | }
|
| 177 | }
|
| 178 |
|
| 179 | public static class LineOfBusiness{
|
| 180 | public final String lineOfBusinessName;
|
| 181 |
|
| 182 | public LineOfBusiness(String lineOfBusiness) {
|
| 183 | this.lineOfBusinessName = lineOfBusiness;
|
| 184 | }
|
| 185 | }
|
| 186 | }
|
| 187 |
|