Skip to content

Commit 106cdfd

Browse files
committed
Paths class
1 parent 15bf016 commit 106cdfd

File tree

3 files changed

+89
-87
lines changed

3 files changed

+89
-87
lines changed

meilisearch/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_all_stats(self):
8989
stats: `dict`
9090
Dictionnary containing stats about your MeiliSearch instance
9191
"""
92-
return HttpRequests.get(self.config, self.config.stat_path)
92+
return HttpRequests.get(self.config, self.config.paths.stat)
9393

9494
def health(self):
9595
"""Get health of meilisearch
@@ -101,7 +101,7 @@ def health(self):
101101
HTTPError
102102
If meilisearch is not healthy
103103
"""
104-
return HttpRequests.get(self.config, self.config.health_path)
104+
return HttpRequests.get(self.config, self.config.paths.health)
105105

106106
def update_health(self, health):
107107
"""Update health of meilisearch
@@ -113,7 +113,7 @@ def update_health(self, health):
113113
health: bool
114114
Boolean reprensenting the healthyness of meilisearch. True for healthy.
115115
"""
116-
return HttpRequests.put(self.config, self.config.health_path, {'health': health})
116+
return HttpRequests.put(self.config, self.config.paths.health, {'health': health})
117117

118118
def get_keys(self):
119119
"""Get all keys created
@@ -126,7 +126,7 @@ def get_keys(self):
126126
List of keys and their information.
127127
https://docs.meilisearch.com/references/keys.html#get-keys
128128
"""
129-
return HttpRequests.get(self.config, self.config.key_path)
129+
return HttpRequests.get(self.config, self.config.paths.keys)
130130

131131
def get_sys_info(self):
132132
"""Get system information of meilisearch
@@ -138,7 +138,7 @@ def get_sys_info(self):
138138
sys_info: dict
139139
Information about memory and processor usage.
140140
"""
141-
return HttpRequests.get(self.config, self.config.sys_info_path)
141+
return HttpRequests.get(self.config, self.config.paths.sys_info)
142142

143143
def get_version(self):
144144
"""Get version meilisearch
@@ -148,7 +148,7 @@ def get_version(self):
148148
version: dict
149149
Information about version of meilisearch.
150150
"""
151-
return HttpRequests.get(self.config, self.config.version_path)
151+
return HttpRequests.get(self.config, self.config.paths.version)
152152

153153
def version(self):
154154
"""Alias for get_version

meilisearch/config.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@ class Config:
33
A client's credentials and configuration parameters
44
"""
55

6-
health_path = "health"
7-
key_path = 'keys'
8-
sys_info_path = 'sys-info'
9-
version_path = 'version'
10-
index_path = 'indexes'
11-
update_path = 'updates'
12-
stat_path = 'stats'
13-
search_path = 'search'
14-
document_path = 'documents'
15-
setting_path = 'settings'
16-
ranking_rules_path = 'ranking-rules'
17-
distinct_attribute_path = 'distinct-attribute'
18-
searchable_attributes_path = 'searchable-attributes'
19-
displayed_attributes_path = 'displayed-attributes'
20-
stop_words_path = 'stop-words'
21-
synonyms_path = 'synonyms'
22-
accept_new_fields_path = 'accept-new-fields'
6+
class Paths():
7+
health = "health"
8+
keys = 'keys'
9+
sys_info = 'sys-info'
10+
version = 'version'
11+
index = 'indexes'
12+
update = 'updates'
13+
stat = 'stats'
14+
search = 'search'
15+
document = 'documents'
16+
setting = 'settings'
17+
ranking_rules = 'ranking-rules'
18+
distinct_attribute = 'distinct-attribute'
19+
searchable_attributes = 'searchable-attributes'
20+
displayed_attributes = 'displayed-attributes'
21+
stop_words = 'stop-words'
22+
synonyms = 'synonyms'
23+
accept_new_fields = 'accept-new-fields'
2324

2425
def __init__(self, url, apikey=None):
2526
"""
@@ -33,3 +34,4 @@ def __init__(self, url, apikey=None):
3334

3435
self.url = url
3536
self.apikey = apikey
37+
self.paths = self.Paths()

0 commit comments

Comments
 (0)