fix a wrong error code and add tests on the document resource

This commit is contained in:
Tamo 2023-01-18 15:28:02 +01:00
parent 7322f4e78e
commit a4476c20f8
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
4 changed files with 112 additions and 2 deletions

View file

@ -155,6 +155,11 @@ impl Index<'_> {
self.service.get(url).await
}
pub async fn get_all_documents_raw(&self, options: &str) -> (Value, StatusCode) {
let url = format!("/indexes/{}/documents{}", urlencode(self.uid.as_ref()), options);
self.service.get(url).await
}
pub async fn get_all_documents(&self, options: GetAllDocumentsOptions) -> (Value, StatusCode) {
let mut url = format!("/indexes/{}/documents?", urlencode(self.uid.as_ref()));
if let Some(limit) = options.limit {
@ -187,6 +192,11 @@ impl Index<'_> {
self.service.post_encoded(url, serde_json::to_value(&ids).unwrap(), self.encoder).await
}
pub async fn delete_batch_raw(&self, body: Value) -> (Value, StatusCode) {
let url = format!("/indexes/{}/documents/delete-batch", urlencode(self.uid.as_ref()));
self.service.post_encoded(url, body, self.encoder).await
}
pub async fn settings(&self) -> (Value, StatusCode) {
let url = format!("/indexes/{}/settings", urlencode(self.uid.as_ref()));
self.service.get(url).await