Record Class RestServiceRequest

java.lang.Object
java.lang.Record
com.bonitasoft.processbuilder.records.RestServiceRequest
Record Components:
url - The full URL to call (required)
method - The HTTP method (GET, POST, PUT, etc.)
headers - Additional headers to include in the request
queryParams - Query parameters to append to the URL
body - The request body (for POST, PUT, PATCH)
contentType - The content type of the request body
auth - Authentication configuration
timeoutMs - Connection and read timeout in milliseconds
followRedirects - Whether to follow HTTP redirects
verifySsl - Whether to verify SSL certificates

public record RestServiceRequest(String url, RestHttpMethod method, Map<String,String> headers, Map<String,String> queryParams, String body, RestContentType contentType, RestAuthConfig auth, int timeoutMs, boolean followRedirects, boolean verifySsl) extends Record
Represents a REST service request configuration.

This record contains all the information needed to execute a REST API call, including the URL, HTTP method, headers, body, authentication, and timeout settings.

Since:
1.0
Author:
Bonitasoft
  • Field Details

    • DEFAULT_TIMEOUT_MS

      public static final int DEFAULT_TIMEOUT_MS
      Default timeout in milliseconds (30 seconds).
      See Also:
  • Constructor Details

  • Method Details

    • builder

      public static RestServiceRequest.Builder builder(String url)
      Creates a new builder for RestServiceRequest.
      Parameters:
      url - The URL to call
      Returns:
      A new builder instance
    • get

      public static RestServiceRequest get(String url)
      Creates a simple GET request.
      Parameters:
      url - The URL to call
      Returns:
      A GET request
    • postJson

      public static RestServiceRequest postJson(String url, String body)
      Creates a POST request with JSON body.
      Parameters:
      url - The URL to call
      body - The JSON body string
      Returns:
      A POST request
    • fromJson

      public static RestServiceRequest fromJson(com.fasterxml.jackson.databind.JsonNode requestNode, org.slf4j.Logger logger)
      Parses a RestServiceRequest from JSON.
      Parameters:
      requestNode - The JSON node containing the request configuration
      logger - Optional logger for warnings
      Returns:
      The parsed RestServiceRequest
    • buildFullUrl

      public String buildFullUrl()
      Builds the full URL including query parameters.
      Returns:
      The full URL with query parameters
    • buildAllHeaders

      public Map<String,String> buildAllHeaders()
      Builds all headers including auth headers and content type.
      Returns:
      Combined headers map
    • hasBody

      public boolean hasBody()
      Checks if this request has a body.
      Returns:
      true if the request has a non-empty body
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • url

      public String url()
      Returns the value of the url record component.
      Returns:
      the value of the url record component
    • method

      public RestHttpMethod method()
      Returns the value of the method record component.
      Returns:
      the value of the method record component
    • headers

      public Map<String,String> headers()
      Returns the value of the headers record component.
      Returns:
      the value of the headers record component
    • queryParams

      public Map<String,String> queryParams()
      Returns the value of the queryParams record component.
      Returns:
      the value of the queryParams record component
    • body

      public String body()
      Returns the value of the body record component.
      Returns:
      the value of the body record component
    • contentType

      public RestContentType contentType()
      Returns the value of the contentType record component.
      Returns:
      the value of the contentType record component
    • auth

      public RestAuthConfig auth()
      Returns the value of the auth record component.
      Returns:
      the value of the auth record component
    • timeoutMs

      public int timeoutMs()
      Returns the value of the timeoutMs record component.
      Returns:
      the value of the timeoutMs record component
    • followRedirects

      public boolean followRedirects()
      Returns the value of the followRedirects record component.
      Returns:
      the value of the followRedirects record component
    • verifySsl

      public boolean verifySsl()
      Returns the value of the verifySsl record component.
      Returns:
      the value of the verifySsl record component