CosmosEncryptionAsyncContainer Class

  • java.lang.Object
    • com.azure.cosmos.encryption.CosmosEncryptionAsyncContainer

public final class CosmosEncryptionAsyncContainer

CosmosAsyncContainer with encryption capabilities.

Method Summary

Modifier and Type Method and Description
Mono<CosmosItemResponse<T>> createItem(T item)

Creates an item.

Mono<CosmosItemResponse<T>> createItem(T item, CosmosItemRequestOptions requestOptions)

Creates a Cosmos item.

Mono<CosmosItemResponse<T>> createItem(T item, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)

Creates an item.

Mono<CosmosItemResponse<Object>> deleteItem(T item, CosmosItemRequestOptions requestOptions)

Deletes the item.

Mono<CosmosItemResponse<T>> patchItem(String itemId, PartitionKey partitionKey, CosmosPatchOperations cosmosPatchOperations, CosmosPatchItemRequestOptions options, Class<T> itemType)

Run patch operations on an Item.

CosmosPagedFlux<T> queryItems(SqlQuerySpec query, CosmosQueryRequestOptions requestOptions, Class<T> classType)

Query for items in the current container using a SqlQuerySpec and CosmosQueryRequestOptions.

CosmosPagedFlux<T> queryItems(SqlQuerySpec querySpec, Class<T> classType)

Query for items in the current container using a SqlQuerySpec.

CosmosPagedFlux<T> queryItems(String query, CosmosQueryRequestOptions requestOptions, Class<T> classType)

Query for items in the current container using a string.

CosmosPagedFlux<T> queryItems(String query, Class<T> classType)

Query for items in the current container.

CosmosPagedFlux<T> queryItemsOnEncryptedProperties(SqlQuerySpecWithEncryption sqlQuerySpecWithEncryption, CosmosQueryRequestOptions options, Class<T> classType)

Query for items in the current container using a SqlQuerySpecWithEncryption.

Mono<CosmosItemResponse<T>> readItem(String id, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions, Class<T> classType)

Reads an item using a configured CosmosItemRequestOptions.

Mono<CosmosItemResponse<T>> readItem(String id, PartitionKey partitionKey, Class<T> classType)

Reads an item.

Mono<CosmosItemResponse<T>> replaceItem(T item, String itemId, PartitionKey partitionKey)

Replaces an item with the passed in item and encrypts the requested fields.

Mono<CosmosItemResponse<T>> replaceItem(T item, String itemId, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)

Replaces an item with the passed in item and encrypts the requested fields.

Mono<CosmosItemResponse<T>> upsertItem(T item)

Upserts an item.

Mono<CosmosItemResponse<T>> upsertItem(T item, CosmosItemRequestOptions requestOptions)

Upserts an item.

Mono<CosmosItemResponse<T>> upsertItem(T item, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)

Upserts an item.

Flux<CosmosBulkOperationResponse<TContext>> executeBulkOperations(Flux<CosmosItemOperation> operations)

Executes flux of operations in Bulk.

Flux<CosmosBulkOperationResponse<TContext>> executeBulkOperations(Flux<CosmosItemOperation> operations, CosmosBulkExecutionOptions bulkOptions)

Executes flux of operations in Bulk.

Mono<CosmosItemResponse<Object>> deleteItem(String itemId, PartitionKey partitionKey)

Deletes an item.

Mono<CosmosItemResponse<Object>> deleteItem(String itemId, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)

Deletes the item.

Mono<CosmosBatchResponse> executeCosmosBatch(CosmosBatch cosmosBatch)

Executes the encrypted transactional batch.

Mono<CosmosBatchResponse> executeCosmosBatch(CosmosBatch cosmosBatch, CosmosBatchRequestOptions requestOptions)

Executes the encrypted transactional batch.

CosmosAsyncContainer getCosmosAsyncContainer()

Gets the CosmosAsyncContainer

Methods inherited from java.lang.Object

Method Details

createItem

