7c8ab89c1eae2c3e47abbf1a82ead4b2747d081a
[vid.git] / vid-app-common / src / main / java / org / onap / vid / mso / MsoInterface.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2018 Nokia. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.vid.mso;
22
23 import com.fasterxml.jackson.core.JsonProcessingException;
24 import io.joshworks.restclient.http.HttpResponse;
25 import io.joshworks.restclient.http.mapper.ObjectMapper;
26 import org.onap.vid.aai.util.CustomJacksonJaxBJsonProvider;
27 import org.onap.vid.changeManagement.RequestDetailsWrapper;
28 import org.onap.vid.mso.rest.RequestDetails;
29
30 import java.io.IOException;
31
32 /**
33  * Created by pickjonathan on 21/06/2017.
34  */
35 public interface MsoInterface {
36
37     /**
38      * This function will post MSO service with information about how to instantiate the requested service
39      * @param requestDetails The details about the service as they come from the web.
40      * @return MsoResponseWrapper containing information about the service instantiation
41      * --> success : see JSON at resources folder mso_create_instance_response.
42      * --> failure : would return 200 with failure data.
43      * @throws Exception
44      */
45     MsoResponseWrapper createSvcInstance(RequestDetails requestDetails, String endpoint);
46     
47     //For VoLTE E2E services
48     MsoResponseWrapper createE2eSvcInstance(Object requestDetails, String endpoint);
49     MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String endpoint);
50
51     /**
52      * will create a virtual network function using MSO service.
53      * @param requestDetails - information about the vnf to create
54      * @return - the response body recived from MSO
55      * @throws Exception
56      */
57     MsoResponseWrapper createVnf(RequestDetails requestDetails, String endpoint);
58
59     MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String endpoint);
60     /**
61      *
62      * @param requestDetails
63      * @param path
64      * @return
65      * @throws Exception
66      */
67     MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String path);
68
69     /**
70      *
71      * @param requestDetails
72      * @return
73      * @throws Exception
74      */
75     MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String endpoint);
76
77     MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint);
78
79     MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint);
80
81     MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint);
82
83     MsoResponseWrapper unassignSvcInstance(RequestDetails requestDetails, String endpoint);
84
85     MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String endpoint);
86
87     MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String endpoint);
88
89     MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String endpoint);
90
91     MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint);
92
93     MsoResponseWrapper getOrchestrationRequest(String endpoint);
94
95     MsoResponseWrapper getOrchestrationRequestsForDashboard(String t , String sourceId , String endpoint , RestObject restObject);
96
97     MsoResponseWrapper getManualTasksByRequestId(String t , String sourceId , String endpoint , RestObject restObject);
98
99     MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject);
100
101         MsoResponseWrapper updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String vnf_endpoint);
102
103         MsoResponseWrapper replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String vnf_endpoint);
104
105     MsoResponseWrapper deleteConfiguration(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String pmc_endpoint);
106
107     MsoResponseWrapper setConfigurationActiveStatus(RequestDetails requestDetails, String endpoint);
108
109     MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails requestDetails, String endpoint);
110
111     void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject);
112
113     MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint);
114
115     MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String endpoint);
116
117     MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath);
118
119     <T> HttpResponse<T> get(String path, Class<T> responseClass);
120
121     <T> HttpResponse<T> post(String path, RequestDetailsWrapper<?> requestDetailsWrapper,
122       Class<T> responseClass);
123
124     static ObjectMapper objectMapper() {
125       return new ObjectMapper() {
126         CustomJacksonJaxBJsonProvider mapper = new CustomJacksonJaxBJsonProvider();
127
128         @Override
129         public <T> T readValue(String s, Class<T> aClass) {
130             try {
131                 return mapper.getMapper().readValue(s, aClass);
132             } catch (IOException e) {
133                 throw new MsoException(e);
134             }
135         }
136
137         @Override
138         public String writeValue(Object o) {
139             try {
140                 return mapper.getMapper().writeValueAsString(o);
141             } catch (JsonProcessingException e) {
142                 throw new MsoException(e);
143             }
144         }
145       };
146     }
147 }
148