Interface operation feature enhancements
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / utils / rest / InterfaceOperationsRestUtils.java
1 package org.openecomp.sdc.ci.tests.utils.rest;
2
3 import com.google.gson.Gson;
4 import java.io.IOException;
5 import java.util.Map;
6 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
7 import org.openecomp.sdc.be.model.Component;
8 import org.openecomp.sdc.be.model.User;
9 import org.openecomp.sdc.ci.tests.api.Urls;
10 import org.openecomp.sdc.ci.tests.config.Config;
11 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
12 import org.openecomp.sdc.ci.tests.utils.Utils;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 public class InterfaceOperationsRestUtils extends BaseRestUtils {
17
18     @SuppressWarnings("unused")
19     private static Logger logger = LoggerFactory.getLogger(InterfaceOperationsRestUtils.class.getName());
20
21     public static RestResponse addInterfaceOperations(Component component, Map<String, Object> interfaceDefinitionMap,
22             User user) throws IOException {
23         Config config = Utils.getConfig();
24         String url = String.format(Urls.ADD_INTERFACE_OPERATIONS, config.getCatalogBeHost(), config.getCatalogBePort(),
25                 ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId());
26         String jsonBody = new Gson().toJson(interfaceDefinitionMap);
27         return sendPost(url, jsonBody, user.getUserId(), acceptHeaderData);
28     }
29
30     public static RestResponse updateInterfaceOperations(Component component,
31             Map<String, Object> interfaceDefinitionMap, User user) throws IOException {
32         Config config = Utils.getConfig();
33         String url =
34                 String.format(Urls.UPDATE_INTERFACE_OPERATIONS, config.getCatalogBeHost(), config.getCatalogBePort(),
35                         ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId());
36         String jsonBody = new Gson().toJson(interfaceDefinitionMap);
37         return sendPut(url, jsonBody, user.getUserId(), acceptHeaderData);
38     }
39
40     public static RestResponse getInterfaceOperations(Component component, String interfaceId, String operationIds,
41             User user) throws IOException {
42         Config config = Utils.getConfig();
43         String url = String.format(Urls.GET_INTERFACE_OPERATIONS, config.getCatalogBeHost(), config.getCatalogBePort(),
44                 ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId(), interfaceId,
45                 operationIds);
46         return sendGet(url, user.getUserId());
47     }
48
49     public static RestResponse deleteInterfaceOperations(Component component, String interfaceId, String operationIds,
50             User user) throws IOException {
51         Config config = Utils.getConfig();
52         String url =
53                 String.format(Urls.DELETE_INTERFACE_OPERATIONS, config.getCatalogBeHost(), config.getCatalogBePort(),
54                         ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId(),
55                         interfaceId, operationIds);
56         return sendDelete(url, user.getUserId());
57     }
58
59 }