org.springframework.web.client
Interface RestOperations

All Known Implementing Classes:
RestTemplate

public interface RestOperations

Interface specifying a basic set of RESTful operations. Implemented by RestTemplate. Not often used directly, but a useful option to enhance testability, as it can easily be mocked or stubbed.

Since:
3.0
Author:
Arjen Poutsma, Juergen Hoeller
See Also:
RestTemplate

Method Summary
 void delete(java.lang.String url, java.util.Map<java.lang.String,?> uriVariables)
          Delete the resources at the specified URI.
 void delete(java.lang.String url, java.lang.Object... uriVariables)
          Delete the resources at the specified URI.
 void delete(java.net.URI url)
          Delete the resources at the specified URL.
<T> ResponseEntity<T>
exchange(java.lang.String url, HttpMethod method, HttpEntity<?> requestEntity, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables)
          Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity.
<T> ResponseEntity<T>
exchange(java.lang.String url, HttpMethod method, HttpEntity<?> requestEntity, java.lang.Class<T> responseType, java.lang.Object... uriVariables)
          Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity.
<T> ResponseEntity<T>
exchange(java.net.URI url, HttpMethod method, HttpEntity<?> requestEntity, java.lang.Class<T> responseType)
          Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity.
<T> T
execute(java.lang.String url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor, java.util.Map<java.lang.String,?> uriVariables)
          Execute the HTTP method to the given URI template, preparing the request with the RequestCallback, and reading the response with a ResponseExtractor.
<T> T
execute(java.lang.String url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor, java.lang.Object... uriVariables)
          Execute the HTTP method to the given URI template, preparing the request with the RequestCallback, and reading the response with a ResponseExtractor.
<T> T
execute(java.net.URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor)
          Execute the HTTP method to the given URL, preparing the request with the RequestCallback, and reading the response with a ResponseExtractor.
<T> ResponseEntity<T>
getForEntity(java.lang.String url, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables)
          Retrieve a representation by doing a GET on the URI template.
<T> ResponseEntity<T>
getForEntity(java.lang.String url, java.lang.Class<T> responseType, java.lang.Object... uriVariables)
          Retrieve an entity by doing a GET on the specified URL.
<T> ResponseEntity<T>
getForEntity(java.net.URI url, java.lang.Class<T> responseType)
          Retrieve a representation by doing a GET on the URL .
<T> T
getForObject(java.lang.String url, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables)
          Retrieve a representation by doing a GET on the URI template.
<T> T
getForObject(java.lang.String url, java.lang.Class<T> responseType, java.lang.Object... uriVariables)
          Retrieve a representation by doing a GET on the specified URL.
<T> T
getForObject(java.net.URI url, java.lang.Class<T> responseType)
          Retrieve a representation by doing a GET on the URL .
 HttpHeaders headForHeaders(java.lang.String url, java.util.Map<java.lang.String,?> uriVariables)
          Retrieve all headers of the resource specified by the URI template.
 HttpHeaders headForHeaders(java.lang.String url, java.lang.Object... uriVariables)
          Retrieve all headers of the resource specified by the URI template.
 HttpHeaders headForHeaders(java.net.URI url)
          Retrieve all headers of the resource specified by the URL.
 java.util.Set<HttpMethod> optionsForAllow(java.lang.String url, java.util.Map<java.lang.String,?> uriVariables)
          Return the value of the Allow header for the given URI.
 java.util.Set<HttpMethod> optionsForAllow(java.lang.String url, java.lang.Object... uriVariables)
          Return the value of the Allow header for the given URI.
 java.util.Set<HttpMethod> optionsForAllow(java.net.URI url)
          Return the value of the Allow header for the given URL.
<T> ResponseEntity<T>
postForEntity(java.lang.String url, java.lang.Object request, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables)
          Create a new resource by POSTing the given object to the URI template, and returns the response as HttpEntity.
