Skip to content

Commit 99f9e39

Browse files
authored
Update HTTP methods for v0.28.0 (#312)
* Update task api v0.28.0 * Update tests to be relevant with the structures where they are ran * Update types in code-samples * Remove clearAll task type * Add index_uid as an optional in the Tasks * Add comments on best builder implementation * Add execute function on get_tasks * Update code samples * Remove out of context comment * Fix tests * Fix pagination tests * Update HTTP methods for v0.28.0 * Fix clippy * Remove comment of task tests since the tests are now sucesful * Fix doc tests * Fix get tasks inside index structure * Fix none doc tests with new get_tasks api * Add from and limit in tasks params * Add warning on failing test * Update task API * Remove useless comment * Rename type in Task structure * Removed useless newlines * Fix typo in comment * Add missing semi-column * Fix clippy errors
1 parent 0351c8a commit 99f9e39

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

src/dumps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use serde::Deserialize;
4343

4444
/// The status of a dump.\
4545
/// Contained in [`DumpInfo`].
46-
#[derive(Debug, Deserialize, Clone, PartialEq)]
46+
#[derive(Debug, Deserialize, Clone, Eq, PartialEq)]
4747
#[serde(rename_all = "snake_case")]
4848
pub enum DumpStatus {
4949
/// Dump creation is in progress.

src/indexes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Index {
9797
request::<serde_json::Value, serde_json::Value>(
9898
&format!("{}/indexes/{}", self.client.host, self.uid),
9999
&self.client.api_key,
100-
Method::Put(json!({ "primaryKey": primary_key.as_ref() })),
100+
Method::Patch(json!({ "primaryKey": primary_key.as_ref() })),
101101
200,
102102
)
103103
.await?;

src/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize, Serializer};
33
use serde_json::{Map, Value};
44
use std::collections::HashMap;
55

6-
#[derive(Deserialize, Debug, PartialEq)]
6+
#[derive(Deserialize, Debug, Eq, PartialEq)]
77
pub struct MatchRange {
88
pub start: usize,
99
pub length: usize,

src/settings.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl Index {
482482
request::<&Settings, TaskInfo>(
483483
&format!("{}/indexes/{}/settings", self.client.host, self.uid),
484484
&self.client.api_key,
485-
Method::Post(settings),
485+
Method::Patch(settings),
486486
202,
487487
)
488488
.await
@@ -522,7 +522,7 @@ impl Index {
522522
self.client.host, self.uid
523523
),
524524
&self.client.api_key,
525-
Method::Post(synonyms),
525+
Method::Put(synonyms),
526526
202,
527527
)
528528
.await
@@ -558,7 +558,7 @@ impl Index {
558558
self.client.host, self.uid
559559
),
560560
&self.client.api_key,
561-
Method::Post(
561+
Method::Put(
562562
stop_words
563563
.into_iter()
564564
.map(|v| v.as_ref().to_string())
@@ -608,7 +608,7 @@ impl Index {
608608
self.client.host, self.uid
609609
),
610610
&self.client.api_key,
611-
Method::Post(
611+
Method::Put(
612612
ranking_rules
613613
.into_iter()
614614
.map(|v| v.as_ref().to_string())
@@ -649,7 +649,7 @@ impl Index {
649649
self.client.host, self.uid
650650
),
651651
&self.client.api_key,
652-
Method::Post(
652+
Method::Put(
653653
filterable_attributes
654654
.into_iter()
655655
.map(|v| v.as_ref().to_string())
@@ -690,7 +690,7 @@ impl Index {
690690
self.client.host, self.uid
691691
),
692692
&self.client.api_key,
693-
Method::Post(
693+
Method::Put(
694694
sortable_attributes
695695
.into_iter()
696696
.map(|v| v.as_ref().to_string())
@@ -730,7 +730,7 @@ impl Index {
730730
self.client.host, self.uid
731731
),
732732
&self.client.api_key,
733-
Method::Post(distinct_attribute.as_ref().to_string()),
733+
Method::Put(distinct_attribute.as_ref().to_string()),
734734
202,
735735
)
736736
.await
@@ -765,7 +765,7 @@ impl Index {
765765
self.client.host, self.uid
766766
),
767767
&self.client.api_key,
768-
Method::Post(
768+
Method::Put(
769769
searchable_attributes
770770
.into_iter()
771771
.map(|v| v.as_ref().to_string())
@@ -805,7 +805,7 @@ impl Index {
805805
self.client.host, self.uid
806806
),
807807
&self.client.api_key,
808-
Method::Post(
808+
Method::Put(
809809
displayed_attributes
810810
.into_iter()
811811
.map(|v| v.as_ref().to_string())

src/task_info.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ mod test {
164164
}
165165

166166
#[meilisearch_test]
167-
// TODO: failing because settings routes now uses PUT instead of POST as http method
168167
async fn test_failing_task(client: Client, movies: Index) -> Result<(), Error> {
169168
let task_info = movies.set_ranking_rules(["wrong_ranking_rule"]).await?;
170169
let task = client.wait_for_task(task_info, None, None).await?;

src/tasks.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,6 @@ mod test {
694694
}
695695

696696
#[meilisearch_test]
697-
// TODO: failing because settings routes now uses PUT instead of POST as http method
698697
async fn test_failing_task(client: Client, movies: Index) -> Result<(), Error> {
699698
let task_info = movies.set_ranking_rules(["wrong_ranking_rule"]).await?;
700699

0 commit comments

Comments
 (0)