Package com.azure.data.cosmos
Class CosmosContainer
- java.lang.Object
-
- com.azure.data.cosmos.CosmosContainer
-
public class CosmosContainer extends Object
Provides methods for reading, deleting, and replacing existing Containers. Provides methods for interacting with child resources (Items, Scripts, Conflicts)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<CosmosItemResponse>
createItem(Object item)
Creates a cosmos item.Mono<CosmosItemResponse>
createItem(Object item, CosmosItemRequestOptions options)
Creates a cosmos item.Mono<CosmosContainerResponse>
delete()
Deletes the item container After subscription the operation will be performed.Mono<CosmosContainerResponse>
delete(CosmosContainerRequestOptions options)
Deletes the item container After subscription the operation will be performed.CosmosConflict
getConflict(String id)
Gets a CosmosConflict object without making a service callCosmosDatabase
getDatabase()
Gets the parent DatabaseCosmosItem
getItem(String id, Object partitionKey)
Gets a CosmosItem object without making a service callCosmosScripts
getScripts()
String
id()
Get the id of theCosmosContainer
Flux<FeedResponse<CosmosItemProperties>>
queryChangeFeedItems(ChangeFeedOptions changeFeedOptions)
Query for documents in a items in a container After subscription the operation will be performed.Flux<FeedResponse<CosmosConflictProperties>>
queryConflicts(String query)
Queries all the conflicts in the containerFlux<FeedResponse<CosmosConflictProperties>>
queryConflicts(String query, FeedOptions options)
Queries all the conflicts in the containerFlux<FeedResponse<CosmosItemProperties>>
queryItems(SqlQuerySpec querySpec)
Query for documents in a items in a container After subscription the operation will be performed.Flux<FeedResponse<CosmosItemProperties>>
queryItems(SqlQuerySpec querySpec, FeedOptions options)
Query for documents in a items in a container After subscription the operation will be performed.Flux<FeedResponse<CosmosItemProperties>>
queryItems(String query)
Query for documents in a items in a container After subscription the operation will be performed.Flux<FeedResponse<CosmosItemProperties>>
queryItems(String query, FeedOptions options)
Query for documents in a items in a container After subscription the operation will be performed.Mono<CosmosContainerResponse>
read()
Reads the document container After subscription the operation will be performed.Mono<CosmosContainerResponse>
read(CosmosContainerRequestOptions options)
Reads the document container by the container link.Flux<FeedResponse<CosmosConflictProperties>>
readAllConflicts(FeedOptions options)
Lists all the conflicts in the containerFlux<FeedResponse<CosmosItemProperties>>
readAllItems()
Reads all cosmos items in the container.Flux<FeedResponse<CosmosItemProperties>>
readAllItems(FeedOptions options)
Reads all cosmos items in a container.Mono<Integer>
readProvisionedThroughput()
Gets the throughput of the containerMono<CosmosContainerResponse>
replace(CosmosContainerProperties containerSettings)
Replaces a document container.Mono<CosmosContainerResponse>
replace(CosmosContainerProperties containerSettings, CosmosContainerRequestOptions options)
Replaces a document container.Mono<Integer>
replaceProvisionedThroughput(int requestUnitsPerSecond)
Sets throughput provisioned for a container in measurement of Requests-per-Unit in the Azure Cosmos service.Mono<CosmosItemResponse>
upsertItem(Object item)
Upserts an item.Mono<CosmosItemResponse>
upsertItem(Object item, CosmosItemRequestOptions options)
Upserts a cosmos item.
-
-
-
Method Detail
-
id
public String id()
Get the id of theCosmosContainer
- Returns:
- the id of the
CosmosContainer
-
read
public Mono<CosmosContainerResponse> read()
Reads the document container After subscription the operation will be performed. TheMono
upon successful completion will contain a single cosmos container response with the read container. In case of failure theMono
will error.- Returns:
- an
Mono
containing the single cosmos container response with the read container or an error.
-
read
public Mono<CosmosContainerResponse> read(CosmosContainerRequestOptions options)
Reads the document container by the container link. After subscription the operation will be performed. TheMono
upon successful completion will contain a single cosmos container response with the read container. In case of failure theMono
will error.- Parameters:
options
- The cosmos container request options.- Returns:
- an
Mono
containing the single cosmos container response with the read container or an error.
-
delete
public Mono<CosmosContainerResponse> delete(CosmosContainerRequestOptions options)
Deletes the item container After subscription the operation will be performed. TheMono
upon successful completion will contain a single cosmos container response for the deleted database. In case of failure theMono
will error.- Parameters:
options
- the request options.- Returns:
- an
Mono
containing the single cosmos container response for the deleted database or an error.
-
delete
public Mono<CosmosContainerResponse> delete()
Deletes the item container After subscription the operation will be performed. TheMono
upon successful completion will contain a single cosmos container response for the deleted container. In case of failure theMono
will error.- Returns:
- an
Mono
containing the single cosmos container response for the deleted container or an error.
-
replace
public Mono<CosmosContainerResponse> replace(CosmosContainerProperties containerSettings)
Replaces a document container. After subscription the operation will be performed. TheMono
upon successful completion will contain a single cosmos container response with the replaced document container. In case of failure theMono
will error.- Parameters:
containerSettings
- the item container properties- Returns:
- an
Mono
containing the single cosmos container response with the replaced document container or an error.
-
replace
public Mono<CosmosContainerResponse> replace(CosmosContainerProperties containerSettings, CosmosContainerRequestOptions options)
Replaces a document container. After subscription the operation will be performed. TheMono
upon successful completion will contain a single cosmos container response with the replaced document container. In case of failure theMono
will error.- Parameters:
containerSettings
- the item container propertiesoptions
- the cosmos container request options.- Returns:
- an
Mono
containing the single cosmos container response with the replaced document container or an error.
-
createItem
public Mono<CosmosItemResponse> createItem(Object item)
Creates a cosmos item. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the created cosmos item. In case of failure theMono
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<CosmosItemResponse> createItem(Object item, CosmosItemRequestOptions options)
Creates a cosmos item. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the created cosmos item. In case of failure theMono
will error.- Parameters:
item
- the cosmos item represented as a POJO or cosmos item object.options
- the request options.- Returns:
- an
Mono
containing the single resource response with the created cosmos item or an error.
-
upsertItem
public Mono<CosmosItemResponse> upsertItem(Object item)
Upserts an item. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the upserted item. In case of failure theMono
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 document or an error.
-
upsertItem
public Mono<CosmosItemResponse> upsertItem(Object item, CosmosItemRequestOptions options)
Upserts a cosmos item. After subscription the operation will be performed. TheMono
upon successful completion will contain a single resource response with the upserted item. In case of failure theMono
will error.- Parameters:
item
- the item represented as a POJO or Item object to upsert.options
- the request options.- Returns:
- an
Mono
containing the single resource response with the upserted document or an error.
-
readAllItems
public Flux<FeedResponse<CosmosItemProperties>> readAllItems()
Reads all cosmos items in the container. After subscription the operation will be performed. TheFlux
will contain one or several feed response of the read cosmos items. In case of failure theFlux
will error.- Returns:
- an
Flux
containing one or several feed response pages of the read cosmos items or an error.
-
readAllItems
public Flux<FeedResponse<CosmosItemProperties>> readAllItems(FeedOptions options)
Reads all cosmos items in a container. After subscription the operation will be performed. TheFlux
will contain one or several feed response of the read cosmos items. In case of failure theFlux
will error.- Parameters:
options
- the feed options.- Returns:
- an
Flux
containing one or several feed response pages of the read cosmos items or an error.
-
queryItems
public Flux<FeedResponse<CosmosItemProperties>> queryItems(String query)
Query for documents in a items in a container After subscription the operation will be performed. TheFlux
will contain one or several feed response of the obtained items. In case of failure theFlux
will error.- Parameters:
query
- the query.- Returns:
- an
Flux
containing one or several feed response pages of the obtained items or an error.
-
queryItems
public Flux<FeedResponse<CosmosItemProperties>> queryItems(String query, FeedOptions options)
Query for documents in a items in a container After subscription the operation will be performed. TheFlux
will contain one or several feed response of the obtained items. In case of failure theFlux
will error.- Parameters:
query
- the query.options
- the feed options.- Returns:
- an
Flux
containing one or several feed response pages of the obtained items or an error.
-
queryItems
public Flux<FeedResponse<CosmosItemProperties>> queryItems(SqlQuerySpec querySpec)
Query for documents in a items in a container After subscription the operation will be performed. TheFlux
will contain one or several feed response of the obtained items. In case of failure theFlux
will error.- Parameters:
querySpec
- the SQL query specification.- Returns:
- an
Flux
containing one or several feed response pages of the obtained items or an error.
-
queryItems
public Flux<FeedResponse<CosmosItemProperties>> queryItems(SqlQuerySpec querySpec, FeedOptions options)
Query for documents in a items in a container After subscription the operation will be performed. TheFlux
will contain one or several feed response of the obtained items. In case of failure theFlux
will error.- Parameters:
querySpec
- the SQL query specification.options
- the feed options.- Returns:
- an
Flux
containing one or several feed response pages of the obtained items or an error.
-
queryChangeFeedItems
public Flux<FeedResponse<CosmosItemProperties>> queryChangeFeedItems(ChangeFeedOptions changeFeedOptions)
Query for documents in a items in a container After subscription the operation will be performed. TheFlux
will contain one or several feed response of the obtained items. In case of failure theFlux
will error.- Parameters:
changeFeedOptions
- the feed options.- Returns:
- an
Flux
containing one or several feed response pages of the obtained items or an error.
-
getItem
public CosmosItem getItem(String id, Object partitionKey)
Gets a CosmosItem object without making a service call- Parameters:
id
- id of the itempartitionKey
- the partition key- Returns:
- a cosmos item
-
getScripts
public CosmosScripts getScripts()
-
readAllConflicts
public Flux<FeedResponse<CosmosConflictProperties>> readAllConflicts(FeedOptions options)
Lists all the conflicts in the container- Parameters:
options
- the feed options- Returns:
- a
Flux
containing one or several feed response pages of the obtained conflicts or an error.
-
queryConflicts
public Flux<FeedResponse<CosmosConflictProperties>> queryConflicts(String query)
Queries all the conflicts in the container- Parameters:
query
- the query- Returns:
- a
Flux
containing one or several feed response pages of the obtained conflicts or an error.
-
queryConflicts
public Flux<FeedResponse<CosmosConflictProperties>> queryConflicts(String query, FeedOptions options)
Queries all the conflicts in the container- Parameters:
query
- the queryoptions
- the feed options- Returns:
- a
Flux
containing one or several feed response pages of the obtained conflicts or an error.
-
getConflict
public CosmosConflict getConflict(String id)
Gets a CosmosConflict object without making a service call- Parameters:
id
- id of the cosmos conflict- Returns:
- a cosmos conflict
-
readProvisionedThroughput
public Mono<Integer> readProvisionedThroughput()
Gets the throughput of the container- Returns:
- a
Mono
containing throughput or an error.
-
replaceProvisionedThroughput
public Mono<Integer> replaceProvisionedThroughput(int requestUnitsPerSecond)
Sets throughput provisioned for a container in measurement of Requests-per-Unit in the Azure Cosmos service.- Parameters:
requestUnitsPerSecond
- the cosmos container throughput, expressed in Request Units per second- Returns:
- a
Mono
containing throughput or an error.
-
getDatabase
public CosmosDatabase getDatabase()
Gets the parent Database- Returns:
- the
CosmosDatabase
-
-