@@ -4,12 +4,13 @@ use reqwest::Client;
4
4
5
5
use crate :: error:: VssError ;
6
6
use crate :: types:: {
7
- GetObjectRequest , GetObjectResponse , ListKeyVersionsRequest , ListKeyVersionsResponse , PutObjectRequest ,
8
- PutObjectResponse ,
7
+ DeleteObjectRequest , DeleteObjectResponse , GetObjectRequest , GetObjectResponse , ListKeyVersionsRequest ,
8
+ ListKeyVersionsResponse , PutObjectRequest , PutObjectResponse ,
9
9
} ;
10
10
11
11
/// Thin-client to access a hosted instance of Versioned Storage Service (VSS).
12
12
/// The provided [`VssClient`] API is minimalistic and is congruent to the VSS server-side API.
13
+ #[ derive( Clone ) ]
13
14
pub struct VssClient {
14
15
base_url : String ,
15
16
client : Client ,
@@ -59,6 +60,24 @@ impl VssClient {
59
60
}
60
61
}
61
62
63
+ /// Deletes the given `key` and `value` in `request`.
64
+ /// Makes a service call to the `DeleteObject` endpoint of the VSS server.
65
+ /// For API contract/usage, refer to docs for [`DeleteObjectRequest`] and [`DeleteObjectResponse`].
66
+ pub async fn delete_object ( & self , request : & DeleteObjectRequest ) -> Result < DeleteObjectResponse , VssError > {
67
+ let url = format ! ( "{}/deleteObject" , self . base_url) ;
68
+
69
+ let response_raw = self . client . post ( url) . body ( request. encode_to_vec ( ) ) . send ( ) . await ?;
70
+ let status = response_raw. status ( ) ;
71
+ let payload = response_raw. bytes ( ) . await ?;
72
+
73
+ if status. is_success ( ) {
74
+ let response = DeleteObjectResponse :: decode ( & payload[ ..] ) ?;
75
+ Ok ( response)
76
+ } else {
77
+ Err ( VssError :: new ( status, payload) )
78
+ }
79
+ }
80
+
62
81
/// Lists keys and their corresponding version for a given [`ListKeyVersionsRequest::store_id`].
63
82
/// Makes a service call to the `ListKeyVersions` endpoint of the VSS server.
64
83
/// For API contract/usage, refer to docs for [`ListKeyVersionsRequest`] and [`ListKeyVersionsResponse`].
0 commit comments