9dc03ecb88d65308bac7c3b2561ae187e5a54fcb
[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
38 import java.net.URI;
39
40 import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
41 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
42
43 @Component
44 public class SDNCConfigurationResources {
45         @Autowired
46         private GCTopologyOperationRequestMapper sdncRM;
47
48         /**
49          * SDN-C call to assign configuration after it was created in A&AI
50          *
51          * @param serviceInstance
52          * @param requestContext
53          * @param vnrConfiguration
54          * @param voiceVnf
55          * @return
56          * @throws MapperException
57          * @throws BadResponseException
58          */
59         public GenericResourceApiGcTopologyOperationInformation assignVnrConfiguration(ServiceInstance serviceInstance,
60                         RequestContext requestContext,
61                         Customer customer,
62                         Configuration vnrConfiguration,
63                         GenericVnf voiceVnf, String sdncRequestId, URI callbackUri)
64                                         throws MapperException, BadResponseException {
65                 return sdncRM.assignOrActivateVnrReqMapper(
66                                 SDNCSvcAction.ASSIGN,
67                                 GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE ,
68                                 serviceInstance , requestContext, customer, vnrConfiguration,voiceVnf,sdncRequestId,callbackUri);      
69         }
70
71         /**
72          * SDNC Call to Activate VNR Configuration
73          *
74          * @param serviceInstance
75          * @param requestContext
76          * @param vnrConfiguration
77          * @param voiceVnf
78          * @return
79          * @throws MapperException
80          * @throws BadResponseException
81          */
82         public GenericResourceApiGcTopologyOperationInformation activateVnrConfiguration(ServiceInstance serviceInstance,
83                         RequestContext requestContext,
84                         Customer customer,
85                         Configuration vnrConfiguration,
86                         GenericVnf voiceVnf, String sdncRequestId, URI callbackUri)
87                                         throws MapperException, BadResponseException {
88                 return sdncRM.assignOrActivateVnrReqMapper(
89                                 SDNCSvcAction.ACTIVATE,
90                                 GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE,
91                                 serviceInstance , requestContext, customer, vnrConfiguration, voiceVnf,sdncRequestId,callbackUri);      
92         }
93
94         /**
95          * method to unAssign Vnr Configuration in SDNC
96          *
97          * @param serviceInstance
98          * @param requestContext
99          * @param vnrConfiguration
100          * @return
101          * @throws BadResponseException
102          * @throws MapperException
103          */
104         public GenericResourceApiGcTopologyOperationInformation unAssignVnrConfiguration(ServiceInstance serviceInstance, RequestContext requestContext,
105                         Configuration vnrConfiguration, String sdncRequestId, URI callbackUri) throws BadResponseException, MapperException {
106                 return sdncRM.deactivateOrUnassignVnrReqMapper
107                                 (SDNCSvcAction.UNASSIGN,serviceInstance, requestContext, vnrConfiguration,sdncRequestId,callbackUri);        
108         }
109
110         /***
111          *  Deactivate VNR SDNC Call
112          * @param serviceInstance
113          * @param requestContext
114          * @param vnrConfiguration
115          * @throws BadResponseException
116          * @throws MapperException
117          */
118         public GenericResourceApiGcTopologyOperationInformation deactivateVnrConfiguration(ServiceInstance serviceInstance, RequestContext requestContext, Configuration vnrConfiguration, String sdncRequestId, URI callbackUri) throws BadResponseException, MapperException {
119                 return sdncRM.deactivateOrUnassignVnrReqMapper(
120                                 SDNCSvcAction.DEACTIVATE,
121                                 serviceInstance , requestContext, vnrConfiguration,sdncRequestId,callbackUri);     
122         }
123 }