Class RequestParametersResponseParser
java.lang.Object
com.cognite.client.servicesV1.response.RequestParametersResponseParser
- All Implemented Interfaces:
ResponseParser<Request>,Serializable
public abstract class RequestParametersResponseParser
extends Object
implements ResponseParser<Request>, Serializable
Parses a Json payload and generates a
Request object containing the extracted parameters.
The parser will look for Json parameters that match the attribute map. The parameters
are added to the RequestParameters object as root parameters.
The attribute map defines json node -> RequestParameters root node. The key specifies which
json node to extract, and the corresponding value specifies the Request root parameter name.
Example:
{"jobId", "id"} will extract the json value from root.jobId and maps it to the Request
parameter "id".
If you specify '*' as a key in the attribute map, all root attributes that are value nodes (i.e. not container
nodes) will be added to the Request.
A cursor is never returned from this parser.- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionenableItemMode(boolean enable) Enables/disables item mode.com.google.common.collect.ImmutableList<Request>extractItems(byte[] payload) Extract the main items from a results json payload.extractNextCursor(byte[] payload) Extract the next cursor from a response body.
-
Constructor Details
-
RequestParametersResponseParser
public RequestParametersResponseParser()
-
-
Method Details
-
of
-
enableItemMode
Enables/disables item mode. In item mode, theRequestwill be populated with values within an items array. This is a common request pattern for performing per-item requests towards the Cognite API. Example: Given the attribute map{"jobId", "id"}. In non-item mode this will extract the json value fromroot.jobIdand map it to theRequestparameterroot.id. In item mode, this will extract the json value fromroot.jobIdand map it toroot.items[n].idDefault isfalse.- Parameters:
enable-- Returns:
-
extractNextCursor
Extract the next cursor from a response body.- Specified by:
extractNextCursorin interfaceResponseParser<Request>- Parameters:
payload- The response body- Returns:
- Throws:
ExceptionIOException
-
extractItems
public com.google.common.collect.ImmutableList<Request> extractItems(byte[] payload) throws Exception Extract the main items from a results json payload. Returns the entire payload as a json string.- Specified by:
extractItemsin interfaceResponseParser<Request>- Parameters:
payload- The results byte payload- Returns:
- Throws:
IOExceptionException
-