Interface QuarkusRestClientBuilder

All Superinterfaces:
jakarta.ws.rs.core.Configurable<QuarkusRestClientBuilder>
All Known Implementing Classes:
QuarkusRestClientBuilderImpl

public interface QuarkusRestClientBuilder extends jakarta.ws.rs.core.Configurable<QuarkusRestClientBuilder>
This is the main entry point for creating a Type Safe Quarkus Rest Client.

Invoking newBuilder() is intended to always create a new instance, not use a cached version.

The QuarkusRestClientBuilder is based on RestClientBuilder class but Quarkus specific.

  • Method Details

    • newBuilder

      static QuarkusRestClientBuilder newBuilder()
    • baseUrl

      Specifies the base URL to be used when making requests. Assuming that the interface has a @Path("/api") at the interface level and a url is given with http://my-service:8080/service then all REST calls will be invoked with a url of http://my-service:8080/service/api in addition to any @Path annotations included on the method. Subsequent calls to this method will replace the previously specified baseUri/baseUrl.
      Parameters:
      url - the base Url for the service.
      Returns:
      the current builder with the baseUrl set.
    • baseUri

      Specifies the base URI to be used when making requests. Assuming that the interface has a @Path("/api") at the interface level and a uri is given with http://my-service:8080/service then all REST calls will be invoked with a uri of http://my-service:8080/service/api in addition to any @Path annotations included on the method. Subsequent calls to this method will replace the previously specified baseUri/baseUrl.
      Parameters:
      uri - the base URI for the service.
      Returns:
      the current builder with the baseUri set
      Throws:
      IllegalArgumentException - if the passed in URI is invalid
    • connectTimeout

      QuarkusRestClientBuilder connectTimeout(long timeout, TimeUnit unit)
      Set the connect timeout.

      Like JAX-RS's jakarta.ws.rs.client.ClientBuilder's connectTimeout method, specifying a timeout of 0 represents infinity, and negative values are not allowed.

      If the client instance is injected via CDI and the "fully.qualified.InterfaceName/mp-rest/connectTimeout" property is set via MicroProfile Config, that property's value will override, the value specified to this method.

      Parameters:
      timeout - the maximum time to wait.
      unit - the time unit of the timeout argument.
      Returns:
      the current builder with the connect timeout set.
      Throws:
      IllegalArgumentException - if the value of timeout is negative.
    • readTimeout

      QuarkusRestClientBuilder readTimeout(long timeout, TimeUnit unit)
      Set the read timeout.

      Like JAX-RS's jakarta.ws.rs.client.ClientBuilder's readTimeout method, specifying a timeout of 0 represents infinity, and negative values are not allowed.

      Also like the JAX-RS Client API, if the read timeout is reached, the client interface method will throw a jakarta.ws.rs.ProcessingException.

      If the client instance is injected via CDI and the "fully.qualified.InterfaceName/mp-rest/readTimeout" property is set via MicroProfile Config, that property's value will override, the value specified to this method.

      Parameters:
      timeout - the maximum time to wait.
      unit - the time unit of the timeout argument.
      Returns:
      the current builder with the connect timeout set.
      Throws:
      IllegalArgumentException - if the value of timeout is negative.
    • sslContext

      QuarkusRestClientBuilder sslContext(SSLContext sslContext)
      Specifies the SSL context to use when creating secured transport connections to server endpoints from web targets created by the client instance that is using this SSL context.
      Parameters:
      sslContext - the ssl context
      Returns:
      the current builder with ssl context set
      Throws:
      NullPointerException - if the sslContext parameter is null.
    • verifyHost

      QuarkusRestClientBuilder verifyHost(boolean verifyHost)
      Set whether hostname verification is enabled.
      Parameters:
      verifyHost - whether the hostname verification is enabled.
      Returns:
      the current builder with the hostname verification set.
    • trustStore

      QuarkusRestClientBuilder trustStore(KeyStore trustStore)
      Set the client-side trust store.
      Parameters:
      trustStore - key store
      Returns:
      the current builder with the trust store set
      Throws:
      NullPointerException - if the trustStore parameter is null.
    • trustStore

      QuarkusRestClientBuilder trustStore(KeyStore trustStore, String trustStorePassword)
      Set the client-side trust store.
      Parameters:
      trustStore - key store
      trustStorePassword - the password for the specified trustStore
      Returns:
      the current builder with the trust store set
      Throws:
      NullPointerException - if the trustStore parameter is null.
    • keyStore

      QuarkusRestClientBuilder keyStore(KeyStore keyStore, String keystorePassword)
      Set the client-side key store.
      Parameters:
      keyStore - key store
      keystorePassword - the password for the specified keyStore
      Returns:
      the current builder with the key store set
      Throws:
      NullPointerException - if the keyStore parameter is null.
    • hostnameVerifier

      QuarkusRestClientBuilder hostnameVerifier(HostnameVerifier hostnameVerifier)
      Set the hostname verifier to verify the endpoint's hostname
      Parameters:
      hostnameVerifier - the hostname verifier
      Returns:
      the current builder with hostname verifier set
      Throws:
      NullPointerException - if the hostnameVerifier parameter is null.
    • followRedirects

      QuarkusRestClientBuilder followRedirects(boolean follow)
      Specifies whether client built by this builder should follow HTTP redirect responses (30x) or not.
      Parameters:
      follow - true if the client should follow HTTP redirects, false if not.
      Returns:
      the current builder with the followRedirect property set.
    • proxyAddress

      QuarkusRestClientBuilder proxyAddress(String proxyHost, int proxyPort)
      Specifies the HTTP proxy hostname/IP address and port to use for requests from client instances.
      Parameters:
      proxyHost - hostname or IP address of proxy server - must be non-null
      proxyPort - port of proxy server
      Returns:
      the current builder with the proxy host set
      Throws:
      IllegalArgumentException - if the proxyHost is null or the proxyPort is invalid
    • proxyUser

      QuarkusRestClientBuilder proxyUser(String proxyUser)
      Specifies the proxy username.
      Parameters:
      proxyUser - the proxy username.
      Returns:
      the current builder
    • proxyPassword

      QuarkusRestClientBuilder proxyPassword(String proxyPassword)
      Specifies the proxy password.
      Parameters:
      proxyPassword - the proxy password.
      Returns:
      the current builder
    • nonProxyHosts

      QuarkusRestClientBuilder nonProxyHosts(String nonProxyHosts)
      Specifies the hosts to access without proxy.
      Parameters:
      nonProxyHosts - the hosts to access without proxy.
      Returns:
      the current builder
    • queryParamStyle

      QuarkusRestClientBuilder queryParamStyle(org.eclipse.microprofile.rest.client.ext.QueryParamStyle style)
      Specifies the URI formatting style to use when multiple query parameter values are passed to the client.
      Parameters:
      style - the URI formatting style to use for multiple query parameter values
      Returns:
      the current builder with the style of query params set
    • clientHeadersFactory

      QuarkusRestClientBuilder clientHeadersFactory(Class<? extends org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory> clientHeadersFactoryClass)
      Specifies the client headers factory to use.
      Parameters:
      clientHeadersFactoryClass - the client headers factory class to use.
      Returns:
      the current builder
    • clientHeadersFactory

      QuarkusRestClientBuilder clientHeadersFactory(org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory clientHeadersFactory)
      Specifies the client headers factory to use.
      Parameters:
      clientHeadersFactory - the client headers factory to use.
      Returns:
      the current builder
    • httpClientOptions

      QuarkusRestClientBuilder httpClientOptions(Class<? extends io.vertx.core.http.HttpClientOptions> httpClientOptionsClass)
      Specifies the HTTP client options to use.
      Parameters:
      httpClientOptionsClass - the HTTP client options to use.
      Returns:
      the current builder
    • httpClientOptions

      QuarkusRestClientBuilder httpClientOptions(io.vertx.core.http.HttpClientOptions httpClientOptions)
      Specifies the HTTP client options to use.
      Parameters:
      httpClientOptions - the HTTP client options to use.
      Returns:
      the current builder
    • clientLogger

      QuarkusRestClientBuilder clientLogger(org.jboss.resteasy.reactive.client.api.ClientLogger clientLogger)
      Specifies the client logger to use.
      Parameters:
      clientLogger - the client logger to use.
      Returns:
      the current builder
    • loggingScope

      QuarkusRestClientBuilder loggingScope(org.jboss.resteasy.reactive.client.api.LoggingScope loggingScope)
      Specifies the client logger to use.
      Parameters:
      loggingScope - to use
      Returns:
      the current builder
    • loggingBodyLimit

      QuarkusRestClientBuilder loggingBodyLimit(Integer limit)
      How many characters of the body should be logged. Message body can be large and can easily pollute the logs.
    • trustAll

      QuarkusRestClientBuilder trustAll(boolean trustAll)
      Enable trusting all certificates. Disable by default.
    • build

      <T> T build(Class<T> clazz) throws IllegalStateException, org.eclipse.microprofile.rest.client.RestClientDefinitionException
      Based on the configured QuarkusRestClientBuilder, creates a new instance of the given REST interface to invoke API calls against.
      Type Parameters:
      T - the type of the interface
      Parameters:
      clazz - the interface that defines REST API methods for use
      Returns:
      a new instance of an implementation of this REST interface that
      Throws:
      IllegalStateException - if not all pre-requisites are satisfied for the builder, this exception may get thrown. For instance, if the base URI/URL has not been set.
      org.eclipse.microprofile.rest.client.RestClientDefinitionException - if the passed-in interface class is invalid.