Added goal filter in Watcher API
Although it was proposed via python-watcherclient, the feature was not implemented on the Watcher API. As the notion of host aggregate is currently unused in Watcher, decision was made to only implement the filtering of goal within the Watcher API whilst removing the host_aggregate filter from the Watcher client. Thus, this patchset adds this missing functionality by adding the 'goal' parameter to the API. Change-Id: I54d248f7e470249c6412650ddf50a3e3631d2a09 Related-Bug: #1510189
This commit is contained in:
@@ -50,6 +50,15 @@ def validate_sort_dir(sort_dir):
|
||||
return sort_dir
|
||||
|
||||
|
||||
def validate_search_filters(filters, allowed_fields):
|
||||
# Very leightweight validation for now
|
||||
# todo: improve this (e.g. https://www.parse.com/docs/rest/guide/#queries)
|
||||
for filter_name in filters.keys():
|
||||
if filter_name not in allowed_fields:
|
||||
raise wsme.exc.ClientSideError(
|
||||
_("Invalid filter: %s") % filter_name)
|
||||
|
||||
|
||||
def apply_jsonpatch(doc, patch):
|
||||
for p in patch:
|
||||
if p['op'] == 'add' and p['path'].count('/') == 1:
|
||||
@@ -58,3 +67,12 @@ def apply_jsonpatch(doc, patch):
|
||||
' the resource is not allowed')
|
||||
raise wsme.exc.ClientSideError(msg % p['path'])
|
||||
return jsonpatch.apply_patch(doc, jsonpatch.JsonPatch(patch))
|
||||
|
||||
|
||||
def as_filters_dict(**filters):
|
||||
filters_dict = {}
|
||||
for filter_name, filter_value in filters.items():
|
||||
if filter_value:
|
||||
filters_dict[filter_name] = filter_value
|
||||
|
||||
return filters_dict
|
||||
|
||||
Reference in New Issue
Block a user