public CosmosItemResponse deleteItem(T item, CosmosItemRequestOptions options)
Deletes an item in the current container.
Parameters:
item
- the item to be deleted.
options
- the options.
Returns:
the Cosmos item response.
patchItem
public CosmosItemResponse patchItem(String itemId, PartitionKey partitionKey, CosmosPatchOperations cosmosPatchOperations, CosmosPatchItemRequestOptions options, Class itemType)
Run patch operations on an Item.
Parameters:
itemId
- the item id.
partitionKey
- the partition key.
cosmosPatchOperations
- Represents a container having list of operations to be sequentially applied to the referred Cosmos item.
options
- the request options.
itemType
- the item type.
Returns:
the Cosmos item resource response with the patched item or an exception.
queryItems
public CosmosPagedIterable queryItems(SqlQuerySpec query, CosmosQueryRequestOptions requestOptions, Class classType)
Query items in the current container returning the results as CosmosPagedIterable<T> .
Parameters:
query
- the query spec.
requestOptions
- the options.
classType
- the class type.
Returns:
queryItems
public CosmosPagedIterable queryItems(String query, CosmosQueryRequestOptions requestOptions, Class classType)
Query items in the current container returning the results as CosmosPagedIterable<T> .
Parameters:
query
- the query.
requestOptions
- the options.
classType
- the class type.
Returns:
queryItemsOnEncryptedProperties
public CosmosPagedIterable queryItemsOnEncryptedProperties(SqlQuerySpecWithEncryption sqlQuerySpecWithEncryption, CosmosQueryRequestOptions options, Class classType)
Query for items in the current container using a SqlQuerySpecWithEncryption .
Parameters:
sqlQuerySpecWithEncryption
- the sqlQuerySpecWithEncryption.
options
- the query request options.
classType
- the class type.
Returns:
readItem
public CosmosItemResponse readItem(String id, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions, Class classType)
Reads an item in the current container while specifying additional options.
Parameters:
id
- the item id.
partitionKey
- the partition key.
requestOptions
- the options.
classType
- the class type of item.
Returns:
the Cosmos item response.
readItem
public CosmosItemResponse readItem(String id, PartitionKey partitionKey, Class classType)
Reads an item in the current container.
Parameters:
id
- the item id.
partitionKey
- the partition key.
classType
- the class type of item.
Returns:
the Cosmos item response.
replaceItem
public CosmosItemResponse replaceItem(T item, String itemId, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)
Replaces an item in the current container.
Parameters:
item
- the item.
itemId
- the item id.
partitionKey
- the partition key.
requestOptions
- the options.
Returns:
the Cosmos item response.
upsertItem
public CosmosItemResponse upsertItem(T item)
Upserts an Cosmos item in the current container.
Parameters:
item
- the item.
Returns:
the Cosmos item response.
upsertItem
public CosmosItemResponse upsertItem(T item, CosmosItemRequestOptions options)
Upserts a item Cosmos sync item while specifying additional options.
Parameters:
item
- the item.
options
- the options.
Returns:
the Cosmos item response.
upsertItem
public CosmosItemResponse upsertItem(T item, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)
Upserts a item Cosmos sync item while specifying additional options.
Parameters:
item
- the item.
partitionKey
- the partitionKey.
requestOptions
- the options.
Returns:
the Cosmos item response.
executeBulkOperations
public Iterable> executeBulkOperations(Iterable operations)
Executes list of operations in Bulk.
Parameters:
operations
- list of operation which will be executed by this container.
Returns:
An Iterable of
CosmosBulkOperationResponse<TContext> which contains operation and it's response or exception.
To create a operation which can be executed here, use
com.azure.cosmos.models.CosmosBulkOperations . For eg.
for a upsert operation use
com.azure.cosmos.models.CosmosBulkOperations#getUpsertItemOperation(Object, PartitionKey)
We can get the corresponding operation using
CosmosBulkOperationResponse#getOperation() and
it's response using
CosmosBulkOperationResponse#getResponse() . If the operation was executed
successfully, the value returned by
com.azure.cosmos.models.CosmosBulkItemResponse#isSuccessStatusCode() will be true. To get
actual status use
com.azure.cosmos.models.CosmosBulkItemResponse#getStatusCode() .
To check if the operation had any exception, use
CosmosBulkOperationResponse#getException() to
get the exception.
executeBulkOperations
public Iterable> executeBulkOperations(Iterable operations, CosmosBulkExecutionOptions bulkOptions)
Executes list of operations in Bulk.
Parameters:
operations
- list of operation which will be executed by this container.
bulkOptions
- Options that apply for this Bulk request which specifies options regarding execution like
concurrency, batching size, interval and context.
Returns:
An Iterable of
CosmosBulkOperationResponse<TContext> which contains operation and it's response or exception.
To create a operation which can be executed here, use
com.azure.cosmos.models.CosmosBulkOperations . For eg.
for a upsert operation use
com.azure.cosmos.models.CosmosBulkOperations#getUpsertItemOperation(Object, PartitionKey)
We can get the corresponding operation using
CosmosBulkOperationResponse#getOperation() and
it's response using
CosmosBulkOperationResponse#getResponse() . If the operation was executed
successfully, the value returned by
com.azure.cosmos.models.CosmosBulkItemResponse#isSuccessStatusCode() will be true. To get
actual status use
com.azure.cosmos.models.CosmosBulkItemResponse#getStatusCode() .
To check if the operation had any exception, use
CosmosBulkOperationResponse#getException() to
get the exception.
deleteItem
public CosmosItemResponse deleteItem(String itemId, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)
Deletes an item in the current container.
Parameters:
itemId
- the item id.
partitionKey
- the partition key.
requestOptions
- the options.
Returns:
the Cosmos item response.
executeCosmosBatch
public CosmosBatchResponse executeCosmosBatch(CosmosBatch cosmosBatch)
Executes the encrypted transactional batch.
Parameters:
cosmosBatch
- Batch having list of operation and partition key which will be executed by this container.
Returns:
A CosmosBatchResponse which contains details of execution of the transactional batch.
If the transactional batch executes successfully, the value returned by CosmosBatchResponse#getStatusCode on the response returned will be set to 200}.
If an operation within the transactional batch fails during execution, no changes from the batch will be
committed and the status of the failing operation is made available by CosmosBatchResponse#getStatusCode or by the exception. To obtain information about the operations
that failed in case of some user error like conflict, not found etc, the response can be enumerated.
This returns CosmosBatchOperationResult instances corresponding to each operation in the
transactional batch in the order they were added to the transactional batch.
For a result corresponding to an operation within the transactional batch, use
CosmosBatchOperationResult#getStatusCode
to access the status of the operation. If the operation was not executed or it was aborted due to the failure of
another operation within the transactional batch, the value of this field will be 424;
for the operation that caused the batch to abort, the value of this field
will indicate the cause of failure.
If there are issues such as request timeouts, Gone, session not available, network failure
or if the service somehow returns 5xx then this will throw an exception instead of returning a CosmosBatchResponse.
Use CosmosBatchResponse#isSuccessStatusCode on the response returned to ensure that the
transactional batch succeeded.
executeCosmosBatch
public CosmosBatchResponse executeCosmosBatch(CosmosBatch cosmosBatch, CosmosBatchRequestOptions requestOptions)
Executes the encrypted transactional batch.
Parameters:
cosmosBatch
- Batch having list of operation and partition key which will be executed by this container.
requestOptions
- Options that apply specifically to batch request.
Returns:
A CosmosBatchResponse which contains details of execution of the transactional batch.
If the transactional batch executes successfully, the value returned by CosmosBatchResponse#getStatusCode on the response returned will be set to 200}.
If an operation within the transactional batch fails during execution, no changes from the batch will be
committed and the status of the failing operation is made available by CosmosBatchResponse#getStatusCode or by the exception. To obtain information about the operations
that failed in case of some user error like conflict, not found etc, the response can be enumerated.
This returns CosmosBatchOperationResult instances corresponding to each operation in the
transactional batch in the order they were added to the transactional batch.
For a result corresponding to an operation within the transactional batch, use
CosmosBatchOperationResult#getStatusCode
to access the status of the operation. If the operation was not executed or it was aborted due to the failure of
another operation within the transactional batch, the value of this field will be 424;
for the operation that caused the batch to abort, the value of this field
will indicate the cause of failure.
If there are issues such as request timeouts, Gone, session not available, network failure
or if the service somehow returns 5xx then this will throw an exception instead of returning a CosmosBatchResponse.
Use CosmosBatchResponse#isSuccessStatusCode on the response returned to ensure that the
transactional batch succeeded.
getCosmosContainer
public CosmosContainer getCosmosContainer()
Gets the CosmosContainer
Returns:
cosmos container
Applies to