CosmosItemRequestOptions Class
- java.
lang. Object - com.
azure. cosmos. models. CosmosItemRequestOptions
- com.
public class CosmosItemRequestOptions
Encapsulates options that can be specified for a request issued to cosmos Item.
Constructor Summary
Constructor | Description |
---|---|
CosmosItemRequestOptions() |
Constructor |
Method Summary
Modifier and Type | Method and Description |
---|---|
Consistency |
getConsistencyLevel()
Gets the consistency level required for the request. |
Cosmos |
getCustomItemSerializer()
Gets the custom item serializer defined for this instance of request options |
Dedicated |
getDedicatedGatewayRequestOptions()
Gets the Dedicated Gateway Request Options |
Cosmos |
getDiagnosticsThresholds()
Gets the diagnostic thresholds used as an override for a specific operation. |
List<String> |
getExcludedRegions()
Gets the list of regions to be excluded for the request/retries. |
String |
getIfMatchETag()
Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. |
String |
getIfNoneMatchETag()
Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. |
Indexing |
getIndexingDirective()
Gets the indexing directive (index, do not index etc). |
Set<String> |
getKeywordIdentifiers()
Gets the custom ids. |
List<String> |
getPostTriggerInclude()
Gets the triggers to be invoked after the operation. |
List<String> |
getPreTriggerInclude()
Gets the triggers to be invoked before the operation. |
String |
getSessionToken()
Gets the token for use with session consistency. |
Duration |
getThresholdForDiagnosticsOnTracer()
Gets the threshold |
String |
getThroughputControlGroupName()
Gets the throughput control group name. |
Boolean |
isContentResponseOnWriteEnabled()
Gets the boolean to only return the headers and status code in Cosmos DB response in case of Create, Update and Delete operations on Cosmos |
Cosmos |
setConsistencyLevel(ConsistencyLevel consistencyLevel)
Sets the consistency level required for the request. |
Cosmos |
setContentResponseOnWriteEnabled(Boolean contentResponseOnWriteEnabled)
Sets the boolean to only return the headers and status code in Cosmos DB response in case of Create, Update and Delete operations on Cosmos |
Cosmos |
setCosmosEndToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig endToEndOperationLatencyPolicyConfig)
Sets the CosmosEndToEndOperationLatencyPolicyConfig to be used for the request. |
Cosmos |
setCustomItemSerializer(CosmosItemSerializer customItemSerializer)
Allows specifying a custom item serializer to be used for this operation. |
Cosmos |
setDedicatedGatewayRequestOptions(DedicatedGatewayRequestOptions dedicatedGatewayRequestOptions)
Sets the Dedicated Gateway Request Options |
Cosmos |
setDiagnosticsThresholds(CosmosDiagnosticsThresholds operationSpecificThresholds)
Allows overriding the diagnostic thresholds for a specific operation. |
Cosmos |
setExcludedRegions(List<String> excludeRegions)
List of regions to exclude for the request/retries. |
Cosmos |
setIfMatchETag(String ifMatchETag)
Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. |
Cosmos |
setIfNoneMatchETag(String ifNoneMatchETag)
Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. |
Cosmos |
setIndexingDirective(IndexingDirective indexingDirective)
Sets the indexing directive (index, do not index etc). |
Cosmos |
setKeywordIdentifiers(Set<String> keywordIdentifiers)
Sets the custom ids. |
Cosmos |
setNonIdempotentWriteRetryPolicy(boolean nonIdempotentWriteRetriesEnabled, boolean useTrackingIdPropertyForCreateAndReplace)
Enables automatic retries for write operations even when the SDK can't guarantee that they are idempotent. |
Cosmos |
setPostTriggerInclude(List<String> postTriggerInclude)
Sets the triggers to be invoked after the operation. |
Cosmos |
setPreTriggerInclude(List<String> preTriggerInclude)
Sets the triggers to be invoked before the operation. |
Cosmos |
setSessionToken(String sessionToken)
Sets the token for use with session consistency. |
Cosmos |
setThresholdForDiagnosticsOnTracer(Duration thresholdForDiagnosticsOnTracer)
Sets the threshold |
void |
setThroughputControlGroupName(String throughputControlGroupName)
Sets the throughput control group name. |
Methods inherited from java.lang.Object
Constructor Details
CosmosItemRequestOptions
public CosmosItemRequestOptions()
Constructor
Method Details
getConsistencyLevel
public ConsistencyLevel getConsistencyLevel()
Gets the consistency level required for the request.
Returns:
getCustomItemSerializer
public CosmosItemSerializer getCustomItemSerializer()
Gets the custom item serializer defined for this instance of request options
Returns:
getDedicatedGatewayRequestOptions
public DedicatedGatewayRequestOptions getDedicatedGatewayRequestOptions()
Gets the Dedicated Gateway Request Options
Returns:
getDiagnosticsThresholds
public CosmosDiagnosticsThresholds getDiagnosticsThresholds()
Gets the diagnostic thresholds used as an override for a specific operation. If no operation specific diagnostic threshold has been specified, this method will return null, although at runtime the default thresholds specified at the client-level will be used.
Returns:
getExcludedRegions
public List
Gets the list of regions to be excluded for the request/retries. These regions are excluded from the preferred region list.
Returns:
getIfMatchETag
public String getIfMatchETag()
Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service.
Returns:
getIfNoneMatchETag
public String getIfNoneMatchETag()
Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service.
Returns:
getIndexingDirective
public IndexingDirective getIndexingDirective()
Gets the indexing directive (index, do not index etc).
Returns:
getKeywordIdentifiers
public Set
Gets the custom ids.
Returns:
getPostTriggerInclude
public List
Gets the triggers to be invoked after the operation.
Returns:
getPreTriggerInclude
public List
Gets the triggers to be invoked before the operation.
Returns:
getSessionToken
public String getSessionToken()
Gets the token for use with session consistency.
Returns:
getThresholdForDiagnosticsOnTracer
public Duration getThresholdForDiagnosticsOnTracer()
Gets the thresholdForDiagnosticsOnTracer, if latency on CRUD operation is greater than this diagnostics will be sent to open telemetry exporter as events in tracer span of end to end CRUD api. Default is 100 ms.
Returns:
getThroughputControlGroupName
public String getThroughputControlGroupName()
Gets the throughput control group name.
Returns:
isContentResponseOnWriteEnabled
public Boolean isContentResponseOnWriteEnabled()
Gets the boolean to only return the headers and status code in Cosmos DB response in case of Create, Update and Delete operations on CosmosItem. If set to false, service doesn't return a payload in the response. It reduces networking and CPU load by not sending the payload back over the network and serializing it on the client. This feature does not impact RU usage for read or write operations. NOTE: This flag is also present on CosmosClientBuilder, however if specified on CosmosItemRequestOptions, it will override the value specified in CosmosClientBuilder for this request. By-default, this is null.
Returns:
setConsistencyLevel
public CosmosItemRequestOptions setConsistencyLevel(ConsistencyLevel consistencyLevel)
Sets the consistency level required for the request. The effective consistency level can only be reduced for read/query requests. So when the Account's default consistency level is for example Session you can specify on a request-by-request level for individual requests that Eventual consistency is sufficient - which could reduce the latency and RU charges for this request but will not guarantee session consistency (read-your-own-write) anymore NOTE: If the consistency-level set on a request level here is SESSION and the default consistency level specified when constructing the CosmosClient instance via CosmosClientBuilder.consistencyLevel is not SESSION then session token capturing also needs to be enabled by calling CosmosClientBuilder:sessionCapturingOverrideEnabled(true) explicitly.
Parameters:
Returns:
setContentResponseOnWriteEnabled
public CosmosItemRequestOptions setContentResponseOnWriteEnabled(Boolean contentResponseOnWriteEnabled)
Sets the boolean to only return the headers and status code in Cosmos DB response in case of Create, Update and Delete operations on CosmosItem. If set to false, service doesn't return payload in the response. It reduces networking and CPU load by not sending the payload back over the network and serializing it on the client. This feature does not impact RU usage for read or write operations. By-default, this is null. NOTE: This flag is also present on CosmosClientBuilder, however if specified on CosmosItemRequestOptions, it will override the value specified in CosmosClientBuilder for this request.
Parameters:
Returns:
setCosmosEndToEndOperationLatencyPolicyConfig
public CosmosItemRequestOptions setCosmosEndToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig endToEndOperationLatencyPolicyConfig)
Sets the CosmosEndToEndOperationLatencyPolicyConfig to be used for the request. If the config is already set on the client, then this will override the client level config for this request
Parameters:
Returns:
setCustomItemSerializer
public CosmosItemRequestOptions setCustomItemSerializer(CosmosItemSerializer customItemSerializer)
Allows specifying a custom item serializer to be used for this operation. If the serializer on the request options is null, the serializer on CosmosClientBuilder is used. If both serializers are null (the default), an internal Jackson ObjectMapper is ued for serialization/deserialization.
Parameters:
Returns:
setDedicatedGatewayRequestOptions
public CosmosItemRequestOptions setDedicatedGatewayRequestOptions(DedicatedGatewayRequestOptions dedicatedGatewayRequestOptions)
Sets the Dedicated Gateway Request Options
Parameters:
Returns:
setDiagnosticsThresholds
public CosmosItemRequestOptions setDiagnosticsThresholds(CosmosDiagnosticsThresholds operationSpecificThresholds)
Allows overriding the diagnostic thresholds for a specific operation.
Parameters:
Returns:
setExcludedRegions
public CosmosItemRequestOptions setExcludedRegions(List
List of regions to exclude for the request/retries. Example "East US" or "East US, West US" These regions will be excluded from the preferred regions list
Parameters:
Returns:
setIfMatchETag
public CosmosItemRequestOptions setIfMatchETag(String ifMatchETag)
Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service.
Parameters:
Returns:
setIfNoneMatchETag
public CosmosItemRequestOptions setIfNoneMatchETag(String ifNoneMatchETag)
Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service.
Parameters:
Returns:
setIndexingDirective
public CosmosItemRequestOptions setIndexingDirective(IndexingDirective indexingDirective)
Sets the indexing directive (index, do not index etc).
Parameters:
Returns:
setKeywordIdentifiers
public CosmosItemRequestOptions setKeywordIdentifiers(Set
Sets the custom ids.
Parameters:
Returns:
setNonIdempotentWriteRetryPolicy
public CosmosItemRequestOptions setNonIdempotentWriteRetryPolicy(boolean nonIdempotentWriteRetriesEnabled, boolean useTrackingIdPropertyForCreateAndReplace)
Enables automatic retries for write operations even when the SDK can't guarantee that they are idempotent. This is an override of the nonIdempotentWriteRetryOptions(NonIdempotentWriteRetryOptions options) behavior for a specific request/operation. NOTE: the setting on the CosmosClientBuilder will determine the default behavior for Create, Replace, Upsert and Delete operations. It can be overridden on per-request base in the request options. For patch operations by default (unless overridden in the request options) retries are always disabled by default. - Create: retries can result in surfacing (more) 409-Conflict requests to the application when a retry tries to create a document that the initial attempt successfully created. When enabling useTrackingIdPropertyForCreateAndReplace this can be avoided for 409-Conflict caused by retries. - Replace: retries can result in surfacing (more) 412-Precondition failure requests to the application when a replace operations are using a pre-condition check (etag) and a retry tries to update a document that the initial attempt successfully updated (causing the etag to change). When enabling useTrackingIdPropertyForCreateAndReplace this can be avoided for 412-Precondition failures caused by retries. - Delete: retries can result in surfacing (more) 404-NotFound requests when a delete operation is retried and the initial attempt succeeded. Ideally, write retries should only be enabled when applications can gracefully handle 404 - Not Found. - Upsert: retries can result in surfacing a 200 - looking like the document was updated when actually the document has been created by the initial attempt - so logically within the same operation. This will only impact applications who have special casing for 201 vs. 200 for upsert operations. Patch: retries for patch can but will not always be idempotent - it completely depends on the patch operations being executed and the precondition filters being used. Before enabling write retries for patch this needs to be carefully reviewed and tests - which is wht retries for patch can only be enabled on request options - any CosmosClient wide configuration will be ignored. Bulk/Delete by PK/Transactional Batch/Stroed Procedure execution: No automatic retries are supported.
Parameters:
Returns:
setPostTriggerInclude
public CosmosItemRequestOptions setPostTriggerInclude(List
Sets the triggers to be invoked after the operation.
Parameters:
Returns:
setPreTriggerInclude
public CosmosItemRequestOptions setPreTriggerInclude(List
Sets the triggers to be invoked before the operation.
Parameters:
Returns:
setSessionToken
public CosmosItemRequestOptions setSessionToken(String sessionToken)
Sets the token for use with session consistency.
Parameters:
Returns:
setThresholdForDiagnosticsOnTracer
public CosmosItemRequestOptions setThresholdForDiagnosticsOnTracer(Duration thresholdForDiagnosticsOnTracer)
Sets the thresholdForDiagnosticsOnTracer, if latency on CRUD operation is greater than this diagnostics will be sent to open telemetry exporter as events in tracer span of end to end CRUD api. Default is 100 ms.
Parameters:
Returns:
setThroughputControlGroupName
public void setThroughputControlGroupName(String throughputControlGroupName)
Sets the throughput control group name.
Parameters:
Applies to
Azure SDK for Java