Class PlatformClientBuilder
- java.lang.Object
-
- org.sdase.commons.client.jersey.builder.PlatformClientBuilder
-
public class PlatformClientBuilder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description PlatformClientBuilder(io.dropwizard.setup.Environment environment, HttpClientConfiguration httpClientConfiguration, io.opentelemetry.api.OpenTelemetry openTelemetry, java.lang.String consumerToken)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
addFeature(javax.ws.rs.core.Feature feature)
Adds a feature used by the client.T
addFilter(javax.ws.rs.client.ClientRequestFilter clientRequestFilter)
Adds a request filter to the client.<A> ApiClientBuilder<A>
api(java.lang.Class<A> apiInterface)
Creates a client proxy implementation for accessing another service.<A> ApiClientBuilder<A>
api(java.lang.Class<A> apiInterface, java.lang.String customName)
Creates a client proxy implementation for accessing another service.javax.ws.rs.client.Client
buildGenericClient(java.lang.String name)
Builds a generic client that can be used for Http requests.T
disableFollowRedirects()
Set this client to not follow redirects and therewith automatically resolve 3xx status codesPlatformClientBuilder
enableAuthenticationPassThrough()
If authentication pass through is enabled, the JWT in the "Authorization" header of an incoming request will be added to the outgoing request.PlatformClientBuilder
enableConsumerToken()
If consumer token is enabled, the client will create a configured consumer token and add it as header to the outgoing request.
-
-
-
Constructor Detail
-
PlatformClientBuilder
public PlatformClientBuilder(io.dropwizard.setup.Environment environment, HttpClientConfiguration httpClientConfiguration, io.opentelemetry.api.OpenTelemetry openTelemetry, java.lang.String consumerToken)
-
-
Method Detail
-
enableAuthenticationPassThrough
public PlatformClientBuilder enableAuthenticationPassThrough()
If authentication pass through is enabled, the JWT in the "Authorization" header of an incoming request will be added to the outgoing request.- Returns:
- this builder instance
-
enableConsumerToken
public PlatformClientBuilder enableConsumerToken()
If consumer token is enabled, the client will create a configured consumer token and add it as header to the outgoing request.- Returns:
- this builder instance
-
addFilter
public T addFilter(javax.ws.rs.client.ClientRequestFilter clientRequestFilter)
Adds a request filter to the client.- Parameters:
clientRequestFilter
- the filter to add- Returns:
- this builder instance
-
addFeature
public T addFeature(javax.ws.rs.core.Feature feature)
Adds a feature used by the client.- Parameters:
feature
- to be added- Returns:
- this builder instance
-
disableFollowRedirects
public T disableFollowRedirects()
Set this client to not follow redirects and therewith automatically resolve 3xx status codes- Returns:
- this builder instance
-
buildGenericClient
public javax.ws.rs.client.Client buildGenericClient(java.lang.String name)
Builds a generic client that can be used for Http requests.- Parameters:
name
- the name of the client is used for metrics and thread names- Returns:
- the client instance
-
api
public <A> ApiClientBuilder<A> api(java.lang.Class<A> apiInterface)
Creates a client proxy implementation for accessing another service.- Type Parameters:
A
- the type of the api- Parameters:
apiInterface
- the interface that declares the API using JAX-RS annotations.- Returns:
- a builder to define the root path of the API for the proxy that is build
-
api
public <A> ApiClientBuilder<A> api(java.lang.Class<A> apiInterface, java.lang.String customName)
Creates a client proxy implementation for accessing another service. Allows to set a custom name if required, e.g. if you have multiple clients generated from the same interface.- Type Parameters:
A
- the type of the api- Parameters:
apiInterface
- the interface that declares the API using JAX-RS annotations.customName
- the custom name to use for the client. The name is used for the executor service and metrics. Names have to be unique.- Returns:
- a builder to define the root path of the API for the proxy that is build
-
-