1+ use crate :: headers:: from_headers:: * ;
12use crate :: prelude:: * ;
23
4+ use azure_core:: headers:: session_token_from_headers;
35use azure_core:: prelude:: * ;
4- use azure_core:: { Request as HttpRequest , Response as HttpResponse } ;
6+ use azure_core:: Response as HttpResponse ;
57use chrono:: { DateTime , Utc } ;
68
79#[ derive( Debug , Clone ) ]
8- pub struct DeleteDocumentOptions {
10+ pub struct DeleteDocumentBuilder {
11+ client : DocumentClient ,
912 if_match_condition : Option < IfMatchCondition > ,
1013 if_modified_since : Option < IfModifiedSince > ,
1114 consistency_level : Option < ConsistencyLevel > ,
1215 allow_tentative_writes : TentativeWritesAllowance ,
16+ context : Context ,
1317}
1418
15- impl DeleteDocumentOptions {
16- pub fn new ( ) -> DeleteDocumentOptions {
19+ impl DeleteDocumentBuilder {
20+ pub ( crate ) fn new ( client : DocumentClient ) -> DeleteDocumentBuilder {
1721 Self {
22+ client,
1823 if_match_condition : None ,
1924 if_modified_since : None ,
2025 consistency_level : None ,
2126 allow_tentative_writes : TentativeWritesAllowance :: Deny ,
27+ context : Context :: new ( ) ,
2228 }
2329 }
2430
@@ -27,29 +33,50 @@ impl DeleteDocumentOptions {
2733 if_match_condition: IfMatchCondition => Some ( if_match_condition) ,
2834 allow_tentative_writes: TentativeWritesAllowance ,
2935 if_modified_since: DateTime <Utc > => Some ( IfModifiedSince :: new( if_modified_since) ) ,
36+ context: Context => context,
3037 }
3138
32- pub fn decorate_request (
33- & self ,
34- request : & mut HttpRequest ,
35- serialized_partition_key : & str ,
36- ) -> crate :: Result < ( ) > {
37- azure_core:: headers:: add_optional_header2 ( & self . if_match_condition , request) ?;
38- azure_core:: headers:: add_optional_header2 ( & self . if_modified_since , request) ?;
39- azure_core:: headers:: add_optional_header2 ( & self . consistency_level , request) ?;
40- azure_core:: headers:: add_mandatory_header2 ( & self . allow_tentative_writes , request) ?;
39+ pub fn into_future ( self ) -> DeleteDocument {
40+ Box :: pin ( async move {
41+ let mut request = self
42+ . client
43+ . prepare_request_pipeline_with_document_name ( http:: Method :: DELETE ) ;
44+
45+ azure_core:: headers:: add_optional_header2 ( & self . if_match_condition , & mut request) ?;
46+ azure_core:: headers:: add_optional_header2 ( & self . if_modified_since , & mut request) ?;
47+ azure_core:: headers:: add_optional_header2 ( & self . consistency_level , & mut request) ?;
48+ azure_core:: headers:: add_mandatory_header2 ( & self . allow_tentative_writes , & mut request) ?;
4149
42- crate :: cosmos_entity:: add_as_partition_key_header_serialized2 (
43- serialized_partition_key ,
44- request,
45- ) ;
50+ crate :: cosmos_entity:: add_as_partition_key_header_serialized2 (
51+ & self . client . partition_key_serialized ( ) ,
52+ & mut request,
53+ ) ;
4654
47- Ok ( ( ) )
55+ let response = self
56+ . client
57+ . cosmos_client ( )
58+ . pipeline ( )
59+ . send (
60+ self . context . clone ( ) . insert ( ResourceType :: Documents ) ,
61+ & mut request,
62+ )
63+ . await ?;
64+
65+ DeleteDocumentResponse :: try_from ( response) . await
66+ } )
4867 }
4968}
5069
51- use crate :: headers:: from_headers:: * ;
52- use azure_core:: headers:: session_token_from_headers;
70+ type DeleteDocument = futures:: future:: BoxFuture < ' static , crate :: Result < DeleteDocumentResponse > > ;
71+
72+ #[ cfg( feature = "into_future" ) ]
73+ impl std:: future:: IntoFuture for DeleteDocumentBuilder {
74+ type Future = DeleteDocument ;
75+ type Output = <DeleteDocument as std:: future:: Future >:: Output ;
76+ fn into_future ( self ) -> Self :: Future {
77+ Self :: into_future ( self )
78+ }
79+ }
5380
5481#[ derive( Debug , Clone ) ]
5582pub struct DeleteDocumentResponse {
0 commit comments