3
3
import hmac
4
4
import json
5
5
import datetime
6
+ from urllib import parse
6
7
from typing import Any , Dict , List , Optional , Union
7
8
from meilisearch .index import Index
8
9
from meilisearch .config import Config
@@ -78,9 +79,14 @@ def delete_index(self, uid: str) -> Dict[str, Any]:
78
79
79
80
return self .http .delete (f'{ self .config .paths .index } /{ uid } ' )
80
81
81
- def get_indexes (self ) -> List [Index ]:
82
+ def get_indexes (self , resource_query : Optional [ Dict [ str , Any ]] = None ) -> Dict [ str , List [Index ] ]:
82
83
"""Get all indexes.
83
84
85
+ Parameters
86
+ ----------
87
+ resource_query (optional):
88
+ resource_query accepted by the get indexes route: https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
89
+
84
90
Returns
85
91
-------
86
92
indexes:
@@ -91,10 +97,12 @@ def get_indexes(self) -> List[Index]:
91
97
MeiliSearchApiError
92
98
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
93
99
"""
94
- response = self .http .get (self .config .paths .index )
95
-
96
- return {
97
- 'results' : [
100
+ if resource_query is None :
101
+ resource_query = {}
102
+ response = self .http .get (
103
+ f'{ self .config .paths .index } ?{ parse .urlencode (resource_query )} '
104
+ )
105
+ response ['results' ] = [
98
106
Index (
99
107
self .config ,
100
108
index ["uid" ],
@@ -104,11 +112,16 @@ def get_indexes(self) -> List[Index]:
104
112
)
105
113
for index in response ['results' ]
106
114
]
107
- }
115
+ return response
108
116
109
- def get_raw_indexes (self ) -> List [Dict [str , Any ]]:
117
+ def get_raw_indexes (self , resource_query : Optional [ Dict [ str , Any ]] = None ) -> List [Dict [str , Any ]]:
110
118
"""Get all indexes in dictionary format.
111
119
120
+ Parameters
121
+ ----------
122
+ resource_query (optional):
123
+ resource_query accepted by the get indexes route: https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes
124
+
112
125
Returns
113
126
-------
114
127
indexes:
@@ -119,7 +132,11 @@ def get_raw_indexes(self) -> List[Dict[str, Any]]:
119
132
MeiliSearchApiError
120
133
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://docs.meilisearch.com/errors/#meilisearch-errors
121
134
"""
122
- return self .http .get (self .config .paths .index )
135
+ if resource_query is None :
136
+ resource_query = {}
137
+ return self .http .get (
138
+ f'{ self .config .paths .index } ?{ parse .urlencode (resource_query )} '
139
+ )
123
140
124
141
def get_index (self , uid : str ) -> Index :
125
142
"""Get the index.
0 commit comments