pub struct CosmosDBClient { /* private fields */ }Expand description
Low-level CosmosDB REST API client. Wraps reqwest and handles auth headers, serialization, and error mapping.
Implementations§
Source§impl CosmosDBClient
impl CosmosDBClient
pub fn new( endpoint: &str, key: &str, database: &str, container: &str, ) -> Result<Self, String>
pub fn endpoint(&self) -> &str
pub fn database(&self) -> &str
pub fn container(&self) -> &str
Sourcepub async fn ensure_database(&self) -> Result<(), ProviderError>
pub async fn ensure_database(&self) -> Result<(), ProviderError>
Create database if it doesn’t exist.
Sourcepub async fn ensure_container(
&self,
indexing_policy: Option<Value>,
) -> Result<(), ProviderError>
pub async fn ensure_container( &self, indexing_policy: Option<Value>, ) -> Result<(), ProviderError>
Create container if it doesn’t exist.
Sourcepub async fn delete_container(&self) -> Result<(), ProviderError>
pub async fn delete_container(&self) -> Result<(), ProviderError>
Delete container.
Sourcepub async fn create_document(
&self,
partition_key: &str,
document: &Value,
) -> Result<CosmosDBResponse, ProviderError>
pub async fn create_document( &self, partition_key: &str, document: &Value, ) -> Result<CosmosDBResponse, ProviderError>
Create a document. Returns the response with the created document.
Sourcepub async fn upsert_document(
&self,
partition_key: &str,
document: &Value,
) -> Result<CosmosDBResponse, ProviderError>
pub async fn upsert_document( &self, partition_key: &str, document: &Value, ) -> Result<CosmosDBResponse, ProviderError>
Upsert a document (create or replace).
Sourcepub async fn read_document(
&self,
doc_id: &str,
partition_key: &str,
) -> Result<CosmosDBResponse, ProviderError>
pub async fn read_document( &self, doc_id: &str, partition_key: &str, ) -> Result<CosmosDBResponse, ProviderError>
Read a document by ID.
Sourcepub async fn replace_document(
&self,
doc_id: &str,
partition_key: &str,
document: &Value,
if_match: Option<&str>,
) -> Result<CosmosDBResponse, ProviderError>
pub async fn replace_document( &self, doc_id: &str, partition_key: &str, document: &Value, if_match: Option<&str>, ) -> Result<CosmosDBResponse, ProviderError>
Replace a document by ID with optional ETag condition.
Sourcepub async fn delete_document(
&self,
doc_id: &str,
partition_key: &str,
) -> Result<CosmosDBResponse, ProviderError>
pub async fn delete_document( &self, doc_id: &str, partition_key: &str, ) -> Result<CosmosDBResponse, ProviderError>
Delete a document by ID.
Sourcepub async fn query(
&self,
sql: &str,
parameters: Vec<QueryParameter>,
partition_key: Option<&str>,
) -> Result<Vec<Value>, ProviderError>
pub async fn query( &self, sql: &str, parameters: Vec<QueryParameter>, partition_key: Option<&str>, ) -> Result<Vec<Value>, ProviderError>
Execute a SQL query. If partition_key is None, this is a cross-partition query.
Sourcepub async fn transactional_batch(
&self,
partition_key: &str,
operations: Vec<BatchOperation>,
) -> Result<Vec<BatchOperationResult>, ProviderError>
pub async fn transactional_batch( &self, partition_key: &str, operations: Vec<BatchOperation>, ) -> Result<Vec<BatchOperationResult>, ProviderError>
Execute a transactional batch of operations within a single partition.
Trait Implementations§
Source§impl Clone for CosmosDBClient
impl Clone for CosmosDBClient
Source§fn clone(&self) -> CosmosDBClient
fn clone(&self) -> CosmosDBClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CosmosDBClient
impl !RefUnwindSafe for CosmosDBClient
impl Send for CosmosDBClient
impl Sync for CosmosDBClient
impl Unpin for CosmosDBClient
impl UnsafeUnpin for CosmosDBClient
impl !UnwindSafe for CosmosDBClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more