2 * ============LICENSE_START=======================================================
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
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.so.client.orchestration;
23 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
24 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
25 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
26 import org.onap.so.client.exception.BadResponseException;
27 import org.onap.so.client.exception.MapperException;
28 import org.onap.so.client.sdnc.SDNCClient;
29 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
30 import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
31 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
32 import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper;
33 import org.onap.so.logger.MsoLogger;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.stereotype.Component;
37 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
38 import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
41 public class SDNCServiceInstanceResources {
43 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,
44 SDNCServiceInstanceResources.class);
47 private ServiceTopologyOperationMapper sdncRM;
50 private SDNCClient sdncClient;
53 * SDNC call to perform Service Topology Assign for ServiceInsatnce
54 * @param serviceInstance
56 * @param requestContext
57 * @throws MapperException
58 * @throws BadResponseException
59 * @return the response as a String
61 public String assignServiceInstance(ServiceInstance serviceInstance, Customer customer,
62 RequestContext requestContext) throws MapperException, BadResponseException {
63 GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper(
64 SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
66 return sdncClient.post(sdncReq, SDNCTopology.SERVICE);
70 * SDNC call to perform Service Topology Delete for ServiceInsatnce
71 * @param serviceInstance
73 * @param requestContext
74 * @throws MapperException
75 * @throws BadResponseException
76 * @return the response as a String
78 public String deleteServiceInstance(ServiceInstance serviceInstance, Customer customer,
79 RequestContext requestContext) throws MapperException, BadResponseException {
80 GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper(
81 SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE, GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
83 return sdncClient.post(sdncReq, SDNCTopology.SERVICE);
86 public String unassignServiceInstance(ServiceInstance serviceInstance, Customer customer,
87 RequestContext requestContext) throws MapperException, BadResponseException {
88 GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper(
89 SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE, GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
91 return sdncClient.post(sdncReq, SDNCTopology.SERVICE);
95 * SDNC call to perform Service Topology Deactivate for ServiceInstance
96 * @param serviceInstance
98 * @param requestContext
99 * @throws MapperException
100 * @throws BadResponseException
101 * @return the response as a String
103 public String deactivateServiceInstance(ServiceInstance serviceInstance, Customer customer,
104 RequestContext requestContext) throws MapperException, BadResponseException {
105 GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper(
106 SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
108 return sdncClient.post(sdncReq, SDNCTopology.SERVICE);
112 * SDNC call to perform Service Topology Change Assign for the ServiceInstance
113 * @param serviceInstance
115 * @param requestContext
116 * @throws MapperException
117 * @throws BadResponseException
118 * @return the response as a String
120 public String changeModelServiceInstance(ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) throws MapperException, BadResponseException {
121 GenericResourceApiServiceOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, requestContext);
122 return sdncClient.post(sdncReq, SDNCTopology.SERVICE);