ISE
This guide shows how to use the
CiscoISE client to interact with Cisco Identity Services Engine (ISE) APIs.
ISE is unique among the clients for its support of both OpenAPI and ERS endpoints, bulk operations, and advanced filtering. The client automatically handles paging for large datasets and supports both JSON and XML endpoints (with some limitations).
Environment Variables
You can set the environment variables in your shell to avoid hardcoding sensitive information in your code. Check out the FAQ section on Environment Variables for more details.
from wingpy import CiscoISE
ise = CiscoISE(
base_url="https://ise.example.com", # (1)!
username="admin", # (2)!
password="password", # (3)!
verify=False,
)
-
Environment variable:
-
Environment variable:
-
Environment variable:
endpoint_data = {"mac": "00:11:22:33:44:55"}
rsp = ise.post("/api/v1/endpoint", data=endpoint_data)
print(rsp.status_code)
endpoints = [
{"mac": f"74:00:00:00:00:{i:02x}"} for i in range(1, 11)
]
rsp = ise.post("/api/v1/endpoint/bulk", data=endpoints)
print(rsp.status_code)
You can schedule and run multiple requests concurrently, in this instance we fetch all the endpoints we just created:
macs = [item["mac"] for item in endpoints]
for mac in macs:
ise.tasks.schedule(
ise.get,
f"/api/v1/endpoint/{mac}",
_task_name=mac,
)
responses = ise.tasks.run()
for mac, rsp in responses.items():
print(mac, rsp.status_code)
You can also use the get_all() method to fetch all endpoints, which handles paging automatically.
endpoints = ise.get_all(
"/api/v1/endpoint",
page_size=50,
params={"filter": "mac.STARTSW.74:00:00"},
)
for ep in endpoints:
print(ep)
endpoint_id = "00:11:22:33:44:55"
update_data = {"mac": endpoint_id, "description": "Updated via PUT"}
rsp = ise.put(
f"/api/v1/endpoint/{endpoint_id}",
data=update_data,
)
print(rsp.status_code)
patch_data = {"ERSEndPoint": {"description": "Patched via ERS"}}
rsp = ise.patch(
f"/ers/config/endpoint/{endpoint_id}",
data=patch_data,
)
print(rsp.status_code)
endpoint_id = "00:11:22:33:44:55"
rsp = ise.delete(f"/api/v1/endpoint/{endpoint_id}")
print(rsp.status_code)
macs = [f"74:00:00:00:00:{i:02x}" for i in range(1, 11)]
payload = {"endpoints": macs}
rsp = ise.delete("/api/v1/endpoint/bulk", data=payload)
print(rsp.status_code)
- Use
ise.is_ers(path)to check if an endpoint is ERS. - Use
ise.is_xml(path)to check if an endpoint is XML - The client raises
InvalidEndpointErrorfor unsupported operations (e.g., paging on XML endpoints).