@@ -4,12 +4,13 @@ use reqwest::Client;
44
55use crate :: error:: VssError ;
66use crate :: types:: {
7- GetObjectRequest , GetObjectResponse , ListKeyVersionsRequest , ListKeyVersionsResponse , PutObjectRequest ,
8- PutObjectResponse ,
7+ DeleteObjectRequest , DeleteObjectResponse , GetObjectRequest , GetObjectResponse , ListKeyVersionsRequest ,
8+ ListKeyVersionsResponse , PutObjectRequest , PutObjectResponse ,
99} ;
1010
1111/// Thin-client to access a hosted instance of Versioned Storage Service (VSS).
1212/// The provided [`VssClient`] API is minimalistic and is congruent to the VSS server-side API.
13+ #[ derive( Clone ) ]
1314pub struct VssClient {
1415 base_url : String ,
1516 client : Client ,
@@ -59,6 +60,24 @@ impl VssClient {
5960 }
6061 }
6162
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+
6281 /// Lists keys and their corresponding version for a given [`ListKeyVersionsRequest::store_id`].
6382 /// Makes a service call to the `ListKeyVersions` endpoint of the VSS server.
6483 /// For API contract/usage, refer to docs for [`ListKeyVersionsRequest`] and [`ListKeyVersionsResponse`].
0 commit comments