1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2021 Wipro Limited.
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=========================================================
20 *******************************************************************************/
22 package org.onap.slice.analysis.ms.restclients;
24 import java.util.Collections;
26 import org.springframework.core.ParameterizedTypeReference;
27 import org.springframework.http.HttpHeaders;
28 import org.springframework.http.MediaType;
29 import org.springframework.http.ResponseEntity;
30 import org.springframework.stereotype.Component;
33 * This class represents rest client for AAI interfaces
36 public class AaiRestClient extends RestClient {
38 public AaiRestClient() {
42 public <T> ResponseEntity<T> sendPostRequest(String requestUrl, String requestBody,
43 ParameterizedTypeReference<T> responseType) {
44 HttpHeaders headers = new HttpHeaders();
45 headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
46 headers.setContentType(MediaType.APPLICATION_JSON);
47 return super.sendPostRequest(headers, requestUrl, requestBody, responseType);
50 public <T> ResponseEntity<T> sendGetRequest(String requestUrl, ParameterizedTypeReference<T> responseType) {
51 HttpHeaders headers = new HttpHeaders();
52 headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
53 headers.setContentType(MediaType.APPLICATION_JSON);
54 headers.set("X-FromAppId", "AAI");
55 headers.set("X-TransactionId", "get_aai_subscr");
56 return super.sendGetRequest(headers, requestUrl, responseType);