ISE 2.x Python API example EndPointGroup creation

Here is just a quick tidbit I tossed together for interfacing with the ISE 2.x API.n  Sadly, Parent Groups are not yet defined in the API.

#!/usr/bin/python3
import json, requests
from requests.auth import HTTPBasicAuth
#modify your values here
username = '<USERNAME>'
password = '<PASSWORD>'
fqdn = '<FQDN>'
name = '<GROUPNAME>'

description = '<DESCRIPTION>'
#actual script
url = 'https://' + fqdn + ':9060/ers/config/endpointgroup'
headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
payload = {
        "EndPointGroup" : {
                "id" : "id",
                "name" : name,
                "description" : description,
                "systemDefined" : False
        }
}
resp = requests.post(url=url,
        data=json.dumps(payload),
        headers=headers,
        verify=False,
        auth=HTTPBasicAuth(username, password)
)
data = resp.text
if resp.status_code == 201:
        print('EndPointGroup ' + name + ' added!')
else:
        print('Status Code ' + str(resp.status_code))
        print(data)

Comments

Popular posts from this blog

Policy Based Routing on a Nexus

Adding 2 Factor Authentication to Guacamole through Duo and Yubikey