Class ApiJsonRequest<T extends ApiJsonRequest<T>>
- java.lang.Object
-
- io.helidon.integrations.common.rest.ApiJsonBuilder<T>
-
- io.helidon.integrations.common.rest.ApiJsonRequest<T>
-
- Type Parameters:
T
- type of the request
- All Implemented Interfaces:
ApiRequest<T>
- Direct Known Subclasses:
JsonRequest
,OciRequestBase
,VaultRequest
public abstract class ApiJsonRequest<T extends ApiJsonRequest<T>> extends ApiJsonBuilder<T> implements ApiRequest<T>
Common base class for REST requests that have an entity. This class acts as a mutable builder of request JSON object. Path is not a part of this request.- See Also:
ApiRequest
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ApiJsonRequest()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
addHeader(String name, String... value)
Add an HTTP header.T
addQueryParam(String name, String... value)
Add an HTTP query parameter.Map<String,List<String>>
headers()
Returns immutable configured headers.Map<String,List<String>>
queryParams()
Returns immutable configured query parameters.Optional<String>
requestId()
Configured request ID.T
requestId(String requestId)
Configure request ID for logging (and possibly to send over the network).Optional<MediaType>
requestMediaType()
Request media type.T
requestMediaType(MediaType mediaType)
The media type header, defaults toMediaType.APPLICATION_JSON
when JSON entity is present, toMediaType.APPLICATION_OCTET_STREAM
for publisher base requests, empty otherwise.Optional<MediaType>
responseMediaType()
Response media type.T
responseMediaType(MediaType mediaType)
The accept header, defaults toMediaType.APPLICATION_JSON
for most requests, except for requests that return publisher, which default toMediaType.APPLICATION_OCTET_STREAM
.-
Methods inherited from class io.helidon.integrations.common.rest.ApiJsonBuilder
add, add, add, add, add, add, addBase64, addToArray, addToArray, addToArray, addToArray, addToArray, addToArray, addToObject, addToObject, addToObject, addToObject, addToObject, emptyArray, me, postBuild, preBuild, toJson
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.integrations.common.rest.ApiRequest
toJson
-
-
-
-
Method Detail
-
addHeader
public T addHeader(String name, String... value)
Add an HTTP header.- Specified by:
addHeader
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Parameters:
name
- name of the headervalue
- header value(s)- Returns:
- updated request
-
addQueryParam
public T addQueryParam(String name, String... value)
Add an HTTP query parameter.- Specified by:
addQueryParam
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Parameters:
name
- name of the parametervalue
- parameter value(s)- Returns:
- updated request
-
headers
public Map<String,List<String>> headers()
Returns immutable configured headers.- Specified by:
headers
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Returns:
- headers configured for this request
-
queryParams
public Map<String,List<String>> queryParams()
Returns immutable configured query parameters.- Specified by:
queryParams
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Returns:
- query parameters configured for this request
-
requestMediaType
public T requestMediaType(MediaType mediaType)
Description copied from interface:ApiRequest
The media type header, defaults toMediaType.APPLICATION_JSON
when JSON entity is present, toMediaType.APPLICATION_OCTET_STREAM
for publisher base requests, empty otherwise.- Specified by:
requestMediaType
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Parameters:
mediaType
- media type of request- Returns:
- updated request
-
responseMediaType
public T responseMediaType(MediaType mediaType)
Description copied from interface:ApiRequest
The accept header, defaults toMediaType.APPLICATION_JSON
for most requests, except for requests that return publisher, which default toMediaType.APPLICATION_OCTET_STREAM
.- Specified by:
responseMediaType
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Parameters:
mediaType
- accepted media type- Returns:
- updated request
-
requestId
public T requestId(String requestId)
Description copied from interface:ApiRequest
Configure request ID for logging (and possibly to send over the network).- Specified by:
requestId
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Parameters:
requestId
- request id- Returns:
- updated request
-
requestMediaType
public Optional<MediaType> requestMediaType()
Description copied from interface:ApiRequest
Request media type.- Specified by:
requestMediaType
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Returns:
- media type if configured
- See Also:
ApiRequest.requestMediaType(io.helidon.common.http.MediaType)
-
responseMediaType
public Optional<MediaType> responseMediaType()
Description copied from interface:ApiRequest
Response media type.- Specified by:
responseMediaType
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Returns:
- media type if configured
- See Also:
ApiRequest.responseMediaType(io.helidon.common.http.MediaType)
-
requestId
public Optional<String> requestId()
Description copied from interface:ApiRequest
Configured request ID.- Specified by:
requestId
in interfaceApiRequest<T extends ApiJsonRequest<T>>
- Returns:
- request ID if configured
-
-