-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/add remove and recursive options #67
base: master
Are you sure you want to change the base?
Conversation
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.
@idelcano some comments when testing the different use cases that you suggested, so you can check and let me know if that was the behaviour you were expecting
- UseCase 1 - It is replacing the userGroupAccesses object by the one in usecase/TOREMOVE.json for the objects provided in the --apply-to-objects changing the id provided in the --replace-ids param
- UseCase 2 - It is replacing the userGroupAccesses object by the one in usecase/TOREMOVE.json for the objects provided in the --apply-to-objects entirely removing the object whose id's been provided in the --remove-ids param. The problem is that it generates a malformed json, because reference is just removed leaving the entry malformed when there's only one element (e.g. "chart": "a0lFsy4ZXTx" is changed by "chart":
- UseCase 3 - It is replacing the userGroupAccesses object by the one in usecase/TOREPLACE.json for the objects provided in the --apply-to-objects
- UseCase 4 - It's doing exactly the same as 3 (but recursively)
- UseCase 5 - It's doing exactly the same as 2 but for the object elimination
- UseCase 6 - It's doing exactly the same as 4 (recursively)
So, in a nutshell, I see an error to fix when removing references to objects if the reference is the only element inside its list of references, and I cannot see the difference between remove and replace in the command actions.
@ifoche I rethink some commands to make it easier.
-i dashboards.json -o output.json --replace-ids aMwDgrza9xU newuid --apply-to-objects eventCharts charts dashboards reports --replace-objects none The script will change the aMwDgrza9xU to newuid in the objects eventCharts charts dashboards reports. Adding replace-objects none the script ignore the default options (publicAccess, userAccesses, userGroupAccesses).
Using: You can check that the report with "aMwDgrza9xU" id is removed
Some parameters are a bit confusing, I'll explain: --replace-objects list: |
📌 References
🎩 What is the goal?
📝 How is it being implemented?
I have created a recursive method to apply changes in all the JSON tree.
I have fixed a codification problem with json.dumps.
I have added remove objects by id option using the recursive method.
I have added some new params:
--remove-objects param to remove provided objects.
--remove-ids to remove the objects with the provided id.
-r --recursive to apply actions recursively.
💥 How can it be tested?
Zip with all the example files
usecase.zip
change_user_groups.py -i dashboards.json -o output.json -uga TOREMOVE.json --replace-ids aMwDgrza9xU newuid --apply-to-objects eventCharts charts dashboards reports
All the aMwDgrza9xU id must have been changed by newuid.
change_user_groups.py -i usecase/dashboards.json -o usecase/output.json -uga usecase/TOREMOVE.json --remove-ids aMwDgrza9xU --apply-to-objects eventCharts charts dashboards reports
All the objects with aMwDgrza9xU as id must have been removed from the output file.
change_user_groups.py -i dashboards.json -o output.json -Uga TOREPLACE.json --replace-objects userGroupAccesses --apply-to-objects eventCharts charts dashboards reports
The usergroupaccesses lists inside of the root items must have been replaced by the TOREPLACE.json content.
change_user_groups.py -i dashboards.json -o output.json -uga TOREPLACE.json --replace-objects userGroupAccesses --apply-to-objects eventCharts charts dashboards reports -r
All the usergroupsaccesses lists must have been replaced by the TOREPLACE.json content.
change_user_groups.py -i dashboards.json -o output.json -Uga TOREMOVE.json --remove-objects userGroupAccesses --apply-to-objects eventCharts charts dashboards reports
All the toremove.json usergroups must have been removed from the output.
change_user_groups.py -i dashboards.json -o output.json -uga TOREPLACE.json --remove-objects userGroupAccesses --apply-to-objects eventCharts charts dashboards reports -r
All the usergroupsaccesses lists must have been replaced by the TOREPLACE.json content.