Skip to content

Commit

Permalink
WIP: add ErrataConnector::filter() function
Browse files Browse the repository at this point in the history
- helper function to implement general filter query pattern
- added workaround for errata endpoint

Works with the following

et.filter('/api/v1/releases', 'filter', is_active="true",
	  enabled="true", name='OpenStack 14.0.z for RHEL 7')

works with the following
et.filter('/errata', 'errata_filter[filter_params]',
	  show_type_RHBA=1, show_type_RHEA=1, show_type_RHSA=1,
	  show_state_NEW_FILES=1, show_state_QE=1,
          show_state_REL_PREP=1,show_state_PUSH_READY=1,
          open_closed_option='exclude', release=856)

Note: errata endpoint releases and products have to be special
handled to include extra [] and multiple entries if you want them

Related: red-hat-storage#132
  • Loading branch information
yazug committed May 7, 2019
1 parent 62303af commit 81ebb0d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions errata_tool/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,24 @@ def _processResponse(self, r):

raise ErrataException(err_msg + "Unhandled HTTP status code: " +
str(r.status_code))


def filter(self, endpoint, filter_arg, **kwargs):
"""format and generate filter request
expose a general filter helper method to format kwargs up
as parameters for ET filter request. Then return generated
json object
"""
url = endpoint + "?"
param_list = []
for k,v in kwargs.items():
if k in ('release','product'):
param_list.append("{0}[{1}][]={2}".format(filter_arg, k, v))
else:
param_list.append("{0}[{1}]={2}".format(filter_arg, k, v))
print(param_list)
url = url + "&".join(param_list)
if endpoint == '/errata':
url = url + '&format=json'
print(url)
return self._get(url)

0 comments on commit 81ebb0d

Please sign in to comment.