@@ -2,28 +2,60 @@ use crate::headers::from_headers::*;
2
2
use crate :: prelude:: * ;
3
3
use crate :: ResourceQuota ;
4
4
use azure_core:: headers:: session_token_from_headers;
5
- use azure_core:: Request as HttpRequest ;
5
+ use azure_core:: Context ;
6
6
use azure_core:: Response as HttpResponse ;
7
7
8
8
#[ derive( Debug , Clone ) ]
9
- pub struct DeleteDatabaseOptions {
9
+ pub struct DeleteDatabaseBuilder {
10
+ client : DatabaseClient ,
10
11
consistency_level : Option < ConsistencyLevel > ,
12
+ context : Context ,
11
13
}
12
14
13
- impl DeleteDatabaseOptions {
14
- pub fn new ( ) -> Self {
15
+ impl DeleteDatabaseBuilder {
16
+ pub ( crate ) fn new ( client : DatabaseClient ) -> Self {
15
17
Self {
18
+ client,
16
19
consistency_level : None ,
20
+ context : Context :: new ( ) ,
17
21
}
18
22
}
19
23
20
24
setters ! {
21
25
consistency_level: ConsistencyLevel => Some ( consistency_level) ,
26
+ context: Context => context,
22
27
}
23
28
24
- pub fn decorate_request ( & self , request : & mut HttpRequest ) -> crate :: Result < ( ) > {
25
- azure_core:: headers:: add_optional_header2 ( & self . consistency_level , request) ?;
26
- Ok ( ( ) )
29
+ pub fn into_future ( self ) -> DeleteDatabase {
30
+ Box :: pin ( async move {
31
+ let mut request = self . client . cosmos_client ( ) . prepare_request_pipeline (
32
+ & format ! ( "dbs/{}" , self . client. database_name( ) ) ,
33
+ http:: Method :: DELETE ,
34
+ ) ;
35
+
36
+ azure_core:: headers:: add_optional_header2 ( & self . consistency_level , & mut request) ?;
37
+ let response = self
38
+ . client
39
+ . pipeline ( )
40
+ . send (
41
+ self . context . clone ( ) . insert ( ResourceType :: Databases ) ,
42
+ & mut request,
43
+ )
44
+ . await ?;
45
+
46
+ Ok ( DeleteDatabaseResponse :: try_from ( response) . await ?)
47
+ } )
48
+ }
49
+ }
50
+
51
+ type DeleteDatabase = futures:: future:: BoxFuture < ' static , crate :: Result < DeleteDatabaseResponse > > ;
52
+
53
+ #[ cfg( feature = "into_future" ) ]
54
+ impl std:: future:: IntoFuture for DeleteDatabaseBuilder {
55
+ type Future = DeleteDatabase ;
56
+ type Output = <DeleteDatabase as std:: future:: Future >:: Output ;
57
+ fn into_future ( self ) -> Self :: Future {
58
+ Self :: into_future ( self )
27
59
}
28
60
}
29
61
0 commit comments