Skip to content

Commit a29ea75

Browse files
bors[bot]irevoire
andauthored
Merge #416
416: Create getters for the `Client` r=bidoubiwa a=irevoire # Pull Request We currently can't extract the data contained in a client which is boring if suddenly the sdk is not suitable anymore for your use case and you just need to make one quick call yourself. ## Related issue Fixes nothing ## What does this PR do? - create getters for the `Client` ## PR checklist Please check if your PR fulfills the following requirements: - [ ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [ ] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: Tamo <[email protected]>
2 parents 2ade385 + 293625f commit a29ea75

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)