-
Notifications
You must be signed in to change notification settings - Fork 64
feat(rules): endpoint implementation #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Missing tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ercolanelli-leo There are a few glitches to solve before merging this PR, most notably a wrong HTTP method for batch_rules
. :)
algoliasearch/index.py
Outdated
before saving this batch? Default is False. | ||
""" | ||
params = {'forwardToReplicas': forward_to_replicas, 'clearExistingRules': clear_existing_rules} | ||
return self._req(False, '/rules/batch', 'PUT', params, data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The batch endpoint uses POST, not PUT.
algoliasearch/index.py
Outdated
params =- {'forwardToReplicas': forward_to_replicas} | ||
return self._req(False, '/rules/%s' % str(objectID), 'DELETE', params) | ||
|
||
def clear_rule(self, forward_to_replicas=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer clear_rules
(plural) rather than clear_rule
(singular), as this endpoint clears all rules.
algoliasearch/index.py
Outdated
params = {'forwardToReplicas': forward_to_replicas} | ||
return self._req(False, '/rules/clear', 'POST', params) | ||
|
||
def search_rules(self, query=None, anchoring=None, context=None, page=0, hitsPerPage=20): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better not to hard-code the default values for page
and hitsPerPage
in the API client. If you omit these values, the API will use the default; so I had rather put None
as default.
algoliasearch/index.py
Outdated
|
||
def search_rules(self, query=None, anchoring=None, context=None, page=0, hitsPerPage=20): | ||
""" | ||
Search for a rule inside the index. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search for rules, not just a single one. :)
No description provided.