Class RocketRestConfig

  • Direct Known Subclasses:
    RocketRestSecureConfig

    public class RocketRestConfig
    extends Object
    Configuration container for RocketRest clients.

    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.Builder to 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
    • 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