Package com.linecorp.armeria.client
Interface RestClient
- All Superinterfaces:
ClientBuilderParams
,Unwrappable
A client designed for calling RESTful APIs conveniently.
-
Method Summary
Modifier and TypeMethodDescriptionstatic RestClientBuilder
builder()
Returns a newRestClientBuilder
created without a baseURI
.static RestClientBuilder
builder
(SessionProtocol protocol, EndpointGroup endpointGroup) static RestClientBuilder
builder
(SessionProtocol protocol, EndpointGroup endpointGroup, String path) Returns a newRestClientBuilder
created with the specifiedSessionProtocol
, baseEndpointGroup
and path.static RestClientBuilder
Returns a newRestClientBuilder
created with the specified baseuri
.static RestClientBuilder
builder
(String protocol, EndpointGroup endpointGroup) static RestClientBuilder
builder
(String protocol, EndpointGroup endpointGroup, String path) Returns a newRestClientBuilder
created with the specifiedprotocol
.static RestClientBuilder
Returns a newRestClientBuilder
created with the specified baseURI
.default RestClientPreparation
Sets anHttpMethod.DELETE
and thepath
and returns a fluent request builder.default RestClientPreparation
Sets anHttpMethod.GET
and thepath
and returns a fluent request builder.static RestClient
of()
Returns aRestClient
without a base URI using the defaultClientFactory
and the defaultClientOptions
.static RestClient
Returns a newRestClient
with the specifiedWebClient
.static RestClient
of
(SessionProtocol protocol, EndpointGroup endpointGroup) Returns a newRestClient
that connects to the specifiedEndpointGroup
with the specifiedSessionProtocol
using the defaultClientFactory
and the defaultClientOptions
.static RestClient
of
(SessionProtocol protocol, EndpointGroup endpointGroup, String path) Returns a newRestClient
that connects to the specifiedEndpointGroup
with the specifiedSessionProtocol
andpath
using the defaultClientFactory
and the defaultClientOptions
.static RestClient
Returns a newRestClient
that connects to the specifieduri
using the default options.static RestClient
of
(String protocol, EndpointGroup endpointGroup) Returns a newRestClient
that connects to the specifiedEndpointGroup
with the specifiedprotocol
using the defaultClientFactory
and the defaultClientOptions
.static RestClient
of
(String protocol, EndpointGroup endpointGroup, String path) Returns a newRestClient
that connects to the specifiedEndpointGroup
with the specifiedprotocol
andpath
using the defaultClientFactory
and the defaultClientOptions
.static RestClient
Returns a newRestClient
that connects to the specifiedURI
using the default options.default RestClientPreparation
Sets anHttpMethod.PATCH
and thepath
and returns a fluent request builder.path
(HttpMethod method, String path) Sets theHttpMethod
and thepath
and returns a fluent request builder.default RestClientPreparation
Sets anHttpMethod.POST
and thepath
and returns a fluent request builder.default RestClientPreparation
Sets anHttpMethod.PUT
and thepath
and returns a fluent request builder.unwrap()
Unwraps this object and returns the object being decorated.Methods inherited from interface com.linecorp.armeria.client.ClientBuilderParams
absolutePathRef, clientType, endpointGroup, options, scheme, uri
Methods inherited from interface com.linecorp.armeria.common.util.Unwrappable
as, equalsIgnoreWrapper, unwrapAll
-
Method Details
-
of
Returns aRestClient
without a base URI using the defaultClientFactory
and the defaultClientOptions
. -
of
Returns a newRestClient
with the specifiedWebClient
. -
of
Returns a newRestClient
that connects to the specifieduri
using the default options.- Parameters:
uri
- the URI of the server endpoint- Throws:
IllegalArgumentException
- if theuri
is not valid or its scheme is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
Returns a newRestClient
that connects to the specifiedURI
using the default options.- Parameters:
uri
- theURI
of the server endpoint- Throws:
IllegalArgumentException
- if theuri
is not valid or its scheme is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
Returns a newRestClient
that connects to the specifiedEndpointGroup
with the specifiedprotocol
using the defaultClientFactory
and the defaultClientOptions
.- Parameters:
protocol
- the session protocol of theEndpointGroup
endpointGroup
- the serverEndpointGroup
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
Returns a newRestClient
that connects to the specifiedEndpointGroup
with the specifiedSessionProtocol
using the defaultClientFactory
and the defaultClientOptions
.- Parameters:
protocol
- theSessionProtocol
of theEndpointGroup
endpointGroup
- the serverEndpointGroup
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
Returns a newRestClient
that connects to the specifiedEndpointGroup
with the specifiedprotocol
andpath
using the defaultClientFactory
and the defaultClientOptions
.- Parameters:
protocol
- the session protocol of theEndpointGroup
endpointGroup
- the serverEndpointGroup
path
- the path to the endpoint- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
of
Returns a newRestClient
that connects to the specifiedEndpointGroup
with the specifiedSessionProtocol
andpath
using the defaultClientFactory
and the defaultClientOptions
.- Parameters:
protocol
- theSessionProtocol
of theEndpointGroup
endpointGroup
- the serverEndpointGroup
path
- the path to the endpoint- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
Returns a newRestClientBuilder
created without a baseURI
. -
builder
Returns a newRestClientBuilder
created with the specified baseuri
.- Throws:
IllegalArgumentException
- if theuri
is not valid or its scheme is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
Returns a newRestClientBuilder
created with the specified baseURI
.- Throws:
IllegalArgumentException
- if theuri
is not valid or its scheme is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
builder
static RestClientBuilder builder(SessionProtocol protocol, EndpointGroup endpointGroup, String path) Returns a newRestClientBuilder
created with the specifiedSessionProtocol
, baseEndpointGroup
and path.- Throws:
IllegalArgumentException
- if theprotocol
is not one of the values inSessionProtocol.httpValues()
orSessionProtocol.httpsValues()
.
-
get
Sets anHttpMethod.GET
and thepath
and returns a fluent request builder.RestClient restClient = RestClient.of("..."); CompletableFuture<ResponseEntity<Customer>> response = restClient.get("/api/v1/customers/{customerId}") .pathParam("customerId", "0000001") .execute(Customer.class);
-
post
Sets anHttpMethod.POST
and thepath
and returns a fluent request builder.RestClient restClient = RestClient.of("..."); CompletableFuture<ResponseEntity<Result>> response = restClient.post("/api/v1/customers") .contentJson(new Customer(...)) .execute(Result.class);
-
put
Sets anHttpMethod.PUT
and thepath
and returns a fluent request builder.RestClient restClient = RestClient.of("..."); CompletableFuture<ResponseEntity<Result>> response = restClient.put("/api/v1/customers") .contentJson(new Customer(...)) .execute(Result.class);
-
patch
Sets anHttpMethod.PATCH
and thepath
and returns a fluent request builder.RestClient restClient = RestClient.of("..."); CompletableFuture<ResponseEntity<Result>> response = restClient.patch("/api/v1/customers") .contentJson(new Customer(...)) .execute(Result.class);
-
delete
Sets anHttpMethod.DELETE
and thepath
and returns a fluent request builder.RestClient restClient = RestClient.of("..."); CompletableFuture<ResponseEntity<Result>> response = restClient.delete("/api/v1/customers") .pathParam("customerId", "0000001") .execute(Result.class);
-
path
Sets theHttpMethod
and thepath
and returns a fluent request builder.RestClient restClient = RestClient.of("..."); CompletableFuture<ResponseEntity<Customer>> response = restClient.path(HttpMethod.GET, "/api/v1/customers/{customerId}") .pathParam("customerId", "0000001") .execute(Customer.class);
-
unwrap
HttpClient unwrap()Description copied from interface:Unwrappable
Unwraps this object and returns the object being decorated. If thisUnwrappable
is the innermost object, this method returns itself. For example:class Foo implements Unwrappable {} class Bar<T extends Unwrappable> extends AbstractUnwrappable<T> { Bar(T delegate) { super(delegate); } } class Qux<T extends Unwrappable> extends AbstractUnwrappable<T> { Qux(T delegate) { super(delegate); } } Foo foo = new Foo(); assert foo.unwrap() == foo; Bar<Foo> bar = new Bar<>(foo); assert bar.unwrap() == foo; Qux<Bar<Foo>> qux = new Qux<>(bar); assert qux.unwrap() == bar; assert qux.unwrap().unwrap() == foo;
- Specified by:
unwrap
in interfaceUnwrappable
-