2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.ci.tests.utils.rest;
23 import com.google.gson.Gson;
24 import java.io.IOException;
26 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
27 import org.openecomp.sdc.be.model.Component;
28 import org.openecomp.sdc.be.model.User;
29 import org.openecomp.sdc.ci.tests.api.Urls;
30 import org.openecomp.sdc.ci.tests.config.Config;
31 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
32 import org.openecomp.sdc.ci.tests.utils.Utils;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class InterfaceOperationsRestUtils extends BaseRestUtils {
38 @SuppressWarnings("unused")
39 private static Logger logger = LoggerFactory.getLogger(InterfaceOperationsRestUtils.class.getName());
41 public static RestResponse addInterfaceOperations(Component component, Map<String, Object> interfaceDefinitionMap,
42 User user) throws IOException {
43 Config config = Utils.getConfig();
44 String url = String.format(Urls.ADD_INTERFACE_OPERATIONS, config.getCatalogBeHost(), config.getCatalogBePort(),
45 ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId());
46 String jsonBody = new Gson().toJson(interfaceDefinitionMap);
47 return sendPost(url, jsonBody, user.getUserId(), acceptHeaderData);
50 public static RestResponse updateInterfaceOperations(Component component,
51 Map<String, Object> interfaceDefinitionMap, User user) throws IOException {
52 Config config = Utils.getConfig();
54 String.format(Urls.UPDATE_INTERFACE_OPERATIONS, config.getCatalogBeHost(), config.getCatalogBePort(),
55 ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId());
56 String jsonBody = new Gson().toJson(interfaceDefinitionMap);
57 return sendPut(url, jsonBody, user.getUserId(), acceptHeaderData);
60 public static RestResponse getInterfaceOperations(Component component, String interfaceId, String operationIds,
61 User user) throws IOException {
62 Config config = Utils.getConfig();
63 String url = String.format(Urls.GET_INTERFACE_OPERATIONS, config.getCatalogBeHost(), config.getCatalogBePort(),
64 ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId(), interfaceId,
66 return sendGet(url, user.getUserId());
69 public static RestResponse deleteInterfaceOperations(Component component, String interfaceId, String operationIds,
70 User user) throws IOException {
71 Config config = Utils.getConfig();
73 String.format(Urls.DELETE_INTERFACE_OPERATIONS, config.getCatalogBeHost(), config.getCatalogBePort(),
74 ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId(),
75 interfaceId, operationIds);
76 return sendDelete(url, user.getUserId());