|
33 | 33 | from meilisearch.models.key import Key, KeysResults |
34 | 34 | from meilisearch.models.task import Batch, BatchResults, Task, TaskInfo, TaskResults |
35 | 35 | from meilisearch.models.webhook import Webhook, WebhooksResults |
| 36 | +from meilisearch.models.dynamic_search_rule import DynamicSearchRule, DynamicSearchRuleResults |
36 | 37 | from meilisearch.task import TaskHandler |
37 | 38 |
|
38 | 39 |
|
@@ -600,6 +601,105 @@ def delete_webhook(self, webhook_uuid: str) -> int: |
600 | 601 | """ |
601 | 602 | response = self.http.delete(f"{self.config.paths.webhooks}/{webhook_uuid}") |
602 | 603 | return response.status_code |
| 604 | + |
| 605 | + # DYNAMIC SEARCH RULES ROUTES |
| 606 | + |
| 607 | + def get_dynamic_search_rules(self) -> DynamicSearchRuleResults: |
| 608 | + """Get all dynamic search rules. |
| 609 | +
|
| 610 | + Returns |
| 611 | + ------- |
| 612 | + rules: |
| 613 | + DynamicSearchRuleResults instance containing list of rules and pagination info. |
| 614 | + https://www.meilisearch.com/docs/reference/api/dynamic-search-rules/list-dynamic-search-rules |
| 615 | +
|
| 616 | + Raises |
| 617 | + ------ |
| 618 | + MeilisearchApiError |
| 619 | + An error containing details about why Meilisearch can't process your request. |
| 620 | + Meilisearch error codes are described here: |
| 621 | + https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors |
| 622 | + """ |
| 623 | + rules = self.http.post(self.config.paths.dynamic_search_rules, {}) |
| 624 | + return DynamicSearchRuleResults(**rules) |
| 625 | + |
| 626 | + def get_dynamic_search_rule(self, uid: str) -> DynamicSearchRule: |
| 627 | + """Get information about a specific dynamic search rule. |
| 628 | +
|
| 629 | + Parameters |
| 630 | + ---------- |
| 631 | + uid: |
| 632 | + The uid of the dynamic search rule to retrieve. |
| 633 | +
|
| 634 | + Returns |
| 635 | + ------- |
| 636 | + rule: |
| 637 | + The dynamic search rule information. |
| 638 | + https://www.meilisearch.com/docs/reference/api/dynamic-search-rules/get-a-dynamic-search-rule |
| 639 | +
|
| 640 | + Raises |
| 641 | + ------ |
| 642 | + MeilisearchApiError |
| 643 | + An error containing details about why Meilisearch can't process your request. |
| 644 | + Meilisearch error codes are described here: |
| 645 | + https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors |
| 646 | + """ |
| 647 | + rule = self.http.get(f"{self.config.paths.dynamic_search_rules}/{uid}") |
| 648 | + return DynamicSearchRule(**rule) |
| 649 | + |
| 650 | + def create_or_update_dynamic_search_rule( |
| 651 | + self, uid: str, options: Mapping[str, Any] |
| 652 | + ) -> DynamicSearchRule: |
| 653 | + """Create or update a dynamic search rule. |
| 654 | +
|
| 655 | + Parameters |
| 656 | + ---------- |
| 657 | + uid: |
| 658 | + The uid of the dynamic search rule to create or update. |
| 659 | + options: |
| 660 | + The dynamic search rule fields to create or update. |
| 661 | +
|
| 662 | + Returns |
| 663 | + ------- |
| 664 | + rule: |
| 665 | + The created or updated dynamic search rule. |
| 666 | + https://www.meilisearch.com/docs/reference/api/dynamic-search-rules/create-or-update-a-dynamic-search-rule |
| 667 | +
|
| 668 | + Raises |
| 669 | + ------ |
| 670 | + MeilisearchApiError |
| 671 | + An error containing details about why Meilisearch can't process your request. |
| 672 | + Meilisearch error codes are described here: |
| 673 | + https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors |
| 674 | + """ |
| 675 | + rule = self.http.patch(f"{self.config.paths.dynamic_search_rules}/{uid}", options) |
| 676 | + return DynamicSearchRule(**rule) |
| 677 | + |
| 678 | + |
| 679 | + def delete_dynamic_search_rule(self, uid: str) -> int: |
| 680 | + """Delete a dynamic search rule. |
| 681 | +
|
| 682 | + Parameters |
| 683 | + ---------- |
| 684 | + uid: |
| 685 | + The uid of the dynamic search rule to delete. |
| 686 | +
|
| 687 | + Returns |
| 688 | + ------- |
| 689 | + status_code: |
| 690 | + The Response status code. 204 signifies a successful delete. |
| 691 | + https://www.meilisearch.com/docs/reference/api/dynamic-search-rules/delete-a-dynamic-search-rule |
| 692 | +
|
| 693 | + Raises |
| 694 | + ------ |
| 695 | + MeilisearchApiError |
| 696 | + An error containing details about why Meilisearch can't process your request. |
| 697 | + Meilisearch error codes are described here: |
| 698 | + https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors |
| 699 | + """ |
| 700 | + response = self.http.delete(f"{self.config.paths.dynamic_search_rules}/{uid}") |
| 701 | + return response.status_code |
| 702 | + |
603 | 703 |
|
604 | 704 | def get_version(self) -> Dict[str, str]: |
605 | 705 | """Get version Meilisearch |
|
0 commit comments