Package com.ibm.cloud.sdk.core.http
Interface ServiceCall<T>
-
- Type Parameters:
T
- the generic type
public interface ServiceCall<T>
Service Call.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ServiceCall<T>
addHeader(java.lang.String name, java.lang.String value)
Add a header to the request before executing.void
cancel()
Cancel the current request if possible.void
enqueue(ServiceCallback<T> callback)
Asynchronous request with added HTTP information.Response<T>
execute()
Synchronous request.io.reactivex.Single<Response<T>>
reactiveRequest()
Reactive request using the RxJava 2 library.
-
-
-
Method Detail
-
addHeader
ServiceCall<T> addHeader(java.lang.String name, java.lang.String value)
Add a header to the request before executing.- Parameters:
name
- the name of the headervalue
- the value of the header- Returns:
- the ServiceCall with updated headers
-
execute
Response<T> execute() throws java.lang.RuntimeException
Synchronous request.- Returns:
- a Response object with the generic response model and various HTTP information fields
- Throws:
java.lang.RuntimeException
- the exception from HTTP request
-
enqueue
void enqueue(ServiceCallback<T> callback)
Asynchronous request with added HTTP information. In this case, you receive a callback when the data has been received.- Parameters:
callback
- the callback
-
reactiveRequest
io.reactivex.Single<Response<T>> reactiveRequest()
Reactive request using the RxJava 2 library. See https://github.com/ReactiveX/RxJava. In addition, the wrapped service call will contain added HTTP information.- Returns:
- a Single object containing the service call to be observed/subscribed to
-
cancel
void cancel()
Cancel the current request if possible.
-
-