<T> ResponseEntity<T>
postForEntity(java.lang.String url, java.lang.Object request, java.lang.Class<T> responseType, java.lang.Object... uriVariables)
          Create a new resource by POSTing the given object to the URI template, and returns the response as ResponseEntity.
<T> ResponseEntity<T>
postForEntity(java.net.URI url, java.lang.Object request, java.lang.Class<T> responseType)
          Create a new resource by POSTing the given object to the URL, and returns the response as ResponseEntity.
 java.net.URI postForLocation(java.lang.String url, java.lang.Object request, java.util.Map<java.lang.String,?> uriVariables)
          Create a new resource by POSTing the given object to the URI template, and returns the value of the Location header.
 java.net.URI postForLocation(java.lang.String url, java.lang.Object request, java.lang.Object... uriVariables)
          Create a new resource by POSTing the given object to the URI template, and returns the value of the Location header.
 java.net.URI postForLocation(java.net.URI url, java.lang.Object request)
          Create a new resource by POSTing the given object to the URL, and returns the value of the Location header.
<T> T
postForObject(java.lang.String url, java.lang.Object request, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables)
          Create a new resource by POSTing the given object to the URI template, and returns the representation found in the response.
<T> T
postForObject(java.lang.String url, java.lang.Object request, java.lang.Class<T> responseType, java.lang.Object... uriVariables)
          Create a new resource by POSTing the given object to the URI template, and returns the representation found in the response.
<T> T
postForObject(java.net.URI url, java.lang.Object request, java.lang.Class<T> responseType)
          Create a new resource by POSTing the given object to the URL, and returns the representation found in the response.
 void put(java.lang.String url, java.lang.Object request, java.util.Map<java.lang.String,?> uriVariables)
          Creates a new resource by PUTting the given object to URI template.
 void put(java.lang.String url, java.lang.Object request, java.lang.Object... uriVariables)
          Create or update a resource by PUTting the given object to the URI.
 void put(java.net.URI url, java.lang.Object request)
          Creates a new resource by PUTting the given object to URL.
 

Method Detail

getForObject

<T> T getForObject(java.lang.String url,
                   java.lang.Class<T> responseType,
                   java.lang.Object... uriVariables)
               throws RestClientException
Retrieve a representation by doing a GET on the specified URL. The response (if any) is converted and returned.

URI Template variables are expanded using the given URI variables, if any.

Parameters:
url - the URL
responseType - the type of the return value
uriVariables - the variables to expand the template
Returns:
the converted object
Throws:
RestClientException

getForObject

<T> T getForObject(java.lang.String url,
                   java.lang.Class<T> responseType,
                   java.util.Map<java.lang.String,?> uriVariables)
               throws RestClientException
Retrieve a representation by doing a GET on the URI template. The response (if any) is converted and returned.

URI Template variables are expanded using the given map.

Parameters:
url - the URL
responseType - the type of the return value
uriVariables - the map containing variables for the URI template
Returns:
the converted object
Throws:
RestClientException

getForObject

<T> T getForObject(java.net.URI url,
                   java.lang.Class<T> responseType)
               throws RestClientException
Retrieve a representation by doing a GET on the URL . The response (if any) is converted and returned.

Parameters:
url - the URL
responseType - the type of the return value
Returns:
the converted object
Throws:
RestClientException

getForEntity

<T> ResponseEntity<T> getForEntity(java.lang.String url,
                                   java.lang.Class<T> responseType,
                                   java.lang.Object... uriVariables)
                               throws RestClientException
Retrieve an entity by doing a GET on the specified URL. The response is converted and stored in an ResponseEntity.

URI Template variables are expanded using the given URI variables, if any.

Parameters:
url - the URL
responseType - the type of the return value
uriVariables - the variables to expand the template
Returns:
the entity
Throws:
RestClientException
Since:
3.0.2

getForEntity

<T> ResponseEntity<T> getForEntity(java.lang.String url,
                                   java.lang.Class<T> responseType,
                                   java.util.Map<java.lang.String,?> uriVariables)
                               throws RestClientException
Retrieve a representation by doing a GET on the URI template. The response is converted and stored in an ResponseEntity.

