Skip to content

Commit 3cc7536

Browse files
bors[bot]curquiza
andauthored
Merge #183
183: Update comments r=curquiza a=curquiza Co-authored-by: Clementine Urquizar <[email protected]>
2 parents 264b7bd + 1e7fba8 commit 3cc7536

25 files changed

+552
-320
lines changed

meilisearch/client.py

Lines changed: 73 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,34 @@ def create_index(self, uid, options=None):
3232
Parameters
3333
----------
3434
uid: str
35-
UID of the index
36-
options: dict, optional
37-
Options passed during index creation (ex: primaryKey)
35+
UID of the index.
36+
options (optional): dict
37+
Options passed during index creation (ex: primaryKey).
3838
3939
Returns
4040
-------
4141
index : Index
42-
an instance of Index containing the information of the newly created index
42+
An instance of Index containing the information of the newly created index.
43+
4344
Raises
4445
------
45-
HTTPError
46-
In case of any other error found here https://docs.meilisearch.com/references/#errors-status-code
46+
MeiliSearchApiError
47+
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
4748
"""
4849
return Index.create(self.config, uid, options)
4950

5051
def get_indexes(self):
5152
"""Get all indexes.
5253
53-
Raises
54-
------
55-
HTTPError
56-
In case of any error found here https://docs.meilisearch.com/references/#errors-status-code
5754
Returns
5855
-------
59-
list
60-
List of indexes in dictionnary format. (e.g [{ 'uid': 'movies' 'primaryKey': 'objectID' }])
56+
indexes: list
57+
List of indexes in dictionary format. (e.g [{ 'uid': 'movies' 'primaryKey': 'objectID' }])
58+
59+
Raises
60+
------
61+
MeiliSearchApiError
62+
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
6163
"""
6264
return self.http.get(self.config.paths.index)
6365

@@ -70,20 +72,21 @@ def get_index(self, uid):
7072
uid: str
7173
UID of the index.
7274
73-
Raises
74-
------
75-
HTTPError
76-
In case of any error found here https://docs.meilisearch.com/references/#errors-status-code
7775
Returns
7876
-------
7977
index : Index
8078
An Index instance containing the information of the fetched index.
79+
80+
Raises
81+
------
82+
MeiliSearchApiError
83+
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
8184
"""
8285
return Index(self.config, uid).fetch_info()
8386

8487
def index(self, uid):
85-
"""Create a local reference to an index identified by `uid`, without doing an HTTP call.
86-
Calling this method doesn't create an index by itself, but grants access to all the other methods in the Index class.
88+
"""Create a local reference to an index identified by UID, without doing an HTTP call.
89+
Calling this method doesn't create an index in the MeiliSearch instance, but grants access to all the other methods in the Index class.
8790
8891
Parameters
8992
----------
@@ -100,23 +103,24 @@ def index(self, uid):
100103
raise Exception('The index UID should not be None')
101104

102105
def get_or_create_index(self, uid, options=None):
103-
"""Retrieve an index in MeiliSearch, or create it if it doesn't exist yet.
106+
"""Get an index, or create it if it doesn't exist.
104107
105108
Parameters
106109
----------
107110
uid: str
108111
UID of the index
109-
options: dict, optional
112+
options (optional): dict
110113
Options passed during index creation (ex: primaryKey)
111114
112115
Returns
113116
-------
114117
index : Index
115-
An Index instance containing the information of the retrieved or newly created index.
118+
An instance of Index containing the information of the retrieved or newly created index.
119+
116120
Raises
117121
------
118122
MeiliSearchApiError
119-
In case of any other error found here https://docs.meilisearch.com/references/#errors-status-code
123+
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
120124
"""
121125
try:
122126
index_instance = self.get_index(uid)
@@ -131,82 +135,113 @@ def get_all_stats(self):
131135
132136
Get information about database size and all indexes
133137
https://docs.meilisearch.com/references/stats.html
138+
134139
Returns
135-
----------
140+
-------
136141
stats: `dict`
137-
Dictionnary containing stats about your MeiliSearch instance
142+
Dictionary containing stats about your MeiliSearch instance.
143+
144+
Raises
145+
------
146+
MeiliSearchApiError
147+
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
138148
"""
139149
return self.http.get(self.config.paths.stat)
140150

