Skip to content

Commit 293625f

Browse files
committed
Create getters for the Client
1 parent 4e359df commit 293625f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/client.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,38 @@ impl Client {
6363
Ok(indexes_results)
6464
}
6565

66+
/// Return the host associated with this index.
67+
///
68+
/// # Example
69+
///
70+
/// ```
71+
/// # use meilisearch_sdk::{client::*};
72+
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
73+
/// // create the client
74+
/// let client = Client::new("http://doggo.dog", MEILISEARCH_API_KEY);
75+
///
76+
/// assert_eq!(client.get_host(), "http://doggo.dog");
77+
/// ```
78+
pub fn get_host(&self) -> &str {
79+
&self.host
80+
}
81+
82+
/// Return the api key associated with this index.
83+
///
84+
/// # Example
85+
///
86+
/// ```
87+
/// # use meilisearch_sdk::{client::*};
88+
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
89+
/// // create the client
90+
/// let client = Client::new(MEILISEARCH_URL, "doggo");
91+
///
92+
/// assert_eq!(client.get_api_key(), "doggo");
93+
/// ```
94+
pub fn get_api_key(&self) -> &str {
95+
&self.api_key
96+
}
97+
6698
/// List all [Index]es with query parameters and returns values as instances of [Index].
6799
///
68100
/// # Example

0 commit comments

Comments
 (0)