Package com.cognite.client.servicesV1
Class ResponseItems<T>
- java.lang.Object
-
- com.cognite.client.servicesV1.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 Summary
Constructors Constructor Description ResponseItems()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description com.google.common.collect.ImmutableList<String>getDuplicateItems()Returns a list of duplicate items.com.google.common.collect.ImmutableList<String>getErrorMessage()Returns the response error message as item[0], if any.com.google.common.collect.ImmutableList<String>getMissingItems()Returns a list of missing items.abstract ResponseBinarygetResponseBinary()StringgetResponseBodyAsString()Returns the response body as a string.com.google.common.collect.ImmutableList<T>getResultsItems()Returns the main result items.com.google.common.collect.ImmutableList<String>getStatus()Returns the status message of the response.Optional<String>getXRequestId()Returns the x-request-id (set by Cognite Data Fusion) if it exists in the response header.booleanisSuccessful()Returnstrueif the request was successful,falseif unsuccessful.static <T> ResponseItems<T>of(ResponseParser<T> responseParser, ResponseBinary response)ResponseItems<T>withDuplicateResponseParser(ResponseParser<String> parser)Specifies the parser for extracting duplicate items from the response payload.ResponseItems<T>withErrorMessageResponseParser(ResponseParser<String> parser)Specifies the parser for extracting the error message from the response payload.ResponseItems<T>withMissingResponseParser(ResponseParser<String> parser)Specifies the parser for extracting missing items from the response payload.ResponseItems<T>withResultsItemsList(com.google.common.collect.ImmutableList<T> itemsList)Specifies a results items list.ResponseItems<T>withStatusResponseParser(ResponseParser<String> parser)Specifies the parser for extracting the error code (http status code) from the response payload.
-
-
-
Method Detail
-
of
public static <T> ResponseItems<T> of(ResponseParser<T> responseParser, ResponseBinary response)
-
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()
Returnstrueif the request was successful,falseif unsuccessful.- Returns:
trueif the request was successful,falseif unsuccessful.
-
-