acisession module¶
This module contains the Session class that controls communication with the APIC.
-
class
acitoolkit.acisession.
Session
(url, uid, pwd=None, cert_name=None, key=None, verify_ssl=False, appcenter_user=False, subscription_enabled=True, proxies=None)¶ 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.
- cert_name – String containing the certificate name that will be used as part of the the APIC certificate authentication credentials.
- key – String containing the private key file name that will be used as part of the the APIC certificate authentication 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.
- appcenter_user – Set True when using certificate authentication from the context of an APIC appcenter app
- proxies – Optional dictionary containing the proxies passed directly to the Requests library
-
close
()¶ Close the session
-
deregister_login_callback
(callback_fn)¶ Delete the registration of a callback function that was registered via the register_login_callback function.
Parameters: callback_fn – function to be deregistered
-
get
(url, timeout=None)¶ 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.
-
get_event_count
(url)¶ Check the number of subscription events for a particular APIC URL
Parameters: url – URL string belonging to subscription Returns: Interger number of events in event queue
-
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.
-
invoke_login_callbacks
()¶ Invoke registered callback functions when the session performs a successful relogin attempt after disconnecting from the APIC.
-
is_subscribed
(url)¶ Check if subscribed to events for a particular URL.
Parameters: url – URL string to issue subscription
-
logged_in
()¶ Returns whether the session is logged in to the APIC
Returns: True or False. True if the session is logged in to the APIC.
-
login
(timeout=None)¶ 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, timeout=None)¶ 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.
-
refresh_login
(timeout=None)¶ Refresh the login to the APIC
Parameters: timeout – Integer containing the number of seconds for connection timeout Returns: Instance of requests.Response
-
register_login_callback
(callback_fn)¶ Register a callback function that will be called when the session performs a successful relogin attempt after disconnecting from the APIC.
Parameters: callback_fn – function to be called
-
resubscribe
()¶ Resubscribe to the current subscriptions. Used by the login thread after a re-login
Returns: None
-
subscribe
(url, only_new=False)¶ 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
- url – String containing the APIC URL such as