Package com.cognite.client
Class Request
- java.lang.Object
-
- com.cognite.client.Request
-
- All Implemented Interfaces:
Serializable
public abstract class Request extends Object implements Serializable
This class represents the Cognite Data Fusion API request parameters. The available parameters depend on which API endpoint you are working towards. The parameters mirrors what is available in the api. For example, which filters you can use. Please refer to the Cognite API documentationhttps://docs.cognite.com/api/v1/for reference.- See Also:
- Cognite API v1 specification, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRequest.Builder
-
Constructor Summary
Constructors Constructor Description Request()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Requestcreate()abstract AuthConfiggetAuthConfig()Returns the project configuration for a request.com.google.common.collect.ImmutableMap<String,Object>getFilterParameters()Returns the collection of filter parameters as a Map.com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableMap<String,Object>>getItems()Returns the list of items.com.google.common.collect.ImmutableMap<String,String>getMetadataFilterParameters()Returns the collection of metadata specific filter parameters as a Map.abstract com.google.protobuf.MessagegetProtoRequestBody()For internal use only.abstract com.google.common.collect.ImmutableMap<String,Object>getRequestParameters()Returns the object representation of the composite request body.StringgetRequestParametersAsJson()RequestwithAuthConfig(AuthConfig config)Sets the project configuration for a request.RequestwithDbName(String dbName)Convenience method for adding the database name when reading from Cognite.Raw.RequestwithFilterMetadataParameter(String key, String value)Adds a new parameter to the filter.metadata node.RequestwithFilterParameter(String key, Object value)Adds a new parameter to the filter node.RequestwithItemExternalId(String externalId)Deprecated.RequestwithItemExternalIds(String... externalId)Convenience method for setting the external id for requesting multiple items.RequestwithItemInternalId(long internalId)Deprecated.RequestwithItemInternalIds(long... internalId)Convenience method for setting the external id for requesting multiple items.RequestwithItems(List<? extends Map<String,Object>> items)Sets the items array to the specified input list.RequestwithProtoRequestBody(com.google.protobuf.Message requestBody)Adds the complete request body as a protobuf object.RequestwithRequestJson(String value)Adds the complete request parameter structure based on Json.RequestwithRequestParameters(Map<String,Object> requestParameters)Adds the complete request parameter structure based on Java objects.RequestwithRootParameter(String key, Object value)Adds a new parameter to the root level.RequestwithTableName(String tableName)Convenience method for adding the table name when reading from Cognite.Raw.
-
-
-
Method Detail
-
create
public static Request create()
-
getRequestParameters
public abstract com.google.common.collect.ImmutableMap<String,Object> getRequestParameters()
Returns the object representation of the composite request body. It is similar to the Cognite API Json request body, withMap<String, Object>as the Json container,Listas the Json array.- Returns:
-
getProtoRequestBody
@Nullable public abstract com.google.protobuf.Message getProtoRequestBody()
For internal use only. Returns the protobuf request body.- Returns:
-
getAuthConfig
@Nullable public abstract AuthConfig getAuthConfig()
Returns the project configuration for a request. The configuration includes host (optional), project/tenant and key.- Returns:
-
withRequestParameters
public Request withRequestParameters(Map<String,Object> requestParameters)
Adds the complete request parameter structure based on Java objects. Calling this method will overwrite any previously added parameters. - All keys must be String. - Values can be primitives or containers - Valid primitives are String, Integer, Double, Float, Long, Boolean. - Valid containers are Map (Json Object) and List (Json array).- Parameters:
requestParameters-- Returns:
- The request object with the parameter applied.
-
withProtoRequestBody
public Request withProtoRequestBody(com.google.protobuf.Message requestBody)
Adds the complete request body as a protobuf object.- Parameters:
requestBody-- Returns:
- The request object with the parameter applied.
-
withRequestJson
public Request withRequestJson(String value) throws Exception
Adds the complete request parameter structure based on Json. Calling this method will overwrite any previously added parameters.- Parameters:
value-- Returns:
- The request object with the parameter applied.
- Throws:
Exception
-
withRootParameter
public Request withRootParameter(String key, Object value)
Adds a new parameter to the root level.- Parameters:
key-value-- Returns:
- The request object with the parameter applied.
-
withFilterParameter
public Request withFilterParameter(String key, Object value)
Adds a new parameter to the filter node.- Parameters:
key-value-- Returns:
- The request object with the parameter applied.
-
withFilterMetadataParameter
public Request withFilterMetadataParameter(String key, String value)
Adds a new parameter to the filter.metadata node.- Parameters:
key-value-- Returns:
- The request object with the parameter applied.
-
withItems
public Request withItems(List<? extends Map<String,Object>> items)
Sets the items array to the specified input list. The list represents an array of objects via Java Map. That is, an instance of Map equals a Json object. For most write operations the maximum number of items per request is 1k. For time series datapoints the maximum number of items is 10k, with a maximum of 100k data points.- Parameters:
items-- Returns:
- The request object with the parameter applied.
-
withItemExternalId
@Deprecated public Request withItemExternalId(String externalId)
Deprecated.Convenience method for setting the external id for requesting an item. You can use this method when requesting a data item by id, for example when requesting the data points from a time series.- Parameters:
externalId-- Returns:
- The request object with the parameter applied.
-
withItemExternalIds
public Request withItemExternalIds(String... externalId)
Convenience method for setting the external id for requesting multiple items. You can use this method when requesting a data item by id, for example when requesting a set of events.- Parameters:
externalId-- Returns:
- The request object with the parameter applied.
-
withItemInternalId
@Deprecated public Request withItemInternalId(long internalId)
Deprecated.Convenience method for setting the external id for requesting an item. You can use this method when requesting a data item by id, for example when requesting the data points from a time series.- Parameters:
internalId-- Returns:
- The request object with the parameter applied.
-
withItemInternalIds
public Request withItemInternalIds(long... internalId)
Convenience method for setting the external id for requesting multiple items. You can use this method when requesting a data item by id, for example when requesting a set of events.- Parameters:
internalId-- Returns:
- The request object with the parameter applied.
-
withDbName
public Request withDbName(String dbName)
Convenience method for adding the database name when reading from Cognite.Raw.- Parameters:
dbName- The name of the database to read from.- Returns:
- The request object with the parameter applied.
-
withTableName
public Request withTableName(String tableName)
Convenience method for adding the table name when reading from Cognite.Raw.- Parameters:
tableName- The name of the database to read from.- Returns:
- The request object with the parameter applied.
-
withAuthConfig
public Request withAuthConfig(AuthConfig config)
Sets the project configuration for a request. The configuration includes host (optional), project/tenant and key. You can use this method if you need detailed, per-request control over auth config. In most cases, however, you will configure this once on theCogniteClient.- Parameters:
config- The auth config- Returns:
- The request object with the configuration applied.
-
getRequestParametersAsJson
public String getRequestParametersAsJson() throws com.fasterxml.jackson.core.JsonProcessingException
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getFilterParameters
public com.google.common.collect.ImmutableMap<String,Object> getFilterParameters()
Returns the collection of filter parameters as a Map. The filter parameter must have a key of type String in order to be included in the return collection. Please note that all entries (with a key of typeString) under the filter node are returned, potentially including nested collections (such as metadata).- Returns:
-
getMetadataFilterParameters
public com.google.common.collect.ImmutableMap<String,String> getMetadataFilterParameters()
Returns the collection of metadata specific filter parameters as a Map. The parameters must have both a key and value of type String in order to be included in the return collection.- Returns:
-
-