141151
def health(self):
142-
"""Get health of MeiliSearch
152+
"""Get health of the MeiliSearch server.
143153
144154
`204` HTTP status response when MeiliSearch is healthy.
145155
146156
Raises
147-
----------
148-
HTTPError
149-
If MeiliSearch is not healthy
157+
------
158+
MeiliSearchApiError
159+
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
150160
"""
151161
return self.http.get(self.config.paths.health)
152162

153163
def get_keys(self):
154-
"""Get all keys created
164+
"""Get all keys.
155165
156-
Get list of all the keys that were created and all their related information.
166+
Get list of all the keys.
157167
158168
Returns
159-
----------
169+
-------
160170
keys: list
161171
List of keys and their information.
162172
https://docs.meilisearch.com/references/keys.html#get-keys
173+
174+
Raises
175+
------
176+
MeiliSearchApiError
177+
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
163178
"""
164179
return self.http.get(self.config.paths.keys)
165180

166181
def get_version(self):
167182
"""Get version MeiliSearch
168183
169184
Returns
170-
----------
185+
-------
171186
version: dict
172187
Information about the version of MeiliSearch.
188+
189+
Raises
190+
------
191+
MeiliSearchApiError
192+
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
173193
"""
174194
return self.http.get(self.config.paths.version)
175195

176196
def version(self):
177197
"""Alias for get_version
178198
179199
Returns
180-
----------
200+
-------
181201
version: dict
182202
Information about the version of MeiliSearch.
203+
204+
Raises
205+
------
206+
MeiliSearchApiError
207+
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
183208
"""
184209
return self.get_version()
185210

186211
def create_dump(self):
187-
"""Triggers the creation of a MeiliSearch dump
212+
"""Trigger the creation of a MeiliSearch dump.
188213
189214
Returns
190-
----------
215+
-------
191216
Dump: dict
192217
Information about the dump.
193218
https://docs.meilisearch.com/references/dump.html#create-a-dump
219+
220+
Raises
221+
------
222+
MeiliSearchApiError
223+
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
194224
"""
195225
return self.http.post(self.config.paths.dumps)
196226

197227
def get_dump_status(self, uid):
198-
"""Retrieves the status of a MeiliSearch dump creation
228+
"""Retrieve the status of a MeiliSearch dump creation.
199229
200230
Parameters
201231
----------
202232
uid: str
203-
UID of the dump
233+
UID of the dump.
204234
205235
Returns
206-
----------
236+
-------
207237
Dump status: dict
208238
Information about the dump status.
209239
https://docs.meilisearch.com/references/dump.html#get-dump-status
240+
241+
Raises
242+
------
243+
MeiliSearchApiError
244+
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
210245
"""
211246
return self.http.get(
212247
self.config.paths.dumps + '/' + str(uid) + '/status'

meilisearch/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Config:
22
"""
3-
A client's credentials and configuration parameters
3+
Client's credentials and configuration parameters
44
"""
55

66
class Paths():
@@ -27,9 +27,9 @@ def __init__(self, url, api_key=None):
2727
"""
2828
Parameters
2929
----------
30-
url : str
30+
url: str
3131
The url to the MeiliSearch API (ex: http://localhost:7700)
32-
api_key : str
32+
api_key (optional): str
3333
The optional API key to access MeiliSearch
3434
"""
3535

meilisearch/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __str__(self):
2727
return f'MeiliSearchApiError. Error code: {self.error_code}. Error message: {self.message}. Error documentation: {self.error_link}'
2828

2929
class MeiliSearchCommunicationError(MeiliSearchError):
30-
"""Error connecting to MeiliSearch"""
30+
"""Error when connecting to MeiliSearch"""
3131

3232
def __str__(self):
3333
return f'MeiliSearchCommunicationError, {self.message}'

0 commit comments

Comments
 (0)