2 * ============LICENSE_START=======================================================
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
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 java.io.IOException;
26 import org.openecomp.sdc.ci.tests.api.Urls;
27 import org.openecomp.sdc.ci.tests.config.Config;
28 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
29 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
30 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
31 import org.openecomp.sdc.ci.tests.utils.Utils;
33 public class CatalogRestUtils extends BaseRestUtils {
35 public static RestResponse getAbstractResources() throws IOException {
37 Config config = Utils.getConfig();
38 String url = String.format(Urls.GET_ALL_ABSTRACT_RESOURCES, config.getCatalogBeHost(),
39 config.getCatalogBePort());
41 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
44 public static RestResponse getCatalog() throws IOException {
45 return getCatalog(UserRoleEnum.DESIGNER.getUserId());
48 public static RestResponse getCatalog(String userId) throws IOException {
49 Config config = Utils.getConfig();
50 String url = String.format(Urls.GET_CATALOG_DATA, config.getCatalogBeHost(), config.getCatalogBePort());
51 return sendGet(url, userId);
54 public static RestResponse getAllCategoriesTowardsCatalogBe() throws IOException {
56 Config config = Utils.getConfig();
57 String url = String.format(Urls.GET_ALL_CATEGORIES, config.getCatalogBeHost(), config.getCatalogBePort(),
58 BaseRestUtils.RESOURCE_COMPONENT_TYPE);
60 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
63 public static RestResponse getAllCategoriesTowardsCatalogFeWithUuid(String uuid) throws IOException {
65 Config config = Utils.getConfig();
66 String url = String.format(Urls.GET_ALL_CATEGORIES_FE, config.getCatalogFeHost(), config.getCatalogFePort(),
67 BaseRestUtils.RESOURCE_COMPONENT_TYPE);
69 Map<String, String> additionalHeaders = new HashMap<String, String>();
70 additionalHeaders.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(), uuid);
72 return sendGet(url, UserRoleEnum.DESIGNER.getUserId(), additionalHeaders);
75 public static RestResponse getOnboardVersion() throws IOException {
77 Config config = Utils.getConfig();
78 String url = String.format(Urls.ONBOARD_VERSION, config.getCatalogBeHost(),
79 config.getCatalogBePort());
81 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
84 public static RestResponse getOsVersion() throws IOException {
86 Config config = Utils.getConfig();
87 String url = String.format(Urls.OS_VERSION, config.getCatalogBeHost(),
88 config.getCatalogBePort());
90 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());