EOS eAPI interaction module. This module allows interaction with the CLI via eAPI command requests. This allows EOS SDK applications access to configuration and status of EOS state for which EOS SDK APIs do not yet exist. Note that each method is a synchronous call, and opens a unix-domain socket. Therefore, this is not intended to be a replacement for other EosSdk modules.
For more information about eAPI, please visit https://eos.arista.com/arista-eapi-101/
The following snippet shows how to load an eAPI response into a json_t object from the jansson library, although any json library to convert from json-formatted text will do. Based on the jansson library documentation: https://jansson.readthedocs.io/en/2.10/tutorial.html
* eapi_response_t show_interfaces = eapiMgr->run_show_cmd("show interfaces"); * json_t* root; * json_error_t error; * if (show_interfaces.success()) { * root = json_loads(show_interfaces.responses()[0], 0, &error); * } * if (!root) { * fprintf(stderr, "error: on line %d: %s\n", error.line, error.text); * } * json_t* interfaces = json_object_get(root, "interfaces"); * json_t* intf1 = json_object_get(interfaces, "Ethernet1"); * json_t* desc1 = json_object_get(intf1, "description"); * * printf("Ethernet1's description: " << json_string_value(desc1)); * ... *
eAPI manager.
Public Functions
Executes a “show” CLI command in enable mode.
Executes one or many CLI commands in configuration mode.
Protected Functions
Private Members
An eAPI response from the Cli server.
Public Functions
Default constructor.
Full constructor.
Getter for ‘success’: indicates if a response was received.
Getter for ‘error_code’: error code from eAPI response.
Getter for ‘error_message’: error message from response.
Getter for ‘responses’: the set of strings that constitute an eAPI response.
Getter for ‘raw_response’: raw eAPI response (if requested).
Returns a string representation of the current object’s values.
Private Members
Friends
A utility stream operator that adds a string representation of eapi_response_t to the ostream.