Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b4031ec
Updated dependencies
annatisch Aug 27, 2019
9f30dd6
Added core pipeline
annatisch Aug 27, 2019
d2ec4b3
Ignore test config
annatisch Aug 27, 2019
81d0a62
Merge remote-tracking branch 'upstream/master' into cosmos-pipeline
annatisch Aug 27, 2019
d7394d7
Fixed indexes test
annatisch Aug 27, 2019
d628d91
Refactored request creation
annatisch Aug 28, 2019
8c091d8
Fixed index test
annatisch Aug 28, 2019
abc9030
Added trace decorators
annatisch Aug 28, 2019
f02ca0f
Bumped version
annatisch Aug 28, 2019
c9ae867
Updated policies
annatisch Aug 28, 2019
095f6f8
Renamed request_options -> request_params
annatisch Aug 28, 2019
6b88446
Merge remote-tracking branch 'upstream/master' into cosmos-pipeline
annatisch Aug 28, 2019
872cb26
Renamed clients
annatisch Aug 29, 2019
85ee07d
Updated with azure-core errors
annatisch Aug 30, 2019
0aacc0b
Fixed test warnings
annatisch Aug 30, 2019
943595c
Updated config
annatisch Aug 30, 2019
7e54f58
Merge remote-tracking branch 'upstream/feature/cosmos-preview2' into …
annatisch Aug 30, 2019
ff3628a
PR fixes
annatisch Aug 30, 2019
1986464
Fixed init user import
annatisch Aug 30, 2019
6366f02
Fixed init clients
annatisch Aug 30, 2019
01bb2b4
Started revising constructors
annatisch Sep 3, 2019
50f9b12
Test conn str constructor
annatisch Sep 3, 2019
8441a6c
Update iterables with core paging
annatisch Sep 3, 2019
ce6c622
Added context managers
annatisch Sep 3, 2019
398d9dd
Reverted storage changes
annatisch Sep 3, 2019
dab0703
Updated constructor
annatisch Sep 4, 2019
be457d6
Mypy and Pylint
annatisch Sep 4, 2019
44f88af
Renamed all listing operations
annatisch Sep 4, 2019
c1053ee
Some mypy fixes
annatisch Sep 4, 2019
44fb172
Cleaned up method signatures
annatisch Sep 4, 2019
5d1ad18
Fix pylint
annatisch Sep 4, 2019
70b5ee6
Propagate kwargs
annatisch Sep 5, 2019
ba45e57
Fix pylint
annatisch Sep 5, 2019
338209c
Some mypy fixes
annatisch Sep 5, 2019
e6a427b
Updated readme and release notes
annatisch Sep 5, 2019
404dae0
Fix for passing in extra headers
annatisch Sep 5, 2019
11509db
Reverted credentials
annatisch Sep 5, 2019
3f7a7d0
Review feedback
annatisch Sep 5, 2019
191eb6f
Fix pylint
annatisch Sep 5, 2019
90b0064
Fixed samples
annatisch Sep 6, 2019
cfa1b8c
Updated docstrings
annatisch Sep 6, 2019
9f3ea2f
Fixed whitespace and imports
annatisch Sep 6, 2019
4fad699
Some mypy fixes
annatisch Sep 6, 2019
34246ba
Mypy fixes
annatisch Sep 6, 2019
56c341e
Removed continuation token support
annatisch Sep 6, 2019
d36e04b
Pylint fix
annatisch Sep 6, 2019
f74ec89
Docs tweaks
annatisch Sep 9, 2019
0ba76ab
Updated continuation token
annatisch Sep 9, 2019
da5f0f9
Updated response header
annatisch Sep 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions sdk/cosmos/azure-cosmos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export ACCOUNT_KEY=$(az cosmosdb list-keys --resource-group $RES_GROUP --name $A
Once you've populated the `ACCOUNT_URI` and `ACCOUNT_KEY` environment variables, you can create the [CosmosClient][ref_cosmosclient].

```Python
from azure.cosmos import HTTPFailure, CosmosClient, Container, Database, PartitionKey
from azure.cosmos import CosmosClient, Container, Database, PartitionKey, errors

import os
url = os.environ['ACCOUNT_URI']
Expand Down Expand Up @@ -106,9 +106,7 @@ After authenticating your [CosmosClient][ref_cosmosclient], you can work with an
database_name = 'testDatabase'
try:
database = client.create_database(database_name)
except HTTPFailure as e:
if e.status_code != 409:
raise
except errors.CosmosResourceExistsError:
database = client.get_database_client(database_name)
```

Expand All @@ -120,13 +118,13 @@ This example creates a container with default settings. If a container with the
container_name = 'products'
try:
container = database.create_container(id=container_name, partition_key=PartitionKey(path="/productName"))
except HTTPFailure as e:
if e.status_code != 409:
raise
except errors.CosmosResourceExistsError:
container = database.get_container_client(container_name)
except errors.CosmosHttpResponseError:
raise
```

The preceding snippet also handles the [HTTPFailure][ref_httpfailure] exception if the container creation failed. For more information on error handling and troubleshooting, see the [Troubleshooting](#troubleshooting) section.
The preceding snippet also handles the [CosmosHttpResponseError][ref_httpfailure] exception if the container creation failed. For more information on error handling and troubleshooting, see the [Troubleshooting](#troubleshooting) section.

### Get an existing container

Expand Down Expand Up @@ -243,13 +241,11 @@ For example, if you try to create a container using an ID (name) that's already
```Python
try:
database.create_container(id=container_name, partition_key=PartitionKey(path="/productName")
except HTTPFailure as e:
if e.status_code == 409:
print("""Error creating container.
except errors.CosmosResourceExistsError:
print("Error creating container.")
HTTP status code 409: The ID (name) provided for the container is already in use.
The container name must be unique within the database.""")
else:
raise

```

## More sample code
Expand Down Expand Up @@ -285,7 +281,7 @@ For more extensive documentation on the Cosmos DB service, see the [Azure Cosmos
[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.httpfailure
[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
Expand Down
16 changes: 8 additions & 8 deletions sdk/cosmos/azure-cosmos/azure/cosmos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from .container import Container
from .container_client import ContainerClient
from .cosmos_client import CosmosClient
from .database import Database
from .database_client import DatabaseClient
from .user_client import UserClient
from .scripts_client import ScriptsClient
from .documents import (
ConsistencyLevel,
DataType,
Expand All @@ -35,18 +37,16 @@
)
from .partition_key import PartitionKey
from .permission import Permission
from .scripts import Scripts
from .user import User
from .version import VERSION

__all__ = (
"Container",
"ContainerClient",
"CosmosClient",
"Database",
"DatabaseClient",
"PartitionKey",
"Permission",
"Scripts",
"User",
"ScriptsClient",
"UserClient",
"ConsistencyLevel",
"DataType",
"IndexKind",
Expand Down
Loading