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 aRequestobject containing the extracted parameters. The parser will look for Json parameters that match the attribute map. The parameters are added to theRequestParametersobject as root parameters. The attribute map definesjson node->RequestParameters root node. Thekeyspecifies which json node to extract, and the correspondingvaluespecifies theRequestroot parameter name. Example:{"jobId", "id"}will extract the json value fromroot.jobIdand maps it to theRequestparameter "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 theRequest. A cursor is never returned from this parser.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRequestParametersResponseParser.Builder
-
Constructor Summary
Constructors Constructor Description RequestParametersResponseParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestParametersResponseParserenableItemMode(boolean enable)Enables/disables item mode.com.google.common.collect.ImmutableList<Request>extractItems(byte[] payload)Extract the main items from a results json payload.Optional<String>extractNextCursor(byte[] payload)Extract the next cursor from a response body.static RequestParametersResponseParserof(Map<String,String> attributeMap)
-
-
-
Method Detail
-
of
public static RequestParametersResponseParser of(Map<String,String> attributeMap)
-
enableItemMode
public RequestParametersResponseParser enableItemMode(boolean enable)
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
public Optional<String> extractNextCursor(byte[] payload) throws Exception
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
-
-