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).
Connect to ISE
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:
Create an endpoint (OpenAPI)
endpoint_data = {"mac": "00:11:22:33:44:55"}
rsp = ise.post("/api/v1/endpoint", data=endpoint_data)
print(rsp.status_code)
Bulk create endpoints
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:
Concurrent GET requests
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.
Get all endpoints with filter and paging
endpoints = ise.get_all(
"/api/v1/endpoint",
page_size=50,
params={"filter": "mac.STARTSW.74:00:00"},
)
for ep in endpoints:
print(ep)
Update endpoint description (PUT)
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 endpoint description (ERS)
patch_data = {"ERSEndPoint": {"description": "Patched via ERS"}}
rsp = ise.patch(
f"/ers/config/endpoint/{endpoint_id}",
data=patch_data,
)
print(rsp.status_code)
Delete an endpoint
endpoint_id = "00:11:22:33:44:55"
rsp = ise.delete(f"/api/v1/endpoint/{endpoint_id}")
print(rsp.status_code)
Bulk delete endpoints
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
InvalidEndpointError
for unsupported operations (e.g., paging on XML endpoints).