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 requestqueryParams- Query parameters to append to the URLbody- The request body (for POST, PUT, PATCH)contentType- The content type of the request bodyauth- Authentication configurationtimeoutMs- Connection and read timeout in millisecondsfollowRedirects- Whether to follow HTTP redirectsverifySsl- 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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructing RestServiceRequest instances. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault timeout in milliseconds (30 seconds). -
Constructor Summary
ConstructorsConstructorDescriptionRestServiceRequest(String url, RestHttpMethod method, Map<String, String> headers, Map<String, String> queryParams, String body, RestContentType contentType, RestAuthConfig auth, int timeoutMs, boolean followRedirects, boolean verifySsl) Compact constructor with validation and defaults. -
Method Summary
Modifier and TypeMethodDescriptionauth()Returns the value of theauthrecord component.body()Returns the value of thebodyrecord component.Builds all headers including auth headers and content type.static RestServiceRequest.BuilderCreates a new builder for RestServiceRequest.Builds the full URL including query parameters.Returns the value of thecontentTyperecord component.final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of thefollowRedirectsrecord component.static RestServiceRequestfromJson(com.fasterxml.jackson.databind.JsonNode requestNode, org.slf4j.Logger logger) Parses a RestServiceRequest from JSON.static RestServiceRequestCreates a simple GET request.booleanhasBody()Checks if this request has a body.final inthashCode()Returns a hash code value for this object.headers()Returns the value of theheadersrecord component.method()Returns the value of themethodrecord component.static RestServiceRequestCreates a POST request with JSON body.Returns the value of thequeryParamsrecord component.intReturns the value of thetimeoutMsrecord component.final StringtoString()Returns a string representation of this record class.url()Returns the value of theurlrecord component.booleanReturns the value of theverifySslrecord component.
-
Field Details
-
DEFAULT_TIMEOUT_MS
public static final int DEFAULT_TIMEOUT_MSDefault timeout in milliseconds (30 seconds).- See Also:
-
-
Constructor Details
-
RestServiceRequest
public 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) Compact constructor with validation and defaults.
-
-
Method Details
-
builder
Creates a new builder for RestServiceRequest.- Parameters:
url- The URL to call- Returns:
- A new builder instance
-
get
Creates a simple GET request.- Parameters:
url- The URL to call- Returns:
- A GET request
-
postJson
Creates a POST request with JSON body.- Parameters:
url- The URL to callbody- 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 configurationlogger- Optional logger for warnings- Returns:
- The parsed RestServiceRequest
-
buildFullUrl
Builds the full URL including query parameters.- Returns:
- The full URL with query parameters
-
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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
url
Returns the value of theurlrecord component.- Returns:
- the value of the
urlrecord component
-
method
Returns the value of themethodrecord component.- Returns:
- the value of the
methodrecord component
-
headers
Returns the value of theheadersrecord component.- Returns:
- the value of the
headersrecord component
-
queryParams
Returns the value of thequeryParamsrecord component.- Returns:
- the value of the
queryParamsrecord component
-
body
Returns the value of thebodyrecord component.- Returns:
- the value of the
bodyrecord component
-
contentType
Returns the value of thecontentTyperecord component.- Returns:
- the value of the
contentTyperecord component
-
auth
Returns the value of theauthrecord component.- Returns:
- the value of the
authrecord component
-
timeoutMs
public int timeoutMs()Returns the value of thetimeoutMsrecord component.- Returns:
- the value of the
timeoutMsrecord component
-
followRedirects
public boolean followRedirects()Returns the value of thefollowRedirectsrecord component.- Returns:
- the value of the
followRedirectsrecord component
-
verifySsl
public boolean verifySsl()Returns the value of theverifySslrecord component.- Returns:
- the value of the
verifySslrecord component
-