From b6868dee45bf53a987ff9e5ce62d359ba74d633d Mon Sep 17 00:00:00 2001 From: antisch Date: Mon, 9 Sep 2019 14:46:48 -0700 Subject: [PATCH 1/8] Bumped dependency --- sdk/cosmos/azure-cosmos/setup.py | 2 +- shared_requirements.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/cosmos/azure-cosmos/setup.py b/sdk/cosmos/azure-cosmos/setup.py index a2bc049eaf9d..3dab953d7475 100644 --- a/sdk/cosmos/azure-cosmos/setup.py +++ b/sdk/cosmos/azure-cosmos/setup.py @@ -70,7 +70,7 @@ ), install_requires=[ 'six >=1.6', - 'azure-core<2.0.0,>=1.0.0b2' + 'azure-core<2.0.0,>=1.0.0b3' ], extras_require={ ":python_version<'3.0'": ["azure-nspkg"], diff --git a/shared_requirements.txt b/shared_requirements.txt index c03066fba99e..896c7089826c 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -100,3 +100,4 @@ aiohttp>=3.0 aiodns>=2.0 python-dateutil>=2.8.0 six>=1.6 +#override azure-cosmos azure-core<2.0.0,>=1.0.0b3 From c94bf26eb1ddbf0bcff085dc37e3c85b0460f2ef Mon Sep 17 00:00:00 2001 From: antisch Date: Mon, 9 Sep 2019 16:33:38 -0700 Subject: [PATCH 2/8] Update reqs --- sdk/cosmos/azure-cosmos/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/requirements.txt b/sdk/cosmos/azure-cosmos/requirements.txt index f21e3797be8f..5d92f68f2287 100644 --- a/sdk/cosmos/azure-cosmos/requirements.txt +++ b/sdk/cosmos/azure-cosmos/requirements.txt @@ -1,2 +1,2 @@ -requests >=2.10.0 -six >=1.6 \ No newline at end of file +azure-core<2.0.0,>=1.0.0b3 +six>=1.6 \ No newline at end of file From e4deab02d3529be979ed396bfef56bf64c96c96b Mon Sep 17 00:00:00 2001 From: antisch Date: Tue, 10 Sep 2019 08:25:42 -0700 Subject: [PATCH 3/8] Fixed dependency, replaced changelog --- sdk/cosmos/azure-cosmos/MANIFEST.in | 2 +- sdk/cosmos/azure-cosmos/changelog.md | 135 --------------------------- sdk/cosmos/azure-cosmos/setup.py | 3 +- 3 files changed, 3 insertions(+), 137 deletions(-) delete mode 100644 sdk/cosmos/azure-cosmos/changelog.md diff --git a/sdk/cosmos/azure-cosmos/MANIFEST.in b/sdk/cosmos/azure-cosmos/MANIFEST.in index e900c8b1d850..d9252e22d644 100644 --- a/sdk/cosmos/azure-cosmos/MANIFEST.in +++ b/sdk/cosmos/azure-cosmos/MANIFEST.in @@ -1,5 +1,5 @@ include README.md -include changelog.md +include HISTORY.md include LICENSE.txt include azure/__init__.py recursive-include doc *.bat diff --git a/sdk/cosmos/azure-cosmos/changelog.md b/sdk/cosmos/azure-cosmos/changelog.md deleted file mode 100644 index f394a7eea2dc..000000000000 --- a/sdk/cosmos/azure-cosmos/changelog.md +++ /dev/null @@ -1,135 +0,0 @@ -## Changes in 4.0.0b1 : ## - -- Alpha release for new object model. - -## Changes in 3.0.2 : ## - -- Added Support for MultiPolygon Datatype -- Bug Fix in Session Read Retry Policy -- Bug Fix for Incorrect padding issues while decoding base 64 strings - -## Changes in 3.0.1 : ## - -- Bug fix in LocationCache -- Bug fix endpoint retry logic -- Fixed documentation - -## Changes in 3.0.0 : ## - -- Multi-region write support added -- Naming changes - - DocumentClient to CosmosClient - - Collection to Container - - Document to Item - - Package name updated to "azure-cosmos" - - Namespace updated to "azure.cosmos" - -## Changes in 2.3.3 : ## - -- Added support for proxy -- Added support for reading change feed -- Added support for collection quota headers -- Bugfix for large session tokens issue -- Bugfix for ReadMedia API -- Bugfix in partition key range cache - -## Changes in 2.3.2 : ## - -- Added support for default retries on connection issues. - -## Changes in 2.3.1 : ## - -- Updated documentation to reference Azure Cosmos DB instead of Azure DocumentDB. - -## Changes in 2.3.0 : ## - -- This SDK version requires the latest version of Azure Cosmos DB Emulator available for download from https://aka.ms/cosmosdb-emulator. - -## Changes in 2.2.1 : ## - -- bugfix for aggregate dict -- bugfix for trimming slashes in the resource link -- tests for unicode encoding - -## Changes in 2.2.0 : ## - -- Added support for Request Unit per Minute (RU/m) feature. -- Added support for a new consistency level called ConsistentPrefix. - -## Changes in 2.1.0 : ## - -- Added support for aggregation queries (COUNT, MIN, MAX, SUM, and AVG). -- Added an option for disabling SSL verification when running against DocumentDB Emulator. -- Removed the restriction of dependent requests module to be exactly 2.10.0. -- Lowered minimum throughput on partitioned collections from 10,100 RU/s to 2500 RU/s. -- Added support for enabling script logging during stored procedure execution. -- REST API version bumped to '2017-01-19' with this release. - -## Changes in 2.0.1 : ## - -- Made editorial changes to documentation comments. - -## Changes in 2.0.0 : ## - -- Added support for Python 3.5. -- Added support for connection pooling using the requests module. -- Added support for session consistency. -- Added support for TOP/ORDERBY queries for partitioned collections. - -## Changes in 1.9.0 : ## - -- Added retry policy support for throttled requests. (Throttled requests receive a request rate too large exception, error code 429.) - By default, DocumentDB retries nine times for each request when error code 429 is encountered, honoring the retryAfter time in the response header. - A fixed retry interval time can now be set as part of the RetryOptions property on the ConnectionPolicy object if you want to ignore the retryAfter time returned by server between the retries. - DocumentDB now waits for a maximum of 30 seconds for each request that is being throttled (irrespective of retry count) and returns the response with error code 429. - This time can also be overriden in the RetryOptions property on ConnectionPolicy object. - -- DocumentDB now returns x-ms-throttle-retry-count and x-ms-throttle-retry-wait-time-ms as the response headers in every request to denote the throttle retry count - and the cummulative time the request waited between the retries. - -- Removed the RetryPolicy class and the corresponding property (retry_policy) exposed on the document_client class and instead introduced a RetryOptions class - exposing the RetryOptions property on ConnectionPolicy class that can be used to override some of the default retry options. - -## Changes in 1.8.0 : ## - -- Added the support for geo-replicated database accounts. -- Test fixes to move the global host and masterKey into the individual test classes. - -## Changes in 1.7.0 : ## - -- Added the support for Time To Live(TTL) feature for documents. - -## Changes in 1.6.1 : ## - -- Bug fixes related to server side partitioning to allow special characters in partitionkey path. - -## Changes in 1.6.0 : ## - -- Added the support for server side partitioned collections feature. - -## Changes in 1.5.0 : ## - -- Added Client-side sharding framework to the SDK. Implemented HashPartionResolver and RangePartitionResolver classes. - -## Changes in 1.4.2 : ## - -- Implement Upsert. New UpsertXXX methods added to support Upsert feature. -- Implement ID Based Routing. No public API changes, all changes internal. - -## Changes in 1.3.0 : ## - -- Release skipped to bring version number in alignment with other SDKs - -## Changes in 1.2.0 : ## - -- Supports GeoSpatial index. -- Validates id property for all resources. Ids for resources cannot contain ?, /, #, \\, characters or end with a space. -- Adds new header "index transformation progress" to ResourceResponse. - -## Changes in 1.1.0 : ## - -- Implements V2 indexing policy - -## Changes in 1.0.1 : ## - -- Supports proxy connection diff --git a/sdk/cosmos/azure-cosmos/setup.py b/sdk/cosmos/azure-cosmos/setup.py index 3dab953d7475..fbf49b5e4527 100644 --- a/sdk/cosmos/azure-cosmos/setup.py +++ b/sdk/cosmos/azure-cosmos/setup.py @@ -27,7 +27,7 @@ with open("README.md", encoding="utf-8") as f: README = f.read() -with open("changelog.md", encoding="utf-8") as f: +with open("HISTORY.md", encoding="utf-8") as f: HISTORY = f.read() setup( @@ -73,6 +73,7 @@ 'azure-core<2.0.0,>=1.0.0b3' ], extras_require={ + ":python_version<'3.4'": ['enum34>=1.0.4'], ":python_version<'3.0'": ["azure-nspkg"], ":python_version<'3.5'": ["typing"] }, From 10f3f039ce27b214ecdc20046dad63c05a03c470 Mon Sep 17 00:00:00 2001 From: antisch Date: Tue, 10 Sep 2019 08:40:11 -0700 Subject: [PATCH 4/8] Updated readme and examples --- sdk/cosmos/azure-cosmos/README.md | 8 +- sdk/cosmos/azure-cosmos/samples/examples.py | 145 ++++++++++++++++++++ 2 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 sdk/cosmos/azure-cosmos/samples/examples.py diff --git a/sdk/cosmos/azure-cosmos/README.md b/sdk/cosmos/azure-cosmos/README.md index 84bf724222dd..ed1b31cb6d5b 100644 --- a/sdk/cosmos/azure-cosmos/README.md +++ b/sdk/cosmos/azure-cosmos/README.md @@ -281,10 +281,10 @@ For more extensive documentation on the Cosmos DB service, see the [Azure Cosmos [ref_database]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.Database [ref_httpfailure]: https://docs.microsoft.com/python/api/azure-cosmos/azure.cosmos.errors.CosmosHttpResponseError [ref_item]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.Item -[sample_database_mgmt]: https://github.com/binderjoe/cosmos-python-prototype/blob/master/examples/databasemanagementsample.py -[sample_document_mgmt]: https://github.com/binderjoe/cosmos-python-prototype/blob/master/examples/documentmanagementsample.py -[sample_examples_misc]: https://github.com/binderjoe/cosmos-python-prototype/blob/master/examples/examples.py -[source_code]: https://github.com/binderjoe/cosmos-python-prototype +[sample_database_mgmt]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cosmos/azure-cosmos/samples/DatabaseManagement +[sample_document_mgmt]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cosmos/azure-cosmos/samples/DocumentManagement +[sample_examples_misc]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cosmos/azure-cosmos/samples/examples.py +[source_code]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cosmos/azure-cosmos [venv]: https://docs.python.org/3/library/venv.html [virtualenv]: https://virtualenv.pypa.io diff --git a/sdk/cosmos/azure-cosmos/samples/examples.py b/sdk/cosmos/azure-cosmos/samples/examples.py new file mode 100644 index 000000000000..c92a01633e25 --- /dev/null +++ b/sdk/cosmos/azure-cosmos/samples/examples.py @@ -0,0 +1,145 @@ +# These examples are ingested by the documentation system, and are +# displayed in the SDK reference documentation. When editing these +# example snippets, take into consideration how this might affect +# the readability and usability of the reference documentation. + +# All interaction with Cosmos DB starts with an instance of the CosmosClient +# [START create_client] +from azure.cosmos import errors, CosmosClient, PartitionKey + +import os + +url = os.environ["ACCOUNT_URI"] +key = os.environ["ACCOUNT_KEY"] +client = CosmosClient(url, key) +# [END create_client] + +# Create a database in the account using the CosmosClient, +# specifying that the operation shouldn't throw an exception +# if a database with the given ID already exists. +# [START create_database] +database_name = "testDatabase" +try: + database = client.create_database(id=database_name) +except errors.CosmosResourceExistsError: + database = client.get_database_client(database=database_name) +# [END create_database] + +# Create a container, handling the exception if a container with the +# same ID (name) already exists in the database. +# [START create_container] +container_name = "products" +try: + container = database.create_container( + id=container_name, partition_key=PartitionKey(path="/productName") + ) +except errors.CosmosResourceExistsError: + container = database.get_container_client(container_name) +# [END create_container] + +# Create a container with custom settings. This example +# creates a container with a custom partition key. +# [START create_container_with_settings] +customer_container_name = "customers" +try: + customer_container = database.create_container( + id=customer_container_name, + partition_key=PartitionKey(path="/city"), + default_ttl=200, + ) +except errors.CosmosResourceExistsError: + customer_container = database.get_container_client(customer_container_name) +# [END create_container_with_settings] + +# Retrieve a container by walking down the resource hierarchy +# (client->database->container), handling the exception generated +# if no container with the specified ID was found in the database. +# [START get_container] +database = client.get_database_client(database_name) +container = database.get_container_client(container_name) +# [END get_container] + +# [START list_containers] +database = client.get_database_client(database_name) +for container in database.list_containers(): + print(f"Container ID: {container.id}") +# [END list_containers] + +# Insert new items by defining a dict and calling Container.upsert_item +# [START upsert_items] +container = database.get_container_client(container_name) +for i in range(1, 10): + container.upsert_item( + dict(id=f"item{i}", productName="Widget", productModel=f"Model {i}") + ) +# [END upsert_items] + +# Modify an existing item in the container +# [START update_item] +item = container.read_item("item2", partition_key="Widget") +item["productModel"] = "DISCONTINUED" +updated_item = container.upsert_item(item) +# [END update_item] + +# Query the items in a container using SQL-like syntax. This example +# gets all items whose product model hasn't been discontinued. +# [START query_items] +import json + +for item in container.query_items( + query='SELECT * FROM products p WHERE p.productModel <> "DISCONTINUED"', + enable_cross_partition_query=True, +): + print(json.dumps(item, indent=True)) +# [END query_items] + +# Parameterized queries are also supported. This example +# gets all items whose product model has been discontinued. +# [START query_items_param] +discontinued_items = container.query_items( + query='SELECT * FROM products p WHERE p.productModel = @model AND p.productName="Widget"', + parameters=[dict(name="@model", value="DISCONTINUED")], +) +for item in discontinued_items: + print(json.dumps(item, indent=True)) +# [END query_items_param] + +# Delete items from the container. +# The Cosmos DB SQL API does not support 'DELETE' queries, +# so deletes must be done with the delete_item method +# on the container. +# [START delete_items] +for item in container.query_items( + query='SELECT * FROM products p WHERE p.productModel = "DISCONTINUED" AND p.productName="Widget"' +): + container.delete_item(item, partition_key="Widget") +# [END delete_items] + +# Retrieve the properties of a database +# [START get_database_properties] +properties = database.read() +print(json.dumps(properties, indent=True)) +# [END get_database_properties] + +# Modify the properties of an existing container +# This example sets the default time to live (TTL) for items in the +# container to 3600 seconds (1 hour). An item in container is deleted +# when the TTL has elapsed since it was last edited. +# [START reset_container_properties] +# Set the TTL on the container to 3600 seconds (one hour) +database.replace_container(container, partition_key=PartitionKey(path='/productName'), default_ttl=3600) + +# Display the new TTL setting for the container +container_props = database.get_container_client(container_name).read() +print(f"New container TTL: {json.dumps(container_props['defaultTtl'])}") +# [END reset_container_properties] + +# Create a user in the database. +# [START create_user] +try: + database.create_user(dict(id="Walter Harp")) +except errors.CosmosResourceExistsError: + print("A user with that ID already exists.") +except errors.CosmosHttpResponseError as failure: + print(f"Failed to create user. Status code:{failure.status_code}") +# [END create_user] From 29605fc428c41b30cbde25c920c478670de478fe Mon Sep 17 00:00:00 2001 From: antisch Date: Tue, 10 Sep 2019 08:52:30 -0700 Subject: [PATCH 5/8] Updated docs URLs --- sdk/cosmos/azure-cosmos/README.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/README.md b/sdk/cosmos/azure-cosmos/README.md index ed1b31cb6d5b..271f0a378191 100644 --- a/sdk/cosmos/azure-cosmos/README.md +++ b/sdk/cosmos/azure-cosmos/README.md @@ -79,7 +79,7 @@ Once you've initialized a [CosmosClient][ref_cosmosclient], you can interact wit * [Container][ref_container]: A container is a collection of JSON documents. You create (insert), read, update, and delete items in a container by using methods on the [ContainerProxy][ref_container] object. -* [Item][ref_item]: An Item is the dictionary-like representation of a JSON document stored in a container. Each Item you add to a container must include an `id` key with a value that uniquely identifies the item within the container. +* Item: An Item is the dictionary-like representation of a JSON document stored in a container. Each Item you add to a container must include an `id` key with a value that uniquely identifies the item within the container. For more information about these resources, see [Working with Azure Cosmos databases, containers and items][cosmos_resources]. @@ -271,16 +271,15 @@ For more extensive documentation on the Cosmos DB service, see the [Azure Cosmos [cosmos_sql_queries]: https://docs.microsoft.com/azure/cosmos-db/how-to-sql-query [cosmos_ttl]: https://docs.microsoft.com/azure/cosmos-db/time-to-live [python]: https://www.python.org/downloads/ -[ref_container_delete_item]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.Container.delete_item -[ref_container_query_items]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.Container.query_items -[ref_container_upsert_item]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.Container.upsert_item -[ref_container]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.Container -[ref_cosmos_sdk]: http://cosmosproto.westus.azurecontainer.io -[ref_cosmosclient_create_database]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.CosmosClient.create_database -[ref_cosmosclient]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.CosmosClient -[ref_database]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.Database -[ref_httpfailure]: https://docs.microsoft.com/python/api/azure-cosmos/azure.cosmos.errors.CosmosHttpResponseError -[ref_item]: http://cosmosproto.westus.azurecontainer.io/#azure.cosmos.Item +[ref_container_delete_item]: https://azure.github.io/azure-sdk-for-python/ref/azure.cosmos.container.html#azure.cosmos.container.ContainerProxy.delete_item +[ref_container_query_items]: https://azure.github.io/azure-sdk-for-python/ref/azure.cosmos.container.html#azure.cosmos.container.ContainerProxy.query_items +[ref_container_upsert_item]: https://azure.github.io/azure-sdk-for-python/ref/azure.cosmos.container.html#azure.cosmos.container.ContainerProxy.upsert_item +[ref_container]: https://azure.github.io/azure-sdk-for-python/ref/azure.cosmos.container.html +[ref_cosmos_sdk]: https://azure.github.io/azure-sdk-for-python/ref/azure.cosmos.html +[ref_cosmosclient_create_database]: https://azure.github.io/azure-sdk-for-python/ref/azure.cosmos.cosmos_client.html#azure.cosmos.cosmos_client.CosmosClient.create_database +[ref_cosmosclient]: https://azure.github.io/azure-sdk-for-python/ref/azure.cosmos.cosmos_client.html +[ref_database]: https://azure.github.io/azure-sdk-for-python/ref/azure.cosmos.database.html +[ref_httpfailure]: https://azure.github.io/azure-sdk-for-python/ref/azure.cosmos.errors.html#azure.cosmos.errors.CosmosHttpResponseError [sample_database_mgmt]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cosmos/azure-cosmos/samples/DatabaseManagement [sample_document_mgmt]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cosmos/azure-cosmos/samples/DocumentManagement [sample_examples_misc]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/cosmos/azure-cosmos/samples/examples.py From df9a537b0c226aa3ef16b3b1116393925fd063d2 Mon Sep 17 00:00:00 2001 From: antisch Date: Tue, 10 Sep 2019 09:43:07 -0700 Subject: [PATCH 6/8] Fixed f-strings --- sdk/cosmos/azure-cosmos/samples/examples.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/samples/examples.py b/sdk/cosmos/azure-cosmos/samples/examples.py index c92a01633e25..95b96f6bb0eb 100644 --- a/sdk/cosmos/azure-cosmos/samples/examples.py +++ b/sdk/cosmos/azure-cosmos/samples/examples.py @@ -62,7 +62,7 @@ # [START list_containers] database = client.get_database_client(database_name) for container in database.list_containers(): - print(f"Container ID: {container.id}") + print("Container ID: {}".format(container.id)) # [END list_containers] # Insert new items by defining a dict and calling Container.upsert_item @@ -131,7 +131,7 @@ # Display the new TTL setting for the container container_props = database.get_container_client(container_name).read() -print(f"New container TTL: {json.dumps(container_props['defaultTtl'])}") +print("New container TTL: {}".format(json.dumps(container_props['defaultTtl']))) # [END reset_container_properties] # Create a user in the database. @@ -141,5 +141,5 @@ except errors.CosmosResourceExistsError: print("A user with that ID already exists.") except errors.CosmosHttpResponseError as failure: - print(f"Failed to create user. Status code:{failure.status_code}") + print("Failed to create user. Status code:{}".format(failure.status_code)) # [END create_user] From e13c3c9361b58d4084acce5777bc1caeddc5caec Mon Sep 17 00:00:00 2001 From: antisch Date: Tue, 10 Sep 2019 10:03:20 -0700 Subject: [PATCH 7/8] Another f-string --- sdk/cosmos/azure-cosmos/samples/examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cosmos/azure-cosmos/samples/examples.py b/sdk/cosmos/azure-cosmos/samples/examples.py index 95b96f6bb0eb..ef20ef5f31bc 100644 --- a/sdk/cosmos/azure-cosmos/samples/examples.py +++ b/sdk/cosmos/azure-cosmos/samples/examples.py @@ -70,7 +70,7 @@ container = database.get_container_client(container_name) for i in range(1, 10): container.upsert_item( - dict(id=f"item{i}", productName="Widget", productModel=f"Model {i}") + dict(id="item{}".format(i), productName="Widget", productModel="Model {}".format(i)) ) # [END upsert_items] From af5ad8b49461e2ece39bd9c9595c06ed7c0ef877 Mon Sep 17 00:00:00 2001 From: antisch Date: Tue, 10 Sep 2019 10:20:33 -0700 Subject: [PATCH 8/8] Snippet references --- sdk/cosmos/azure-cosmos/azure/cosmos/container.py | 6 +++--- .../azure-cosmos/azure/cosmos/cosmos_client.py | 4 ++-- sdk/cosmos/azure-cosmos/azure/cosmos/database.py | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py index bb94879c7923..f2418eb15d76 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py @@ -176,7 +176,7 @@ def read_item( :raise `CosmosHttpResponseError`: If the given item couldn't be retrieved. :rtype: dict[str, Any] - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START update_item] :end-before: [END update_item] :language: python @@ -320,7 +320,7 @@ def query_items( :returns: An Iterable of items (dicts). :rtype: Iterable[dict[str, Any]] - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START query_items] :end-before: [END query_items] :language: python @@ -328,7 +328,7 @@ def query_items( :caption: Get all products that have not been discontinued: :name: query_items - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START query_items_param] :end-before: [END query_items_param] :language: python diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py b/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py index 9387163ce416..16f546c6cfdb 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py @@ -138,7 +138,7 @@ class CosmosClient(object): and so on. *connection_policy* - An instance of ~azure.cosmos.documents.ConnectionPolicy - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START create_client] :end-before: [END create_client] :language: python @@ -222,7 +222,7 @@ def create_database( # pylint: disable=redefined-builtin :rtype: ~azure.cosmos.database.DatabaseProxy :raises `CosmosResourceExistsError`: If database with the given ID already exists. - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START create_database] :end-before: [END create_database] :language: python diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/database.py b/sdk/cosmos/azure-cosmos/azure/cosmos/database.py index a1ee733918b5..b73f995bcba2 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/database.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/database.py @@ -177,7 +177,7 @@ def create_container( :raise CosmosHttpResponseError: The container creation failed. :rtype: ~azure.cosmos.container.ContainerProxy - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START create_container] :end-before: [END create_container] :language: python @@ -185,7 +185,7 @@ def create_container( :caption: Create a container with default settings: :name: create_container - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START create_container_with_settings] :end-before: [END create_container_with_settings] :language: python @@ -264,7 +264,7 @@ def get_container_client(self, container): or a dict representing the properties of the container to be retrieved. :rtype: ~azure.cosmos.container.ContainerProxy - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START get_container] :end-before: [END get_container] :language: python @@ -297,7 +297,7 @@ def list_containers(self, max_item_count=None, populate_query_metrics=None, **kw :returns: An Iterable of container properties (dicts). :rtype: Iterable[dict[str, Any]] - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START list_containers] :end-before: [END list_containers] :language: python @@ -395,7 +395,7 @@ def replace_container( :returns: A `ContainerProxy` instance representing the container after replace completed. :rtype: ~azure.cosmos.container.ContainerProxy - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START reset_container_properties] :end-before: [END reset_container_properties] :language: python @@ -522,7 +522,7 @@ def create_user(self, body, **kwargs): :raise `CosmosHttpResponseError`: If the given user couldn't be created. :rtype: ~azure.cosmos.user.UserProxy - .. literalinclude:: ../../examples/examples.py + .. literalinclude:: ../../samples/examples.py :start-after: [START create_user] :end-before: [END create_user] :language: python