Class ResponseItems<T>

  • All Implemented Interfaces:
    Serializable

    public abstract class ResponseItems<T>
    extends Object
    implements Serializable
    This class represents a collection of response items from a Cognite API request.
    See Also:
    Serialized Form
    • Constructor Detail

      • ResponseItems

        public ResponseItems()
    • Method Detail

      • getResponseBinary

        public abstract ResponseBinary getResponseBinary()
      • withDuplicateResponseParser

        public ResponseItems<T> withDuplicateResponseParser​(ResponseParser<String> parser)
        Specifies the parser for extracting duplicate items from the response payload. The default parser looks in the *duplicated* object of the response json.
        Parameters:
        parser -
        Returns:
      • withMissingResponseParser

        public ResponseItems<T> withMissingResponseParser​(ResponseParser<String> parser)
        Specifies the parser for extracting missing items from the response payload. The default parser looks in the *missing* object of the response json.
        Parameters:
        parser -
        Returns:
      • withErrorMessageResponseParser

        public ResponseItems<T> withErrorMessageResponseParser​(ResponseParser<String> parser)
        Specifies the parser for extracting the error message from the response payload. The default parser looks in the *message* attribute of the response json.
        Parameters:
        parser -
        Returns:
      • withStatusResponseParser

        public ResponseItems<T> withStatusResponseParser​(ResponseParser<String> parser)
        Specifies the parser for extracting the error code (http status code) from the response payload. The default parser looks in the *code* attribute of the response json.
        Parameters:
        parser -
        Returns:
      • withResultsItemsList

        public ResponseItems<T> withResultsItemsList​(com.google.common.collect.ImmutableList<T> itemsList)
        Specifies a results items list. By setting this list you will override the default behavior which is to parse the results items from the response body (bytes). That is, if a results items list is specified, the parser will not attempt to parse the response body.
        Parameters:
        itemsList -
        Returns:
      • getResultsItems

        public com.google.common.collect.ImmutableList<T> getResultsItems()
                                                                   throws Exception
        Returns the main result items. A response payload from Cognite Data Fusion may contain 0..* results items (typically max 1k items), so the items are returned in a list.
        Returns:
        A list of result items.
        Throws:
        Exception
      • getDuplicateItems

        public com.google.common.collect.ImmutableList<String> getDuplicateItems()
                                                                          throws Exception
        Returns a list of duplicate items. If Cognite Data Fusion reports duplicates in its response, they will be returned by this method.
        Returns:
        A list of duplicate items.
        Throws:
        Exception
      • getMissingItems

        public com.google.common.collect.ImmutableList<String> getMissingItems()
                                                                        throws Exception
        Returns a list of missing items. If Cognite Data Fusion reports missing items, they will be returned by this method.
        Returns:
        a list of missing items.
        Throws:
        Exception
      • getStatus

        public com.google.common.collect.ImmutableList<String> getStatus()
                                                                  throws Exception
        Returns the status message of the response. Usually, the response will contain 0..1 status message, so you should check the first item in the returned list for the status message.
        Returns:
        a list with the status message as item[0].
        Throws:
        Exception
      • getErrorMessage

        public com.google.common.collect.ImmutableList<String> getErrorMessage()
                                                                        throws Exception
        Returns the response error message as item[0], if any.
        Returns:
        Throws:
        Exception
      • getResponseBodyAsString

        public String getResponseBodyAsString()
        Returns the response body as a string.
        Returns:
        the response body as a string.
      • isSuccessful

        public boolean isSuccessful()
        Returns true if the request was successful, false if unsuccessful.
        Returns:
        true if the request was successful, false if unsuccessful.
      • getXRequestId

        public Optional<String> getXRequestId()
        Returns the x-request-id (set by Cognite Data Fusion) if it exists in the response header.
        Returns:
        The x-request-id header value if it exists.