URI Template variables are expanded using the given map.

Parameters:
url - the URL
responseType - the type of the return value
uriVariables - the map containing variables for the URI template
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2

getForEntity

<T> ResponseEntity<T> getForEntity(java.net.URI url,
                                   java.lang.Class<T> responseType)
                               throws RestClientException
Retrieve a representation by doing a GET on the URL . The response is converted and stored in an ResponseEntity.

Parameters:
url - the URL
responseType - the type of the return value
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2

headForHeaders

HttpHeaders headForHeaders(java.lang.String url,
                           java.lang.Object... uriVariables)
                           throws RestClientException
Retrieve all headers of the resource specified by the URI template.

URI Template variables are expanded using the given URI variables, if any.

Parameters:
url - the URL
uriVariables - the variables to expand the template
Returns:
all HTTP headers of that resource
Throws:
RestClientException

headForHeaders

HttpHeaders headForHeaders(java.lang.String url,
                           java.util.Map<java.lang.String,?> uriVariables)
                           throws RestClientException
Retrieve all headers of the resource specified by the URI template.

URI Template variables are expanded using the given map.

Parameters:
url - the URL
uriVariables - the map containing variables for the URI template
Returns:
all HTTP headers of that resource
Throws:
RestClientException

headForHeaders

HttpHeaders headForHeaders(java.net.URI url)
                           throws RestClientException
Retrieve all headers of the resource specified by the URL.

Parameters:
url - the URL
Returns:
all HTTP headers of that resource
Throws:
RestClientException

postForLocation

java.net.URI postForLocation(java.lang.String url,
                             java.lang.Object request,
                             java.lang.Object... uriVariables)
                             throws RestClientException
Create a new resource by POSTing the given object to the URI template, and returns the value of the Location header. This header typically indicates where the new resource is stored.

URI Template variables are expanded using the given URI variables, if any.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be POSTed, may be null
uriVariables - the variables to expand the template
Returns:
the value for the Location header
Throws:
RestClientException
See Also:
HttpEntity

postForLocation

java.net.URI postForLocation(java.lang.String url,
                             java.lang.Object request,
                             java.util.Map<java.lang.String,?> uriVariables)
                             throws RestClientException
Create a new resource by POSTing the given object to the URI template, and returns the value of the Location header. This header typically indicates where the new resource is stored.

URI Template variables are expanded using the given map.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be POSTed, may be null
uriVariables - the variables to expand the template
Returns:
the value for the Location header
Throws:
RestClientException
See Also:
HttpEntity

postForLocation

java.net.URI postForLocation(java.net.URI url,
                             java.lang.Object request)
                             throws RestClientException
Create a new resource by POSTing the given object to the URL, and returns the value of the Location header. This header typically indicates where the new resource is stored.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be POSTed, may be null
Returns:
the value for the Location header
Throws:
RestClientException
See Also:
HttpEntity

postForObject

<T> T postForObject(java.lang.String url,
                    java.lang.Object request,
                    java.lang.Class<T> responseType,
                    java.lang.Object... uriVariables)
                throws RestClientException
Create a new resource by POSTing the given object to the URI template, and returns the representation found in the response.

URI Template variables are expanded using the given URI variables, if any.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be POSTed, may be null
responseType - the type of the return value
uriVariables - the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
See Also:
HttpEntity

postForObject

<T> T postForObject(java.lang.String url,
                    java.lang.Object request,
                    java.lang.Class<T> responseType,
                    java.util.Map<java.lang.String,?> uriVariables)
                throws RestClientException
Create a new resource by POSTing the given object to the URI template, and returns the representation found in the response.

URI Template variables are expanded using the given map.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be POSTed, may be null
responseType - the type of the return value
uriVariables - the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
See Also:
HttpEntity

postForObject

<T> T postForObject(java.net.URI url,
                    java.lang.Object request,
                    java.lang.Class<T> responseType)
                throws RestClientException
