62e39ad52599b9a62c4cc40134031f98507bb275
[dcaegen2/services.git] /
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  slice-analysis-ms
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
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
22 package org.onap.slice.analysis.ms.restclients;
23
24 import java.util.Collections;
25
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;
31
32 /**
33  * This class represents rest client for AAI interfaces
34  */
35 @Component
36 public class AaiRestClient extends RestClient {
37
38         public AaiRestClient() {
39                 super();
40         }
41
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);
48         }
49
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);
57         }
58 }
59