Hi! I was wondering if anyone could point me in direction of the documentation for the iControl REST at version 12.1.2 (or similar). I have only found this: https://cdn.f5.com/websites/devcentral.f5.com/downloads/icontrol-rest-api-user-guide-12-1-0.pdf but this does not explain how to e.g. create a draft of a policy. The documentation seems focused on ASM.
Kind regards
Johnny
Here’s how I did it in Python. I couldn’t find the answer anywhere, and finally figured it out. Having to do a ‘patch’ and the payload is {“createDraft”:“True”} is the magic.
Publishing the draft is also a little tricky. I’ve included a code snippet for that too.
import requests
lb_name = "f5"
username = "admin"
password = "admin"
def create_policy_draft(policy_name):
ret = requests.patch(
'https://%s/mgmt/tm/ltm/policy/%s' % (lb_name, policy_name),
json={"createDraft": True},
auth=(username, password),
verify=False
)
def add_policy_rule(draft_policy_name, rule_json):
ret = requests.post(
'https://%s/mgmt/tm/ltm/policy/~Common~Drafts~%s/rules' % (
lb_name, draft_policy_name),
json=rule_json,
auth=(username, password),
verify=False
)
def publish_policy_draft(draft_policy_name):
ret = requests.post('https://%s/mgmt/tm/ltm/policy' % lb_name,
json={"command": "publish",
"name": "Drafts/%s" % draft_policy_name},
auth=(username, password),
verify=False)
Please check out: https://github.com/F5Networks/f5-common-python, as this is an F5 built python SDK for REST API.