Create a new resource by POSTing the given object to the URL, and returns the representation found in the response.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be POSTed, may be null
responseType - the type of the return value
Returns:
the converted object
Throws:
RestClientException
See Also:
HttpEntity

postForEntity

<T> ResponseEntity<T> postForEntity(java.lang.String url,
                                    java.lang.Object request,
                                    java.lang.Class<T> responseType,
                                    java.lang.Object... uriVariables)
                                throws RestClientException
Create a new resource by POSTing the given object to the URI template, and returns the response as ResponseEntity.

URI Template variables are expanded using the given URI variables, if any.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be POSTed, may be null
uriVariables - the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2
See Also:
HttpEntity

postForEntity

<T> ResponseEntity<T> postForEntity(java.lang.String url,
                                    java.lang.Object request,
                                    java.lang.Class<T> responseType,
                                    java.util.Map<java.lang.String,?> uriVariables)
                                throws RestClientException
Create a new resource by POSTing the given object to the URI template, and returns the response as HttpEntity.

URI Template variables are expanded using the given map.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be POSTed, may be null
uriVariables - the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2
See Also:
HttpEntity

postForEntity

<T> ResponseEntity<T> postForEntity(java.net.URI url,
                                    java.lang.Object request,
                                    java.lang.Class<T> responseType)
                                throws RestClientException
Create a new resource by POSTing the given object to the URL, and returns the response as ResponseEntity.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be POSTed, may be null
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2
See Also:
HttpEntity

put

void put(java.lang.String url,
         java.lang.Object request,
         java.lang.Object... uriVariables)
         throws RestClientException
Create or update a resource by PUTting the given object to the URI.

URI Template variables are expanded using the given URI variables, if any.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be PUT, may be null
uriVariables - the variables to expand the template
Throws:
RestClientException
See Also:
HttpEntity

put

void put(java.lang.String url,
         java.lang.Object request,
         java.util.Map<java.lang.String,?> uriVariables)
         throws RestClientException
Creates a new resource by PUTting the given object to URI template.

URI Template variables are expanded using the given map.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be PUT, may be null
uriVariables - the variables to expand the template
Throws:
RestClientException
See Also:
HttpEntity

put

void put(java.net.URI url,
         java.lang.Object request)
         throws RestClientException
Creates a new resource by PUTting the given object to URL.

The request parameter can be a HttpEntity in order to add additional HTTP headers to the request.

Parameters:
url - the URL
request - the Object to be PUT, may be null
Throws:
RestClientException
See Also:
HttpEntity

delete

void delete(java.lang.String url,
            java.lang.Object... uriVariables)
            throws RestClientException
Delete the resources at the specified URI.

URI Template variables are expanded using the given URI variables, if any.

Parameters:
url - the URL
uriVariables - the variables to expand in the template
Throws:
RestClientException

delete

void delete(java.lang.String url,
            java.util.Map<java.lang.String,?> uriVariables)
            throws RestClientException
Delete the resources at the specified URI.

URI Template variables are expanded using the given map.

Parameters:
url - the URL
uriVariables - the variables to expand the template
Throws:
RestClientException

delete

void delete(java.net.URI url)
            throws RestClientException
Delete the resources at the specified URL.

Parameters:
url - the URL
Throws:
RestClientException

optionsForAllow

java.util.Set<HttpMethod> optionsForAllow(java.lang.String url,
                                          java.lang.Object... uriVariables)
                                          throws RestClientException
Return the value of the Allow header for the given URI.

URI Template variables are expanded using the given URI variables, if any.

Parameters:
url - the URL
uriVariables - the variables to expand in the template
Returns:
the value of the allow header
Throws:
RestClientException

optionsForAllow

java.util.Set<HttpMethod> optionsForAllow(java.lang.String url,
                                          java.util.Map<java.lang.String,?> uriVariables)
                                          throws RestClientException
Return the value of the Allow header for the given URI.

URI Template variables are expanded using the given map.

Parameters:
url - the URL
uriVariables - the variables to expand in the template
Returns:
the value of the allow header
Throws:
RestClientException

