a4c9b8fe05a895c685c9e2cadf9816ee1b3cc6e6
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / client / orchestration / SDNCServiceInstanceResources.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.so.client.orchestration;
22
23 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
24 import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
25 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
27 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
28 import org.onap.so.client.exception.BadResponseException;
29 import org.onap.so.client.exception.MapperException;
30 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
31 import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
32 import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.stereotype.Component;
35
36 @Component
37 public class SDNCServiceInstanceResources {
38
39         @Autowired
40         private ServiceTopologyOperationMapper sdncRM;
41
42         /**
43          * SDNC call to perform Service Topology Assign for ServiceInsatnce
44          * 
45          * @param serviceInstance
46          * @param customer
47          * @param requestContext
48          * @throws MapperException
49          * @throws BadResponseException
50          * @return the response as a String
51          */
52         public GenericResourceApiServiceOperationInformation assignServiceInstance(ServiceInstance serviceInstance,
53                         Customer customer, RequestContext requestContext) {
54                 return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
55                                 GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
56                                 requestContext);
57         }
58
59         /**
60          * SDNC call to perform Service Topology Delete for ServiceInsatnce
61          * 
62          * @param serviceInstance
63          * @param customer
64          * @param requestContext
65          * @throws MapperException
66          * @throws BadResponseException
67          * @return the response as a String
68          */
69         public GenericResourceApiServiceOperationInformation deleteServiceInstance(ServiceInstance serviceInstance,
70                         Customer customer, RequestContext requestContext) {
71                 return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
72                                 GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
73                                 requestContext);
74         }
75
76         public GenericResourceApiServiceOperationInformation unassignServiceInstance(ServiceInstance serviceInstance,
77                         Customer customer, RequestContext requestContext) {
78                 return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
79                                 GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
80                                 requestContext);
81         }
82
83         /**
84          * SDNC call to perform Service Topology Deactivate for ServiceInstance
85          * 
86          * @param serviceInstance
87          * @param customer
88          * @param requestContext
89          * @throws MapperException
90          * @throws BadResponseException
91          * @return the response as a String
92          */
93         public GenericResourceApiServiceOperationInformation deactivateServiceInstance(ServiceInstance serviceInstance,
94                         Customer customer, RequestContext requestContext) {
95                 return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
96                                 GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE, serviceInstance, customer,
97                                 requestContext);
98         }
99
100         /**
101          * SDNC call to perform Service Topology Change Assign for the
102          * ServiceInstance
103          * 
104          * @param serviceInstance
105          * @param customer
106          * @param requestContext
107          * @throws MapperException
108          * @throws BadResponseException
109          * @return the response as a String
110          */
111         public GenericResourceApiServiceOperationInformation changeModelServiceInstance(ServiceInstance serviceInstance,
112                         Customer customer, RequestContext requestContext) {
113                 return sdncRM.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
114                                 GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
115                                 requestContext);
116         }
117 }