ca32130c23a916e2512671add048928bd471784f
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / client / orchestration / SDNCConfigurationResources.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
24 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
25 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
26 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
27 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
29 import org.onap.so.client.exception.BadResponseException;
30 import org.onap.so.client.exception.MapperException;
31 import org.onap.so.client.sdnc.SDNCClient;
32 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
33 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
34 import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.stereotype.Component;
37 import java.net.URI;
38 import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
39 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
40
41 @Component
42 public class SDNCConfigurationResources {
43     @Autowired
44     private GCTopologyOperationRequestMapper sdncRM;
45
46     /**
47      * SDN-C call to assign configuration after it was created in A&AI
48      *
49      * @param serviceInstance
50      * @param requestContext
51      * @param vnrConfiguration
52      * @param voiceVnf
53      * @return
54      * @throws MapperException
55      * @throws BadResponseException
56      */
57     public GenericResourceApiGcTopologyOperationInformation assignVnrConfiguration(ServiceInstance serviceInstance,
58             RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf,
59             String sdncRequestId, URI callbackUri) throws MapperException, BadResponseException {
60         return sdncRM.assignOrActivateVnrReqMapper(SDNCSvcAction.ASSIGN,
61                 GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE, serviceInstance,
62                 requestContext, customer, vnrConfiguration, voiceVnf, sdncRequestId, callbackUri);
63     }
64
65     /**
66      * SDNC Call to Activate VNR Configuration
67      *
68      * @param serviceInstance
69      * @param requestContext
70      * @param vnrConfiguration
71      * @param voiceVnf
72      * @return
73      * @throws MapperException
74      * @throws BadResponseException
75      */
76     public GenericResourceApiGcTopologyOperationInformation activateVnrConfiguration(ServiceInstance serviceInstance,
77             RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf,
78             String sdncRequestId, URI callbackUri) throws MapperException, BadResponseException {
79         return sdncRM.assignOrActivateVnrReqMapper(SDNCSvcAction.ACTIVATE,
80                 GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE, serviceInstance,
81                 requestContext, customer, vnrConfiguration, voiceVnf, sdncRequestId, callbackUri);
82     }
83
84     /**
85      * method to unAssign Vnr Configuration in SDNC
86      *
87      * @param serviceInstance
88      * @param requestContext
89      * @param vnrConfiguration
90      * @return
91      * @throws BadResponseException
92      * @throws MapperException
93      */
94     public GenericResourceApiGcTopologyOperationInformation unAssignVnrConfiguration(ServiceInstance serviceInstance,
95             RequestContext requestContext, Configuration vnrConfiguration, String sdncRequestId, URI callbackUri)
96             throws BadResponseException, MapperException {
97         return sdncRM.deactivateOrUnassignVnrReqMapper(SDNCSvcAction.UNASSIGN, serviceInstance, requestContext,
98                 vnrConfiguration, sdncRequestId, callbackUri);
99     }
100
101     /***
102      * Deactivate VNR SDNC Call
103      * 
104      * @param serviceInstance
105      * @param requestContext
106      * @param vnrConfiguration
107      * @throws BadResponseException
108      * @throws MapperException
109      */
110     public GenericResourceApiGcTopologyOperationInformation deactivateVnrConfiguration(ServiceInstance serviceInstance,
111             RequestContext requestContext, Configuration vnrConfiguration, String sdncRequestId, URI callbackUri)
112             throws BadResponseException, MapperException {
113         return sdncRM.deactivateOrUnassignVnrReqMapper(SDNCSvcAction.DEACTIVATE, serviceInstance, requestContext,
114                 vnrConfiguration, sdncRequestId, callbackUri);
115     }
116 }