optionsForAllow

java.util.Set<HttpMethod> optionsForAllow(java.net.URI url)
                                          throws RestClientException
Return the value of the Allow header for the given URL.

Parameters:
url - the URL
Returns:
the value of the allow header
Throws:
RestClientException

exchange

<T> ResponseEntity<T> exchange(java.lang.String url,
                               HttpMethod method,
                               HttpEntity<?> requestEntity,
                               java.lang.Class<T> responseType,
                               java.lang.Object... uriVariables)
                           throws RestClientException
Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity.

URI Template variables are expanded using the given URI variables, if any.

Parameters:
url - the URL
method - the HTTP method (GET, POST, etc)
requestEntity - the entity (headers and/or body) to write to the request, may be null
responseType - the type of the return value
uriVariables - the variables to expand in the template
Returns:
the response as entity
Throws:
RestClientException
Since:
3.0.2

exchange

<T> ResponseEntity<T> exchange(java.lang.String url,
                               HttpMethod method,
                               HttpEntity<?> requestEntity,
                               java.lang.Class<T> responseType,
                               java.util.Map<java.lang.String,?> uriVariables)
                           throws RestClientException
Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity.

URI Template variables are expanded using the given URI variables, if any.

Parameters:
url - the URL
method - the HTTP method (GET, POST, etc)
requestEntity - the entity (headers and/or body) to write to the request, may be null
responseType - the type of the return value
uriVariables - the variables to expand in the template
Returns:
the response as entity
Throws:
RestClientException
Since:
3.0.2

exchange

<T> ResponseEntity<T> exchange(java.net.URI url,
                               HttpMethod method,
                               HttpEntity<?> requestEntity,
                               java.lang.Class<T> responseType)
                           throws RestClientException
Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity.

Parameters:
url - the URL
method - the HTTP method (GET, POST, etc)
requestEntity - the entity (headers and/or body) to write to the request, may be null
responseType - the type of the return value
Returns:
the response as entity
Throws:
RestClientException
Since:
3.0.2

execute

<T> T execute(java.lang.String url,
              HttpMethod method,
              RequestCallback requestCallback,
              ResponseExtractor<T> responseExtractor,
              java.lang.Object... uriVariables)
          throws RestClientException
Execute the HTTP method to the given URI template, preparing the request with the RequestCallback, and reading the response with a ResponseExtractor.

URI Template variables are expanded using the given URI variables, if any.

Parameters:
url - the URL
method - the HTTP method (GET, POST, etc)
requestCallback - object that prepares the request
responseExtractor - object that extracts the return value from the response
uriVariables - the variables to expand in the template
Returns:
an arbitrary object, as returned by the ResponseExtractor
Throws:
RestClientException

execute

<T> T execute(java.lang.String url,
              HttpMethod method,
              RequestCallback requestCallback,
              ResponseExtractor<T> responseExtractor,
              java.util.Map<java.lang.String,?> uriVariables)
          throws RestClientException
Execute the HTTP method to the given URI template, preparing the request with the RequestCallback, and reading the response with a ResponseExtractor.

URI Template variables are expanded using the given URI variables map.

Parameters:
url - the URL
method - the HTTP method (GET, POST, etc)
requestCallback - object that prepares the request
responseExtractor - object that extracts the return value from the response
uriVariables - the variables to expand in the template
Returns:
an arbitrary object, as returned by the ResponseExtractor
Throws:
RestClientException

execute

<T> T execute(java.net.URI url,
              HttpMethod method,
              RequestCallback requestCallback,
              ResponseExtractor<T> responseExtractor)
          throws RestClientException
Execute the HTTP method to the given URL, preparing the request with the RequestCallback, and reading the response with a ResponseExtractor.

Parameters:
url - the URL
method - the HTTP method (GET, POST, etc)
requestCallback - object that prepares the request
responseExtractor - object that extracts the return value from the response
Returns:
an arbitrary object, as returned by the ResponseExtractor
Throws:
RestClientException