Compartir a través de


DocumentClient Class

  • java.lang.Object
    • com.microsoft.azure.documentdb.DocumentClient

Implements

com.microsoft.azure.documentdb.internal.CollectionCacheInternal java.lang.AutoCloseable

public class DocumentClient
implements java.lang.AutoCloseable, com.microsoft.azure.documentdb.internal.CollectionCacheInternal

Provides a client-side logical representation of the Azure Cosmos DB service. This client is used to configure and execute requests against the service.

The service client encapsulates the endpoint and credentials used to access the Azure Cosmos DB service.

Field Summary

Modifier and Type Field and Description
protected static final java.lang.String PartitionResolverErrorMessage

Constructor Summary

Constructor Description
DocumentClient(String serviceEndpoint, String masterKey, ObjectMapper objectMapper, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the DocumentClient class using the specified Azure Cosmos DB service endpoint and keys.

DocumentClient(String serviceEndpoint, String masterKey, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the DocumentClient class using the specified Azure Cosmos DB service endpoint and keys.

DocumentClient(String serviceEndpoint, List<Permission> permissionFeed, ObjectMapper objectMapper, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the Microsoft.Azure.Documents.Client.DocumentClient class using the specified Azure Cosmos DB service endpoint and permissions.

DocumentClient(String serviceEndpoint, List<Permission> permissionFeed, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the Microsoft.Azure.Documents.Client.DocumentClient class using the specified Azure Cosmos DB service endpoint and permissions.

Method Summary

Modifier and Type Method and Description
void close()

Close this DocumentClient instance

ResourceResponse<Attachment> createAttachment(String documentLink, Attachment attachment, RequestOptions options)

Creates an attachment.

ResourceResponse<Attachment> createAttachment(String documentLink, InputStream mediaStream, MediaOptions options)

Creates an attachment.

ResourceResponse<DocumentCollection> createCollection(String databaseLink, DocumentCollection collection, RequestOptions options)

Creates a document collection.

ResourceResponse<Database> createDatabase(Database database, RequestOptions options)

Creates a database.

ResourceResponse<Document> createDocument(String collectionLink, Object document, RequestOptions options, boolean disableAutomaticIdGeneration)

Creates a document.

ResourceResponse<Permission> createPermission(String userLink, Permission permission, RequestOptions options)

Creates a permission.

ResourceResponse<StoredProcedure> createStoredProcedure(String collectionLink, StoredProcedure storedProcedure, RequestOptions options)

Creates a stored procedure.

ResourceResponse<Trigger> createTrigger(String collectionLink, Trigger trigger, RequestOptions options)

Creates a trigger.

ResourceResponse<User> createUser(String databaseLink, User user, RequestOptions options)

Creates a user.

ResourceResponse<UserDefinedFunction> createUserDefinedFunction(String collectionLink, UserDefinedFunction udf, RequestOptions options)

Creates a user defined function.

ResourceResponse<Attachment> deleteAttachment(String attachmentLink, RequestOptions options)

Deletes an attachment.

ResourceResponse<DocumentCollection> deleteCollection(String collectionLink, RequestOptions options)

Deletes a document collection by the collection link.

ResourceResponse<Conflict> deleteConflict(String conflictLink, RequestOptions options)

Deletes a conflict.

ResourceResponse<Database> deleteDatabase(String databaseLink, RequestOptions options)

Deletes a database.

ResourceResponse<Document> deleteDocument(String documentLink, RequestOptions options)

Deletes a document by the document link.

ResourceResponse<Permission> deletePermission(String permissionLink, RequestOptions options)

Deletes a permission.

ResourceResponse<StoredProcedure> deleteStoredProcedure(String storedProcedureLink, RequestOptions options)

Deletes a stored procedure by the stored procedure link.

ResourceResponse<Trigger> deleteTrigger(String triggerLink, RequestOptions options)

Deletes a trigger.

ResourceResponse<User> deleteUser(String userLink, RequestOptions options)

Deletes a user.

ResourceResponse<UserDefinedFunction> deleteUserDefinedFunction(String udfLink, RequestOptions options)

Deletes a user defined function.

StoredProcedureResponse executeStoredProcedure(String storedProcedureLink, RequestOptions options, Object[] procedureParams)

Executes a stored procedure by the stored procedure link.

StoredProcedureResponse executeStoredProcedure(String storedProcedureLink, Object[] procedureParams)

Executes a stored procedure by the stored procedure link.

ConnectionPolicy getConnectionPolicy()
DatabaseAccount getDatabaseAccount()

Gets database account information.

protected PartitionResolver getPartitionResolver(String databaseLink)
java.net.URI getReadEndpoint()

Gets the current read endpoint chosen based on availability and preference.

java.net.URI getServiceEndpoint()

Gets the default service endpoint as passed in by the user during construction.

java.net.URI getWriteEndpoint()

Gets the current write endpoint chosen based on availability and preference.

java.util.List<java.lang.Object> queryAggregateValues(String collectionLink, SqlQuerySpec querySpec, FeedOptions feedOptions)

Query for aggregation values in a document collection.

java.util.List<java.lang.Object> queryAggregateValues(String collectionLink, SqlQuerySpec querySpec, FeedOptions feedOptions, Object partitionKey)

Query for aggregation values in a document collection.

java.util.List<java.lang.Object> queryAggregateValues(String collectionLink, String query, FeedOptions feedOptions)

Query for aggregation values in a document collection.

java.util.List<java.lang.Object> queryAggregateValues(String collectionLink, String query, FeedOptions feedOptions, String partitionKey)

Query for aggregation values in a document collection.

FeedResponse<Attachment> queryAttachments(String documentLink, SqlQuerySpec querySpec, FeedOptions options)

Query for attachments.

FeedResponse<Attachment> queryAttachments(String documentLink, String query, FeedOptions options)

Query for attachments.

FeedResponse<DocumentCollection> queryCollections(String databaseLink, SqlQuerySpec querySpec, FeedOptions options)

Query for document collections in a database.

FeedResponse<DocumentCollection> queryCollections(String databaseLink, String query, FeedOptions options)

Query for document collections in a database.

FeedResponse<Conflict> queryConflicts(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for conflicts.

FeedResponse<Conflict> queryConflicts(String collectionLink, String query, FeedOptions options)

Query for conflicts.

FeedResponse<Database> queryDatabases(SqlQuerySpec querySpec, FeedOptions options)

Query for databases.

FeedResponse<Database> queryDatabases(String query, FeedOptions options)

Query for databases.

FeedResponse<Document> queryDocumentChangeFeed(String collectionLink, ChangeFeedOptions changeFeedOptions)

Query for documents change feed in a document collection.

FeedResponse<Document> queryDocuments(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for documents in a document collection.

FeedResponse<Document> queryDocuments(String collectionLink, SqlQuerySpec querySpec, FeedOptions options, Object partitionKey)

Query for documents in a document collection.

FeedResponse<Document> queryDocuments(String collectionLink, String query, FeedOptions options)

Query for documents in a document collection.

FeedResponse<Document> queryDocuments(String collectionLink, String query, FeedOptions options, Object partitionKey)

Query for documents in a document collection with a partitionKey

FeedResponse<Offer> queryOffers(SqlQuerySpec querySpec, FeedOptions options)

Query for offers in a database.

FeedResponse<Offer> queryOffers(String query, FeedOptions options)

Query for offers in a database.

FeedResponse<Permission> queryPermissions(String permissionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for permissions.

FeedResponse<Permission> queryPermissions(String userLink, String query, FeedOptions options)

Query for permissions.

FeedResponse<StoredProcedure> queryStoredProcedures(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for stored procedures in a document collection.

FeedResponse<StoredProcedure> queryStoredProcedures(String collectionLink, String query, FeedOptions options)

Query for stored procedures in a document collection.

FeedResponse<Trigger> queryTriggers(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for triggers.

FeedResponse<Trigger> queryTriggers(String collectionLink, String query, FeedOptions options)

Query for triggers.

FeedResponse<UserDefinedFunction> queryUserDefinedFunctions(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for user defined functions.

FeedResponse<UserDefinedFunction> queryUserDefinedFunctions(String collectionLink, String query, FeedOptions options)

Query for user defined functions.

FeedResponse<User> queryUsers(String databaseLink, SqlQuerySpec querySpec, FeedOptions options)

Query for users.

FeedResponse<User> queryUsers(String databaseLink, String query, FeedOptions options)

Query for users.

ResourceResponse<Attachment> readAttachment(String attachmentLink, RequestOptions options)

Reads an attachment.

FeedResponse<Attachment> readAttachments(String documentLink, FeedOptions options)

Reads all attachments in a document.

ResourceResponse<DocumentCollection> readCollection(String collectionLink, RequestOptions options)

Reads a document collection by the collection link.

FeedResponse<DocumentCollection> readCollections(String databaseLink, FeedOptions options)

Reads all document collections in a database.

ResourceResponse<Conflict> readConflict(String conflictLink, RequestOptions options)

Reads a conflict.

FeedResponse<Conflict> readConflicts(String collectionLink, FeedOptions options)

Reads all conflicts in a document collection.

ResourceResponse<Database> readDatabase(String databaseLink, RequestOptions options)

Reads a database.

FeedResponse<Database> readDatabases(FeedOptions options)

Reads all databases.

ResourceResponse<Document> readDocument(String documentLink, RequestOptions options)

Reads a document by the document link.

FeedResponse<Document> readDocuments(String collectionLink, FeedOptions options)

Reads all documents in a document collection.

MediaResponse readMedia(String mediaLink)

Reads a media by the media link.

ResourceResponse<Offer> readOffer(String offerLink)

Reads an offer.

FeedResponse<Offer> readOffers(FeedOptions options)

Reads offers.

FeedResponse<PartitionKeyRange> readPartitionKeyRanges(DocumentCollection documentCollection, FeedOptions options)

Reads all partition key ranges in a document collection.

FeedResponse<PartitionKeyRange> readPartitionKeyRanges(String collectionLink, FeedOptions options)

Reads all partition key ranges in a document collection.

java.util.Collection<PartitionKeyRange> readPartitionKeyRanges(String collectionLink, String query)

Reads all partition key ranges in a document collection for a provided query.

ResourceResponse<Permission> readPermission(String permissionLink, RequestOptions options)

Reads a permission.

FeedResponse<Permission> readPermissions(String userLink, FeedOptions options)

Reads all permissions.

ResourceResponse<StoredProcedure> readStoredProcedure(String storedProcedureLink, RequestOptions options)

Read a stored procedure by the stored procedure link.

FeedResponse<StoredProcedure> readStoredProcedures(String collectionLink, FeedOptions options)

Reads all stored procedures in a document collection link.

ResourceResponse<Trigger> readTrigger(String triggerLink, RequestOptions options)

Reads a trigger by the trigger link.

FeedResponse<Trigger> readTriggers(String collectionLink, FeedOptions options)

Reads all triggers in a document collection.

ResourceResponse<User> readUser(String userLink, RequestOptions options)

Reads a user.

ResourceResponse<UserDefinedFunction> readUserDefinedFunction(String udfLink, RequestOptions options)

Read a user defined function.

FeedResponse<UserDefinedFunction> readUserDefinedFunctions(String collectionLink, FeedOptions options)

Reads all user defined functions in a document collection.

FeedResponse<User> readUsers(String databaseLink, FeedOptions options)

Reads all users in a database.

void registerPartitionResolver(String databaseLink, PartitionResolver partitionResolver)
ResourceResponse<Attachment> replaceAttachment(Attachment attachment, RequestOptions options)

Replaces an attachment.

ResourceResponse<DocumentCollection> replaceCollection(DocumentCollection collection, RequestOptions options)

Replaces a document collection.

ResourceResponse<Document> replaceDocument(Document document, RequestOptions options)

Replaces a document with the passed in document.

ResourceResponse<Document> replaceDocument(String documentLink, Object document, RequestOptions options)

Replaces a document using a POJO object.

ResourceResponse<Offer> replaceOffer(Offer offer)

Replaces an offer.

ResourceResponse<Permission> replacePermission(Permission permission, RequestOptions options)

Replaces a permission.

ResourceResponse<StoredProcedure> replaceStoredProcedure(StoredProcedure storedProcedure, RequestOptions options)

Replaces a stored procedure.

ResourceResponse<Trigger> replaceTrigger(Trigger trigger, RequestOptions options)

Replaces a trigger.

ResourceResponse<User> replaceUser(User user, RequestOptions options)

Replaces a user.

ResourceResponse<UserDefinedFunction> replaceUserDefinedFunction(UserDefinedFunction udf, RequestOptions options)

Replaces a user defined function.

MediaResponse updateMedia(String mediaLink, InputStream mediaStream, MediaOptions options)

Updates a media by the media link.

ResourceResponse<Attachment> upsertAttachment(String documentLink, Attachment attachment, RequestOptions options)

Upserts an attachment.

ResourceResponse<Attachment> upsertAttachment(String documentLink, InputStream mediaStream, MediaOptions options)

Upserts an attachment to the media stream

ResourceResponse<Document> upsertDocument(String collectionLink, Object document, RequestOptions options, boolean disableAutomaticIdGeneration)

Upserts a document.

ResourceResponse<Permission> upsertPermission(String userLink, Permission permission, RequestOptions options)

Upserts a permission.

ResourceResponse<StoredProcedure> upsertStoredProcedure(String collectionLink, StoredProcedure storedProcedure, RequestOptions options)

Upserts a stored procedure.

ResourceResponse<Trigger> upsertTrigger(String collectionLink, Trigger trigger, RequestOptions options)

Upserts a trigger.

ResourceResponse<User> upsertUser(String databaseLink, User user, RequestOptions options)

Upserts a user.

ResourceResponse<UserDefinedFunction> upsertUserDefinedFunction(String collectionLink, UserDefinedFunction udf, RequestOptions options)

Upserts a user defined function.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

PartitionResolverErrorMessage


protected static final String PartitionResolverErrorMessage

Constructor Details

DocumentClient

public DocumentClient(String serviceEndpoint, String masterKey, ObjectMapper objectMapper, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the DocumentClient class using the specified Azure Cosmos DB service endpoint and keys.

Parameters:

serviceEndpoint - the URI of the service end point.
masterKey - the master key.
objectMapper - the custom objectMapper
connectionPolicy - the connection policy.
desiredConsistencyLevel - the desired consistency level.

DocumentClient

public DocumentClient(String serviceEndpoint, String masterKey, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the DocumentClient class using the specified Azure Cosmos DB service endpoint and keys.

Parameters:

serviceEndpoint - the URI of the service end point.
masterKey - the master key.
connectionPolicy - the connection policy.
desiredConsistencyLevel - the desired consistency level.

DocumentClient

public DocumentClient(String serviceEndpoint, List permissionFeed, ObjectMapper objectMapper, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the Microsoft.Azure.Documents.Client.DocumentClient class using the specified Azure Cosmos DB service endpoint and permissions.

Parameters:

serviceEndpoint - the URI of the service end point.
permissionFeed - the permission feed.
objectMapper - the custom objectMapper
connectionPolicy - the connection policy.
desiredConsistencyLevel - the desired consistency level.

DocumentClient

public DocumentClient(String serviceEndpoint, List permissionFeed, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the Microsoft.Azure.Documents.Client.DocumentClient class using the specified Azure Cosmos DB service endpoint and permissions.

Parameters:

serviceEndpoint - the URI of the service end point.
permissionFeed - the permission feed.
connectionPolicy - the connection policy.
desiredConsistencyLevel - the desired consistency level.

Method Details

close

public void close()

Close this DocumentClient instance

createAttachment

public ResourceResponse createAttachment(String documentLink, Attachment attachment, RequestOptions options)

Creates an attachment.

Parameters:

documentLink - the document link.
attachment - the attachment to create.
options - the request options.

Returns:

the resource response with the created attachment.

Throws:

DocumentClientException - the document client exception.

createAttachment

public ResourceResponse createAttachment(String documentLink, InputStream mediaStream, MediaOptions options)

Creates an attachment.

Parameters:

documentLink - the document link.
mediaStream - the media stream for creating the attachment.
options - the media options.

Returns:

the resource response with the created attachment.

Throws:

DocumentClientException - the document client exception.

createCollection

public ResourceResponse createCollection(String databaseLink, DocumentCollection collection, RequestOptions options)

Creates a document collection.

Parameters:

databaseLink - the database link.
collection - the collection.
options - the request options.

Returns:

the resource response with the created collection.

Throws:

DocumentClientException - the document client exception.

createDatabase

public ResourceResponse createDatabase(Database database, RequestOptions options)

Creates a database.

Parameters:

database - the database.
options - the request options.

Returns:

the resource response with the created database.

Throws:

DocumentClientException - the document client exception.

createDocument

public ResourceResponse createDocument(String collectionLink, Object document, RequestOptions options, boolean disableAutomaticIdGeneration)

Creates a document.

Parameters:

collectionLink - the link to the parent document collection.
document - the document represented as a POJO or Document object.
options - the request options.
disableAutomaticIdGeneration - the flag for disabling automatic id generation.

Returns:

the resource response with the created document.

Throws:

DocumentClientException - the document client exception.

createPermission

public ResourceResponse createPermission(String userLink, Permission permission, RequestOptions options)

Creates a permission.

Parameters:

userLink - the user link.
permission - the permission to create.
options - the request options.

Returns:

the resource response with the created permission.

Throws:

DocumentClientException - the document client exception.

createStoredProcedure

public ResourceResponse createStoredProcedure(String collectionLink, StoredProcedure storedProcedure, RequestOptions options)

Creates a stored procedure.

Parameters:

collectionLink - the collection link.
storedProcedure - the stored procedure to create.
options - the request options.

Returns:

the resource response with the created stored procedure.

Throws:

DocumentClientException - the document client exception.

createTrigger

public ResourceResponse createTrigger(String collectionLink, Trigger trigger, RequestOptions options)

Creates a trigger.

Parameters:

collectionLink - the collection link.
trigger - the trigger.
options - the request options.

Returns:

the resource response with the created trigger.

Throws:

DocumentClientException - the document client exception.

createUser

public ResourceResponse createUser(String databaseLink, User user, RequestOptions options)

Creates a user.

Parameters:

databaseLink - the database link.
user - the user to create.
options - the request options.

Returns:

the resource response with the created user.

Throws:

DocumentClientException - the document client exception.

createUserDefinedFunction

public ResourceResponse createUserDefinedFunction(String collectionLink, UserDefinedFunction udf, RequestOptions options)

Creates a user defined function.

Parameters:

collectionLink - the collection link.
udf - the user defined function.
options - the request options.

Returns:

the resource response with the created user defined function.

Throws:

DocumentClientException - the document client exception.

deleteAttachment

public ResourceResponse deleteAttachment(String attachmentLink, RequestOptions options)

Deletes an attachment.

Parameters:

attachmentLink - the attachment link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

deleteCollection

public ResourceResponse deleteCollection(String collectionLink, RequestOptions options)

Deletes a document collection by the collection link.

Parameters:

collectionLink - the collection link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

deleteConflict

public ResourceResponse deleteConflict(String conflictLink, RequestOptions options)

Deletes a conflict.

Parameters:

conflictLink - the conflict link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

deleteDatabase

public ResourceResponse deleteDatabase(String databaseLink, RequestOptions options)

Deletes a database.

Parameters:

databaseLink - the database link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

deleteDocument

public ResourceResponse deleteDocument(String documentLink, RequestOptions options)

Deletes a document by the document link.

Parameters:

documentLink - the document link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

deletePermission

public ResourceResponse deletePermission(String permissionLink, RequestOptions options)

Deletes a permission.

Parameters:

permissionLink - the permission link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

deleteStoredProcedure

public ResourceResponse deleteStoredProcedure(String storedProcedureLink, RequestOptions options)

Deletes a stored procedure by the stored procedure link.

Parameters:

storedProcedureLink - the stored procedure link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

deleteTrigger

public ResourceResponse deleteTrigger(String triggerLink, RequestOptions options)

Deletes a trigger.

Parameters:

triggerLink - the trigger link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

deleteUser

public ResourceResponse deleteUser(String userLink, RequestOptions options)

Deletes a user.

Parameters:

userLink - the user link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

deleteUserDefinedFunction

public ResourceResponse deleteUserDefinedFunction(String udfLink, RequestOptions options)

Deletes a user defined function.

Parameters:

udfLink - the user defined function link.
options - the request options.

Returns:

the resource response.

Throws:

DocumentClientException - the document client exception.

executeStoredProcedure

public StoredProcedureResponse executeStoredProcedure(String storedProcedureLink, RequestOptions options, Object[] procedureParams)

Executes a stored procedure by the stored procedure link.

Parameters:

storedProcedureLink - the stored procedure link.
options - the request options.
procedureParams - the array of procedure parameter values.

Returns:

the stored procedure response.

Throws:

DocumentClientException - the document client exception.

executeStoredProcedure

public StoredProcedureResponse executeStoredProcedure(String storedProcedureLink, Object[] procedureParams)

Executes a stored procedure by the stored procedure link.

Parameters:

storedProcedureLink - the stored procedure link.
procedureParams - the array of procedure parameter values.

Returns:

the stored procedure response.

Throws:

DocumentClientException - the document client exception.

getConnectionPolicy

public ConnectionPolicy getConnectionPolicy()

getDatabaseAccount

public DatabaseAccount getDatabaseAccount()

Gets database account information.

Returns:

the database account.

Throws:

DocumentClientException - the document client exception.

getPartitionResolver


protected PartitionResolver getPartitionResolver(String databaseLink)

Parameters:

databaseLink

getReadEndpoint

public URI getReadEndpoint()

Gets the current read endpoint chosen based on availability and preference.

Returns:

the read endpoint URI

getServiceEndpoint

public URI getServiceEndpoint()

Gets the default service endpoint as passed in by the user during construction.

Returns:

the service endpoint URI

getWriteEndpoint

public URI getWriteEndpoint()

Gets the current write endpoint chosen based on availability and preference.

Returns:

the write endpoint URI

queryAggregateValues

public List queryAggregateValues(String collectionLink, SqlQuerySpec querySpec, FeedOptions feedOptions)

Query for aggregation values in a document collection.

Parameters:

collectionLink - the link to the parent document collection.
querySpec - the SQL query specification.
feedOptions - the feed options.

Returns:

a list containing the aggregation values

queryAggregateValues

public List queryAggregateValues(String collectionLink, SqlQuerySpec querySpec, FeedOptions feedOptions, Object partitionKey)

Query for aggregation values in a document collection.

Parameters:

collectionLink - the link to the parent document collection.
querySpec - the SQL query specification.
feedOptions - the feed options.
partitionKey - the partitionKey.

Returns:

a list containing the aggregation values

queryAggregateValues

public List queryAggregateValues(String collectionLink, String query, FeedOptions feedOptions)

Query for aggregation values in a document collection.

Parameters:

collectionLink - the link to the parent document collection.
query - the query string.
feedOptions - the feed options.

Returns:

a list containing the aggregation values

queryAggregateValues

public List queryAggregateValues(String collectionLink, String query, FeedOptions feedOptions, String partitionKey)

Query for aggregation values in a document collection.

Parameters:

collectionLink - the link to the parent document collection.
query - the query string.
feedOptions - the feed options.
partitionKey - the partitionKey.

Returns:

a list containing the aggregation values

queryAttachments

public FeedResponse queryAttachments(String documentLink, SqlQuerySpec querySpec, FeedOptions options)

Query for attachments.

Parameters:

documentLink - the document link.
querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response with the obtained attachments.

queryAttachments

public FeedResponse queryAttachments(String documentLink, String query, FeedOptions options)

Query for attachments.

Parameters:

documentLink - the document link.
query - the query.
options - the feed options.

Returns:

the feed response with the obtained attachments.

queryCollections

public FeedResponse queryCollections(String databaseLink, SqlQuerySpec querySpec, FeedOptions options)

Query for document collections in a database.

Parameters:

databaseLink - the database link.
querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response with the obtained collections.

queryCollections

public FeedResponse queryCollections(String databaseLink, String query, FeedOptions options)

Query for document collections in a database.

Parameters:

databaseLink - the database link.
query - the query.
options - the feed options.

Returns:

the feed response with the obtained collections.

queryConflicts

public FeedResponse queryConflicts(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for conflicts.

Parameters:

collectionLink - the collection link.
querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response of the obtained conflicts.

queryConflicts

public FeedResponse queryConflicts(String collectionLink, String query, FeedOptions options)

Query for conflicts.

Parameters:

collectionLink - the collection link.
query - the query.
options - the feed options.

Returns:

the feed response of the obtained conflicts.

queryDatabases

public FeedResponse queryDatabases(SqlQuerySpec querySpec, FeedOptions options)

Query for databases.

Parameters:

querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response with the obtained databases.

queryDatabases

public FeedResponse queryDatabases(String query, FeedOptions options)

Query for databases.

Parameters:

query - the query.
options - the feed options.

Returns:

the feed response with the obtained databases.

queryDocumentChangeFeed

public FeedResponse queryDocumentChangeFeed(String collectionLink, ChangeFeedOptions changeFeedOptions)

Query for documents change feed in a document collection.

Example:

String partitionKeyRangeId = "0";   // Use client.readPartitionKeyRanges() to obtain the ranges.
 String checkpointContinuation = null;
 ChangeFeedOptions options = new ChangeFeedOptions();
 options.setPartitionKeyRangeId(partitionKeyRangeId);
 options.setRequestContinuation(checkpointContinuation);
 options.setStartFromBeginning(true);
 FeedResponse<Document> query = client.queryDocumentChangeFeed(coll.getSelfLink(), options);
 do {
     List<Document> docs = query.getQueryIterable().fetchNextBlock();
     // Process the documents
     // Checkpoint query.getResponseContinuation()
 } while (query.getQueryIterator().hasNext());

Parameters:

collectionLink - the link to the parent document collection
changeFeedOptions - the options for processing the query results feed

Returns:

the feed response with the obtained documents

queryDocuments

public FeedResponse queryDocuments(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for documents in a document collection.

Parameters:

collectionLink - the link to the parent document collection.
querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response with the obtained documents.

queryDocuments

public FeedResponse queryDocuments(String collectionLink, SqlQuerySpec querySpec, FeedOptions options, Object partitionKey)

Query for documents in a document collection.

Parameters:

collectionLink - the link to the parent document collection.
querySpec - the SQL query specification.
options - the feed options.
partitionKey - the partitionKey.

Returns:

the feed response with the obtained documents.

queryDocuments

public FeedResponse queryDocuments(String collectionLink, String query, FeedOptions options)

Query for documents in a document collection.

Parameters:

collectionLink - the link to the parent document collection.
query - the query.
options - the feed options.

Returns:

the feed response with the obtained documents.

queryDocuments

public FeedResponse queryDocuments(String collectionLink, String query, FeedOptions options, Object partitionKey)

Query for documents in a document collection with a partitionKey

Parameters:

collectionLink - the link to the parent document collection.
query - the query.
options - the feed options.
partitionKey - the partitionKey.

Returns:

the feed response with the obtained documents.

queryOffers

public FeedResponse queryOffers(SqlQuerySpec querySpec, FeedOptions options)

Query for offers in a database.

Parameters:

querySpec - the query specification.
options - the feed options.

Returns:

the feed response with the obtained offers.

queryOffers

public FeedResponse queryOffers(String query, FeedOptions options)

Query for offers in a database.

Parameters:

query - the query.
options - the feed options.

Returns:

the feed response with the obtained offers.

queryPermissions

public FeedResponse queryPermissions(String permissionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for permissions.

Parameters:

permissionLink - the permission link.
querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response with the obtained permissions.

queryPermissions

public FeedResponse queryPermissions(String userLink, String query, FeedOptions options)

Query for permissions.

Parameters:

userLink - the user link.
query - the query.
options - the feed options.

Returns:

the feed response with the obtained permissions.

queryStoredProcedures

public FeedResponse queryStoredProcedures(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for stored procedures in a document collection.

Parameters:

collectionLink - the collection link.
querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response with the obtained stored procedures.

queryStoredProcedures

public FeedResponse queryStoredProcedures(String collectionLink, String query, FeedOptions options)

Query for stored procedures in a document collection.

Parameters:

collectionLink - the collection link.
query - the query.
options - the feed options.

Returns:

the feed response with the obtained stored procedures.

queryTriggers

public FeedResponse queryTriggers(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for triggers.

Parameters:

collectionLink - the collection link.
querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response with the obtained triggers.

queryTriggers

public FeedResponse queryTriggers(String collectionLink, String query, FeedOptions options)

Query for triggers.

Parameters:

collectionLink - the collection link.
query - the query.
options - the feed options.

Returns:

the feed response with the obtained triggers.

queryUserDefinedFunctions

public FeedResponse queryUserDefinedFunctions(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for user defined functions.

Parameters:

collectionLink - the collection link.
querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response with the obtained user defined functions.

queryUserDefinedFunctions

public FeedResponse queryUserDefinedFunctions(String collectionLink, String query, FeedOptions options)

Query for user defined functions.

Parameters:

collectionLink - the collection link.
query - the query.
options - the feed options.

Returns:

the feed response with the obtained user defined functions.

queryUsers

public FeedResponse queryUsers(String databaseLink, SqlQuerySpec querySpec, FeedOptions options)

Query for users.

Parameters:

databaseLink - the database link.
querySpec - the SQL query specification.
options - the feed options.

Returns:

the feed response of the obtained users.

queryUsers

public FeedResponse queryUsers(String databaseLink, String query, FeedOptions options)

Query for users.

Parameters:

databaseLink - the database link.
query - the query.
options - the feed options.

Returns:

the feed response of the obtained users.

readAttachment

public ResourceResponse readAttachment(String attachmentLink, RequestOptions options)

Reads an attachment.

Parameters:

attachmentLink - the attachment link.
options - the request options.

Returns:

the resource response with the read attachment.

Throws:

DocumentClientException - the document client exception.

readAttachments

public FeedResponse readAttachments(String documentLink, FeedOptions options)

Reads all attachments in a document.

Parameters:

documentLink - the document link.
options - the feed options.

Returns:

the feed response with the read attachments.

readCollection

public ResourceResponse readCollection(String collectionLink, RequestOptions options)

Reads a document collection by the collection link.

Parameters:

collectionLink - the collection link.
options - the request options.

Returns:

the resource response with the read collection.

Throws:

DocumentClientException - the document client exception.

readCollections

public FeedResponse readCollections(String databaseLink, FeedOptions options)

Reads all document collections in a database.

Parameters:

databaseLink - the database link.
options - the fee options.

Returns:

the feed response with the read collections.

readConflict

public ResourceResponse readConflict(String conflictLink, RequestOptions options)

Reads a conflict.

Parameters:

conflictLink - the conflict link.
options - the request options.

Returns:

the resource response with the read conflict.

Throws:

DocumentClientException - the document client exception.

readConflicts

public FeedResponse readConflicts(String collectionLink, FeedOptions options)

Reads all conflicts in a document collection.

Parameters:

collectionLink - the collection link.
options - the feed options.

Returns:

the feed response with the read conflicts.

readDatabase

public ResourceResponse readDatabase(String databaseLink, RequestOptions options)

Reads a database.

Parameters:

databaseLink - the database link.
options - the request options.

Returns:

the resource response with the read database.

Throws:

DocumentClientException - the document client exception.

readDatabases

public FeedResponse readDatabases(FeedOptions options)

Reads all databases.

Parameters:

options - the feed options.

Returns:

the feed response with the read databases.

readDocument

public ResourceResponse readDocument(String documentLink, RequestOptions options)

Reads a document by the document link.

Parameters:

documentLink - the document link.
options - the request options.

Returns:

the resource response with the read document.

Throws:

DocumentClientException - the document client exception.

readDocuments

public FeedResponse readDocuments(String collectionLink, FeedOptions options)

Reads all documents in a document collection.

Parameters:

collectionLink - the collection link.
options - the feed options.

Returns:

the feed response with read documents.

readMedia

public MediaResponse readMedia(String mediaLink)

Reads a media by the media link.

Parameters:

mediaLink - the media link.

Returns:

the media response.

Throws:

DocumentClientException - the document client exception.

readOffer

public ResourceResponse readOffer(String offerLink)

Reads an offer.

Parameters:

offerLink - the offer link.

Returns:

the resource response with the read offer.

Throws:

DocumentClientException - the document client exception.

readOffers

public FeedResponse readOffers(FeedOptions options)

Reads offers.

Parameters:

options - the feed options.

Returns:

the feed response with the read offers.

readPartitionKeyRanges

public FeedResponse readPartitionKeyRanges(DocumentCollection documentCollection, FeedOptions options)

Reads all partition key ranges in a document collection.

Example:

FeedResponse<PartitionKeyRange> partitionKeyRanges = this.client.readPartitionKeyRanges(coll, null);
 List<String> ids = new ArrayList<String>();
 for (PartitionKeyRange range : partitionKeyRanges.getQueryIterable()) {
     ids.add(range.getId());
 }

Parameters:

documentCollection - the document collection.
options - the feed options.

Returns:

the feed response with the read partition key ranges.

readPartitionKeyRanges

public FeedResponse readPartitionKeyRanges(String collectionLink, FeedOptions options)

Reads all partition key ranges in a document collection.

Example:

FeedResponse<PartitionKeyRange> partitionKeyRanges = this.client.readPartitionKeyRanges(coll, null);
 List<String> ids = new ArrayList<String>();
 for (PartitionKeyRange range : partitionKeyRanges.getQueryIterable()) {
     ids.add(range.getId());
 }

Parameters:

collectionLink - the collection link.
options - the feed options.

Returns:

the feed response with the read partition key ranges.

readPartitionKeyRanges

public Collection readPartitionKeyRanges(String collectionLink, String query)

Reads all partition key ranges in a document collection for a provided query.

Parameters:

collectionLink - the document collection link
query - the query string

Returns:

the list of the serving partition key ranges for the query

Throws:

DocumentClientException - from partition key ranges query

readPermission

public ResourceResponse readPermission(String permissionLink, RequestOptions options)

Reads a permission.

Parameters:

permissionLink - the permission link.
options - the request options.

Returns:

the resource response with the read permission.

Throws:

DocumentClientException - the document client exception.

readPermissions

public FeedResponse readPermissions(String userLink, FeedOptions options)

Reads all permissions.

Parameters:

userLink - the user link.
options - the feed options.

Returns:

the feed response with the read permissions.

readStoredProcedure

public ResourceResponse readStoredProcedure(String storedProcedureLink, RequestOptions options)

Read a stored procedure by the stored procedure link.

Parameters:

storedProcedureLink - the stored procedure link.
options - the request options.

Returns:

the resource response with the read stored procedure.

Throws:

DocumentClientException - the document client exception.

readStoredProcedures

public FeedResponse readStoredProcedures(String collectionLink, FeedOptions options)

Reads all stored procedures in a document collection link.

Parameters:

collectionLink - the collection link.
options - the feed options.

Returns:

the feed response with the read stored procedure.

readTrigger

public ResourceResponse readTrigger(String triggerLink, RequestOptions options)

Reads a trigger by the trigger link.

Parameters:

triggerLink - the trigger link.
options - the request options.

Returns:

the resource response with the read trigger.

Throws:

DocumentClientException - the document client exception.

readTriggers

public FeedResponse readTriggers(String collectionLink, FeedOptions options)

Reads all triggers in a document collection.

Parameters:

collectionLink - the collection link.
options - the feed options.

Returns:

the feed response with the read triggers.

readUser

public ResourceResponse readUser(String userLink, RequestOptions options)

Reads a user.

Parameters:

userLink - the user link.
options - the request options.

Returns:

the resource response with the read user.

Throws:

DocumentClientException - the document client exception.

readUserDefinedFunction

public ResourceResponse readUserDefinedFunction(String udfLink, RequestOptions options)

Read a user defined function.

Parameters:

udfLink - the user defined function link.
options - the request options.

Returns:

the resource response with the read user defined function.

Throws:

DocumentClientException - the document client exception.

readUserDefinedFunctions

public FeedResponse readUserDefinedFunctions(String collectionLink, FeedOptions options)

Reads all user defined functions in a document collection.

Parameters:

collectionLink - the collection link.
options - the feed options.

Returns:

the feed response with the read user defined functions.

readUsers

public FeedResponse readUsers(String databaseLink, FeedOptions options)

Reads all users in a database.

Parameters:

databaseLink - the database link.
options - the feed options.

Returns:

the feed response with the read users.

registerPartitionResolver


public void registerPartitionResolver(String databaseLink, PartitionResolver partitionResolver)

Parameters:

databaseLink
partitionResolver

Throws:

replaceAttachment

public ResourceResponse replaceAttachment(Attachment attachment, RequestOptions options)

Replaces an attachment.

Parameters:

attachment - the attachment to use.
options - the request options.

Returns:

the resource response with the replaced attachment.

Throws:

DocumentClientException - the document client exception.

replaceCollection

public ResourceResponse replaceCollection(DocumentCollection collection, RequestOptions options)

Replaces a document collection.

Parameters:

collection - the document collection to use.
options - the request options.

Returns:

the resource response with the replaced document collection.

Throws:

DocumentClientException - the document client exception.

replaceDocument

public ResourceResponse replaceDocument(Document document, RequestOptions options)

Replaces a document with the passed in document.

Parameters:

document - the document to replace (containing the document id).
options - the request options.

Returns:

the resource response with the replaced document.

Throws:

DocumentClientException - the document client exception.

replaceDocument

public ResourceResponse replaceDocument(String documentLink, Object document, RequestOptions options)

Replaces a document using a POJO object.

Parameters:

documentLink - the document link.
document - the document represented as a POJO or Document object.
options - the request options.

Returns:

the resource response with the replaced document.

Throws:

DocumentClientException - the document client exception.

replaceOffer

public ResourceResponse replaceOffer(Offer offer)

Replaces an offer.

Parameters:

offer - the offer to use.

Returns:

the resource response with the replaced offer.

Throws:

DocumentClientException - the document client exception.

replacePermission

public ResourceResponse replacePermission(Permission permission, RequestOptions options)

Replaces a permission.

Parameters:

permission - the permission to use.
options - the request options.

Returns:

the resource response with the replaced permission.

Throws:

DocumentClientException - the document client exception.

replaceStoredProcedure

public ResourceResponse replaceStoredProcedure(StoredProcedure storedProcedure, RequestOptions options)

Replaces a stored procedure.

Parameters:

storedProcedure - the stored procedure to use.
options - the request options.

Returns:

the resource response with the replaced stored procedure.

Throws:

DocumentClientException - the document client exception.

replaceTrigger

public ResourceResponse replaceTrigger(Trigger trigger, RequestOptions options)

Replaces a trigger.

Parameters:

trigger - the trigger to use.
options - the request options.

Returns:

the resource response with the replaced trigger.

Throws:

DocumentClientException - the document client exception.

replaceUser

public ResourceResponse replaceUser(User user, RequestOptions options)

Replaces a user.

Parameters:

user - the user to use.
options - the request options.

Returns:

the resource response with the replaced user.

Throws:

DocumentClientException - the document client exception.

replaceUserDefinedFunction

public ResourceResponse replaceUserDefinedFunction(UserDefinedFunction udf, RequestOptions options)

Replaces a user defined function.

Parameters:

udf - the user defined function.
options - the request options.

Returns:

the resource response with the replaced user defined function.

Throws:

DocumentClientException - the document client exception.

updateMedia

public MediaResponse updateMedia(String mediaLink, InputStream mediaStream, MediaOptions options)

Updates a media by the media link.

Parameters:

mediaLink - the media link.
mediaStream - the media stream to upload.
options - the media options.

Returns:

the media response.

Throws:

DocumentClientException - the document client exception.

upsertAttachment

public ResourceResponse upsertAttachment(String documentLink, Attachment attachment, RequestOptions options)

Upserts an attachment.

Parameters:

documentLink - the document link.
attachment - the attachment to upsert.
options - the request options.

Returns:

the resource response with the upserted attachment.

Throws:

DocumentClientException - the document client exception.

upsertAttachment

public ResourceResponse upsertAttachment(String documentLink, InputStream mediaStream, MediaOptions options)

Upserts an attachment to the media stream

Parameters:

documentLink - the document link.
mediaStream - the media stream for upserting the attachment.
options - the media options.

Returns:

the resource response with the upserted attachment.

Throws:

DocumentClientException - the document client exception.

upsertDocument

public ResourceResponse upsertDocument(String collectionLink, Object document, RequestOptions options, boolean disableAutomaticIdGeneration)

Upserts a document.

Parameters:

collectionLink - the link to the parent document collection.
document - the document represented as a POJO or Document object to upsert.
options - the request options.
disableAutomaticIdGeneration - the flag for disabling automatic id generation.

Returns:

the resource response with the upserted document.

Throws:

DocumentClientException - the document client exception.

upsertPermission

public ResourceResponse upsertPermission(String userLink, Permission permission, RequestOptions options)

Upserts a permission.

Parameters:

userLink - the user link.
permission - the permission to upsert.
options - the request options.

Returns:

the resource response with the upserted permission.

Throws:

DocumentClientException - the document client exception.

upsertStoredProcedure

public ResourceResponse upsertStoredProcedure(String collectionLink, StoredProcedure storedProcedure, RequestOptions options)

Upserts a stored procedure.

Parameters:

collectionLink - the collection link.
storedProcedure - the stored procedure to upsert.
options - the request options.

Returns:

the resource response with the upserted stored procedure.

Throws:

DocumentClientException - the document client exception.

upsertTrigger

public ResourceResponse upsertTrigger(String collectionLink, Trigger trigger, RequestOptions options)

Upserts a trigger.

Parameters:

collectionLink - the collection link.
trigger - the trigger to upsert.
options - the request options.

Returns:

the resource response with the upserted trigger.

Throws:

DocumentClientException - the document client exception.

upsertUser

public ResourceResponse upsertUser(String databaseLink, User user, RequestOptions options)

Upserts a user.

Parameters:

databaseLink - the database link.
user - the user to upsert.
options - the request options.

Returns:

the resource response with the upserted user.

Throws:

DocumentClientException - the document client exception.

upsertUserDefinedFunction

public ResourceResponse upsertUserDefinedFunction(String collectionLink, UserDefinedFunction udf, RequestOptions options)

Upserts a user defined function.

Parameters:

collectionLink - the collection link.
udf - the user defined function to upsert.
options - the request options.

Returns:

the resource response with the upserted user defined function.

Throws:

DocumentClientException - the document client exception.

Applies to