public interface

RestOperations

org.springframework.web.client.RestOperations
Known Indirect Subclasses

Class Overview

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.

See Also

Summary

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

Public Methods

public abstract void delete (String url, Object... uriVariables)

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

public abstract void delete (URI url)

Delete the resources at the specified URL.

Parameters
url the URL

public abstract void delete (String url, Map<String, ?> uriVariables)

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

public abstract ResponseEntity<T> exchange (String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Map<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.

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

public abstract ResponseEntity<T> exchange (URI url, HttpMethod method, HttpEntity<?> requestEntity, 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.

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

public abstract ResponseEntity<T> exchange (String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, 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.

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

public abstract T execute (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.

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

public abstract T execute (String url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Object... uriVariables)

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

public abstract T execute (String url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables)

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

public abstract ResponseEntity<T> getForEntity (URI url, Class<T> responseType)

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

public abstract ResponseEntity<T> getForEntity (String url, Class<T> responseType, Map<String, ?> uriVariables)

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

public abstract ResponseEntity<T> getForEntity (String url, Class<T> responseType, Object... uriVariables)

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

public abstract T getForObject (String url, Class<T> responseType, Map<String, ?> uriVariables)

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

public abstract T getForObject (URI url, Class<T> responseType)

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

public abstract T getForObject (String url, Class<T> responseType, Object... uriVariables)

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

public abstract HttpHeaders headForHeaders (String url, Object... uriVariables)

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

public abstract HttpHeaders headForHeaders (URI url)

Retrieve all headers of the resource specified by the URL.

Parameters
url the URL
Returns
  • all HTTP headers of that resource

public abstract HttpHeaders headForHeaders (String url, Map<String, ?> uriVariables)

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

public abstract Set<HttpMethod> optionsForAllow (URI url)

Return the value of the Allow header for the given URL.

Parameters
url the URL
Returns
  • the value of the allow header

public abstract Set<HttpMethod> optionsForAllow (String url, Map<String, ?> uriVariables)

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

public abstract Set<HttpMethod> optionsForAllow (String url, Object... uriVariables)

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

public abstract ResponseEntity<T> postForEntity (String url, Object request, Class<T> responseType, Map<String, ?> uriVariables)

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
See Also

public abstract ResponseEntity<T> postForEntity (String url, Object request, Class<T> responseType, Object... uriVariables)

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
See Also

public abstract ResponseEntity<T> postForEntity (URI url, Object request, Class<T> responseType)

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
See Also

public abstract URI postForLocation (String url, Object request, Map<String, ?> uriVariables)

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
See Also

public abstract URI postForLocation (URI url, Object request)

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
See Also

public abstract URI postForLocation (String url, Object request, Object... uriVariables)

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
See Also

public abstract T postForObject (String url, Object request, Class<T> responseType, Map<String, ?> uriVariables)

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
See Also

public abstract T postForObject (URI url, Object request, Class<T> responseType)

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
See Also

public abstract T postForObject (String url, Object request, Class<T> responseType, Object... uriVariables)

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
See Also

public abstract void put (URI url, Object request)

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
See Also

public abstract void put (String url, Object request, Object... uriVariables)

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
See Also

public abstract void put (String url, Object request, Map<String, ?> uriVariables)

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
See Also