Deleting access rules
The final capability we are looking for is how we can automate housekeeping tasks such as finding and deleting outdated rules. We have already covered finding a rule by retrieving all of the rules and iterating over their details in previous chapters, so this recipe will show you how you can delete an existing access rule.
Getting ready
Open your code editor and start by creating a file called delete_access_rules.py
. Next, navigate in your terminal to the same directory in which you just created the delete_access_rules.py
file.
How to do it…
Follow these steps to delete an existing access rule for your access policy:
- Import the required
requests
library as well as thejson
andsys
modules from the standard library:import requests import json import sys from requests.auth import HTTPBasicAuth
- Specify the required variables such as your username, password, domain ID, and the ID of the policy, as well as the ID of the rule we want...