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:
  • Constructor Details

    • RequestParametersResponseParser

      public RequestParametersResponseParser()
  • Method Details

    • of

      public static RequestParametersResponseParser of(Map<String,String> attributeMap)
    • enableItemMode

      public RequestParametersResponseParser enableItemMode(boolean enable)
      Enables/disables item mode. In item mode, the Request will 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 from root.jobId and map it to the Request parameter root.id. In item mode, this will extract the json value from root.jobId and map it to root.items[n].id Default is false.
      Parameters:
      enable -
      Returns:
    • extractNextCursor

      public Optional<String> extractNextCursor(byte[] payload) throws Exception
      Extract the next cursor from a response body.
      Specified by:
      extractNextCursor in interface ResponseParser<Request>
      Parameters:
      payload - The response body
      Returns:
      Throws:
      Exception
      IOException
    • 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:
      extractItems in interface ResponseParser<Request>
      Parameters:
      payload - The results byte payload
      Returns:
      Throws:
      IOException
      Exception