Class CosmosDatabaseRequestOptions

java.lang.Object
com.azure.cosmos.models.CosmosDatabaseRequestOptions

public final class CosmosDatabaseRequestOptions extends Object
Encapsulates options that can be specified for a request issued to cosmos database.
  • Constructor Details

    • CosmosDatabaseRequestOptions

      public CosmosDatabaseRequestOptions()
  • Method Details

    • getIfMatchETag

      public String getIfMatchETag()
      Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. Most commonly used with replace and delete requests. This will be ignored if specified for create requests. For more details, refer to optimistic concurrency control documentation
      Returns:
      the ifMatchETag associated with the request.
    • setIfMatchETag

      public CosmosDatabaseRequestOptions setIfMatchETag(String ifMatchETag)
      Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. Most commonly used with replace and delete requests. This will be ignored if specified for create requests. For more details, refer to optimistic concurrency control documentation
      Parameters:
      ifMatchETag - the ifMatchETag associated with the request.
      Returns:
      the current request options
    • getIfNoneMatchETag

      public String getIfNoneMatchETag()
      Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. Most commonly used to detect changes to the resource via read requests. When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200. To match any Etag use "*" This will be ignored if specified for write requests (ex: Create, Replace, Delete). For more details, refer to optimistic concurrency control documentation
      Returns:
      the ifNoneMatchETag associated with the request.
    • setIfNoneMatchETag

      public CosmosDatabaseRequestOptions setIfNoneMatchETag(String ifNoneMatchETag)
      Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. Most commonly used to detect changes to the resource via read requests. When Item Etag matches the specified ifNoneMatchETag then 304 status code will be returned, otherwise existing Item will be returned with 200. To match any Etag use "*" This will be ignored if specified for write requests (ex: Create, Replace, Delete). For more details, refer to optimistic concurrency control documentation
      Parameters:
      ifNoneMatchETag - the ifNoneMatchETag associated with the request.
      Returns:
      the current request options
    • setAdditionalHeaders

      public CosmosDatabaseRequestOptions setAdditionalHeaders(Map<CosmosAdditionalHeaderName,String> additionalHeaders)
      Sets additional headers to be included with this specific request.

      The CosmosAdditionalHeaderName class defines exactly which headers are supported. This allows per-request header customization, such as setting a workload ID that overrides the client-level default set via CosmosClientBuilder.additionalHeaders(java.util.Map).

      If the same header is also set at the client level, the request-level value takes precedence.

      Note: This method uses additive (merge) semantics — headers from multiple calls are merged into the existing set. Passing null or an empty map does not clear previously set headers. To reset headers, create a new options instance.

      Parameters:
      additionalHeaders - map of CosmosAdditionalHeaderName to value
      Returns:
      the CosmosDatabaseRequestOptions.
      Throws:
      IllegalArgumentException - if the workload-id value is not a valid integer
    • getAdditionalHeaders

      public Map<CosmosAdditionalHeaderName,String> getAdditionalHeaders()
      Gets the additional headers configured on this request options instance.
      Returns:
      unmodifiable map of additional headers, or null if none are set