@InterfaceAudience.Public @InterfaceStability.Experimental public class AsyncRestBuilder extends Object implements RestBuilderMarker
| Constructor and Description |
|---|
AsyncRestBuilder(String username,
String password,
ClusterFacade core,
com.couchbase.client.deps.io.netty.handler.codec.http.HttpMethod method,
String path) |
| Modifier and Type | Method and Description |
|---|---|
AsyncRestBuilder |
accept(String type)
Sets the "Accept" standard header's value.
|
RestApiRequest |
asRequest() |
String |
body() |
AsyncRestBuilder |
body(JsonValue jsonBody)
Sets the body for the request, assuming it is JSON.
|
AsyncRestBuilder |
body(String jsonBody)
Sets the body for the request, assuming it is JSON.
|
AsyncRestBuilder |
bodyForm(Form form)
Sets the body for the request to be an url-encoded form.
|
AsyncRestBuilder |
bodyRaw(String body)
Sets the body for the request without assuming a Content-Type or Accept header.
|
AsyncRestBuilder |
contentType(String type)
Sets the "Content-Type" standard header's value.
|
rx.Observable<RestApiResponse> |
execute()
Executes the API request in an asynchronous fashion.
|
Map<String,Object> |
headers() |
com.couchbase.client.deps.io.netty.handler.codec.http.HttpMethod |
method() |
Map<String,String> |
params() |
String |
path() |
AsyncRestBuilder |
withHeader(String key,
Object value)
Adds an HTTP header to the request.
|
AsyncRestBuilder |
withParam(String key,
String value)
Adds an URL query parameter to the request.
|
public AsyncRestBuilder(String username, String password, ClusterFacade core, com.couchbase.client.deps.io.netty.handler.codec.http.HttpMethod method, String path)
username - the username to authenticate the request with.password - the password to authenticate the request with.core - the core through which to send the request.method - the HttpMethod for the request.path - the full URL path for the request.public AsyncRestBuilder withParam(String key, String value)
key - the parameter key.value - the parameter value.public AsyncRestBuilder withHeader(String key, Object value)
key - the header name (see "HttpHeaders.Names" for standard names).value - the header value (see "HttpHeaders.Values" for standard values).public AsyncRestBuilder bodyRaw(String body)
body - the raw body value to use, as a String.public AsyncRestBuilder contentType(String type)
withHeader("Content-Type", type).type - the "Content-Type" to use.public AsyncRestBuilder accept(String type)
withHeader("Accept", type).type - the "Accept" type to use.public AsyncRestBuilder body(String jsonBody)
"Content-Type" to "application/json"
and then setting the body via bodyRaw(String).
Note that you should avoid calling this for HTTP methods where it makes no sense
(eg. GET, DELETE), as it won't be ignored for these types of requests.jsonBody - the JSON body to use, as a String.public AsyncRestBuilder body(JsonValue jsonBody)
"Content-Type" to "application/json"
and then setting the body via bodyRaw(String).
Note that you should avoid calling this for HTTP methods where it makes no sense
(eg. GET, DELETE), as it won't be ignored for these types of requests.jsonBody - the JSON body to use, as a JsonObject.public AsyncRestBuilder bodyForm(Form form)
"Content-Type" to "application/x-www-form-urlencoded"
and then setting the body via bodyRaw(String).form - the Form builder object used to set form parameters.public com.couchbase.client.deps.io.netty.handler.codec.http.HttpMethod method()
HttpMethod used for this request.public String path()
public String body()
public Map<String,String> params()
public Map<String,Object> headers()
public RestApiRequest asRequest()
RestApiRequest message sent through the ClusterFacade
when executing this request.public rx.Observable<RestApiResponse> execute()
Observable that will only emit the result of executing the request.
It is a cold Observable (and the request is only sent when it is subscribed to).Observable of the result of the API call, which is a RestApiResponse.Copyright © 2015 Couchbase, Inc.