Provided by: python3-pydocumentdb_2.3.3-2_all 

NAME
pydocumentdb - pydocumentdb 2.3.3
SYSTEM REQUIREMENTS:
The supported Python versions are 2.7, 3.3, 3.4 and 3.5. To download Python, please visit https://www.python.org/download/releases. Python Tools for Visual Studio is required when using Microsoft Visual Studio to develop Python applications. To download Python Tools for Visual Studio, please visit http://microsoft.github.io/PTVS.
INSTALLATION:
Method 1: 1. Download the Azure DocumentDB Python SDK source from https://github.com/Azure/azure-documentdb-python which is needed to manage the Azure DocumentDB database service. 2. Execute the following setup script in bash shell: $ python setup.py install Method 2: 1. Install the Azure DocumentDB Python SDK using pip. For more information on pip, please visit https://pypi.python.org/pypi/pip 2. Execute the following in bash shell: $ pip install pydocumentdb
TO RUN TESTS:
$ python -m unittest discover -s .\test -p "*.py" If you use Microsoft Visual Studio, open the project file python.pyproj, and run all the tests in Test Explorer.
TO GENERATE DOCUMENTATIONS:
Install Sphinx: http://sphinx-doc.org/install.html $ cd doc $ sphinx-apidoc -f -e -o api ..\pydocumentdb $ make.bat html · genindex · modindex · search
PYDOCUMENTDB PACKAGE
Subpackages pydocumentdb.execution_context package Submodules pydocumentdb.execution_context.aggregators module Internal class for aggregation queries implementation in the Azure Cosmos DB database service. pydocumentdb.execution_context.base_execution_context module Internal class for query execution context implementation in the Azure Cosmos DB database service. pydocumentdb.execution_context.document_producer module Internal class for document producer implementation in the Azure Cosmos DB database service. pydocumentdb.execution_context.endpoint_component module Internal class for query execution endpoint component implementation in the Azure Cosmos DB database service. pydocumentdb.execution_context.execution_dispatcher module Internal class for proxy query execution context implementation in the Azure Cosmos DB database service. pydocumentdb.execution_context.multi_execution_aggregator module Internal class for multi execution context aggregator implementation in the Azure Cosmos DB database service. pydocumentdb.execution_context.query_execution_info module Internal class for partitioned query execution info implementation in the Azure Cosmos DB database service. Module contents pydocumentdb.routing package Submodules pydocumentdb.routing.collection_routing_map module Internal class for collection routing map implementation in the Azure Cosmos DB database service. pydocumentdb.routing.routing_map_provider module Internal class for partition key range cache implementation in the Azure Cosmos DB database service. pydocumentdb.routing.routing_range module Internal class for partition key range implementation in the Azure Cosmos DB database service. Module contents Submodules pydocumentdb.auth module Authorization helper functions in the Azure Cosmos DB database service. pydocumentdb.auth.GetAuthorizationHeader(document_client, verb, path, resource_id_or_fullname, is_name_based, resource_type, headers) Gets the authorization header. Parameters · document_client (document_client.DocumentClient) -- · verb (str) -- · path (str) -- · resource_id_or_fullname (str) -- · resource_type (str) -- · headers (dict) -- Returns The authorization headers. Return type dict pydocumentdb.base module Base functions in the Azure Cosmos DB database service. pydocumentdb.base.DecodeBase64String(string_to_decode) Decodes a Base64 encoded string by replacing '-' with '/' Parameters string_to_decode (string) -- String to decode. Returns Path with beginning and ending slashes trimmed. Return type str pydocumentdb.base.GenerateGuidId() Gets a random GUID. Note that here we use python's UUID generation library. Basically UUID is the same as GUID when represented as a string. Returns The generated random GUID. Return type str pydocumentdb.base.GetAttachmentIdFromMediaId(media_id) Gets attachment id from media id. Parameters media_id (str) -- Returns The attachment id from the media id. Return type str pydocumentdb.base.GetDocumentCollectionInfo(self_link, alt_content_path, id_from_response) Given the self link and alt_content_path from the reponse header and result extract the collection name and collection id Ever response header has alt-content-path that is the owner's path in ascii. For document create / update requests, this can be used to get the collection name, but for collection create response, we can't use it. So we also rely on Parameters · self_link (str) -- Self link of the resource, as obtained from response result. · alt_content_path (str) -- Owner path of the resource, as obtained from response header. · resource_id (str) -- .INDENT 2.0 'id' as returned from the response result. This is only used if it is deduced that the request was to create a collection. Returns tuple of (collection rid, collection name) Return type tuple pydocumentdb.base.GetDocumentCollectionLink(link) Gets the document collection link Parameters link (str) -- Resource link Returns Document collection link. Return type str pydocumentdb.base.GetHeaders(document_client, default_headers, verb, path, resource_id, resource_type, options, partition_key_range_id=None) Gets HTTP request headers. Parameters · document_client (document_client.DocumentClient) -- · default_headers (dict) -- · verb (str) -- · path (str) -- · resource_id (str) -- · resource_type (str) -- · options (dict) -- · partition_key_range_id (str) -- Returns The HTTP request headers. Return type dict pydocumentdb.base.GetPathFromLink(resource_link, resource_type='') Gets path from resource link with optional resource type Parameters · resource_link (str) -- · resource_type (str) -- Returns Path from resource link with resource type appended (if provided). Return type str pydocumentdb.base.GetResourceIdOrFullNameFromLink(resource_link) Gets resource id or full name from resource link. Parameters resource_link (str) -- Returns The resource id or full name from the resource link. Return type str pydocumentdb.base.IndexOfNth(s, value, n) Gets the index of Nth occurance of a given character in a string Parameters · s (str) -- Input string · value (char) -- Input char to be searched. · n (int) -- Nth occurrence of char to be searched. Returns Index of the Nth occurrence in the string. Return type int pydocumentdb.base.IsDatabaseLink(link) Finds whether the link is a database Self Link or a database ID based link Parameters link (str) -- Link to analyze Returns True or False. Return type boolean pydocumentdb.base.IsDocumentCollectionLink(link) Finds whether the link is a document colllection Self Link or a document colllection ID based link Parameters link (str) -- Link to analyze Returns True or False. Return type boolean pydocumentdb.base.IsMasterResource(resourceType) pydocumentdb.base.IsNameBased(link) Finds whether the link is name based or not Parameters link (str) -- Returns True if link is name-based; otherwise, False. Return type boolean pydocumentdb.base.ParsePaths(paths) pydocumentdb.base.TrimBeginningAndEndingSlashes(path) Trims beginning and ending slashes Parameters path (str) -- Returns Path with beginning and ending slashes trimmed. Return type str pydocumentdb.consistent_hash_ring module Internal class for consistent hash ring implementation in the Azure Cosmos DB database service. pydocumentdb.constants module Class for defining internal constants in the Azure Cosmos DB database service. pydocumentdb.default_retry_policy module Internal class for connection reset retry policy implementation in the Azure Cosmos DB database service. pydocumentdb.document_client module Document client class for the Azure Cosmos DB database service. class pydocumentdb.document_client.DocumentClient(url_connection, auth, connection_policy=None, consistency_level='Session') Bases: object Represents a document client. 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. Parameters · url_connection (str) -- The URL for connecting to the DB server. · auth (dict) -- Contains 'masterKey' or 'resourceTokens', where auth['masterKey'] is the default authorization key to use to create the client, and auth['resourceTokens'] is the alternative authorization key. · connection_policy (documents.ConnectionPolicy) -- The connection policy for the client. · consistency_level (documents.ConsistencyLevel) -- The default consistency policy for client operations. Create(body, path, type, id, initial_headers, options=None) Creates a Azure Cosmos DB resource and returns it. Parameters · body (dict) -- · path (str) -- · type (str) -- · id (str) -- · initial_headers (dict) -- · options (dict) -- The request options for the request. Returns The created Azure Cosmos DB resource. Return type dict CreateAttachment(document_link, attachment, options=None) Creates an attachment in a document. Parameters · document_link (str) -- The link to the document. · attachment (dict) -- The Azure Cosmos DB attachment to create. · options (dict) -- The request options for the request. Returns The created Attachment. Return type dict CreateAttachmentAndUploadMedia(document_link, readable_stream, options=None) Creates an attachment and upload media. Parameters · document_link (str) -- The link to the document. · stream object) readable_stream ((file-like) -- · options (dict) -- The request options for the request. Returns The created Attachment. Return type dict CreateCollection(database_link, collection, options=None) Creates a collection in a database. Parameters · database_link (str) -- The link to the database. · collection (dict) -- The Azure Cosmos DB collection to create. · options (dict) -- The request options for the request. Returns The Collection that was created. Return type dict CreateDatabase(database, options=None) Creates a database. Parameters · database (dict) -- The Azure Cosmos DB database to create. · options (dict) -- The request options for the request. Returns The Database that was created. Return type dict CreateDocument(database_or_collection_link, document, options=None) Creates a document in a collection. Parameters · database_or_collection_link (str) -- The link to the database when using partitioning, otherwise link to the document collection. · document (dict) -- The Azure Cosmos DB document to create. · options (dict) -- The request options for the request. · options['disableAutomaticIdGeneration'] (bool) -- Disables the automatic id generation. If id is missing in the body and this option is true, an error will be returned. Returns The created Document. Return type dict CreatePermission(user_link, permission, options=None) Creates a permission for a user. Parameters · user_link (str) -- The link to the user entity. · permission (dict) -- The Azure Cosmos DB user permission to create. · options (dict) -- The request options for the request. Returns The created Permission. Return type dict CreateStoredProcedure(collection_link, sproc, options=None) Creates a stored procedure in a collection. Parameters · collection_link (str) -- The link to the document collection. · sproc (str) -- · options (dict) -- The request options for the request. Returns The created Stored Procedure. Return type dict CreateTrigger(collection_link, trigger, options=None) Creates a trigger in a collection. Parameters · collection_link (str) -- The link to the document collection. · trigger (dict) -- · options (dict) -- The request options for the request. Returns The created Trigger. Return type dict CreateUser(database_link, user, options=None) Creates a user. Parameters · database_link (str) -- The link to the database. · user (dict) -- The Azure Cosmos DB user to create. · options (dict) -- The request options for the request. Returns The created User. Return type dict CreateUserDefinedFunction(collection_link, udf, options=None) Creates a user defined function in a collection. Parameters · collection_link (str) -- The link to the collection. · udf (str) -- · options (dict) -- The request options for the request. Returns The created UDF. Return type dict DeleteAttachment(attachment_link, options=None) Deletes an attachment. Parameters · attachment_link (str) -- The link to the attachment. · options (dict) -- The request options for the request. Returns The deleted Attachment. Return type dict DeleteCollection(collection_link, options=None) Deletes a collection. Parameters · collection_link (str) -- The link to the document collection. · options (dict) -- The request options for the request. Returns The deleted Collection. Return type dict DeleteConflict(conflict_link, options=None) Deletes a conflict. Parameters · conflict_link (str) -- The link to the conflict. · options (dict) -- The request options for the request. Returns The deleted Conflict. Return type dict DeleteDatabase(database_link, options=None) Deletes a database. Parameters · database_link (str) -- The link to the database. · options (dict) -- The request options for the request. Returns The deleted Database. Return type dict DeleteDocument(document_link, options=None) Deletes a document. Parameters · document_link (str) -- The link to the document. · options (dict) -- The request options for the request. Returns The deleted Document. Return type dict DeletePermission(permission_link, options=None) Deletes a permission. Parameters · permission_link (str) -- The link to the permission. · options (dict) -- The request options for the request. Returns The deleted Permission. Return type dict DeleteResource(path, type, id, initial_headers, options=None) Deletes a Azure Cosmos DB resource and returns it. Parameters · path (str) -- · type (str) -- · id (str) -- · initial_headers (dict) -- · options (dict) -- The request options for the request. Returns The deleted Azure Cosmos DB resource. Return type dict DeleteStoredProcedure(sproc_link, options=None) Deletes a stored procedure. Parameters · sproc_link (str) -- The link to the stored procedure. · options (dict) -- The request options for the request. Returns The deleted Stored Procedure. Return type dict DeleteTrigger(trigger_link, options=None) Deletes a trigger. Parameters · trigger_link (str) -- The link to the trigger. · options (dict) -- The request options for the request. Returns The deleted Trigger. Return type dict DeleteUser(user_link, options=None) Deletes a user. Parameters · user_link (str) -- The link to the user entity. · options (dict) -- The request options for the request. Returns The deleted user. Return type dict DeleteUserDefinedFunction(udf_link, options=None) Deletes a user defined function. Parameters · udf_link (str) -- The link to the user defined function. · options (dict) -- The request options for the request. Returns The deleted UDF. Return type dict ExecuteStoredProcedure(sproc_link, params, options=None) Executes a store procedure. Parameters · sproc_link (str) -- The link to the stored procedure. · params (dict) -- List or None · options (dict) -- The request options for the request. Returns The Stored Procedure response. Return type dict GetDatabaseAccount(url_connection=None) Gets database account info. Returns The Database Account. Return type documents.DatabaseAccount GetPartitionResolver(database_link) Gets the partition resolver associated with the database link Parameters database_link (str) -- Database self link or ID based link. Returns An instance of PartitionResolver. Return type object PartitionResolverErrorMessage = Couldn't find any partition resolvers for the database link provided. Ensure that the link you used when registering the partition resolvers matches the link provided or you need to register both types of database link(self link as well as ID based link). QueryAttachments(document_link, query, options=None) Queries attachments in a document. Parameters · document_link (str) -- The link to the document. · or dict) query ((str) -- · options (dict) -- The request options for the request. Returns Query Iterable of Attachments. Return type query_iterable.QueryIterable QueryCollections(database_link, query, options=None) Queries collections in a database. Parameters · database_link (str) -- The link to the database. · or dict) query ((str) -- · options (dict) -- The request options for the request. Returns Query Iterable of Collections. Return type query_iterable.QueryIterable QueryConflicts(collection_link, query, options=None) Queries conflicts in a collection. Parameters · collection_link (str) -- The link to the document collection. · or dict) query ((str) -- · options (dict) -- The request options for the request. Returns Query Iterable of Conflicts. Return type query_iterable.QueryIterable QueryDatabases(query, options=None) Queries databases. Parameters · or dict) query ((str) -- · options (dict) -- The request options for the request. Returns Query Iterable of Databases. Return type query_iterable.QueryIterable QueryDocuments(database_or_collection_link, query, options=None, partition_key=None) Queries documents in a collection. Parameters · database_or_collection_link (str) -- The link to the database when using partitioning, otherwise link to the document collection. · or dict) query ((str) -- · options (dict) -- The request options for the request. · partition_key (str) -- Partition key for the query(default value None) Returns Query Iterable of Documents. Return type query_iterable.QueryIterable QueryDocumentsChangeFeed(collection_link, options=None) Queries documents change feed in a collection. Parameters · collection_link (str) -- The link to the document collection. · options (dict) -- The request options for the request. options may also specify partition key range id. Returns Query Iterable of Documents. Return type query_iterable.QueryIterable QueryFeed(path, collection_id, query, options, partition_key_range_id=None) Query Feed for Document Collection resource. Parameters · path (str) -- Path to the document collection. · collection_id (str) -- Id of the document collection. · or dict) query ((str) -- · options (dict) -- The request options for the request. · partition_key_range_id (str) -- Partition key range id. Return type tuple QueryOffers(query, options=None) Query for all offers. Parameters · or dict) query ((str) -- · options (dict) -- The request options for the request Returns Query Iterable of Offers. Return type query_iterable.QueryIterable QueryPermissions(user_link, query, options=None) Queries permissions for a user. Parameters · user_link (str) -- The link to the user entity. · or dict) query ((str) -- · options (dict) -- The request options for the request. Returns Query Iterable of Permissions. Return type query_iterable.QueryIterable QueryStoredProcedures(collection_link, query, options=None) Queries stored procedures in a collection. Parameters · collection_link (str) -- The link to the document collection. · or dict) query ((str) -- · options (dict) -- The request options for the request. Returns Query Iterable of Stored Procedures. Return type query_iterable.QueryIterable QueryTriggers(collection_link, query, options=None) Queries triggers in a collection. Parameters · collection_link (str) -- The link to the document collection. · or dict) query ((str) -- · options (dict) -- The request options for the request. Returns Query Iterable of Triggers. Return type query_iterable.QueryIterable QueryUserDefinedFunctions(collection_link, query, options=None) Queries user defined functions in a collection. Parameters · collection_link (str) -- The link to the collection. · or dict) query ((str) -- · options (dict) -- The request options for the request. Returns Query Iterable of UDFs. Return type query_iterable.QueryIterable QueryUsers(database_link, query, options=None) Queries users in a database. Parameters · database_link (str) -- The link to the database. · or dict) query ((str) -- · options (dict) -- The request options for the request. Returns Query Iterable of Users. Return type query_iterable.QueryIterable Read(path, type, id, initial_headers, options=None) Reads a Azure Cosmos DB resource and returns it. Parameters · path (str) -- · type (str) -- · id (str) -- · initial_headers (dict) -- · options (dict) -- The request options for the request. Returns The upserted Azure Cosmos DB resource. Return type dict ReadAttachment(attachment_link, options=None) Reads an attachment. Parameters · attachment_link (str) -- The link to the attachment. · options (dict) -- The request options for the request. Returns The read Attachment. Return type dict ReadAttachments(document_link, options=None) Reads all attachments in a document. Parameters · document_link (str) -- The link to the document. · options (dict) -- The request options for the request. Returns Query Iterable of Attachments. Return type query_iterable.QueryIterable ReadCollection(collection_link, options=None) Reads a collection. Parameters · collection_link (str) -- The link to the document collection. · options (dict) -- The request options for the request. Returns The read Collection. Return type dict ReadCollections(database_link, options=None) Reads all collections in a database. Parameters · database_link (str) -- The link to the database. · options (dict) -- The request options for the request. Returns Query Iterable of Collections. Return type query_iterable.QueryIterable ReadConflict(conflict_link, options=None) Reads a conflict. Parameters · conflict_link (str) -- The link to the conflict. · options (dict) -- Returns The read Conflict. Return type dict ReadConflicts(collection_link, feed_options=None) Reads conflicts. Parameters · collection_link (str) -- The link to the document collection. · feed_options (dict) -- Returns Query Iterable of Conflicts. Return type query_iterable.QueryIterable ReadDatabase(database_link, options=None) Reads a database. Parameters · database_link (str) -- The link to the database. · options (dict) -- The request options for the request. Returns The Database that was read. Return type dict ReadDatabases(options=None) Reads all databases. Parameters options (dict) -- The request options for the request. Returns Query Iterable of Databases. Return type query_iterable.QueryIterable ReadDocument(document_link, options=None) Reads a document. Parameters · document_link (str) -- The link to the document. · options (dict) -- The request options for the request. Returns The read Document. Return type dict ReadDocuments(collection_link, feed_options=None) Reads all documents in a collection. Parameters · collection_link (str) -- The link to the document collection. · feed_options (dict) -- Returns Query Iterable of Documents. Return type query_iterable.QueryIterable ReadEndpoint Gets the curent read endpoint for a geo-replicated database account. ReadMedia(media_link) Reads a media. When self.connection_policy.MediaReadMode == documents.MediaReadMode.Streamed, returns a file-like stream object; otherwise, returns a str. Parameters media_link (str) -- The link to the media. Returns The read Media. Return type str or file-like stream object ReadOffer(offer_link) Reads an offer. Parameters offer_link (str) -- The link to the offer. Returns The read Offer. Return type dict ReadOffers(options=None) Reads all offers. Parameters options (dict) -- The request options for the request Returns Query Iterable of Offers. Return type query_iterable.QueryIterable ReadPermission(permission_link, options=None) Reads a permission. Parameters · permission_link (str) -- The link to the permission. · options (dict) -- The request options for the request. Returns The read permission. Return type dict ReadPermissions(user_link, options=None) Reads all permissions for a user. Parameters · user_link (str) -- The link to the user entity. · options (dict) -- The request options for the request. Returns Query Iterable of Permissions. Return type query_iterable.QueryIterable ReadStoredProcedure(sproc_link, options=None) Reads a stored procedure. Parameters · sproc_link (str) -- The link to the stored procedure. · options (dict) -- The request options for the request. Returns The read Stored Procedure. Return type dict ReadStoredProcedures(collection_link, options=None) Reads all store procedures in a collection. Parameters · collection_link (str) -- The link to the document collection. · options (dict) -- The request options for the request. Returns Query Iterable of Stored Procedures. Return type query_iterable.QueryIterable ReadTrigger(trigger_link, options=None) Reads a trigger. Parameters · trigger_link (str) -- The link to the trigger. · options (dict) -- The request options for the request. Returns The read Trigger. Return type dict ReadTriggers(collection_link, options=None) Reads all triggers in a collection. Parameters · collection_link (str) -- The link to the document collection. · options (dict) -- The request options for the request. Returns Query Iterable of Triggers. Return type query_iterable.QueryIterable ReadUser(user_link, options=None) Reads a user. Parameters · user_link (str) -- The link to the user entity. · options (dict) -- The request options for the request. Returns The read User. Return type dict ReadUserDefinedFunction(udf_link, options=None) Reads a user defined function. Parameters · udf_link (str) -- The link to the user defined function. · options (dict) -- The request options for the request. Returns The read UDF. Return type dict ReadUserDefinedFunctions(collection_link, options=None) Reads all user defined functions in a collection. Parameters · collection_link (str) -- The link to the document collection. · options (dict) -- The request options for the request. Returns Query Iterable of UDFs. Return type query_iterable.QueryIterable ReadUsers(database_link, options=None) Reads all users in a database. Params str database_link The link to the database. Params dict options The request options for the request. Returns Query iterable of Users. Return type query_iterable.QueryIterable RegisterPartitionResolver(database_link, partition_resolver) Registers the partition resolver associated with the database link Parameters · database_link (str) -- Database Self Link or ID based link. · partition_resolver (object) -- An instance of PartitionResolver. Replace(resource, path, type, id, initial_headers, options=None) Replaces a Azure Cosmos DB resource and returns it. Parameters · resource (dict) -- · path (str) -- · type (str) -- · id (str) -- · initial_headers (dict) -- · options (dict) -- The request options for the request. Returns The new Azure Cosmos DB resource. Return type dict ReplaceAttachment(attachment_link, attachment, options=None) Replaces an attachment and returns it. Parameters · attachment_link (str) -- The link to the attachment. · attachment (dict) -- · options (dict) -- The request options for the request. Returns The replaced Attachment Return type dict ReplaceCollection(collection_link, collection, options=None) Replaces a collection and return it. Parameters · collection_link (str) -- The link to the collection entity. · collection (dict) -- The collection to be used. · options (dict) -- The request options for the request. Returns The new Collection. Return type dict ReplaceDocument(document_link, new_document, options=None) Replaces a document and returns it. Parameters · document_link (str) -- The link to the document. · new_document (dict) -- · options (dict) -- The request options for the request. Returns The new Document. Return type dict ReplaceOffer(offer_link, offer) Replaces an offer and returns it. Parameters · offer_link (str) -- The link to the offer. · offer (dict) -- Returns The replaced Offer. Return type dict ReplacePermission(permission_link, permission, options=None) Replaces a permission and return it. Parameters · permission_link (str) -- The link to the permission. · permission (dict) -- · options (dict) -- The request options for the request. Returns The new Permission. Return type dict ReplaceStoredProcedure(sproc_link, sproc, options=None) Replaces a stored procedure and returns it. Parameters · sproc_link (str) -- The link to the stored procedure. · sproc (dict) -- · options (dict) -- The request options for the request. Returns The replaced Stored Procedure. Return type dict ReplaceTrigger(trigger_link, trigger, options=None) Replaces a trigger and returns it. Parameters · trigger_link (str) -- The link to the trigger. · trigger (dict) -- · options (dict) -- The request options for the request. Returns The replaced Trigger. Return type dict ReplaceUser(user_link, user, options=None) Replaces a user and return it. Parameters · user_link (str) -- The link to the user entity. · user (dict) -- · options (dict) -- The request options for the request. Returns The new User. Return type dict ReplaceUserDefinedFunction(udf_link, udf, options=None) Replaces a user defined function and returns it. Parameters · udf_link (str) -- The link to the user defined function. · udf (dict) -- · options (dict) -- The request options for the request. Returns The new UDF. Return type dict Session Gets the session object from the client UpdateMedia(media_link, readable_stream, options=None) Updates a media and returns it. Parameters · media_link (str) -- The link to the media. · stream object) readable_stream ((file-like) -- · options (dict) -- The request options for the request. Returns The updated Media. Return type str or file-like stream object Upsert(body, path, type, id, initial_headers, options=None) Upserts a Azure Cosmos DB resource and returns it. Parameters · body (dict) -- · path (str) -- · type (str) -- · id (str) -- · initial_headers (dict) -- · options (dict) -- The request options for the request. Returns The upserted Azure Cosmos DB resource. Return type dict UpsertAttachment(document_link, attachment, options=None) Upserts an attachment in a document. Parameters · document_link (str) -- The link to the document. · attachment (dict) -- The Azure Cosmos DB attachment to upsert. · options (dict) -- The request options for the request. Returns The upserted Attachment. Return type dict UpsertAttachmentAndUploadMedia(document_link, readable_stream, options=None) Upserts an attachment and upload media. Parameters · document_link (str) -- The link to the document. · stream object) readable_stream ((file-like) -- · options (dict) -- The request options for the request. Returns The upserted Attachment. Return type dict UpsertDocument(database_or_collection_link, document, options=None) Upserts a document in a collection. Parameters · database_or_collection_link (str) -- The link to the database when using partitioning, otherwise link to the document collection. · document (dict) -- The Azure Cosmos DB document to upsert. · options (dict) -- The request options for the request. · options['disableAutomaticIdGeneration'] (bool) -- Disables the automatic id generation. If id is missing in the body and this option is true, an error will be returned. Returns The upserted Document. Return type dict UpsertPermission(user_link, permission, options=None) Upserts a permission for a user. Parameters · user_link (str) -- The link to the user entity. · permission (dict) -- The Azure Cosmos DB user permission to upsert. · options (dict) -- The request options for the request. Returns The upserted permission. Return type dict UpsertStoredProcedure(collection_link, sproc, options=None) Upserts a stored procedure in a collection. Parameters · collection_link (str) -- The link to the document collection. · sproc (str) -- · options (dict) -- The request options for the request. Returns The upserted Stored Procedure. Return type dict UpsertTrigger(collection_link, trigger, options=None) Upserts a trigger in a collection. Parameters · collection_link (str) -- The link to the document collection. · trigger (dict) -- · options (dict) -- The request options for the request. Returns The upserted Trigger. Return type dict UpsertUser(database_link, user, options=None) Upserts a user. Parameters · database_link (str) -- The link to the database. · user (dict) -- The Azure Cosmos DB user to upsert. · options (dict) -- The request options for the request. Returns The upserted User. Return type dict UpsertUserDefinedFunction(collection_link, udf, options=None) Upserts a user defined function in a collection. Parameters · collection_link (str) -- The link to the collection. · udf (str) -- · options (dict) -- The request options for the request. Returns The upserted UDF. Return type dict WriteEndpoint Gets the curent write endpoint for a geo-replicated database account. pydocumentdb.documents module AzureDocument classes and enums for the Azure Cosmos DB database service. class pydocumentdb.documents.ConnectionMode Bases: object Represents the connection mode to be used by the client. Variables Gateway (int) -- Use the Azure Cosmos DB gateway to route all requests. The gateway proxies requests to the right data partition. Gateway = 0 class pydocumentdb.documents.ConnectionPolicy Bases: object Represents the Connection policy assocated with a DocumentClient. Variables · RequestTimeout (int) -- Gets or sets the request timeout (time to wait for response from network peer). · MediaRequestTimeout (int) -- Gets or sets Time to wait for response from network peer for attachment content (aka media) operations. · ConnectionMode (documents.ConnectionMode) -- Gets or sets the connection mode used in the client. Currently only Gateway is supported. · MediaReadMode (MediaReadMode.Buffered) -- Gets or sets the attachment content (aka media) download mode. · SSLConfiguration (documents.SSLConfiguration) -- Gets or sets the SSL configuration. · ProxyConfiguration (documents.ProxyConfiguration) -- Gets or sets the proxy configuration. · EnableEndpointDiscovery (boolean) -- Gets or sets endpoint discovery flag for geo-replicated database accounts. When EnableEndpointDiscovery is true, the client will automatically discover the current write and read locations and direct the requests to the correct location taking into consideration of the user's preference(if provided) as PreferredLocations. · PreferredLocations (list) -- Gets or sets the preferred locations for geo-replicated database accounts. When EnableEndpointDiscovery is true and PreferredLocations is non-empty, the client will use this list to evaluate the final location, taking into consideration the order specified in PreferredLocations list. The locations in this list are specified as the names of the azure cosmos db locations like, 'West US', 'East US', 'Central India' and so on. · RetryOptions (RetryOptions) -- Gets or sets the retry options to be applied to all requests when retrying. · DisableSSLVerification (boolean) -- Flag to disable SSL verification for the requests. SSL verification is enabled by default. Don't set this when targeting production endpoints. This is intended to be used only when targeting emulator endpoint to avoid failing your requests with SSL related error. class pydocumentdb.documents.ConsistencyLevel Bases: object Represents the consistency levels supported for Azure Cosmos DB client operations. The requested ConsistencyLevel must match or be weaker than that provisioned for the database account. Consistency levels. Consistency levels by order of strength are Strong, BoundedStaleness, Session, ConsistentPrefix and Eventual. Variables · Strong (str) -- Strong Consistency guarantees that read operations always return the value that was last written. · BoundedStaleness (str) -- Bounded Staleness guarantees that reads are not too out-of-date. This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds). · Session (str) -- Session Consistency guarantees monotonic reads (you never read old data, then new, then old again), monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads) within any single session. · Eventual (str) -- Eventual Consistency guarantees that reads will return a subset of writes. All writes will be eventually be available for reads. · ConsistentPrefix (str) -- ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps. All writes will be eventually be available for reads. BoundedStaleness = 'BoundedStaleness' ConsistentPrefix = 'ConsistentPrefix' Eventual = 'Eventual' Session = 'Session' Strong = 'Strong' class pydocumentdb.documents.DataType Bases: object Specifies the data type of index specs. Variables · Number (str) -- Represents a numeric data type. · String (str) -- Represents a string data type. · Point (str) -- Represents a point data type. · LineString (str) -- Represents a line string data type. · Polygon (str) -- Represents a polygon data type. LineString = 'LineString' Number = 'Number' Point = 'Point' Polygon = 'Polygon' String = 'String' class pydocumentdb.documents.DatabaseAccount Bases: object Database account. A DatabaseAccount is the container for databases. Variables · DatabaseLink (str) -- The self-link for Databases in the databaseAccount. · MediaLink (str) -- The self-link for Media in the databaseAccount. · MaxMediaStorageUsageInMB (int) -- Attachment content (media) storage quota in MBs (Retrieved from gateway). · CurrentMediaStorageUsageInMB (int) -- Current attachment content (media) usage in MBs (Retrieved from gateway). Value is returned from cached information updated periodically and is not guaranteed to be real time. · ConsistencyPolicy (dict) -- UserConsistencyPolicy settings. · ConsistencyPolicy['defaultConsistencyLevel'] (dict) -- The default consistency level. · ConsistencyPolicy['maxStalenessPrefix'] (int) -- In bounded staleness consistency, the maximum allowed staleness in terms difference in sequence numbers (aka version). · ConsistencyPolicy['maxStalenessIntervalInSeconds'] (int) -- In bounded staleness consistency, the maximum allowed staleness in terms time interval. ReadableLocations Gets the list of readable locations for a geo-replicated database account. WritableLocations Gets the list of writable locations for a geo-replicated database account. class pydocumentdb.documents.IndexKind Bases: object Specifies the index kind of index specs. Variables · Hash (str) -- The index entries are hashed to serve point look up queries. Can be used to serve queries like: SELECT * FROM docs d WHERE d.prop = 5 · Range (str) -- The index entries are ordered. Range indexes are optimized for inequality predicate queries with efficient range scans. Can be used to serve queries like: SELECT * FROM docs d WHERE d.prop > 5 Hash = 'Hash' Range = 'Range' class pydocumentdb.documents.IndexingDirective Bases: object Specifies whether or not the resource is to be indexed. Variables · Default (int) -- Use any pre-defined/pre-configured defaults. · Exclude (int) -- Index the resource. · Include (int) -- Do not index the resource. Default = 0 Exclude = 1 Include = 2 class pydocumentdb.documents.IndexingMode Bases: object Specifies the supported indexing modes. Variables · Consistent (str) -- Index is updated synchronously with a create or update operation. With consistent indexing, query behavior is the same as the default consistency level for the collection. The index is always kept up to date with the data. · Lazy (str) -- Index is updated asynchronously with respect to a create or update operation. With lazy indexing, queries are eventually consistent. The index is updated when the collection is idle. · NoIndex (str) -- No index is provided. Setting IndexingMode to "None" drops the index. Use this if you don't want to maintain the index for a document collection, to save the storage cost or improve the write throughput. Your queries will degenerate to scans of the entire collection. Consistent = 'consistent' Lazy = 'lazy' NoIndex = 'none' class pydocumentdb.documents.MediaReadMode Bases: object Represents the mode for use with downloading attachment content (aka media). Variables · Buffered (str) -- Content is buffered at the client and not directly streamed from the content store. Use Buffered to reduce the time taken to read and write media files. · Streamed (str) -- Content is directly streamed from the content store without any buffering at the client. Use Streamed to reduce the client memory overhead of reading and writing media files. Buffered = 'Buffered' Streamed = 'Streamed' class pydocumentdb.documents.PartitionKind Bases: object Specifies the kind of partitioning to be applied. Variables Hash (str) -- The partition key definition path is hashed. Hash = 'Hash' class pydocumentdb.documents.PermissionMode Bases: object Enumeration specifying applicability of permission. Variables · NoneMode (str) -- None. · Read (str) -- Permission applicable for read operations only. · All (str) -- Permission applicable for all operations. All = 'all' NoneMode = 'none' Read = 'read' class pydocumentdb.documents.ProxyConfiguration Bases: object Configurations for proxy. Variables · Host (str) -- The host address of the proxy. · Port (int) -- The port number of the proxy. class pydocumentdb.documents.SSLConfiguration Bases: object Configurations for SSL connections. Please refer to http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification for more detail. Variables · SSLKeyFIle (str) -- The path of the key file for ssl connection. · SSLCertFile (str) -- The path of the cert file for ssl connection. · SSLCaCerts (str) -- The path of the CA_BUNDLE file with certificates of trusted CAs. class pydocumentdb.documents.TriggerOperation Bases: object Specifies the operations on which a trigger should be executed. Variables · All (str) -- All operations. · Create (str) -- Create operations only. · Update (str) -- Update operations only. · Delete (str) -- Delete operations only. · Replace (str) -- Replace operations only. All = 'all' Create = 'create' Delete = 'delete' Replace = 'replace' Update = 'update' class pydocumentdb.documents.TriggerType Bases: object Specifies the type of the trigger. Variables · Pre (str) -- Trigger should be executed before the associated operation(s). · Post (str) -- Trigger should be executed after the associated operation(s). Post = 'post' Pre = 'pre' class pydocumentdb.documents.Undefined Bases: object Represents undefined value for partitionKey when it's mising. pydocumentdb.endpoint_discovery_retry_policy module Internal class for endpoint discovery retry policy implementation in the Azure Cosmos DB database service. pydocumentdb.errors module PyDocumentDB Exceptions in the Azure Cosmos DB database service. exception pydocumentdb.errors.DocumentDBError Bases: Exception Base class for all Azure Cosmos DB errors. exception pydocumentdb.errors.HTTPFailure(status_code, message='', headers=None) Bases: pydocumentdb.errors.DocumentDBError Raised when a HTTP request to the Azure Cosmos DB has failed. Parameters · status_code (int) -- · message (str) -- exception pydocumentdb.errors.JSONParseFailure Bases: pydocumentdb.errors.DocumentDBError Raised when fails to parse JSON message. exception pydocumentdb.errors.UnexpectedDataType Bases: pydocumentdb.errors.DocumentDBError Raised when unexpected data type is provided as parameter. pydocumentdb.global_endpoint_manager module Internal class for global endpoint manager implementation in the Azure Cosmos DB database service. pydocumentdb.hash_partition_resolver module Hash partition resolver implementation in the Azure Cosmos DB database service. class pydocumentdb.hash_partition_resolver.HashPartitionResolver(partition_key_extractor, collection_links, default_number_of_virtual_nodes_per_collection=128, hash_generator=None) Bases: object HashPartitionResolver implements partitioning based on the value of a hash function, allowing you to evenly distribute requests and data across a number of partitions. Parameters · partition_key_extractor (lambda) -- Returning the partition key from the document passed. · collection_links (list) -- The links of collections participating in partitioning. · default_number_of_virtual_nodes_per_collection (int) -- Number of virtual nodes per collection. · hash_generator (HashGenerator) -- The hash generator to be used for hashing algorithm. ResolveForCreate(document) Resolves the collection for creating the document based on the partition key. Parameters document (dict) -- The document to be created. Returns Collection Self link or Name based link which should handle the Create operation. Return type str ResolveForRead(partition_key) Resolves the collection for reading/querying the documents based on the partition key. Parameters document (dict) -- The document to be read/queried. Returns Collection Self link(s) or Name based link(s) which should handle the Read operation. Return type list pydocumentdb.http_constants module HTTP Constants in the Azure Cosmos DB database service. class pydocumentdb.http_constants.CookieHeaders Bases: object Constants of cookie headers. SessionToken = 'x-ms-session-token' class pydocumentdb.http_constants.Delimiters Bases: object Constants of delimiters. ClientContinuationDelimiter = '!!' ClientContinuationFormat = '{0}!!{1}' class pydocumentdb.http_constants.HttpContextProperties Bases: object Constants of http context properties. SubscriptionId = 'SubscriptionId' class pydocumentdb.http_constants.HttpHeaderPreferenceTokens Bases: object Constants of http header preference tokens. PreferUnfilteredQueryResponse = 'PreferUnfilteredQueryResponse' class pydocumentdb.http_constants.HttpHeaders Bases: object Constants of http headers. AIM = 'A-IM' Accept = 'Accept' AcceptCharset = 'Accept-Charset' AcceptEncoding = 'Accept-Encoding' AcceptLanguage = 'Accept-Language' AcceptRanges = 'Accept-Ranges' AccessControlAllowHeaders = 'Access-Control-Allow-Headers' AccessControlAllowOrigin = 'Access-Control-Allow-Origin' ActivityId = 'x-ms-activity-id' AlternateContentPath = 'x-ms-alt-content-path' Authorization = 'authorization' CacheControl = 'Cache-Control' CharacterSet = 'CharacterSet' CollectionCurrentUsageInMb = 'x-ms-collection-usage-mb' CollectionPartitionInfo = 'x-ms-collection-partition-info' CollectionQuotaInMb = 'x-ms-collection-quota-mb' CollectionServiceInfo = 'x-ms-collection-service-info' ConsistencyLevel = 'x-ms-consistency-level' ContentEncoding = 'Content-Encoding' ContentLanguage = 'Content-Language' ContentLength = 'Content-Length' ContentLocation = 'Content-Location' ContentMd5 = 'Content-Md5' ContentRange = 'Content-Range' ContentType = 'Content-Type' Continuation = 'x-ms-continuation' CurrentEntityCount = 'x-ms-root-entity-current-count' CurrentMediaStorageUsageInMB = 'x-ms-media-storage-usage-mb' DisableRUPerMinuteUsage = 'x-ms-documentdb-disable-ru-per-minute-usage' ETag = 'etag' EmitVerboseTracesInQuery = 'x-ms-documentdb-query-emit-traces' EnableCrossPartitionQuery = 'x-ms-documentdb-query-enablecrosspartition' EnableScanInQuery = 'x-ms-documentdb-query-enable-scan' EnableScriptLogging = 'x-ms-documentdb-script-enable-logging' ForceRefresh = 'x-ms-force-refresh' FullUpgrade = 'x-ms-force-full-upgrade' Host = 'Host' HttpDate = 'date' IfMatch = 'If-Match' IfModified_since = 'If-Modified-Since' IfNoneMatch = 'If-None-Match' IfRange = 'If-Range' IfUnmodifiedSince = 'If-Unmodified-Since' IgnoreInProgressUpgrade = 'x-ms-ignore-inprogress-upgrade' IncrementalFeedHeaderValue = 'Incremental feed' IndexTransformationProgress = 'x-ms-documentdb-collection-index-transformation-progress' IndexingDirective = 'x-ms-indexing-directive' IsCanary = 'x-ms-iscanary' IsContinuationExpected = 'x-ms-documentdb-query-iscontinuationexpected' IsFeedUnfiltered = 'x-ms-is-feed-unfiltered' IsQuery = 'x-ms-documentdb-isquery' IsRUPerMinuteUsed = 'x-ms-documentdb-is-ru-per-minute-used' IsUpsert = 'x-ms-documentdb-is-upsert' ItemCount = 'x-ms-item-count' KeepAlive = 'Keep-Alive' KeyValueEncodingFormat = 'application/x-www-form-urlencoded' LastModified = 'Last-Modified' LastStateChangeUtc = 'x-ms-last-state-change-utc' LazyIndexingProgress = 'x-ms-documentdb-collection-lazy-indexing-progress' Location = 'Location' MaxEntityCount = 'x-ms-root-entity-max-count' MaxForwards = 'Max-Forwards' MaxMediaStorageUsageInMB = 'x-ms-max-media-storage-usage-mb' MethodOverride = 'X-HTTP-Method' NewResourceId = 'x-ms-new-resource-id' OcpResourceProviderRegisteredUri = 'ocp-resourceprovider-registered-uri' OfferIsRUPerMinuteThroughputEnabled = 'x-ms-offer-is-ru-per-minute-throughput-enabled' OfferThroughput = 'x-ms-offer-throughput' OfferType = 'x-ms-offer-type' OnlyUpgradeNonSystemApplications = 'x-ms-only-upgrade-non-system-applications' OnlyUpgradeSystemApplications = 'x-ms-only-upgrade-system-applications' Origin = 'Origin' PageSize = 'x-ms-max-item-count' PartitionKey = 'x-ms-documentdb-partitionkey' PartitionKeyRangeID = 'x-ms-documentdb-partitionkeyrangeid' PopulatePartitionKeyRangeStatistics = 'x-ms-documentdb-populatepartitionstatistics' PopulateQueryMetrics = 'x-ms-documentdb-populatequerymetrics' PopulateQuotaInfo = 'x-ms-documentdb-populatequotainfo' PostTriggerExclude = 'x-ms-documentdb-post-trigger-exclude' PostTriggerInclude = 'x-ms-documentdb-post-trigger-include' PreTriggerExclude = 'x-ms-documentdb-pre-trigger-exclude' PreTriggerInclude = 'x-ms-documentdb-pre-trigger-include' Prefer = 'Prefer' ProxyAuthenticate = 'Proxy-Authenticate' ProxyAuthorization = 'Proxy-Authorization' Query = 'x-ms-documentdb-query' Referer = 'referer' RequestCharge = 'x-ms-request-charge' RequestId = 'x-ms-request-id' ResourceTokenExpiry = 'x-ms-documentdb-expiry-seconds' RetryAfter = 'Retry-After' RetryAfterInMilliseconds = 'x-ms-retry-after-ms' ScriptLogResults = 'x-ms-documentdb-script-log-results' SessionToken = 'x-ms-session-token' SetCookie = 'Set-Cookie' SimpleToken = 'SWT' Slug = 'Slug' SubStatus = 'x-ms-substatus' ThrottleRetryCount = 'x-ms-throttle-retry-count' ThrottleRetryWaitTimeInMs = 'x-ms-throttle-retry-wait-time-ms' TransferEncoding = 'Transfer-Encoding' UpgradeFabricRingCodeAndConfig = 'x-ms-upgrade-fabric-code-config' UpgradeVerificationKind = 'x-ms-upgrade-verification-kind' UseMasterCollectionResolver = 'x-ms-use-master-collection-resolver' UserAgent = 'User-Agent' Version = 'x-ms-version' WrapAssertion = 'wrap_assertion' WrapAssertionFormat = 'wrap_assertion_format' WrapScope = 'wrap_scope' WwwAuthenticate = 'Www-Authenticate' XDate = 'x-ms-date' class pydocumentdb.http_constants.HttpListenerErrorCodes Bases: object Constants of http listener error codes. ERROR_CONNECTION_INVALID = 1229 ERROR_OPERATION_ABORTED = 995 class pydocumentdb.http_constants.HttpMethods Bases: object Constants of http methods. Delete = 'DELETE' Get = 'GET' Head = 'HEAD' Options = 'OPTIONS' Post = 'POST' Put = 'PUT' class pydocumentdb.http_constants.HttpStatusDescriptions Bases: object Constants of http status descriptions. Accepted = 'Accepted' BadGateway = 'Bad Gateway' BadRequest = 'Bad Request' Conflict = 'Conflict' Created = 'Created' Forbidden = 'Forbidden' GatewayTimeout = 'Gateway timed out' Gone = 'Gone' InternalServerError = 'Internal Server Error' LengthRequired = 'Length Required' MethodNotAllowed = 'MethodNotAllowed' NoContent = 'No Content' NotAcceptable = 'Not Acceptable' NotFound = 'Not Found' NotModified = 'Not Modified' OK = 'Ok' PreconditionFailed = 'Precondition Failed' RequestEntityTooLarge = 'Request Entity Too Large' RequestTimeout = 'Request timed out' RetryWith = 'Retry the request' ServiceUnavailable = 'Service Unavailable' TooManyRequests = 'Too Many Requests' Unauthorized = 'Unauthorized' UnsupportedMediaType = 'Unsupported Media Type' class pydocumentdb.http_constants.QueryStrings Bases: object Constants of query strings. ContentView = 'contentview' Filter = '$filter' GenerateId = '$generateFor' GenerateIdBatchSize = '$batchSize' Generic = 'generic' GetChildResourcePartitions = '$getChildResourcePartitions' Query = 'query' RootIndex = '$rootIndex' SQLQueryType = 'sql' Url = '$resolveFor' class pydocumentdb.http_constants.ResourceType Bases: object Types of resources in Azure Cosmos DB Attachment = 'attachments' Collection = 'colls' Conflict = 'conflicts' Database = 'dbs' DatabaseAccount = 'databaseaccount' Document = 'docs' Offer = 'offers' PartitionKeyRange = 'pkranges' Permission = 'permissions' Schema = 'schemas' StoredProcedure = 'sprocs' Topology = 'topology' Trigger = 'triggers' User = 'users' UserDefinedFunction = 'udfs' class pydocumentdb.http_constants.StatusCodes Bases: object HTTP status codes returned by the REST operations ACCEPTED = 202 BAD_REQUEST = 400 CONFLICT = 409 CREATED = 201 FORBIDDEN = 403 GONE = 410 INTERNAL_SERVER_ERROR = 500 METHOD_NOT_ALLOWED = 405 NOT_FOUND = 404 NOT_MODIFIED = 304 NO_CONTENT = 204 OK = 200 OPERATION_CANCELLED = 1201 OPERATION_PAUSED = 1200 PRECONDITION_FAILED = 412 REQUEST_ENTITY_TOO_LARGE = 413 REQUEST_TIMEOUT = 408 RETRY_WITH = 449 SERVICE_UNAVAILABLE = 503 TOO_MANY_REQUESTS = 429 UNAUTHORIZED = 401 class pydocumentdb.http_constants.SubStatusCodes Bases: object Sub status codes returned by the REST operations specifying the details of the operation COMPLETING_PARTITION_MIGRATION = 1008 COMPLETING_SPLIT = 1007 CONFLICT_WITH_CONTROL_PLANE = 1006 CROSS_PARTITION_QUERY_NOT_SERVABLE = 1004 DATABASE_ACCOUNT_NOT_FOUND = 1008 INSUFFICIENT_BINDABLE_PARTITIONS = 1007 NAME_CACHE_IS_STALE = 1000 OWNER_RESOURCE_NOT_FOUND = 1003 PARTITION_KEY_MISMATCH = 1001 PARTITION_KEY_RANGE_GONE = 1002 PROVISION_LIMIT_REACHED = 1005 READ_SESSION_NOTAVAILABLE = 1002 REDUNDANT_COLLECTION_PUT = 1009 SHARED_THROUGHPUT_DATABASE_QUOTA_EXCEEDED = 1010 SHARED_THROUGHPUT_OFFER_GROW_NOT_NEEDED = 1011 UNKNOWN = 0 WRITE_FORBIDDEN = 3 class pydocumentdb.http_constants.Versions Bases: object Constants of versions. CurrentVersion = '2017-11-15' SDKName = 'documentdb-python-sdk' SDKVersion = '2.3.3' pydocumentdb.murmur_hash module Internal class for Murmur hash implementation in the Azure Cosmos DB database service. pydocumentdb.partition module Internal class for client side partition implementation in the Azure Cosmos DB database service. pydocumentdb.query_iterable module Iterable query results in the Azure Cosmos DB database service. class pydocumentdb.query_iterable.QueryIterable(client, query, options, fetch_function, collection_link=None) Bases: object Represents an iterable object of the query results. QueryIterable is a wrapper for query execution context. Instantiates a QueryIterable for non-client side partitioning queries. _ProxyQueryExecutionContext will be used as the internal query execution context Parameters · client (DocumentClient) -- Instance of document client. · or dict) query ((str) -- · options (dict) -- The request options for the request. · fetch_function (method) -- · collection_link (str) -- If this is a Document query/feed collection_link is required. Example of fetch_function: >>> def result_fn(result): >>> return result['Databases'] class Iterator(iterable) Bases: object next() classmethod PartitioningQueryIterable(client, query, options, database_link, partition_key) Represents a client side partitioning query iterable. This constructor instantiates a QueryIterable for client side partitioning queries, and sets _MultiCollectionQueryExecutionContext as the internal execution context. :param DocumentClient client: Instance of document client Parameters · or dict) options ((str) -- · options (dict) -- The request options for the request. · database_link (str) -- Database self link or ID based link · partition_key (str) -- Partition key for the query fetch_next_block() Returns a block of results with respecting retry policy. This method only exists for backward compatibility reasons. (Because QueryIterable has exposed fetch_next_block api). Returns List of results. Return type list pydocumentdb.range module Range class implementation in the Azure Cosmos DB database service. class pydocumentdb.range.Range(low, high) Bases: object Represents the Range class used to map the partition key of the document to their associated collection. Contains(other) Checks if the passed parameter is in the range of this object. Intersect(other) Checks if the passed parameter intersects the range of this object. pydocumentdb.range_partition_resolver module Range partition resolver implementation in the Azure Cosmos DB database service. class pydocumentdb.range_partition_resolver.RangePartitionResolver(partition_key_extractor, partition_map) Bases: object RangePartitionResolver implements partitioning based on the ranges, allowing you to distribute requests and data across a number of partitions. Parameters · partition_key_extractor (lambda) -- Returning the partition key from the document passed. · partition_map (dict) -- The dictionary of ranges mapped to their associated collection ResolveForCreate(document) Resolves the collection for creating the document based on the partition key. Parameters document (dict) -- The document to be created. Returns Collection Self link or Name based link which should handle the Create operation. Return type str ResolveForRead(partition_key) Resolves the collection for reading/querying the documents based on the partition key. Parameters document (dict) -- The document to be read/queried. Returns Collection Self link(s) or Name based link(s) which should handle the Read operation. Return type list pydocumentdb.resource_throttle_retry_policy module Internal class for resource throttle retry policy implementation in the Azure Cosmos DB database service. pydocumentdb.retry_options module Class for retry options in the Azure Cosmos DB database service. class pydocumentdb.retry_options.RetryOptions(max_retry_attempt_count=9, fixed_retry_interval_in_milliseconds=None, max_wait_time_in_seconds=30) Bases: object The retry options to be applied to all requests when retrying Variables · MaxRetryAttemptCount (int) -- Max number of retries to be performed for a request. Default value 9. · FixedRetryIntervalInMilliseconds (int) -- Fixed retry interval in milliseconds to wait between each retry ignoring the retryAfter returned as part of the response. · MaxWaitTimeInSeconds (int) -- Max wait time in seconds to wait for a request while the retries are happening. Default value 30 seconds. FixedRetryIntervalInMilliseconds MaxRetryAttemptCount MaxWaitTimeInSeconds pydocumentdb.retry_utility module Internal methods for executing functions in the Azure Cosmos DB database service. pydocumentdb.runtime_constants module Runtime Constants in the Azure Cosmos DB database service. class pydocumentdb.runtime_constants.MediaTypes Bases: object Constants of media types. http://www.iana.org/assignments/media-types/media-types.xhtml Any = '*/*' ImageJpeg = 'image/jpeg' ImagePng = 'image/png' JavaScript = 'application/x-javascript' Json = 'application/json' OctetStream = 'application/octet-stream' QueryJson = 'application/query+json' SQL = 'application/sql' TextHtml = 'text/html' TextPlain = 'text/plain' Xml = 'application/xml' pydocumentdb.session module Session Consistency Tracking in the Azure Cosmos DB database service. class pydocumentdb.session.Session(url_connection) Bases: object State of a Azure Cosmos DB session. This session object can be shared across clients within the same process get_session_token(resource_path) update_session(response_result, response_headers) class pydocumentdb.session.SessionContainer Bases: object get_session_token(resource_path) Get Session Token for collection_link Parameters resource_path (str) -- Self link / path to the resource Returns Session Token dictionary for the collection_id Return type dict static parse_session_token(response_headers) Extracts session token from response headers and parses Parameters response_headers (dict) -- Returns A dictionary of partition id to session lsn for given collection Return type dict set_session_token(response_result, response_headers) Session token must only be updated from response of requests that successfully mutate resource on the server side (write, replace, delete etc) Parameters · response_result (dict) -- · response_headers (dict) -- Returns · None pydocumentdb.synchronized_request module Synchronized request in the Azure Cosmos DB database service. pydocumentdb.synchronized_request.SynchronizedRequest(client, global_endpoint_manager, connection_policy, requests_session, method, base_url, path, request_data, query_params, headers) Performs one synchronized http request according to the parameters. Parameters · client (object) -- Document client instance · global_endpoint_manager (_GlobalEndpointManager) -- · connection_policy (documents.ConnectionPolicy) -- · requests_session (requests.Session) -- Session object in requests module · method (str) -- · base_url (str) -- · path (str) -- · unicode, file-like stream object, dict, list or None) request_data ((str,) -- · query_params (dict) -- · headers (dict) -- Returns tuple of (result, headers) Return type tuple of (dict dict) pydocumentdb.utils module Internal Helper functions in the Azure Cosmos DB database service. Module contents
PYDOCUMENTDB
COPYRIGHT
2019, Microsoft