This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for CosmosDB
Get Partition Key Ranges
REST API (#269)
- Loading branch information
Francesco Cogno
authored
May 14, 2020
1 parent
3eb8a80
commit 20b1673
Showing
14 changed files
with
453 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "azure_sdk_cosmos" | ||
version = "0.42.3" | ||
version = "0.42.4" | ||
description = "Rust wrappers around Microsoft Azure REST APIs - Azure Cosmos DB crate" | ||
readme = "README.md" | ||
authors = ["Francesco Cogno <[email protected]>", "Max Gortman <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use azure_sdk_cosmos::prelude::*; | ||
use std::error::Error; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
let database = std::env::args() | ||
.nth(1) | ||
.expect("please specify database name as first command line parameter"); | ||
let collection = std::env::args() | ||
.nth(2) | ||
.expect("please specify collection name as second command line parameter"); | ||
|
||
let master_key = | ||
std::env::var("COSMOS_MASTER_KEY").expect("Set env variable COSMOS_MASTER_KEY first!"); | ||
let account = std::env::var("COSMOS_ACCOUNT").expect("Set env variable COSMOS_ACCOUNT first!"); | ||
|
||
let authorization_token = AuthorizationToken::new_master(&master_key)?; | ||
let client = ClientBuilder::new(account, authorization_token.clone())?; | ||
let client = client.with_database(&database); | ||
let client = client.with_collection(&collection); | ||
|
||
let resp = client.get_partition_key_ranges().execute().await?; | ||
println!("resp == {:#?}", resp); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#[derive(Debug, PartialEq, PartialOrd, Clone, Deserialize)] | ||
pub struct PartitionKeyRange { | ||
#[serde(rename = "_rid")] | ||
pub rid: String, | ||
pub id: String, | ||
#[serde(rename = "_etag")] | ||
pub etag: String, | ||
#[serde(rename = "minInclusive")] | ||
pub min_exclusive: String, | ||
#[serde(rename = "maxExclusive")] | ||
pub max_exclusive: String, | ||
#[serde(rename = "ridPrefix")] | ||
pub rid_prefix: u64, | ||
pub _self: String, | ||
#[serde(rename = "throughputFraction")] | ||
pub throughput_fraction: u64, | ||
pub status: String, | ||
// TODO: parents | ||
#[serde(rename = "_ts")] | ||
pub ts: u64, | ||
} |
64 changes: 64 additions & 0 deletions
64
azure_sdk_cosmos/src/requests/get_partition_key_ranges_builder.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"name": "GetPartitionKeyRangesBuilder", | ||
"derive": "Debug, Clone", | ||
"uses": [ | ||
"crate::clients::{CollectionClient, CosmosUriBuilder, ResourceType}", | ||
"crate::prelude::*", | ||
"crate::responses::*", | ||
"crate::CollectionClientRequired", | ||
"azure_sdk_core::errors::{check_status_extract_headers_and_body, AzureError}", | ||
"azure_sdk_core::modify_conditions::IfMatchCondition", | ||
"azure_sdk_core::prelude::*", | ||
"azure_sdk_core::{IfMatchConditionOption, IfMatchConditionSupport}", | ||
"chrono::{DateTime, Utc}", | ||
"hyper::StatusCode", | ||
"std::convert::TryInto" | ||
], | ||
"inline": true, | ||
"extra_types": [ "'a", "'b", "CUB" ], | ||
"extra_wheres": ["CUB: CosmosUriBuilder" ], | ||
"constructor_fields": [ | ||
{ | ||
"name": "collection_client", | ||
"field_type": "&'a CollectionClient<'a, CUB>", | ||
"trait_get": "CollectionClientRequired<'a, CUB>" | ||
} | ||
], | ||
"fields": [ | ||
{ | ||
"name": "if_match_condition", | ||
"field_type": "IfMatchCondition<'b>", | ||
"optional": true, | ||
"trait_get": "IfMatchConditionOption<'b>", | ||
"trait_set": "IfMatchConditionSupport<'b>" | ||
}, | ||
{ | ||
"name": "if_modified_since", | ||
"field_type": "&'b DateTime<Utc>", | ||
"optional": true, | ||
"trait_get": "IfModifiedSinceOption<'b>", | ||
"trait_set": "IfModifiedSinceSupport<'b>" | ||
}, | ||
{ | ||
"name": "user_agent", | ||
"field_type": "&'b str", | ||
"optional": true, | ||
"trait_get": "UserAgentOption<'b>", | ||
"trait_set": "UserAgentSupport<'b>" | ||
}, | ||
{ | ||
"name": "activity_id", | ||
"field_type": "&'b str", | ||
"optional": true, | ||
"trait_get": "ActivityIdOption<'b>", | ||
"trait_set": "ActivityIdSupport<'b>" | ||
}, | ||
{ | ||
"name": "consistency_level", | ||
"field_type": "ConsistencyLevel<'b>", | ||
"optional": true, | ||
"trait_get": "ConsistencyLevelOption<'b>", | ||
"trait_set": "ConsistencyLevelSupport<'b>" | ||
} | ||
] | ||
} |
Oops, something went wrong.