Package com.cognite.client.servicesV1
Class ResponseItems<T>
java.lang.Object
com.cognite.client.servicesV1.ResponseItems<T>
- All Implemented Interfaces:
Serializable
This class represents a collection of response items from a Cognite API request.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.collect.ImmutableList<String>Returns a list of duplicate items.com.google.common.collect.ImmutableList<String>Returns the response error message as item[0], if any.com.google.common.collect.ImmutableList<String>Returns a list of missing items.abstract ResponseBinaryReturns the response body as a string.com.google.common.collect.ImmutableList<T>Returns the main result items.com.google.common.collect.ImmutableList<String>Returns the status message of the response.Returns the x-request-id (set by Cognite Data Fusion) if it exists in the response header.booleanReturnstrueif the request was successful,falseif unsuccessful.static <T> ResponseItems<T>of(ResponseParser<T> responseParser, ResponseBinary response) Specifies the parser for extracting duplicate items from the response payload.Specifies the parser for extracting the error message from the response payload.Specifies the parser for extracting missing items from the response payload.withResultsItemsList(com.google.common.collect.ImmutableList<T> itemsList) Specifies a results items list.withStatusResponseParser(ResponseParser<String> parser) Specifies the parser for extracting the error code (http status code) from the response payload.
-
Constructor Details
-
ResponseItems
public ResponseItems()
-
-
Method Details
-
of
-
getResponseBinary
-
withDuplicateResponseParser
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
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
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
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
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
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
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
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
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
Returns the response error message as item[0], if any.- Returns:
- Throws:
Exception
-
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.
-
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.
-