Added oparent to sdc main
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / utils / rest / ServiceFilterUtils.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.utils.rest;
22
23 import com.google.gson.Gson;
24
25 import java.util.List;
26
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;
34
35 public class ServiceFilterUtils extends BaseRestUtils {
36
37     private static Logger logger = LoggerFactory.getLogger(ServiceFilterUtils.class.getName());
38
39     private static Gson gson = new Gson();
40
41     public static RestResponse createServiceFilter(String externalServiceId, String proxyServiceId,
42                                                    ServiceFilterDetails serviceFilterDetails,
43                                                    User user) throws Exception{
44         Config config = Config.instance();
45
46         String url = String.format(Urls.CREATE_SERVICE_FILTER, config.getCatalogBeHost(), config.getCatalogBePort(),
47                 externalServiceId, proxyServiceId);
48
49         return sendPost(url, gson.toJson(serviceFilterDetails), user.getUserId(), acceptHeaderData);
50     }
51
52     public static RestResponse updateServiceFilter(String externalServiceId, String proxyServiceId,
53                                                    List<ServiceFilterDetails> serviceFilterDetailsList,
54                                                    User user) throws Exception{
55         Config config = Config.instance();
56
57         String url = String.format(Urls.UPDATE_SERVICE_FILTER, config.getCatalogBeHost(), config.getCatalogBePort(),
58                 externalServiceId, proxyServiceId);
59
60         return sendPut(url, gson.toJson(serviceFilterDetailsList), user.getUserId(), acceptHeaderData);
61     }
62
63     public static RestResponse deleteServiceFilter(String externalServiceId, String proxyServiceId,
64                                                    int constraintIndex,
65                                                    User user) throws Exception{
66         Config config = Config.instance();
67
68         String url = String.format(Urls.DELETE_SERVICE_FILTER, config.getCatalogBeHost(), config.getCatalogBePort(),
69                 externalServiceId, proxyServiceId, constraintIndex);
70
71         return sendDelete(url, user.getUserId());
72     }
73 }