dbc42912e15c5c673300f668de1525d84494ff82
[dcaegen2/services.git] / components / slice-analysis-ms / src / main / java / org / onap / slice / analysis / ms / restclients / ConfigDbRestClient.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  slice-analysis-ms
4  *  ================================================================================
5  *   Copyright (C) 2020 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 config db interfaces
34  */
35 @Component
36 public class ConfigDbRestClient extends RestClient {
37
38         public ConfigDbRestClient() {
39                 super();
40         }
41
42         /**
43          * Send Post Request to Config DB.
44          */
45
46         public <T> ResponseEntity<T> sendPostRequest(String requestUrl, String requestBody,
47                         ParameterizedTypeReference<T> responseType) {
48                 HttpHeaders headers = new HttpHeaders();
49                 headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
50                 headers.setContentType(MediaType.APPLICATION_JSON);
51                 return super.sendPostRequest(headers, requestUrl, requestBody, responseType);
52         }
53
54         /**
55          * Send Get Request to Config DB.
56          */
57
58         public <T> ResponseEntity<T> sendGetRequest(String requestUrl, ParameterizedTypeReference<T> responseType) {
59                 HttpHeaders headers = new HttpHeaders();
60                 headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
61                 headers.setContentType(MediaType.APPLICATION_JSON);
62                 return super.sendGetRequest(headers, requestUrl, responseType);
63         }
64 }