1 package org.openecomp.sdc.ci.tests.utils.rest;
3 import com.google.gson.Gson;
4 import java.io.IOException;
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;
16 public class InterfaceOperationsRestUtils extends BaseRestUtils {
18 @SuppressWarnings("unused")
19 private static Logger logger = LoggerFactory.getLogger(InterfaceOperationsRestUtils.class.getName());
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);
30 public static RestResponse updateInterfaceOperations(Component component,
31 Map<String, Object> interfaceDefinitionMap, User user) throws IOException {
32 Config config = Utils.getConfig();
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);
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,
46 return sendGet(url, user.getUserId());
49 public static RestResponse deleteInterfaceOperations(Component component, String interfaceId, String operationIds,
50 User user) throws IOException {
51 Config config = Utils.getConfig();
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());