APIC
This guide shows how to use the
CiscoAPIC
client to interact with Cisco Application Policy Infrastructure Controller (APIC) APIs.
Tip: The APIC API supports both JSON and XML formats, and so does the client. You can use whichever format best fits your workflow.
Connect to APIC¶
from wingpy import CiscoAPIC
apic = CiscoAPIC(
base_url="https://apic.example.com", # (1)!
username="admin", # (2)!
password="password", # (3)!
verify=False,
)
- Environment variable:
- Environment variable:
- Environment variable:
Get All Tenants¶
The
apic.get_all()
method retrieves all items from a paginated endpoint, handling pagination for you. This is useful for large datasets.
Create a Tenant¶
Use the post
method to create a new tenant. You can use either JSON or XML format for the request body, as the client looks the "extension" of the URL to determine the format.
Update a Tenant¶
You can update an existing tenant using the patch
method. Again, you can choose between JSON or XML format.
Delete a Tenant¶
Get a Single Tenant¶
You can retrieve a single tenant by specifying its distinguished name (DN) in the path. Both JSON and XML formats are supported.
Get All EPGs for a Tenant (with Pagination)¶
You can use query parameters to fetch all EPGs (Endpoint Groups) for a tenant, and the client will handle pagination for you.