public Mono> createItem(T item)

Creates an item.

After subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the created Cosmos item. In case of failure the Mono will error.

Parameters:

item - the Cosmos item represented as a POJO or Cosmos item object.

Returns:

an Mono containing the single resource response with the created Cosmos item or an error.

createItem

public Mono> createItem(T item, CosmosItemRequestOptions requestOptions)

Creates a Cosmos item.

Parameters:

item - the item.
requestOptions - the item request options.

Returns:

an Mono containing the single resource response with the created Cosmos item or an error.

createItem

public Mono> createItem(T item, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)

Creates an item.

After subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the created Cosmos item. In case of failure the Mono will error.

Parameters:

item - the Cosmos item represented as a POJO or Cosmos item object.
partitionKey - the partition key.
requestOptions - the request options.

Returns:

an Mono containing the single resource response with the created Cosmos item or an error.

deleteItem

public Mono> deleteItem(T item, CosmosItemRequestOptions requestOptions)

Deletes the item.

After subscription the operation will be performed. The Mono upon successful completion will contain a single Cosmos item response for the deleted item.

Parameters:

item - item to be deleted.
requestOptions - the request options.

Returns:

an Mono containing the Cosmos item resource response.

patchItem

public Mono> patchItem(String itemId, PartitionKey partitionKey, CosmosPatchOperations cosmosPatchOperations, CosmosPatchItemRequestOptions options, Class itemType)

Run patch operations on an Item.

After subscription the operation will be performed. The Mono upon successful completion will contain a single Cosmos item response with the patched 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:

an Mono containing the Cosmos item resource response with the patched item or an error.

queryItems

public CosmosPagedFlux queryItems(SqlQuerySpec query, CosmosQueryRequestOptions requestOptions, Class classType)

Query for items in the current container using a SqlQuerySpec and CosmosQueryRequestOptions.

After subscription the operation will be performed. The Flux will contain one or several feed response of the obtained items. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

query - the SQL query specification.
requestOptions - the query request options.
classType - the class type.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained items or an error.

queryItems

public CosmosPagedFlux queryItems(SqlQuerySpec querySpec, Class classType)

Query for items in the current container using a SqlQuerySpec.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained items. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

querySpec - the SQL query specification.
classType - the class type.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained items or an error.

queryItems

public CosmosPagedFlux queryItems(String query, CosmosQueryRequestOptions requestOptions, Class classType)

Query for items in the current container using a string.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained items. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

query - the query.
requestOptions - the query request options.
classType - the class type.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained items or an error.

queryItems

public CosmosPagedFlux queryItems(String query, Class classType)

Query for items in the current container.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained items. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

query - the query.
classType - the class type.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained items or an error.

queryItemsOnEncryptedProperties

public CosmosPagedFlux queryItemsOnEncryptedProperties(SqlQuerySpecWithEncryption sqlQuerySpecWithEncryption, CosmosQueryRequestOptions options, Class classType)

Query for items in the current container using a SqlQuerySpecWithEncryption.

After subscription the operation will be performed. The CosmosPagedFlux<T> will contain one or several feed response of the obtained items. In case of failure the CosmosPagedFlux<T> will error.

Parameters:

sqlQuerySpecWithEncryption - the sqlQuerySpecWithEncryption.
options - the query request options.
classType - the class type.

Returns:

a CosmosPagedFlux<T> containing one or several feed response pages of the obtained items or an error.

readItem

public Mono> readItem(String id, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions, Class classType)

Reads an item using a configured CosmosItemRequestOptions.

After subscription the operation will be performed. The Mono upon successful completion will contain a Cosmos item response with the read item.

Parameters:

id - the item id.
partitionKey - the partition key.
requestOptions - the request CosmosItemRequestOptions.
classType - the item type.

Returns:

an Mono containing the Cosmos item response with the read item or an error.

readItem

public Mono> readItem(String id, PartitionKey partitionKey, Class classType)

Reads an item.

