@@ -206,6 +206,27 @@ impl<'a> Client<'a> {
206206 }
207207 }
208208
209+ /// Get the private and public key.
210+ ///
211+ /// # Example
212+ ///
213+ /// ```
214+ /// # use meilisearch_sdk::{client::*, errors::Error};
215+ /// #
216+ /// # futures::executor::block_on(async move {
217+ /// let client = Client::new("http://localhost:7700", "masterKey");
218+ /// let keys = client.get_keys().await.unwrap();
219+ /// # });
220+ /// ```
221+ pub async fn get_keys ( & self ) -> Result < Keys , Error > {
222+ request :: < ( ) , Keys > (
223+ & format ! ( "{}/keys" , self . host) ,
224+ self . apikey ,
225+ Method :: Get ,
226+ 200 ,
227+ ) . await
228+ }
229+
209230 /// Get version of the MeiliSearch server.
210231 ///
211232 /// # Example
@@ -236,6 +257,13 @@ pub struct ClientStats {
236257 pub indexes : HashMap < String , IndexStats > ,
237258}
238259
260+ #[ derive( Deserialize ) ]
261+ #[ serde( rename_all = "camelCase" ) ]
262+ pub struct Keys {
263+ pub public : String ,
264+ pub private : String ,
265+ }
266+
239267/// Version of a MeiliSearch server.
240268/// Example:
241269/// ```text
@@ -252,3 +280,17 @@ pub struct Version {
252280 pub build_date : String ,
253281 pub pkg_version : String ,
254282}
283+
284+ #[ cfg( test) ]
285+ mod tests {
286+ use crate :: { client:: * } ;
287+ use futures_await_test:: async_test;
288+
289+ #[ async_test]
290+ async fn test_get_keys ( ) {
291+ let client = Client :: new ( "http://localhost:7700" , "masterKey" ) ;
292+
293+ let result = client. get_keys ( ) . await ;
294+ assert_eq ! ( result. is_err( ) , false ) ;
295+ }
296+ }
0 commit comments