Enhancing SO SDC Controller to invoke ONAP-ETSI Catalog APIs
[so.git] / common / src / main / java / org / onap / so / rest / service / HttpRestServiceProvider.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.rest.service;
22
23 import com.google.common.base.Optional;
24 import org.springframework.http.HttpHeaders;
25 import org.springframework.http.ResponseEntity;
26
27 /**
28  * @author waqas.ikram@est.tech
29  */
30 public interface HttpRestServiceProvider {
31
32     /**
33      * Execute the HTTP GET to the given URI template
34      *
35      * @param url the URL
36      * @param clazz the type of the return value
37      * @return Returns the body of this entity.
38      */
39     <T> Optional<T> get(final String url, final Class<T> clazz);
40
41     /**
42      * Execute the HTTP GET to the given URI template
43      * 
44      * @param url the URL
45      * @param headers request headers
46      * @param clazz the type of the return value
47      * @return Returns the body of this entity.
48      */
49     <T> Optional<T> get(final String url, final HttpHeaders headers, final Class<T> clazz);
50
51     /**
52      * Execute the HTTP GET to the given URI template
53      *
54      * @param url the URL
55      * @param clazz the type of the return value
56      * @return Returns the {@link ResponseEntity}.
57      */
58     <T> ResponseEntity<T> getHttpResponse(final String url, final Class<T> clazz);
59
60     /**
61      * Execute the HTTP GET to the given URI template
62      *
63      * @param url the URL
64      * @param headers request headers
65      * @param clazz the type of the return value
66      * @return Returns the {@link ResponseEntity}.
67      */
68     <T> ResponseEntity<T> getHttpResponse(final String url, final HttpHeaders headers, final Class<T> clazz);
69
70     /**
71      * Execute the HTTP POST to the given URI template
72      *
73      * @param object the entity (i.e. body) to write to the request
74      * @param url the URL
75      * @param clazz the type of the return value
76      * @return Returns the body of this entity.
77      */
78     <T> Optional<T> post(final Object object, final String url, final Class<T> clazz);
79
80     /**
81      * Execute the HTTP POST to the given URI template
82      *
83      * @param object the entity (i.e. body) to write to the request
84      * @param url the URL
85      * @param clazz the type of the return value
86      * @return Returns the {@link ResponseEntity}.
87      */
88     <T> ResponseEntity<T> postHttpRequest(final Object object, final String url, final Class<T> clazz);
89
90     /**
91      * Execute the HTTP POST to the given URI template
92      *
93      * @param object the entity (i.e. body) to write to the request
94      * @param url the URL
95      * @param clazz the type of the return value
96      * @param headers request headers
97      * @return Returns the {@link ResponseEntity}.
98      */
99     <T> ResponseEntity<T> postHttpRequest(final Object object, final String url, final HttpHeaders headers,
100             final Class<T> clazz);
101
102     /**
103      * Execute the HTTP PUT to the given URI template
104      *
105      * @param object the entity (i.e. body) to write to the request
106      * @param url the URL
107      * @param clazz the type of the return value
108      * @return Returns the body of this entity.
109      */
110     <T> Optional<T> put(final Object object, final String url, final Class<T> clazz);
111
112     /**
113      * Execute the HTTP PUT to the given URI template
114      *
115      * @param object the entity (i.e. body) to write to the request
116      * @param url the URL
117      * @param clazz the type of the return value
118      * @return Returns the {@link ResponseEntity}.
119      */
120     <T> ResponseEntity<T> putHttpRequest(final Object object, final String url, final Class<T> clazz);
121
122     /**
123      * Execute the HTTP DELETE to the given URI template
124      *
125      * @param url the URL
126      * @param clazz the type of the return value
127      * @return Returns the {@link ResponseEntity}.
128      */
129     public <T> ResponseEntity<T> deleteHttpRequest(final String url, final Class<T> clazz);
130
131
132 }