Skip to content

Commit 15bf016

Browse files
committed
Move paths to config file
1 parent 0e46042 commit 15bf016

File tree

3 files changed

+90
-115
lines changed

3 files changed

+90
-115
lines changed

meilisearch/client.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ class Client():
1212

1313
config = None
1414

15-
health_path = "health"
16-
key_path = 'keys'
17-
sys_info_path = 'sys-info'
18-
version_path = 'version'
19-
stat_path = 'stats'
20-
2115
def __init__(self, url, apiKey=None):
2216
"""
2317
Parameters
@@ -95,7 +89,7 @@ def get_all_stats(self):
9589
stats: `dict`
9690
Dictionnary containing stats about your MeiliSearch instance
9791
"""
98-
return HttpRequests.get(self.config, self.stat_path)
92+
return HttpRequests.get(self.config, self.config.stat_path)
9993

10094
def health(self):
10195
"""Get health of meilisearch
@@ -107,7 +101,7 @@ def health(self):
107101
HTTPError
108102
If meilisearch is not healthy
109103
"""
110-
return HttpRequests.get(self.config, self.health_path)
104+
return HttpRequests.get(self.config, self.config.health_path)
111105

112106
def update_health(self, health):
113107
"""Update health of meilisearch
@@ -119,7 +113,7 @@ def update_health(self, health):
119113
health: bool
120114
Boolean reprensenting the healthyness of meilisearch. True for healthy.
121115
"""
122-
return HttpRequests.put(self.config, self.health_path, {'health': health})
116+
return HttpRequests.put(self.config, self.config.health_path, {'health': health})
123117

124118
def get_keys(self):
125119
"""Get all keys created
@@ -132,7 +126,7 @@ def get_keys(self):
132126
List of keys and their information.
133127
https://docs.meilisearch.com/references/keys.html#get-keys
134128
"""
135-
return HttpRequests.get(self.config, self.key_path)
129+
return HttpRequests.get(self.config, self.config.key_path)
136130

137131
def get_sys_info(self):
138132
"""Get system information of meilisearch
@@ -144,7 +138,7 @@ def get_sys_info(self):
144138
sys_info: dict
145139
Information about memory and processor usage.
146140
"""
147-
return HttpRequests.get(self.config, self.sys_info_path)
141+
return HttpRequests.get(self.config, self.config.sys_info_path)
148142

149143
def get_version(self):
150144
"""Get version meilisearch
@@ -154,7 +148,7 @@ def get_version(self):
154148
version: dict
155149
Information about version of meilisearch.
156150
"""
157-
return HttpRequests.get(self.config, self.version_path)
151+
return HttpRequests.get(self.config, self.config.version_path)
158152

159153
def version(self):
160154
"""Alias for get_version

meilisearch/config.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +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'
23+
624
def __init__(self, url, apikey=None):
725
"""
826
Parameters

0 commit comments

Comments
 (0)