Package com.guinetik.rr
Class RocketRestConfig
- java.lang.Object
-
- com.guinetik.rr.RocketRestConfig
-
- Direct Known Subclasses:
RocketRestSecureConfig
public class RocketRestConfig extends Object
Configuration container forRocketRestclients.This class holds all configuration options needed to create a RocketRest client, including the service URL, authentication strategy, and default request options. Use the fluent
RocketRestConfig.Builderto construct instances.Basic Usage
RocketRestConfig config = RocketRestConfig.builder("https://api.example.com") .build(); RocketRest client = new RocketRest(config);With Authentication
RocketRestConfig config = RocketRestConfig.builder("https://api.example.com") .authStrategy(AuthStrategyFactory.createBearerToken("my-api-token")) .build();With Default Options
RocketRestConfig config = RocketRestConfig.builder("https://api.example.com") .authStrategy(AuthStrategyFactory.createBasicAuth("user", "pass")) .defaultOptions(options -> { options.set(RocketRestOptions.RETRY_ENABLED, true); options.set(RocketRestOptions.MAX_RETRIES, 3); options.set(RocketRestOptions.CONNECT_TIMEOUT, 5000); options.set(RocketRestOptions.LOG_REQUEST_BODY, true); }) .build();OAuth2 Client Credentials
RocketRestConfig config = RocketRestConfig.builder("https://api.example.com") .tokenUrl("https://auth.example.com/oauth/token") .authStrategy(AuthStrategyFactory.createOAuth2ClientCredentials( "https://auth.example.com/oauth/token", "client-id", "client-secret" )) .build();- Since:
- 1.0.0
- Author:
- guinetik <guinetik@gmail.com>
- See Also:
RocketRest,RocketRestOptions,AuthStrategy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRocketRestConfig.BuilderBuilder for creating RocketRestConfig instances.
-
Constructor Summary
Constructors Modifier Constructor Description protectedRocketRestConfig(RocketRestConfig.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RocketRestConfig.Builderbuilder(String serviceUrl)Creates a new builder for RocketRestConfig.AuthStrategygetAuthStrategy()Gets the authentication strategy.RocketRestOptionsgetDefaultOptions()Gets the default client options for clients created with this config.StringgetServiceUrl()Gets the service URL.StringgetTokenUrl()Gets the token URL for OAuth flows.voidsetServiceUrl(String baseUrl)
-
-
-
Constructor Detail
-
RocketRestConfig
protected RocketRestConfig(RocketRestConfig.Builder builder)
-
-
Method Detail
-
getServiceUrl
public String getServiceUrl()
Gets the service URL.- Returns:
- the service URL
-
getTokenUrl
public String getTokenUrl()
Gets the token URL for OAuth flows.- Returns:
- the token URL
-
getAuthStrategy
public AuthStrategy getAuthStrategy()
Gets the authentication strategy.- Returns:
- the authentication strategy
-
getDefaultOptions
public RocketRestOptions getDefaultOptions()
Gets the default client options for clients created with this config.- Returns:
- the default client options
-
setServiceUrl
public void setServiceUrl(String baseUrl)
-
builder
public static RocketRestConfig.Builder builder(String serviceUrl)
Creates a new builder for RocketRestConfig.- Parameters:
serviceUrl- the base URL for the API service- Returns:
- a new builder instance
-
-