acisession module

This module contains the Session class that controls communication with the APIC.

class acitoolkit.acisession.Session(url, uid, pwd, verify_ssl=False)

Bases: object

Session class This class is responsible for all communication with the APIC.

Parameters:
  • url – String containing the APIC URL such as https://1.2.3.4
  • uid – String containing the username that will be used as part of the the APIC login credentials.
  • pwd – String containing the password that will be used as part of the the APIC login credentials.
  • verify_ssl – Used only for SSL connections with the APIC. Indicates whether SSL certificates must be verified. Possible values are True and False with the default being False.
get(url)

Perform a REST GET call to the APIC.

Parameters:url – String containing the URL that will be used to send the object data to the APIC.
Returns:Response class instance from the requests library. response.ok is True if request is sent successfully. response.json() will return the JSON data sent back by the APIC.
get_event(url)

Get an event for a particular URL. Used internally by the class and instance subscriptions.

Parameters:url – URL string belonging to subscription
Returns:Object belonging to the instance or class that the subscription was made.
has_events(url)

Check if there are events for a particular URL. Used internally by the class and instance subscriptions.

Parameters:url – URL string belonging to subscription
Returns:True or False. True if an event exists for this subscription.
login()

Initiate login to the APIC. Opens a communication session with the APIC using the python requests library.

Returns:Response class instance from the requests library. response.ok is True if login is successful.
push_to_apic(url, data)

Push the object data to the APIC

Parameters:
  • url – String containing the URL that will be used to send the object data to the APIC.
  • data – Dictionary containing the JSON objects to be sent to the APIC.
Returns:

Response class instance from the requests library. response.ok is True if request is sent successfully.

subscribe(url)

Subscribe to events for a particular URL. Used internally by the class and instance subscriptions.

Parameters:url – URL string to issue subscription
unsubscribe(url)

Unsubscribe from events for a particular URL. Used internally by the class and instance subscriptions.

Parameters:url – URL string to remove issue subscription