1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//! Account reference types for Azure Cosmos DB.
use crate::;
use Secret;
use TokenCredential;
use Arc;
/// A reference to a Cosmos DB account, combining an endpoint with a credential.
///
/// This type bundles together the account endpoint and the credential needed to
/// authenticate with it. Use convenience constructors [`with_credential()`](Self::with_credential)
/// or [`with_authentication_key()`](Self::with_authentication_key) (requires the `key_auth` feature) to create instances.
///
/// # Examples
///
/// Using Entra ID authentication:
///
/// ```rust,no_run
/// use azure_data_cosmos::{AccountReference, AccountEndpoint};
/// use std::sync::Arc;
///
/// let credential: Arc<dyn azure_core::credentials::TokenCredential> =
/// azure_identity::DeveloperToolsCredential::new(None).unwrap();
/// let endpoint: AccountEndpoint = "https://myaccount.documents.azure.com/".parse().unwrap();
/// let account = AccountReference::with_credential(endpoint, credential);
/// ```
///
/// Using key authentication (requires `key_auth` feature):
///
/// ```rust,ignore
/// use azure_data_cosmos::{AccountReference, AccountEndpoint};
/// use azure_core::credentials::Secret;
///
/// let endpoint: AccountEndpoint = "https://myaccount.documents.azure.com/".parse().unwrap();
/// let account = AccountReference::with_authentication_key(endpoint, Secret::from("my_account_key"));
/// ```