After subscription the operation will be performed. The Mono upon successful completion will contain an item response with the read item.

Parameters:

id - the item id.
partitionKey - the partition key.
classType - the item type.

Returns:

an Mono containing the Cosmos item response with the read item or an error.

replaceItem

public Mono> replaceItem(T item, String itemId, PartitionKey partitionKey)

Replaces an item with the passed in item and encrypts the requested fields.

After subscription the operation will be performed. The Mono upon successful completion will contain a single Cosmos item response with the replaced item.

Parameters:

item - the item to replace (containing the item id).
itemId - the item id.
partitionKey - the partition key.

Returns:

an Mono containing the Cosmos item resource response with the replaced item or an error.

replaceItem

public Mono> replaceItem(T item, String itemId, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)

Replaces an item with the passed in item and encrypts the requested fields.

After subscription the operation will be performed. The Mono upon successful completion will contain a single Cosmos item response with the replaced item.

Parameters:

item - the item to replace (containing the item id).
itemId - the item id.
partitionKey - the partition key.
requestOptions - the request comosItemRequestOptions.

Returns:

an Mono containing the Cosmos item resource response with the replaced item or an error.

upsertItem

public Mono> upsertItem(T item)

Upserts an item.

After subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the upserted item. In case of failure the Mono will error.

Parameters:

item - the item represented as a POJO or Item object to upsert.

Returns:

an Mono containing the single resource response with the upserted item or an error.

upsertItem

public Mono> upsertItem(T item, CosmosItemRequestOptions requestOptions)

Upserts an item.

After subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the upserted item. In case of failure the Mono will error.

Parameters:

item - the item represented as a POJO or Item object to upsert.
requestOptions - the request options.

Returns:

an Mono containing the single resource response with the upserted item or an error.

upsertItem

public Mono> upsertItem(T item, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)

Upserts an item.

After subscription the operation will be performed. The Mono upon successful completion will contain a single resource response with the upserted item. In case of failure the Mono will error.

Parameters:

item - the item represented as a POJO or Item object to upsert.
partitionKey - the partition key.
requestOptions - the request options.

Returns:

an Mono containing the single resource response with the upserted item or an error.

executeBulkOperations

public Flux> executeBulkOperations(Flux operations)

Executes flux of operations in Bulk.

Parameters:

operations - Flux of operation which will be executed by this container.

Returns:

A Flux 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 Flux> executeBulkOperations(Flux operations, CosmosBulkExecutionOptions bulkOptions)

Executes flux of operations in Bulk.

Parameters:

operations - Flux 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:

A Flux 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 Mono> deleteItem(String itemId, PartitionKey partitionKey)

Deletes an item.

After subscription the operation will be performed. The Mono upon successful completion will contain a single Cosmos item response for the deleted item.

Parameters:

itemId - the item id.
partitionKey - the partition key.

Returns:

an Mono containing the Cosmos item resource response.

deleteItem

public Mono> deleteItem(String itemId, PartitionKey partitionKey, CosmosItemRequestOptions requestOptions)

Deletes the item.

After subscription the operation will be performed. The Mono upon successful completion will contain a single Cosmos item response for the deleted item.

Parameters:

itemId - id of the item.
partitionKey - partitionKey of the item.
requestOptions - the request options.

Returns:

an Mono containing the Cosmos item resource response.

executeCosmosBatch

public Mono 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 Mono response 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 the Mono will return error instead of CosmosBatchResponse.

Use CosmosBatchResponse#isSuccessStatusCode on the response returned to ensure that the transactional batch succeeded.

executeCosmosBatch

public Mono 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 Mono response 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 the Mono will return error instead of CosmosBatchResponse.

Use CosmosBatchResponse#isSuccessStatusCode on the response returned to ensure that the transactional batch succeeded.

getCosmosAsyncContainer

public CosmosAsyncContainer getCosmosAsyncContainer()

Gets the CosmosAsyncContainer

Returns:

cosmos container

Applies to