re base code
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / utils / rest / CatalogRestUtils.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 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 org.openecomp.sdc.ci.tests.api.Urls;
24 import org.openecomp.sdc.ci.tests.config.Config;
25 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
27 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
28 import org.openecomp.sdc.ci.tests.utils.Utils;
29
30 import java.io.IOException;
31 import java.util.HashMap;
32 import java.util.Map;
33
34 public class CatalogRestUtils extends BaseRestUtils {
35
36         public static RestResponse getAbstractResources() throws IOException {
37
38                 Config config = Utils.getConfig();
39                 String url = String.format(Urls.GET_ALL_ABSTRACT_RESOURCES, config.getCatalogBeHost(),
40                                 config.getCatalogBePort());
41
42                 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
43         }
44
45         public static RestResponse getCatalog() throws IOException {
46                 return getCatalog(UserRoleEnum.DESIGNER.getUserId());
47         }
48
49         public static RestResponse getCatalog(String userId) throws IOException {
50                 Config config = Utils.getConfig();
51                 String url = String.format(Urls.GET_CATALOG_DATA, config.getCatalogBeHost(), config.getCatalogBePort());
52                 return sendGet(url, userId);
53         }
54
55         public static RestResponse getAllCategoriesTowardsCatalogBe() throws IOException {
56
57                 Config config = Utils.getConfig();
58                 String url = String.format(Urls.GET_ALL_CATEGORIES, config.getCatalogBeHost(), config.getCatalogBePort(),
59                                 BaseRestUtils.RESOURCE_COMPONENT_TYPE);
60
61                 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
62         }
63
64         public static RestResponse getAllCategoriesTowardsCatalogFeWithUuid(String uuid) throws IOException {
65
66                 Config config = Utils.getConfig();
67                 String url = String.format(Urls.GET_ALL_CATEGORIES_FE, config.getCatalogFeHost(), config.getCatalogFePort(),
68                                 BaseRestUtils.RESOURCE_COMPONENT_TYPE);
69
70                 Map<String, String> additionalHeaders = new HashMap<>();
71                 additionalHeaders.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(), uuid);
72
73                 return sendGet(url, UserRoleEnum.DESIGNER.getUserId(), additionalHeaders);
74         }
75         
76         public static RestResponse getOnboardVersion() throws IOException {
77
78                 Config config = Utils.getConfig();
79                 String url = String.format(Urls.ONBOARD_VERSION, config.getCatalogBeHost(),
80                                 config.getCatalogBePort());
81
82                 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
83         }
84         
85         public static RestResponse getOsVersion() throws IOException {
86
87                 Config config = Utils.getConfig();
88                 String url = String.format(Urls.OS_VERSION, config.getCatalogBeHost(), config.getCatalogBePort());
89
90                 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
91         }
92 }