You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This client library enables client applications to connect to [Azure Cosmos DB](https://azure.microsoft.com/en-us/products/cosmos-db) via the NoSQL API. Azure Cosmos DB is a globally distributed, multi-model database service.
/// Creates a new CosmosClient, using Entra ID authentication.
31
+
///
32
+
/// # Arguments
33
+
///
34
+
/// * `endpoint` - The full URL of the Cosmos DB account, for example `https://myaccount.documents.azure.com/`.
35
+
/// * `credential` - An implementation of [`TokenCredential`](azure_core::auth::TokenCredential) that can provide an Entra ID token to use when authenticating.
36
+
/// * `options` - Optional configuration for the client.
37
+
///
38
+
/// # Examples
39
+
///
40
+
/// ```rust,no_run
41
+
/// use azure_data_cosmos::CosmosClient;
42
+
///
43
+
/// let credential = azure_identity::create_default_credential().unwrap();
44
+
/// let client = CosmosClient::new("https://myaccount.documents.azure.com/", credential, None).unwrap();
45
+
/// ```
31
46
pubfnnew(
32
47
endpoint:implAsRef<str>,
33
48
credential:Arc<dynTokenCredential>,
@@ -44,9 +59,21 @@ impl CosmosClient {
44
59
})
45
60
}
46
61
47
-
/// Creates a new CosmosClient, using shared key authentication.
62
+
/// Creates a new CosmosClient, using key authentication.
63
+
///
64
+
/// # Arguments
65
+
///
66
+
/// * `endpoint` - The full URL of the Cosmos DB account, for example `https://myaccount.documents.azure.com/`.
67
+
/// * `key` - The key to use when authenticating.
68
+
/// * `options` - Optional configuration for the client.
69
+
///
70
+
/// # Examples
71
+
///
72
+
/// ```rust,no_run
73
+
/// let client = CosmosClient::with_shared_key("https://myaccount.documents.azure.com/", "my_key", None)?;
Copy file name to clipboardExpand all lines: sdk/cosmosdb/azure_data_cosmos/src/clients/database_client.rs
+35-1
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,44 @@ use crate::{CosmosClient, ReadDatabaseOptions};
4
4
use azure_core::{Context,Request};
5
5
use url::Url;
6
6
7
+
#[cfg(doc)]
8
+
usecrate::CosmosClientMethods;
9
+
10
+
/// Defines the methods provided by a [`DatabaseClient`]
11
+
///
12
+
/// This trait is intended to allow you to mock out the `DatabaseClient` when testing your application.
13
+
/// Rather than depending on `DatabaseClient`, you can depend on a generic parameter constrained by this trait, or an `impl DatabaseClientMethods` type.
7
14
pubtraitDatabaseClientMethods{
15
+
/// Reads the properties of the database.
16
+
///
17
+
/// # Arguments
18
+
///
19
+
/// * `options` - Optional parameters for the request.
20
+
///
21
+
/// # Examples
22
+
///
23
+
/// ```rust,no_run
24
+
/// # async fn doc() {
25
+
/// use azure_data_cosmos::{CosmosClient, CosmosClientMethods, DatabaseClientMethods};
26
+
///
27
+
/// let credential = azure_identity::create_default_credential().unwrap();
28
+
/// let client = CosmosClient::new("https://myaccount.documents.azure.com/", credential, None).unwrap();
29
+
/// let db_client = client.database("my_database");
0 commit comments