Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion samples/cosmos_read_item_native_tls/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.await?;

let db_client = client.database_client(&args.database);
let container_client = db_client.container_client(&args.container).await?;
let container_client = db_client.container_client(&args.container, None).await?;

let response = container_client
.read_item(&args.partition_key, &args.item_id, None)
Expand Down
1 change: 1 addition & 0 deletions sdk/cosmos/azure_data_cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

### Breaking Changes

- `DatabaseClient::container_client` now requires a second argument of type `Option<ContainerClientOptions>`; pass `None` to retain the previous behavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you link the pr

- Control-plane APIs are now gated behind the new `control_plane` feature, which is **not** enabled by default. Code using database or container management (`CosmosClient::create_database`/`query_databases`, `DatabaseClient::read`/`create_container`/`query_containers`/`delete`, `ContainerClient::replace`/`delete`), throughput management (`read_throughput`/`begin_replace_throughput`, `ThroughputPoller`), or the associated model and options types (`DatabaseProperties`, `ThroughputProperties`, and the container create/replace/delete/query, database, and throughput option types) must now enable the `control_plane` feature. Reading container properties via `ContainerClient::read()` — along with `ContainerProperties`, `IndexingPolicy`, `ResourceResponse`, and `ReadContainerOptions` — remains available without the feature, since it works with Entra ID authentication and mirrors the metadata read the SDK already performs internally. ([#4854](https://github.com/Azure/azure-sdk-for-rust/pull/4854))
- Fresh cross-partition queries and change feed reads now fail with a `BadRequest` error if they would fan out to more than 100 physical partitions. Raise `FeedOptions::max_fan_out` to run a broader operation. The limit is checked only at initial query setup — resuming from a continuation token is unaffected, and a partition split that raises the fan-out mid-execution does not abort the operation. ([#4855](https://github.com/Azure/azure-sdk-for-rust/pull/4855))

Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/examples/cosmos/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct BatchCommand {
impl BatchCommand {
pub async fn run(&self, client: &CosmosClient) -> Result<(), Box<dyn Error>> {
let db_client = client.database_client(&self.database);
let container_client = db_client.container_client(&self.container).await?;
let container_client = db_client.container_client(&self.container, None).await?;

// Parse the operations JSON
let operations: Vec<Value> = serde_json::from_str(&self.operations)?;
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/examples/cosmos/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl CreateCommand {
show_updated,
} => {
let db_client = client.database_client(&database);
let container_client = db_client.container_client(&container).await?;
let container_client = db_client.container_client(&container, None).await?;

let pk = PartitionKey::from(&partition_key);
let item: serde_json::Value = serde_json::from_str(&json)?;
Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmos/azure_data_cosmos/examples/cosmos/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl DeleteCommand {
partition_key,
} => {
let db_client = client.database_client(&database);
let container_client = db_client.container_client(&container).await?;
let container_client = db_client.container_client(&container, None).await?;

let response = container_client
.delete_item(partition_key, &item_id, None)
Expand All @@ -81,7 +81,7 @@ impl DeleteCommand {

Subcommands::Container { database, id } => {
let db_client = client.database_client(&database);
let container_client = db_client.container_client(&id).await?;
let container_client = db_client.container_client(&id, None).await?;
container_client.delete(None).await?;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/examples/cosmos/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl MetadataCommand {
pub async fn run(self, client: CosmosClient) -> Result<(), Box<dyn Error>> {
let db_client = client.database_client(&self.database);
if let Some(container_name) = &self.container {
let container_client = db_client.container_client(container_name).await?;
let container_client = db_client.container_client(container_name, None).await?;
let response = container_client.read(None).await?.into_model()?;
println!("{:#?}", response);
return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/examples/cosmos/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl QueryCommand {
partition_key,
} => {
let db_client = client.database_client(&database);
let container_client = db_client.container_client(&container).await?;
let container_client = db_client.container_client(&container, None).await?;

let scope = match partition_key {
Some(pk) => FeedScope::partition(pk),
Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmos/azure_data_cosmos/examples/cosmos/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl ReadCommand {
partition_key,
} => {
let db_client = client.database_client(&database);
let container_client = db_client.container_client(&container).await?;
let container_client = db_client.container_client(&container, None).await?;

let response = container_client
.read_item(&partition_key, &item_id, None)
Expand Down Expand Up @@ -93,7 +93,7 @@ impl ReadCommand {
container,
} => {
let db_client = client.database_client(&database);
let container_client = db_client.container_client(&container).await?;
let container_client = db_client.container_client(&container, None).await?;
let response = container_client.read(None).await?.into_model()?;
println!("Container:");
println!(" {:#?}", response);
Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmos/azure_data_cosmos/examples/cosmos/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl ReplaceCommand {
show_updated,
} => {
let db_client = client.database_client(&database);
let container_client = db_client.container_client(&container).await?;
let container_client = db_client.container_client(&container, None).await?;

let pk = PartitionKey::from(&partition_key);
let item: serde_json::Value = serde_json::from_str(&json)?;
Expand Down Expand Up @@ -127,7 +127,7 @@ impl ReplaceCommand {
} => {
let throughput_properties = throughput_options.try_into()?;
let db_client = client.database_client(&database);
let container_client = db_client.container_client(&container).await?;
let container_client = db_client.container_client(&container, None).await?;
let new_throughput = container_client
.begin_replace_throughput(throughput_properties, None)
.await?
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/examples/cosmos/upsert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct UpsertCommand {
impl UpsertCommand {
pub async fn run(self, client: CosmosClient) -> Result<(), Box<dyn Error>> {
let db_client = client.database_client(&self.database);
let container_client = db_client.container_client(&self.container).await?;
let container_client = db_client.container_client(&self.container, None).await?;

let pk = PartitionKey::from(&self.partition_key);
let item: serde_json::Value = serde_json::from_str(&self.json)?;
Expand Down
11 changes: 9 additions & 2 deletions sdk/cosmos/azure_data_cosmos/src/clients/database_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

use crate::clients::{ClientContext, ContainerClient};
use crate::options::ContainerClientOptions;
#[cfg(feature = "control_plane")]
use azure_data_cosmos_driver::models::DatabaseReference;

Expand Down Expand Up @@ -67,11 +68,17 @@ impl DatabaseClient {
///
/// # Arguments
/// * `name` - The name of the container.
/// * `options` - Optional parameters for creating the client.
///
/// # Errors
///
/// Returns an error if the container does not exist or the metadata cannot be resolved.
pub async fn container_client(&self, name: &str) -> crate::Result<ContainerClient> {
pub async fn container_client(
&self,
name: &str,
options: Option<ContainerClientOptions>,
) -> crate::Result<ContainerClient> {
Comment thread
analogrelay marked this conversation as resolved.
let _ = options;
Comment thread
analogrelay marked this conversation as resolved.
Outdated
ContainerClient::new(self.context.clone(), name, &self.database_id).await
}

Expand Down Expand Up @@ -355,7 +362,7 @@ mod tests {
fn _assert_futures_are_send() {
fn assert_send<T: Send>(_: T) {}
let client: &DatabaseClient = todo!();
assert_send(client.container_client(todo!()));
assert_send(client.container_client(todo!(), None));
assert_send(client.read(todo!()));
assert_send(client.query_containers(Query::from("SELECT * FROM c"), todo!()));
assert_send(client.create_container(todo!(), todo!()));
Expand Down
5 changes: 5 additions & 0 deletions sdk/cosmos/azure_data_cosmos/src/options/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ use azure_data_cosmos_driver::options::OperationOptions;
#[cfg(feature = "control_plane")]
use crate::models::ThroughputProperties;

/// Options to be passed to [`DatabaseClient::container_client()`](crate::clients::DatabaseClient::container_client()).
#[derive(Clone, Default)]
#[non_exhaustive]
pub struct ContainerClientOptions {}

/// Options to be passed to [`DatabaseClient::create_container()`](crate::clients::DatabaseClient::create_container()).
#[cfg(feature = "control_plane")]
#[derive(Clone, Default)]
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use batch::{
pub use change_feed::{ChangeFeedMode, ChangeFeedOptions, ChangeFeedStartFrom};
pub use client::CosmosClientOptions;
pub use consistency::ConsistencyLevel;
pub use container::ReadContainerOptions;
pub use container::{ContainerClientOptions, ReadContainerOptions};
#[cfg(feature = "control_plane")]
pub use container::{
CreateContainerOptions, DeleteContainerOptions, QueryContainersOptions, ReplaceContainerOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub async fn aad_item_crud_roundtrip() -> Result<(), Box<dyn Error>> {
let (aad_client, recorder) = run_context.aad_client().await?;
let aad_container = aad_client
.database_client(db_client.id())
.container_client(&container_id)
.container_client(&container_id, None)
.await?;

let unique = Uuid::new_v4().to_string();
Expand Down Expand Up @@ -183,7 +183,7 @@ pub async fn aad_read_container_metadata() -> Result<(), Box<dyn Error>> {
let (aad_client, recorder) = run_context.aad_client().await?;
let aad_container = aad_client
.database_client(db_client.id())
.container_client(&container_id)
.container_client(&container_id, None)
.await?;

let properties = aad_container.read(None).await?.into_model()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async fn create_container(
None,
)
.await?;
let container_client = db_client.container_client(&container_id).await?;
let container_client = db_client.container_client(&container_id, None).await?;

Ok(container_client)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub async fn container_crud_simple() -> Result<(), Box<dyn Error>> {
}
assert_eq!(vec![properties.id.clone()], ids);

let container_client = db_client.container_client(&properties.id).await?;
let container_client = db_client.container_client(&properties.id, None).await?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just a duplicate line from the one below?

let mut updated_indexing_policy = IndexingPolicy::default();
updated_indexing_policy.automatic = false;
updated_indexing_policy.indexing_mode = Some(IndexingMode::None);
Expand Down
Loading
Loading