Add site rules support (fixes broken request rules) #45
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.
Site rules have replaced request rules and signal rules in the SigSci API.
Request rules calls where broken in the Site Management Tool: filter_data in util.py reported missing key error because there is no 'action' in the JSON response data from site rules endpoint. Also 'signal' is optional (caused error too) and 'type' was missing (essential for restore).
Description
Implemented support for site rules which should replace the current request and signal rules. Request and signal rules are still supported for clone and deploy commands when these are identified in the source data. If request rules in the backup command are still required for new backups, then suggest to add support for exclude categories in the backups method as indicated in backup.py, line 101.
The following properties of site rules differ from request rules:
Please note that I have not updated Readme to include SITE_RULES category for exclude/include parameters. Suggest to add a message that request rules and signal rules are deprecated now.
Motivation and Context
It fixes the following errors in the backup command:
and also a similar error for the action key:
KeyError: 'action'
This might be depending on the SigSciApi version. The latest version redirects SigSciApi.add_request_rules to SigSciApi.add_site_rules which might have introduced this error.
How Has This Been Tested?
Backup: By invoking the backup command to validate that the error is gone and that the site requests are properly stored in JSON format in the designated output file.
sigsci_site_manager backup --name site1 --out site-policy.json
Deploy (implicitly tests Clone): By invoking the deploy command with the output file from previous test:
sigsci_site_manager deploy --name site2 --file site-policy.json --dry-run --include SITE_RULES
andsigsci_site_manager deploy --name site2 --file site-policy.json --include RULE_LISTS,SIGNAL_RULES,CUSTOM_SIGNALS,SITE_RULES
and verify results via Console and by running backup command for site2 to compare site rules against site rules from site1 backup. Tested rules include both rule types (request and signal exclusion).Merge: Created a new site 'test2', invoked:
sigsci_site_manager merge --src test --dest test2 --include SITE_RULES
and did the same comparison as in Deploy test.Types of changes
Checklist: