Class AsyncRestBuilder

    • Constructor Detail

      • AsyncRestBuilder

        public AsyncRestBuilder​(String username,
                                String password,
                                ClusterFacade core,
                                com.couchbase.client.deps.io.netty.handler.codec.http.HttpMethod method,
                                String path)
        Parameters:
        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.
    • Method Detail

      • withParam

        public AsyncRestBuilder withParam​(String key,
                                          String value)
        Adds an URL query parameter to the request. Using a key twice will result in the last call being taken into account.
        Parameters:
        key - the parameter key.
        value - the parameter value.
      • withHeader

        public AsyncRestBuilder withHeader​(String key,
                                           Object value)
        Adds an HTTP header to the request. Using a key twice will result in the last value being used for a given header.
        Parameters:
        key - the header name (see "HttpHeaders.Names" for standard names).
        value - the header value (see "HttpHeaders.Values" for standard values).
      • bodyRaw

        public AsyncRestBuilder bodyRaw​(String body)
        Sets the body for the request without assuming a Content-Type or Accept header. 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.
        Parameters:
        body - the raw body value to use, as a String.
      • body

        public AsyncRestBuilder body​(String jsonBody)
        Sets the body for the request, assuming it is JSON. This is equivalent to setting the "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.
        Parameters:
        jsonBody - the JSON body to use, as a String.
      • body

        public AsyncRestBuilder body​(JsonValue jsonBody)
        Sets the body for the request, assuming it is JSON. This is equivalent to setting the "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.
        Parameters:
        jsonBody - the JSON body to use, as a JsonObject.
      • bodyForm

        public AsyncRestBuilder bodyForm​(Form form)
        Sets the body for the request to be an url-encoded form. This is equivalent to setting the "Content-Type" to "application/x-www-form-urlencoded" and then setting the body via bodyRaw(String).
        Parameters:
        form - the Form builder object used to set form parameters.
      • method

        public com.couchbase.client.deps.io.netty.handler.codec.http.HttpMethod method()
        Returns:
        the HttpMethod used for this request.
      • path

        public String path()
        Returns:
        the full HTTP path (minus query parameters) used for this request.
      • body

        public String body()
        Returns:
        the body used for this request.
      • params

        public Map<String,​String> params()
        Returns:
        a copy of the query parameters used for this request.
      • headers

        public Map<String,​Object> headers()
        Returns:
        a copy of the HTTP headers used for this request.
      • execute

        public rx.Observable<RestApiResponse> execute()
        Executes the API request in an asynchronous fashion. The return type is an 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).
        Returns:
        an Observable of the result of the API call, which is a RestApiResponse.