Refactor API request handling, add more options for output and use pattern matching for include and exclude #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here are the key changes:
__api_request
method to replace thehits
argument withparams
(a dictionary), allowing for more flexible API requests. Thehits
argument was previously used to control the number of hits per page for GET requests, but this was not an ideal solution. The newparams
argument will allow for more control over GET requests.hits
is greater than 0,params["per_page"]
andparams["page"]
are set accordingly. Ifhits
is not greater than 0,params['full_result']
is set to 'true', which should return all results.api_get
method to accept the newparams
argument and pass it to the__api_request
method.check_products
function to use the newparams
argument when making GET requests via theapi_get
method. Theparams
dictionary is used to pass theorganization_id
to the API.-S
and--short-ok
to control the output display. If-S
is used, only the status is output. If--short-ok
is used, products are only output if any are not ok.check_products
method to respect the new-S
and--short-ok
options when displaying output.Files Changed
ForemanAPIClient.py
main.py
README.md