Package org.springframework.vault.client
Class RestClientBuilder
java.lang.Object
org.springframework.vault.client.RestClientBuilder
Builder that can be used to configure and create a
RestClient. Provides
convenience methods to configure ClientHttpRequestFactory, error handlers
and default headers.
By default, the built RestClient will attempt to use the most suitable
ClientHttpRequestFactory using ClientHttpRequestFactoryFactory.create(org.springframework.vault.support.ClientOptions, org.springframework.vault.support.SslConfiguration).
- Since:
- 4.0
- Author:
- Mark Paluch
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build a newRestClient.static RestClientBuilderbuilder()Create a newRestClientBuilder.protected RestClientCreate theRestClientto use.customizers(RestClientCustomizer... customizer) Add theRestClientCustomizersthat should be applied to theRestClient.defaultHeader(String name, String value) Add a default header that will be set if not already present on the outgoingHttpRequest.endpoint(VaultEndpoint endpoint) Set theVaultEndpointthat should be used with theRestClient.endpointProvider(VaultEndpointProvider provider) Set theVaultEndpointProviderthat should be used with theRestClient.errorHandler(ResponseErrorHandler errorHandler) Set theResponseErrorHandlerthat should be used with theRestClient.requestFactory(Supplier<ClientHttpRequestFactory> requestFactory) Set theSupplierofClientHttpRequestFactorythat should be called each time webuild()a newRestClientinstance.requestFactory(ClientHttpRequestFactory requestFactory) Set theClientHttpRequestFactorythat should be used with theRestClient.requestInitializers(ClientHttpRequestInitializer... requestInitializer) Add theClientHttpRequestInitializersthat should be applied toClientHttpRequestinitialization.
-
Method Details
-
builder
Create a newRestClientBuilder.- Returns:
- a new
RestClientBuilder.
-
endpoint
Set theVaultEndpointthat should be used with theRestClient.- Parameters:
endpoint- theVaultEndpointprovider.- Returns:
thisRestClientBuilder.
-
endpointProvider
Set theVaultEndpointProviderthat should be used with theRestClient.- Parameters:
provider- theVaultEndpointprovider.- Returns:
thisRestClientBuilder.
-
requestFactory
Set theClientHttpRequestFactorythat should be used with theRestClient.- Parameters:
requestFactory- the request factory.- Returns:
thisRestClientBuilder.
-
requestFactory
Set theSupplierofClientHttpRequestFactorythat should be called each time webuild()a newRestClientinstance.- Parameters:
requestFactory- the supplier for the request factory.- Returns:
thisRestClientBuilder.
-
errorHandler
Set theResponseErrorHandlerthat should be used with theRestClient.- Parameters:
errorHandler- the error handler to use.- Returns:
thisRestClientBuilder.
-
defaultHeader
Add a default header that will be set if not already present on the outgoingHttpRequest.- Parameters:
name- the name of the header.value- the header value.- Returns:
thisRestClientBuilder.
-
customizers
Add theRestClientCustomizersthat should be applied to theRestClient. Customizers are applied in the order that they were added.- Parameters:
customizer- the template customizers to add.- Returns:
thisRestClientBuilder.
-
requestInitializers
Add theClientHttpRequestInitializersthat should be applied toClientHttpRequestinitialization. Customizers are applied in the order that they were added.- Parameters:
requestInitializer- the request initializers to add.- Returns:
thisRestClientBuilder.
-
build
Build a newRestClient.VaultEndpointmust be set.Applies also
ResponseErrorHandlerandRestTemplateCustomizerif configured.- Returns:
- a new
RestClient.
-
createClient
Create theRestClientto use.- Returns:
- the
RestClientto use.
-