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;
25 import java.util.List;
27 import org.openecomp.sdc.be.model.User;
28 import org.openecomp.sdc.ci.tests.api.Urls;
29 import org.openecomp.sdc.ci.tests.config.Config;
30 import org.openecomp.sdc.ci.tests.datatypes.ServiceFilterDetails;
31 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 public class ServiceFilterUtils extends BaseRestUtils {
37 private static Logger logger = LoggerFactory.getLogger(ServiceFilterUtils.class.getName());
39 private static Gson gson = new Gson();
41 public static RestResponse createServiceFilter(String externalServiceId, String proxyServiceId,
42 ServiceFilterDetails serviceFilterDetails,
43 User user) throws Exception{
44 Config config = Config.instance();
46 String url = String.format(Urls.CREATE_SERVICE_FILTER, config.getCatalogBeHost(), config.getCatalogBePort(),
47 externalServiceId, proxyServiceId);
49 return sendPost(url, gson.toJson(serviceFilterDetails), user.getUserId(), acceptHeaderData);
52 public static RestResponse updateServiceFilter(String externalServiceId, String proxyServiceId,
53 List<ServiceFilterDetails> serviceFilterDetailsList,
54 User user) throws Exception{
55 Config config = Config.instance();
57 String url = String.format(Urls.UPDATE_SERVICE_FILTER, config.getCatalogBeHost(), config.getCatalogBePort(),
58 externalServiceId, proxyServiceId);
60 return sendPut(url, gson.toJson(serviceFilterDetailsList), user.getUserId(), acceptHeaderData);
63 public static RestResponse deleteServiceFilter(String externalServiceId, String proxyServiceId,
65 User user) throws Exception{
66 Config config = Config.instance();
68 String url = String.format(Urls.DELETE_SERVICE_FILTER, config.getCatalogBeHost(), config.getCatalogBePort(),
69 externalServiceId, proxyServiceId, constraintIndex);
71 return sendDelete(url, user.getUserId());